1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/*: replace #if ENABLE_DEBUG with IS_ACTIVE

This commit is contained in:
Bas Stottelaar 2020-10-23 00:40:33 +02:00
parent 94171b7389
commit 62994dfb16
16 changed files with 118 additions and 115 deletions

View File

@ -144,17 +144,17 @@ int adt7310_init(adt7310_t *dev, spi_t spi, spi_clk_t clk, gpio_t cs)
/* CS */
spi_init_cs(dev->spi, dev->cs);
#if ENABLE_DEBUG
for (int i = 0; i < 8; ++i) {
uint16_t dbg_reg = 0;
status = adt7310_read_reg(dev, i, sizeof(dbg_reg), (uint8_t *)&dbg_reg);
if (status != 0) {
printf("Error reading address 0x%02x", i);
if (IS_ACTIVE(ENABLE_DEBUG)) {
for (int i = 0; i < 8; ++i) {
uint16_t dbg_reg = 0;
status = adt7310_read_reg(dev, i, sizeof(dbg_reg), (uint8_t *)&dbg_reg);
if (status != 0) {
printf("Error reading address 0x%02x", i);
}
dbg_reg = htons(dbg_reg);
printf("%02x: %04" PRIx16 "\n", i, dbg_reg);
}
dbg_reg = htons(dbg_reg);
printf("%02x: %04" PRIx16 "\n", i, dbg_reg);
}
#endif
/* Read ID register from device */
status = adt7310_read_reg(dev, ADT7310_REG_ID, ADT7310_REG_SIZE_ID, &reg);

View File

@ -480,7 +480,7 @@ static int _reg_read(const apds99xx_t *dev, uint8_t reg, uint8_t *data, uint16_t
return -APDS99XX_ERROR_I2C;
}
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[apds99xx] %s i2c dev=%d addr=%02x: read from reg 0x%02x: ",
__func__, dev->params.dev, APDS99XX_I2C_ADDRESS, reg);
for (uint16_t i = 0; i < len; i++) {
@ -496,7 +496,7 @@ static int _reg_write(const apds99xx_t *dev, uint8_t reg, uint8_t *data, uint16_
{
assert(dev != NULL);
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[apds99xx] %s i2c dev=%d addr=%02x: write to reg 0x%02x: ",
__func__, dev->params.dev, APDS99XX_I2C_ADDRESS, reg);
for (uint16_t i = 0; i < len; i++) {

View File

@ -205,7 +205,7 @@ static void _status(const ata8520e_t *dev)
uint8_t sigfox2 = spi_transfer_byte(SPIDEV, CSPIN, false, 0);
spi_release(SPIDEV);
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
_print_atmel_status(atmel);
_print_sigfox_status(sigfox);
_print_sigfox_status(sigfox2);
@ -272,7 +272,7 @@ int ata8520e_init(ata8520e_t *dev, const ata8520e_params_t *params)
xtimer_usleep(100 * US_PER_MS); /* 100 ms */
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
char sigfox_id[SIGFOX_ID_LENGTH + 1];
ata8520e_read_id(dev, sigfox_id);

View File

@ -103,9 +103,10 @@ static void _atwinc15x0_eth_cb(uint8_t type, void *msg, void *ctrl_buf)
DEBUG("%s type=%u msg=%p len=%d remaining=%d\n", __func__,
type, msg, ctrl->u16DataSize, ctrl->u16RemainigDataSize);
#if MODULE_OD && ENABLE_DEBUG_DUMP
od_hex_dump(msg, ctrl->u16DataSize, 16);
#endif
if (IS_ACTIVE(ENABLE_DEBUG) && IS_USED(MODULE_OD)) {
od_hex_dump(msg, ctrl->u16DataSize, 16);
}
/* the buffer shouldn't be used here */
assert(atwinc15x0->rx_buf == NULL);
@ -258,12 +259,13 @@ static int _atwinc15x0_send(netdev_t *netdev, const iolist_t *iolist)
}
}
#if ENABLE_DEBUG
DEBUG("%s send %d byte", __func__, tx_len);
#if MODULE_OD && ENABLE_DEBUG_DUMP
od_hex_dump(dev->tx_buf, dev->tx_len, OD_WIDTH_DEFAULT);
#endif /* MODULE_OD && ENABLE_DEBUG_HEXDUMP */
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("%s send %d byte", __func__, tx_len);
if (IS_ACTIVE(ENABLE_DEBUG_DUMP) && IS_USED(MODULE_OD)) {
od_hex_dump(atwinc15x0_eth_buf, tx_len, OD_WIDTH_DEFAULT);
}
}
irq_restore(state);
/* send the the packet */
@ -320,14 +322,15 @@ static int _atwinc15x0_recv(netdev_t *netdev, void *buf, size_t len, void *info)
dev->rx_len = 0;
dev->rx_buf = NULL;
#if ENABLE_DEBUG
ethernet_hdr_t *hdr = (ethernet_hdr_t *)buf;
DEBUG("%s received %u byte from addr " ATWINC15X0_MAC_STR "\n",
__func__, rx_size, ATWINC15X0_MAC_STR_ARG(hdr->src));
#if MODULE_OD && ENABLE_DEBUG_DUMP
od_hex_dump(buf, rx_size, OD_WIDTH_DEFAULT);
#endif /* MODULE_OD && ENABLE_DEBUG_HEXDUMP */
#endif /* ENABLE_DEBUG */
if (IS_ACTIVE(ENABLE_DEBUG)) {
ethernet_hdr_t *hdr = (ethernet_hdr_t *)buf;
DEBUG("%s received %u byte from addr " ATWINC15X0_MAC_STR "\n",
__func__, rx_size, ATWINC15X0_MAC_STR_ARG(hdr->src));
if (IS_ACTIVE(ENABLE_DEBUG_DUMP) && IS_USED(MODULE_OD)) {
od_hex_dump(buf, rx_size, OD_WIDTH_DEFAULT);
}
}
irq_restore(state);

View File

@ -512,7 +512,7 @@ static int _reg_read(const ccs811_t *dev, uint8_t reg, uint8_t *data, uint32_t l
#endif
if (res == CCS811_OK) {
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[ccs811] %s dev=%d addr=%02x: read following bytes: ",
__func__, dev->params.i2c_dev, dev->params.i2c_addr);
for (unsigned i = 0; i < len; i++) {
@ -537,7 +537,7 @@ static int _reg_write(const ccs811_t *dev, uint8_t reg, uint8_t *data, uint32_t
int res = CCS811_OK;
if (ENABLE_DEBUG && data && len) {
if (IS_ACTIVE(ENABLE_DEBUG) && data && len) {
printf("[css811] %s dev=%d addr=%02x: write following bytes: ",
__func__, dev->params.i2c_dev, dev->params.i2c_addr);
for (unsigned i = 0; i < len; i++) {

View File

@ -79,7 +79,7 @@ int ds3234_pps_init(const ds3234_params_t *dev)
}
DEBUG("ds3234: init on SPI_DEV(%u)\n", dev->spi);
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
for (int k = 0; k <= 0x19; ++k) {
uint8_t dbg_reg = 0;
ds3234_read_reg(dev, k, 1, &dbg_reg);

View File

@ -243,7 +243,7 @@ static int _reg_read(const hmc5883l_t *dev, uint8_t reg, uint8_t *data, uint16_t
i2c_release(dev->dev);
if (res == 0) {
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[hmc5883l] %s i2c dev=%d addr=%02x: read following bytes: ",
__func__, dev->dev, HMC5883L_I2C_ADDRESS);
for (unsigned i = 0; i < len; i++) {
@ -268,7 +268,7 @@ static int _reg_write(const hmc5883l_t *dev, uint8_t reg, uint8_t data)
DEBUG_DEV("write register 0x%02x", dev, reg);
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[hmc5883l] %s i2c dev=%d addr=%02x: write following bytes: ",
__func__, dev->dev, HMC5883L_I2C_ADDRESS);
printf("%02x ", data);

View File

@ -798,7 +798,7 @@ static void _isr(netdev_t *netdev)
}
kw2xrf_write_dreg(dev, MKW2XDM_IRQSTS2, irqsts2);
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
/* for debugging only */
kw2xrf_read_dregs(dev, MKW2XDM_IRQSTS1, dregs, MKW2XDM_IRQSTS1 + 3);
if (dregs[MKW2XDM_IRQSTS1] & 0x7f) {

View File

@ -82,7 +82,7 @@ int lsm303dlhc_init(lsm303dlhc_t *dev, const lsm303dlhc_params_t *params)
i2c_release(DEV_I2C);
/* configure mag data ready pin */
gpio_init(DEV_MAG_PIN, GPIO_IN);
if (ENABLE_DEBUG && res == 0) {
if (IS_ACTIVE(ENABLE_DEBUG) && res == 0) {
DEBUG("[OK]\n");
}
else {

View File

@ -40,7 +40,7 @@ static int mtd_mci_init(mtd_dev_t *dev)
return -EIO;
}
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
uint32_t block_size;
mci_ioctl(GET_BLOCK_SIZE, &block_size);
DEBUG("block size: %lu\n", block_size);

View File

@ -26,12 +26,8 @@
#include <errno.h>
#include "mtd.h"
#if MODULE_XTIMER
#include "xtimer.h"
#include "timex.h"
#else
#include "thread.h"
#endif
#include "byteorder.h"
#include "mtd_spi_nor.h"
@ -110,7 +106,7 @@ static void mtd_spi_cmd_addr_read(const mtd_spi_nor_t *dev, uint8_t opcode,
uint8_t *addr_buf = _be_addr(dev, &addr);
if (ENABLE_TRACE) {
if (IS_ACTIVE(ENABLE_TRACE)) {
TRACE("mtd_spi_cmd_addr_read: addr:");
for (unsigned int i = 0; i < dev->params->addr_width; ++i) {
TRACE(" %02x", addr_buf[i]);
@ -146,7 +142,7 @@ static void mtd_spi_cmd_addr_write(const mtd_spi_nor_t *dev, uint8_t opcode,
uint8_t *addr_buf = _be_addr(dev, &addr);
if (ENABLE_TRACE) {
if (IS_ACTIVE(ENABLE_TRACE)) {
TRACE("mtd_spi_cmd_addr_write: addr:");
for (unsigned int i = 0; i < dev->params->addr_width; ++i) {
TRACE(" %02x", addr_buf[i]);
@ -313,9 +309,10 @@ static inline void wait_for_write_complete(const mtd_spi_nor_t *dev, uint32_t us
{
unsigned i = 0, j = 0;
uint32_t div = 2;
#if ENABLE_DEBUG && defined(MODULE_XTIMER)
uint32_t diff = xtimer_now_usec();
#endif
uint32_t diff = 0;
if (IS_ACTIVE(ENABLE_DEBUG) && IS_USED(MODULE_XTIMER)) {
diff = xtimer_now_usec();
}
do {
uint8_t status;
mtd_spi_cmd_read(dev, dev->params->opcode->rdsr, &status, sizeof(status));
@ -349,10 +346,10 @@ static inline void wait_for_write_complete(const mtd_spi_nor_t *dev, uint32_t us
#endif
} while (1);
DEBUG("wait loop %u times, yield %u times", i, j);
#if ENABLE_DEBUG && defined(MODULE_XTIMER)
diff = xtimer_now_usec() - diff;
DEBUG(", total wait %"PRIu32"us", diff);
#endif
if (IS_ACTIVE(ENABLE_DEBUG) && IS_ACTIVE(MODULE_XTIMER)) {
diff = xtimer_now_usec() - diff;
DEBUG(", total wait %"PRIu32"us", diff);
}
DEBUG("\n");
}

View File

@ -78,7 +78,7 @@
/* Length for passive listings */
#define LIST_PASSIVE_LEN_14443(num) (num * 20)
#if ENABLE_DEBUG
#if IS_ACTIVE(ENABLE_DEBUG)
#define PRINTBUFF printbuff
static void printbuff(uint8_t *buff, unsigned len)
{

View File

@ -100,7 +100,7 @@ void rn2xx3_set_internal_state(rn2xx3_t *dev, uint8_t state)
return;
}
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[rn2xx3] new state: ");
switch(state) {
case RN2XX3_INT_STATE_CMD:

View File

@ -322,13 +322,14 @@ static int _read_data(sht3x_dev_t* dev, uint8_t *data, uint8_t len)
i2c_release(dev->i2c_dev);
if (res == 0) {
#if ENABLE_DEBUG
printf("[sht3x] %s bus=%d addr=%02x: read following bytes: ",
__func__, dev->i2c_dev, dev->i2c_addr);
for (int i=0; i < len; i++)
printf("%02x ", data[i]);
printf("\n");
#endif /* ENABLE_DEBUG */
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[sht3x] %s bus=%d addr=%02x: read following bytes: ",
__func__, dev->i2c_dev, dev->i2c_addr);
for (int i=0; i < len; i++) {
printf("%02x ", data[i]);
}
printf("\n");
}
}
else {
DEBUG_DEV("could not read %d bytes from sensor, reason %d",

View File

@ -44,22 +44,22 @@ uint8_t sx127x_get_state(const sx127x_t *dev)
void sx127x_set_state(sx127x_t *dev, uint8_t state)
{
#if ENABLE_DEBUG
switch (state) {
case SX127X_RF_IDLE:
DEBUG("[sx127x] Change state: IDLE\n");
break;
case SX127X_RF_RX_RUNNING:
DEBUG("[sx127x] Change state: RX\n");
break;
case SX127X_RF_TX_RUNNING:
DEBUG("[sx127x] Change state: TX\n");
break;
default:
DEBUG("[sx127x] Change state: UNKNOWN\n");
break;
if (IS_ACTIVE(ENABLE_DEBUG)) {
switch (state) {
case SX127X_RF_IDLE:
DEBUG("[sx127x] Change state: IDLE\n");
break;
case SX127X_RF_RX_RUNNING:
DEBUG("[sx127x] Change state: RX\n");
break;
case SX127X_RF_TX_RUNNING:
DEBUG("[sx127x] Change state: TX\n");
break;
default:
DEBUG("[sx127x] Change state: UNKNOWN\n");
break;
}
}
#endif
dev->settings.state = state;
}
@ -440,28 +440,28 @@ uint8_t sx127x_get_op_mode(const sx127x_t *dev)
void sx127x_set_op_mode(const sx127x_t *dev, uint8_t op_mode)
{
#if ENABLE_DEBUG
switch(op_mode) {
case SX127X_RF_OPMODE_SLEEP:
DEBUG("[sx127x] Set op mode: SLEEP\n");
break;
case SX127X_RF_OPMODE_STANDBY:
DEBUG("[sx127x] Set op mode: STANDBY\n");
break;
case SX127X_RF_OPMODE_RECEIVER_SINGLE:
DEBUG("[sx127x] Set op mode: RECEIVER SINGLE\n");
break;
case SX127X_RF_OPMODE_RECEIVER:
DEBUG("[sx127x] Set op mode: RECEIVER\n");
break;
case SX127X_RF_OPMODE_TRANSMITTER:
DEBUG("[sx127x] Set op mode: TRANSMITTER\n");
break;
default:
DEBUG("[sx127x] Set op mode: UNKNOWN (%d)\n", op_mode);
break;
if (IS_ACTIVE(ENABLE_DEBUG)) {
switch(op_mode) {
case SX127X_RF_OPMODE_SLEEP:
DEBUG("[sx127x] Set op mode: SLEEP\n");
break;
case SX127X_RF_OPMODE_STANDBY:
DEBUG("[sx127x] Set op mode: STANDBY\n");
break;
case SX127X_RF_OPMODE_RECEIVER_SINGLE:
DEBUG("[sx127x] Set op mode: RECEIVER SINGLE\n");
break;
case SX127X_RF_OPMODE_RECEIVER:
DEBUG("[sx127x] Set op mode: RECEIVER\n");
break;
case SX127X_RF_OPMODE_TRANSMITTER:
DEBUG("[sx127x] Set op mode: TRANSMITTER\n");
break;
default:
DEBUG("[sx127x] Set op mode: UNKNOWN (%d)\n", op_mode);
break;
}
}
#endif
/* Replace previous mode value and setup new mode value */
sx127x_reg_write(dev, SX127X_REG_OPMODE,

View File

@ -75,13 +75,14 @@ int tsl2561_init(tsl2561_t *dev, const tsl2561_params_t *params)
TSL2561_COMMAND_MODE | TSL2561_REGISTER_TIMING,
DEV_INTEGRATION | DEV_GAIN, 0);
#if ENABLE_DEBUG
uint8_t timing;
i2c_read_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_TIMING, &timing, 0);
DEBUG("[Info] Timing ? %d (expected: %d)\n",
timing, DEV_INTEGRATION | DEV_GAIN);
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
uint8_t timing;
i2c_read_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_TIMING,
&timing, 0);
DEBUG("[Info] Timing ? %d (expected: %d)\n",
timing, DEV_INTEGRATION | DEV_GAIN);
}
_disable(dev);
i2c_release(DEV_I2C);
@ -187,12 +188,13 @@ static void _enable(const tsl2561_t *dev)
i2c_write_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_CONTROL,
TSL2561_CONTROL_POWERON, 0);
#if ENABLE_DEBUG
uint8_t en;
i2c_read_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_CONTROL, &en, 0);
DEBUG("[Info] Enabled ? %s\n", en == 3 ? "true" : "false");
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
uint8_t en;
i2c_read_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_CONTROL, &en, 0);
DEBUG("[Info] Enabled ? %s\n", en == 3 ? "true" : "false");
}
}
@ -203,12 +205,12 @@ static void _disable(const tsl2561_t *dev)
TSL2561_COMMAND_MODE | TSL2561_REGISTER_CONTROL,
TSL2561_CONTROL_POWEROFF, 0);
#if ENABLE_DEBUG
uint8_t dis;
i2c_read_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_CONTROL, &dis, 0);
DEBUG("[Info] Disabled ? %s\n", dis == 0 ? "true": "false");
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
uint8_t dis;
i2c_read_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_CONTROL, &dis, 0);
DEBUG("[Info] Disabled ? %s\n", dis == 0 ? "true": "false");
}
}
static void _read_data(const tsl2561_t *dev, uint16_t *full, uint16_t *ir)