Skip to content

Commit

Permalink
Change SERIAL_DEBUG into RF24_DEBUG (#981)
Browse files Browse the repository at this point in the history
resolves #980
  • Loading branch information
2bndy5 authored Jun 15, 2024
1 parent 29231f2 commit 0aac3d5
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 59 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/cmake/PreventInSourceBuilds.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/GetLibInfo.cmake)

# allow CMake CLI options to configure RF24_config.h macros
option(SERIAL_DEBUG "enable/disable debugging output" OFF)
option(RF24_DEBUG "enable/disable debugging output" OFF)
option(MINIMAL "exclude optional source code to keep compile size compact" OFF)

# Link this 'library' to set the c++ standard / compile-time options requested
Expand Down Expand Up @@ -115,9 +115,9 @@ else() # utility driver is compiled with the library - not linking to a pre-comp
endif()

# assert the appropriate preprocessor macros for RF24_config.h
if(SERIAL_DEBUG)
message(STATUS "SERIAL_DEBUG asserted")
target_compile_definitions(${LibTargetName} PUBLIC SERIAL_DEBUG)
if(RF24_DEBUG)
message(STATUS "RF24_DEBUG asserted")
target_compile_definitions(${LibTargetName} PUBLIC RF24_DEBUG)
endif()
if(MINIMAL)
message(STATUS "MINIMAL asserted")
Expand Down
22 changes: 11 additions & 11 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void RF24::write_register(uint8_t reg, uint8_t value, bool is_cmd_only)
{
if (is_cmd_only) {
if (reg != RF24_NOP) { // don't print the get_status() operation
IF_SERIAL_DEBUG(printf_P(PSTR("write_register(%02x)\r\n"), reg));
IF_RF24_DEBUG(printf_P(PSTR("write_register(%02x)\r\n"), reg));
}
beginTransaction();
#if defined(RF24_LINUX)
Expand All @@ -301,7 +301,7 @@ void RF24::write_register(uint8_t reg, uint8_t value, bool is_cmd_only)
endTransaction();
}
else {
IF_SERIAL_DEBUG(printf_P(PSTR("write_register(%02x,%02x)\r\n"), reg, value));
IF_RF24_DEBUG(printf_P(PSTR("write_register(%02x,%02x)\r\n"), reg, value));
#if defined(RF24_LINUX) || defined(RF24_RP2)
beginTransaction();
uint8_t* prx = spi_rxbuff;
Expand Down Expand Up @@ -348,7 +348,7 @@ void RF24::write_payload(const void* buf, uint8_t data_len, const uint8_t writeT
}

//printf("[Writing %u bytes %u blanks]",data_len,blank_len);
IF_SERIAL_DEBUG(printf("[Writing %u bytes %u blanks]\n", data_len, blank_len););
IF_RF24_DEBUG(printf("[Writing %u bytes %u blanks]\n", data_len, blank_len););

#if defined(RF24_LINUX) || defined(RF24_RP2)
beginTransaction();
Expand Down Expand Up @@ -420,7 +420,7 @@ void RF24::read_payload(void* buf, uint8_t data_len)

//printf("[Reading %u bytes %u blanks]",data_len,blank_len);

IF_SERIAL_DEBUG(printf("[Reading %u bytes %u blanks]\n", data_len, blank_len););
IF_RF24_DEBUG(printf("[Reading %u bytes %u blanks]\n", data_len, blank_len););

#if defined(RF24_LINUX) || defined(RF24_RP2)
beginTransaction();
Expand Down Expand Up @@ -1229,7 +1229,7 @@ void RF24::powerUp(void)

void RF24::errNotify()
{
#if defined(SERIAL_DEBUG) || defined(RF24_LINUX)
#if defined(RF24_DEBUG) || defined(RF24_LINUX)
printf_P(PSTR("RF24 HARDWARE FAIL: Radio not responding, verify pin connections, wiring, etc.\r\n"));
#endif
#if defined(FAILURE_HANDLING)
Expand Down Expand Up @@ -1690,7 +1690,7 @@ void RF24::enableDynamicPayloads(void)
//toggle_features();
write_register(FEATURE, read_register(FEATURE) | _BV(EN_DPL));

IF_SERIAL_DEBUG(printf("FEATURE=%i\r\n", read_register(FEATURE)));
IF_RF24_DEBUG(printf("FEATURE=%i\r\n", read_register(FEATURE)));

// Enable dynamic payload on all pipes
//
Expand All @@ -1710,7 +1710,7 @@ void RF24::disableDynamicPayloads(void)
//toggle_features();
write_register(FEATURE, 0);

IF_SERIAL_DEBUG(printf("FEATURE=%i\r\n", read_register(FEATURE)));
IF_RF24_DEBUG(printf("FEATURE=%i\r\n", read_register(FEATURE)));

// Disable dynamic payload on all pipes
//
Expand All @@ -1731,7 +1731,7 @@ void RF24::enableAckPayload(void)
if (!ack_payloads_enabled) {
write_register(FEATURE, read_register(FEATURE) | _BV(EN_ACK_PAY) | _BV(EN_DPL));

IF_SERIAL_DEBUG(printf("FEATURE=%i\r\n", read_register(FEATURE)));
IF_RF24_DEBUG(printf("FEATURE=%i\r\n", read_register(FEATURE)));

// Enable dynamic payload on pipes 0 & 1
write_register(DYNPD, read_register(DYNPD) | _BV(DPL_P1) | _BV(DPL_P0));
Expand All @@ -1748,7 +1748,7 @@ void RF24::disableAckPayload(void)
if (ack_payloads_enabled) {
write_register(FEATURE, static_cast<uint8_t>(read_register(FEATURE) & ~_BV(EN_ACK_PAY)));

IF_SERIAL_DEBUG(printf("FEATURE=%i\r\n", read_register(FEATURE)));
IF_RF24_DEBUG(printf("FEATURE=%i\r\n", read_register(FEATURE)));

ack_payloads_enabled = false;
}
Expand All @@ -1764,7 +1764,7 @@ void RF24::enableDynamicAck(void)
//toggle_features();
write_register(FEATURE, read_register(FEATURE) | _BV(EN_DYN_ACK));

IF_SERIAL_DEBUG(printf("FEATURE=%i\r\n", read_register(FEATURE)));
IF_RF24_DEBUG(printf("FEATURE=%i\r\n", read_register(FEATURE)));
}

/****************************************************************************/
Expand Down Expand Up @@ -1989,7 +1989,7 @@ void RF24::startConstCarrier(rf24_pa_dbm_e level, uint8_t channel)
}
setPALevel(level);
setChannel(channel);
IF_SERIAL_DEBUG(printf_P(PSTR("RF_SETUP=%02x\r\n"), read_register(RF_SETUP)));
IF_RF24_DEBUG(printf_P(PSTR("RF_SETUP=%02x\r\n"), read_register(RF_SETUP)));
ce(HIGH);
if (isPVariant()) {
delay(1); // datasheet says 1 ms is ok in this instance
Expand Down
10 changes: 5 additions & 5 deletions RF24_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/*** USER DEFINES: ***/
#define FAILURE_HANDLING
//#define SERIAL_DEBUG
//#define RF24_DEBUG
//#define MINIMAL
//#define SPI_UART // Requires library from https://github.com/TMRh20/Sketches/tree/master/SPI_UART
//#define SOFTSPI // Requires library from https://github.com/greiman/DigitalIO
Expand Down Expand Up @@ -158,15 +158,15 @@ extern HardwareSPI SPI;
#endif
#endif // defined (ARDUINO) && !defined (__arm__) && !defined (__ARDUINO_X86__)

#ifdef SERIAL_DEBUG
#define IF_SERIAL_DEBUG(x) ({ x; })
#ifdef RF24_DEBUG
#define IF_RF24_DEBUG(x) ({ x; })
#else
#define IF_SERIAL_DEBUG(x)
#define IF_RF24_DEBUG(x)
#if defined(RF24_TINY)
#define printf_P(...)
#endif // defined(RF24_TINY)

#endif // SERIAL_DEBUG
#endif // RF24_DEBUG

#if defined(__ARDUINO_X86__)
#define printf_P printf
Expand Down
8 changes: 4 additions & 4 deletions utility/ATTiny/RF24_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ typedef uint8_t rf24_gpio_pin_t;
#define RF24_CSN_SETTLE_HIGH_DELAY 100
#endif

#ifdef SERIAL_DEBUG
#define IF_SERIAL_DEBUG(x) ({ x; })
#ifdef RF24_DEBUG
#define IF_RF24_DEBUG(x) ({ x; })
#else
#define IF_SERIAL_DEBUG(x)
#define IF_RF24_DEBUG(x)

#if defined(RF24_TINY)
#define printf_P(...)
#endif
#endif // !defined(SERIAL_DEBUG)
#endif // !defined(RF24_DEBUG)

#include <avr/pgmspace.h>

Expand Down
7 changes: 3 additions & 4 deletions utility/ATXMegaD3/RF24_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@
#define _SPI SPI
#define RF24_SPI_PTR

#undef SERIAL_DEBUG
#ifdef SERIAL_DEBUG
#define IF_SERIAL_DEBUG(x) ({ x; })
#ifdef RF24_DEBUG
#define IF_RF24_DEBUG(x) ({ x; })
#else
#define IF_SERIAL_DEBUG(x)
#define IF_RF24_DEBUG(x)
#endif

// Use the avr pgmspace commands
Expand Down
6 changes: 3 additions & 3 deletions utility/LittleWire/RF24_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ typedef uint8_t rf24_gpio_pin_t;
#define PROGMEM
#define PRIPSTR "%s"

#ifdef SERIAL_DEBUG
#define IF_SERIAL_DEBUG(x) ({ x; })
#ifdef RF24_DEBUG
#define IF_RF24_DEBUG(x) ({ x; })
#else
#define IF_SERIAL_DEBUG(x)
#define IF_RF24_DEBUG(x)
#if defined(RF24_TINY)
#define printf_P(...)
#endif
Expand Down
6 changes: 3 additions & 3 deletions utility/MRAA/RF24_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
#define PROGMEM
#define PRIPSTR "%s"

#ifdef SERIAL_DEBUG
#define IF_SERIAL_DEBUG(x) ({ x; })
#ifdef RF24_DEBUG
#define IF_RF24_DEBUG(x) ({ x; })
#else
#define IF_SERIAL_DEBUG(x)
#define IF_RF24_DEBUG(x)
#endif

#define digitalWrite(pin, value) GPIO::write(pin, value)
Expand Down
6 changes: 3 additions & 3 deletions utility/RPi/RF24_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ typedef uint8_t rf24_gpio_pin_t;
#define PROGMEM
#define PRIPSTR "%s"

#ifdef SERIAL_DEBUG
#define IF_SERIAL_DEBUG(x) ({ x; })
#ifdef RF24_DEBUG
#define IF_RF24_DEBUG(x) ({ x; })
#else
#define IF_SERIAL_DEBUG(x)
#define IF_RF24_DEBUG(x)
#endif

#define digitalWrite(pin, value) bcm2835_gpio_write(pin, value)
Expand Down
7 changes: 3 additions & 4 deletions utility/SPIDEV/RF24_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
#define _BV(x) (1 << (x))
#define _SPI spi

//#undef SERIAL_DEBUG
#ifdef SERIAL_DEBUG
#define IF_SERIAL_DEBUG(x) ({ x; })
#ifdef RF24_DEBUG
#define IF_RF24_DEBUG(x) ({ x; })
#else
#define IF_SERIAL_DEBUG(x)
#define IF_RF24_DEBUG(x)
#endif

// Avoid spurious warnings
Expand Down
6 changes: 3 additions & 3 deletions utility/Teensy/RF24_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ typedef uint8_t rf24_gpio_pin_t;

#define printf Serial.printf

#ifdef SERIAL_DEBUG
#define IF_SERIAL_DEBUG(x) ({ x; })
#ifdef RF24_DEBUG
#define IF_RF24_DEBUG(x) ({ x; })
#else
#define IF_SERIAL_DEBUG(x)
#define IF_RF24_DEBUG(x)
#endif

#define PRIPSTR "%s"
Expand Down
7 changes: 3 additions & 4 deletions utility/Template/RF24_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@
#define _BV(x) (1 << (x))
#define _SPI spi

#undef SERIAL_DEBUG
#ifdef SERIAL_DEBUG
#define IF_SERIAL_DEBUG(x) ({ x; })
#ifdef RF24_DEBUG
#define IF_RF24_DEBUG(x) ({ x; })
#else
#define IF_SERIAL_DEBUG(x)
#define IF_RF24_DEBUG(x)
#endif

// Avoid spurious warnings
Expand Down
7 changes: 3 additions & 4 deletions utility/pigpio/RF24_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
#define _BV(x) (1 << (x))
#define _SPI spi

//#undef SERIAL_DEBUG
#ifdef SERIAL_DEBUG
#define IF_SERIAL_DEBUG(x) ({ x; })
#ifdef RF24_DEBUG
#define IF_RF24_DEBUG(x) ({ x; })
#else
#define IF_SERIAL_DEBUG(x)
#define IF_RF24_DEBUG(x)
#endif

// Avoid spurious warnings
Expand Down
6 changes: 3 additions & 3 deletions utility/rp2/RF24_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
#define _SPI SPI
#define RF24_SPI_PTR

#ifdef SERIAL_DEBUG
#define IF_SERIAL_DEBUG(x) ({ x; })
#ifdef RF24_DEBUG
#define IF_RF24_DEBUG(x) ({ x; })
#else
#define IF_SERIAL_DEBUG(x)
#define IF_RF24_DEBUG(x)
#endif

typedef uint16_t prog_uint16_t;
Expand Down
7 changes: 3 additions & 4 deletions utility/wiringPi/RF24_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
#define _BV(x) (1 << (x))
#define _SPI spi

#undef SERIAL_DEBUG
#ifdef SERIAL_DEBUG
#define IF_SERIAL_DEBUG(x) ({ x; })
#ifdef RF24_DEBUG
#define IF_RF24_DEBUG(x) ({ x; })
#else
#define IF_SERIAL_DEBUG(x)
#define IF_RF24_DEBUG(x)
#endif

// Avoid spurious warnings
Expand Down

0 comments on commit 0aac3d5

Please sign in to comment.