diff --git a/ADF7021.cpp b/ADF7021.cpp index 4889e70..d100da0 100644 --- a/ADF7021.cpp +++ b/ADF7021.cpp @@ -974,6 +974,8 @@ void CIO::updateCal() setRX(); } +#if defined(ENABLE_DEBUG) + uint32_t CIO::RXfreq() { return (uint32_t)((float)(ADF7021_PFD / f_div) * ((float)((32768 * m_RX_N_divider) + m_RX_F_divider) / 32768.0)) + 100000; @@ -1023,3 +1025,5 @@ void CIO::printConf() } #endif + +#endif diff --git a/Config.h b/Config.h index 3bcf61f..cade0eb 100644 --- a/Config.h +++ b/Config.h @@ -63,4 +63,7 @@ // Disable mode LEDs blink during scan mode: // #define QUIET_MODE_LEDS +// Enable modem debug messages +// #define ENABLE_DEBUG + #endif diff --git a/DMRIdleRX.cpp b/DMRIdleRX.cpp index 3c84431..60ff9e4 100644 --- a/DMRIdleRX.cpp +++ b/DMRIdleRX.cpp @@ -61,7 +61,7 @@ void CDMRIdleRX::databit(bool bit) if (m_endPtr >= DMR_FRAME_LENGTH_BITS) m_endPtr -= DMR_FRAME_LENGTH_BITS; - DEBUG3("SYNC MS Data found pos/end:", m_dataPtr, m_endPtr); + // DEBUG3("SYNC MS Data found pos/end:", m_dataPtr, m_endPtr); } if (m_dataPtr == m_endPtr) { diff --git a/DStarRX.cpp b/DStarRX.cpp index 444935e..57f8659 100644 --- a/DStarRX.cpp +++ b/DStarRX.cpp @@ -382,10 +382,12 @@ void CDStarRX::processData(bool bit) bool syncSeen = false; if (m_dataBits >= SYNC_SCAN_START && m_dataBits <= (SYNC_POS + 1U)) { if (countBits32((m_patternBuffer & DATA_SYNC_MASK) ^ DATA_SYNC_DATA) <= DATA_SYNC_ERRS) { - if (m_dataBits < SYNC_POS) + if (m_dataBits < SYNC_POS) { DEBUG2("DStarRX: found data sync in Data, early", SYNC_POS - m_dataBits); - else + } + else { DEBUG1("DStarRX: found data sync in Data"); + } m_rxBufferBits = DSTAR_DATA_LENGTH_BITS; m_dataBits = 0U; diff --git a/Debug.h b/Debug.h index 144637d..c98da19 100644 --- a/Debug.h +++ b/Debug.h @@ -19,8 +19,11 @@ #if !defined(DEBUG_H) #define DEBUG_H +#include "Config.h" #include "Globals.h" +#if defined(ENABLE_DEBUG) + #define DEBUG1(a) serial.writeDebug((a)) #define DEBUG2(a,b) serial.writeDebug((a),(b)) #define DEBUG2I(a,b) serial.writeDebugI((a),(b)) @@ -28,5 +31,16 @@ #define DEBUG4(a,b,c,d) serial.writeDebug((a),(b),(c),(d)) #define DEBUG5(a,b,c,d,e) serial.writeDebug((a),(b),(c),(d),(e)) +#else + +#define DEBUG1(a) +#define DEBUG2(a,b) +#define DEBUG2I(a,b) +#define DEBUG3(a,b,c) +#define DEBUG4(a,b,c,d) +#define DEBUG5(a,b,c,d,e) + +#endif + #endif diff --git a/IO.h b/IO.h index 4ca2bb3..b6c13e0 100644 --- a/IO.h +++ b/IO.h @@ -122,6 +122,8 @@ public: void delay_IFcal(void); void delay_reset(void); void delay_us(uint32_t us); + +#if defined(ENABLE_DEBUG) uint32_t RXfreq(void); uint32_t TXfreq(void); uint16_t devDSTAR(void); @@ -130,7 +132,8 @@ public: uint16_t devP25(void); uint16_t devNXDN(void); void printConf(); - +#endif + private: uint8_t m_RX_N_divider; uint16_t m_RX_F_divider; diff --git a/SerialPort.cpp b/SerialPort.cpp index 2a590ea..6a8b14b 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -305,7 +305,9 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length) } io.start(); +#if defined(ENABLE_DEBUG) io.printConf(); +#endif if (modemState == STATE_DMRCAL || modemState == STATE_DMRDMO1K) m_firstCal = true; @@ -1028,6 +1030,8 @@ void CSerialPort::writeNXDNLost() writeInt(1U, reply, 3); } +#if defined(ENABLE_DEBUG) + void CSerialPort::writeDebug(const char* text) { if (!m_debug) @@ -1183,3 +1187,6 @@ void CSerialPort::writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n writeInt(1U, reply, count, true); } + +#endif + diff --git a/SerialPort.h b/SerialPort.h index 23ad071..805a0ee 100644 --- a/SerialPort.h +++ b/SerialPort.h @@ -48,12 +48,14 @@ public: void writeNXDNData(const uint8_t* data, uint8_t length); void writeNXDNLost(); +#if defined(ENABLE_DEBUG) void writeDebug(const char* text); void writeDebug(const char* text, int16_t n1); void writeDebugI(const char* text, int32_t n1); void writeDebug(const char* text, int16_t n1, int16_t n2); void writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n3); void writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n3, int16_t n4); +#endif private: uint8_t m_buffer[256U]; diff --git a/Utils.cpp b/Utils.cpp index 4e756dc..03b2258 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -57,6 +57,7 @@ uint8_t countBits64(uint64_t bits) return n; } +#if defined(ENABLE_DEBUG) // Simple functions to convert from int to string // Example from: https://stackoverflow.com/questions/8257714/how-to-convert-an-int-to-string-in-c static uint8_t *i2str_helper(uint8_t *dest, uint32_t n, int32_t x) { @@ -83,3 +84,4 @@ uint8_t *i2str(uint8_t *dest, uint32_t n, int32_t x) { *p = 0; return dest; } +#endif diff --git a/Utils.h b/Utils.h index 30e45d0..4ab35b7 100644 --- a/Utils.h +++ b/Utils.h @@ -20,6 +20,8 @@ #if !defined(UTILS_H) #define UTILS_H +#include "Config.h" + #if defined(STM32F10X_MD) #include "stm32f10x.h" #elif defined(STM32F4XX) @@ -36,7 +38,9 @@ uint8_t countBits32(uint32_t bits); uint8_t countBits64(uint64_t bits); +#if defined(ENABLE_DEBUG) uint8_t *i2str(uint8_t *dest, uint32_t n, int32_t x); +#endif #endif diff --git a/configs/MMDVM_HS_Hat.h b/configs/MMDVM_HS_Hat.h index 651661f..1e78647 100644 --- a/configs/MMDVM_HS_Hat.h +++ b/configs/MMDVM_HS_Hat.h @@ -63,4 +63,7 @@ // Disable mode LEDs blink during scan mode: // #define QUIET_MODE_LEDS +// Enable modem debug messages +// #define ENABLE_DEBUG + #endif diff --git a/configs/Nano_hotSPOT.h b/configs/Nano_hotSPOT.h index d6bfbb9..11d64de 100644 --- a/configs/Nano_hotSPOT.h +++ b/configs/Nano_hotSPOT.h @@ -63,4 +63,7 @@ // Disable mode LEDs blink during scan mode: // #define QUIET_MODE_LEDS +// Enable modem debug messages +// #define ENABLE_DEBUG + #endif diff --git a/configs/ZUMspot_Libre.h b/configs/ZUMspot_Libre.h index 3bcf61f..cade0eb 100644 --- a/configs/ZUMspot_Libre.h +++ b/configs/ZUMspot_Libre.h @@ -63,4 +63,7 @@ // Disable mode LEDs blink during scan mode: // #define QUIET_MODE_LEDS +// Enable modem debug messages +// #define ENABLE_DEBUG + #endif diff --git a/configs/ZUMspot_RPi.h b/configs/ZUMspot_RPi.h index 67c8a8d..fb49b9f 100644 --- a/configs/ZUMspot_RPi.h +++ b/configs/ZUMspot_RPi.h @@ -63,4 +63,7 @@ // Disable mode LEDs blink during scan mode: // #define QUIET_MODE_LEDS +// Enable modem debug messages +// #define ENABLE_DEBUG + #endif diff --git a/configs/ZUMspot_USB.h b/configs/ZUMspot_USB.h index 9aefdea..cb6c095 100644 --- a/configs/ZUMspot_USB.h +++ b/configs/ZUMspot_USB.h @@ -63,4 +63,7 @@ // Disable mode LEDs blink during scan mode: // #define QUIET_MODE_LEDS +// Enable modem debug messages +// #define ENABLE_DEBUG + #endif diff --git a/configs/ZUMspot_duplex.h b/configs/ZUMspot_duplex.h index 3d478d3..08b44de 100644 --- a/configs/ZUMspot_duplex.h +++ b/configs/ZUMspot_duplex.h @@ -63,4 +63,7 @@ // Disable mode LEDs blink during scan mode: // #define QUIET_MODE_LEDS +// Enable modem debug messages +// #define ENABLE_DEBUG + #endif