diff --git a/src/dw1000-base.c b/src/dw1000-base.c index de7e5c07a2402ba6478f1590a0e2655b2f987fd5..6b6375f75b35edb8a4e23bfb89dfdb6f49145953 100644 --- a/src/dw1000-base.c +++ b/src/dw1000-base.c @@ -28,7 +28,7 @@ /*================================ Includes =================================*/ #include "string.h" // memcpy... -#include "stdio.h" +//#include "stdio.h" #include "udelay.h" #include "math.h" @@ -114,7 +114,7 @@ void dw_init() // // Disable LDE // // TODO: Read old value and flip lderun bit // //value = dw_read_subreg_64(0x36, 0x04, 4); - // //printf("Value: %llx \n", value); + // //DW_DEBUG("Value: %llx \n", value); // const uint32_t lderune = 0x81000738; // dw_write_subreg(0x36, 0x04, 4, (uint8_t *)&lderune); @@ -130,7 +130,7 @@ void dw_init() dw_conf( &dw1000.conf ); // Print information about the board - printf( "Initialising device: %llu\n", dw_get_device_id() ); + DW_DEBUG( "Initialising device: %llu\n", dw_get_device_id() ); dw1000.state = DW_STATE_IDLE; } @@ -472,7 +472,7 @@ void dw_conf_tx( dw1000_tx_conf_t * tx_conf ) /** * \brief Reads the current configuration from device and prints it using - * printf. The current configuration is all registers that can be modified by + * DW_DEBUG. The current configuration is all registers that can be modified by * \ref dw_conf, \ref dw_conf_rx and \ref dw_conf_tx. */ void @@ -515,31 +515,31 @@ dw_conf_print() float temperature = dw_get_temperature(DW_ADC_SRC_LATEST); float voltage = dw_get_voltage(DW_ADC_SRC_LATEST); - printf("============================\n"); - printf("DW1000 Current Configuration\n"); - printf("============================\n"); - printf("Device id : %llx\n", dw_get_device_id()); - printf("sys_status : %llx\n", dw_read_reg_64(DW_REG_SYS_STATUS, DW_LEN_SYS_STATUS)); - printf("============================\n"); - printf( "sys_cfg : %x\n", sys_cfg_val ); - printf( "tx_fctrl : %x\n", tx_fctrl_val ); - printf( "chan_ctrl : %x\n", chan_ctrl_val ); - printf( "agc_tune1 : %x\n", agc_tune1_val ); - printf( "agc_tune2 : %x\n", agc_tune2_val ); - printf( "agc_tune3 : %x\n", agc_tune3_val ); - printf( "drx_tune0b : %x\n", drx_tune0b_val ); - printf( "drx_tune1a : %x\n", drx_tune1a_val ); - printf( "drx_tune1b : %x\n", drx_tune1b_val ); - printf( "drx_tune2 : %x\n", drx_tune2_val ); - printf( "drx_tune4h : %x\n", drx_tune4h_val ); - printf( "rf_rxctrl : %x\n", rf_rxctrl_val ); - printf( "rf_txctrl : %x\n", rf_txctrl_val ); - printf( "tc_pgdelay : %x\n", tc_pgdelay_val ); - printf( "fs_pllcfg : %x\n", fs_pllcfg_val ); - printf( "fs_plltune : %x\n", fs_plltune_val ); - printf("============================\n"); - printf( "temperature : %f\n", temperature ); - printf( "voltage : %f\n", voltage ); + DW_DEBUG("============================\n"); + DW_DEBUG("DW1000 Current Configuration\n"); + DW_DEBUG("============================\n"); + DW_DEBUG("Device id : %llx\n", dw_get_device_id()); + DW_DEBUG("sys_status : %llx\n", dw_read_reg_64(DW_REG_SYS_STATUS, DW_LEN_SYS_STATUS)); + DW_DEBUG("============================\n"); + DW_DEBUG( "sys_cfg : %x\n", sys_cfg_val ); + DW_DEBUG( "tx_fctrl : %x\n", tx_fctrl_val ); + DW_DEBUG( "chan_ctrl : %x\n", chan_ctrl_val ); + DW_DEBUG( "agc_tune1 : %x\n", agc_tune1_val ); + DW_DEBUG( "agc_tune2 : %x\n", agc_tune2_val ); + DW_DEBUG( "agc_tune3 : %x\n", agc_tune3_val ); + DW_DEBUG( "drx_tune0b : %x\n", drx_tune0b_val ); + DW_DEBUG( "drx_tune1a : %x\n", drx_tune1a_val ); + DW_DEBUG( "drx_tune1b : %x\n", drx_tune1b_val ); + DW_DEBUG( "drx_tune2 : %x\n", drx_tune2_val ); + DW_DEBUG( "drx_tune4h : %x\n", drx_tune4h_val ); + DW_DEBUG( "rf_rxctrl : %x\n", rf_rxctrl_val ); + DW_DEBUG( "rf_txctrl : %x\n", rf_txctrl_val ); + DW_DEBUG( "tc_pgdelay : %x\n", tc_pgdelay_val ); + DW_DEBUG( "fs_pllcfg : %x\n", fs_pllcfg_val ); + DW_DEBUG( "fs_plltune : %x\n", fs_plltune_val ); + DW_DEBUG("============================\n"); + DW_DEBUG( "temperature : %f\n", temperature ); + DW_DEBUG( "voltage : %f\n", voltage ); } /** @}*/ @@ -555,7 +555,7 @@ dw_test(void) if ( canTalk ) { - printf("You can now talk with the device (spi)!\n"); + DW_DEBUG("You can now talk with the device (spi)!\n"); } } @@ -863,7 +863,7 @@ dw_receive( dw1000_tranceive_t receive_type ) if ( dw1000.state == DW_STATE_RECEIVING || dw1000.state == DW_STATE_TRANSMITTING ) { - printf("dw1000 error: already using antenna.\n"); + DW_DEBUG("dw1000 error: already using antenna.\n"); return; } @@ -919,7 +919,7 @@ void dw_transmit( uint8_t * p_data, uint32_t data_len, dw1000_tranceive_t transm if ( dw1000.state == DW_STATE_RECEIVING || dw1000.state == DW_STATE_TRANSMITTING ) { - printf("dw1000 error: already using antenna.\n"); + DW_DEBUG("dw1000 error: already using antenna.\n"); return; } @@ -977,7 +977,7 @@ dw_transmit_multiple_data( uint8_t ** pp_data, if ( dw1000.state == DW_STATE_RECEIVING || dw1000.state == DW_STATE_TRANSMITTING ) { - printf("dw1000 error: already using antenna.\n"); + DW_DEBUG("dw1000 error: already using antenna.\n"); return; } @@ -1403,7 +1403,7 @@ dw_disable_rx_timeout() cfgReg = dw_read_reg_32( DW_REG_SYS_CFG, DW_LEN_SYS_CFG ); cfgReg &= ~DW_RXWTOE_MASK; dw_write_reg( DW_REG_SYS_CFG, DW_LEN_SYS_CFG, (uint8_t *)&cfgReg); - printf("CFG: %x\n", cfgReg); + DW_DEBUG("CFG: %x\n", cfgReg); } /** diff --git a/src/dw1000-base.h b/src/dw1000-base.h index dbf1f78d62f862210969cd89cba8f3f4fb455892..8774b17966daa1e6783b86cc1208e9f2b698fe24 100644 --- a/src/dw1000-base.h +++ b/src/dw1000-base.h @@ -388,6 +388,12 @@ #define DW_ERROR(...) #endif +#ifdef DEBUG + #define DW_DEBUG(...) printf(__VA_ARGS__); +#else + #define DW_DEBUG(...) +#endif + /** * \brief Used to choose from which source ADC should sample. */