Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Commit

Permalink
Added debug port configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jgromes committed Nov 14, 2019
1 parent 2a8c38f commit aec5c84
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
6 changes: 4 additions & 2 deletions src/TypeDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
#error "Unsupported Arduino version (< 1.0.0)"
#endif

#define RADIOLIB_DEBUG_PORT Serial

//#define RADIOLIB_DEBUG

#ifdef RADIOLIB_DEBUG
#define RADIOLIB_DEBUG_PRINT(...) { Serial.print(__VA_ARGS__); }
#define RADIOLIB_DEBUG_PRINTLN(...) { Serial.println(__VA_ARGS__); }
#define RADIOLIB_DEBUG_PRINT(...) { RADIOLIB_DEBUG_PORT.print(__VA_ARGS__); }
#define RADIOLIB_DEBUG_PRINTLN(...) { RADIOLIB_DEBUG_PORT.println(__VA_ARGS__); }
#else
#define RADIOLIB_DEBUG_PRINT(...) {}
#define RADIOLIB_DEBUG_PRINTLN(...) {}
Expand Down
31 changes: 15 additions & 16 deletions src/modules/SX127x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,16 +1015,15 @@ bool SX127x::findChip(uint8_t ver) {
flagFound = true;
} else {
#ifdef RADIOLIB_DEBUG
Serial.print(F("SX127x not found! ("));
Serial.print(i + 1);
Serial.print(F(" of 10 tries) SX127X_REG_VERSION == "));
RADIOLIB_DEBUG_PRINT(F("SX127x not found! ("));
RADIOLIB_DEBUG_PRINT(i + 1);
RADIOLIB_DEBUG_PRINT(F(" of 10 tries) SX127X_REG_VERSION == "));

char buffHex[5];
sprintf(buffHex, "0x%02X", version);
Serial.print(buffHex);
Serial.print(F(", expected 0x00"));
Serial.print(ver, HEX);
Serial.println();
RADIOLIB_DEBUG_PRINT(buffHex);
RADIOLIB_DEBUG_PRINT(F(", expected 0x00"));
RADIOLIB_DEBUG_PRINTLN(ver, HEX);
#endif
delay(1000);
i++;
Expand Down Expand Up @@ -1073,23 +1072,23 @@ void SX127x::clearFIFO(size_t count) {

#ifdef RADIOLIB_DEBUG
void SX127x::regDump() {
Serial.println();
Serial.println(F("ADDR\tVALUE"));
RADIOLIB_DEBUG_PRINTLN();
RADIOLIB_DEBUG_PRINTLN(F("ADDR\tVALUE"));
for(uint16_t addr = 0x01; addr <= 0x70; addr++) {
if(addr <= 0x0F) {
Serial.print(F("0x0"));
RADIOLIB_DEBUG_PRINT(F("0x0"));
} else {
Serial.print(F("0x"));
RADIOLIB_DEBUG_PRINT(F("0x"));
}
Serial.print(addr, HEX);
Serial.print('\t');
RADIOLIB_DEBUG_PRINT(addr, HEX);
RADIOLIB_DEBUG_PRINT('\t');
uint8_t val = _mod->SPIreadRegister(addr);
if(val <= 0x0F) {
Serial.print(F("0x0"));
RADIOLIB_DEBUG_PRINT(F("0x0"));
} else {
Serial.print(F("0x"));
RADIOLIB_DEBUG_PRINT(F("0x"));
}
Serial.println(val, HEX);
RADIOLIB_DEBUG_PRINTLN(val, HEX);

delay(50);
}
Expand Down

0 comments on commit aec5c84

Please sign in to comment.