Optional debug messages at compile time to save FLASH space

This commit is contained in:
Andy CA6JAU 2018-02-16 21:30:30 -03:00
parent 64cad981fa
commit 37724bbabf
16 changed files with 63 additions and 4 deletions

View file

@ -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

View file

@ -63,4 +63,7 @@
// Disable mode LEDs blink during scan mode:
// #define QUIET_MODE_LEDS
// Enable modem debug messages
// #define ENABLE_DEBUG
#endif

View file

@ -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) {

View file

@ -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;

14
Debug.h
View file

@ -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

5
IO.h
View file

@ -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;

View file

@ -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

View file

@ -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];

View file

@ -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

View file

@ -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

View file

@ -63,4 +63,7 @@
// Disable mode LEDs blink during scan mode:
// #define QUIET_MODE_LEDS
// Enable modem debug messages
// #define ENABLE_DEBUG
#endif

View file

@ -63,4 +63,7 @@
// Disable mode LEDs blink during scan mode:
// #define QUIET_MODE_LEDS
// Enable modem debug messages
// #define ENABLE_DEBUG
#endif

View file

@ -63,4 +63,7 @@
// Disable mode LEDs blink during scan mode:
// #define QUIET_MODE_LEDS
// Enable modem debug messages
// #define ENABLE_DEBUG
#endif

View file

@ -63,4 +63,7 @@
// Disable mode LEDs blink during scan mode:
// #define QUIET_MODE_LEDS
// Enable modem debug messages
// #define ENABLE_DEBUG
#endif

View file

@ -63,4 +63,7 @@
// Disable mode LEDs blink during scan mode:
// #define QUIET_MODE_LEDS
// Enable modem debug messages
// #define ENABLE_DEBUG
#endif

View file

@ -63,4 +63,7 @@
// Disable mode LEDs blink during scan mode:
// #define QUIET_MODE_LEDS
// Enable modem debug messages
// #define ENABLE_DEBUG
#endif