Cleaned up SmartAudio debugging.

This commit is contained in:
mikeller 2018-05-13 02:08:27 +12:00
parent eab55fc3ee
commit a48da6c1ee
4 changed files with 16 additions and 21 deletions

View File

@ -67,4 +67,5 @@ const char * const debugModeNames[DEBUG_COUNT] = {
"SDIO",
"CURRENT_SENSOR",
"USB",
"SMARTAUDIO",
};

View File

@ -85,6 +85,7 @@ typedef enum {
DEBUG_SDIO,
DEBUG_CURRENT,
DEBUG_USB,
DEBUG_SMARTAUDIO,
DEBUG_COUNT
} debugType_e;

View File

@ -54,12 +54,12 @@
#define SMARTAUDIO_POLLING_INTERVAL 150 // Minimum time between state polling
#define SMARTAUDIO_POLLING_WINDOW 1000 // Time window after command polling for state change
//#define SMARTAUDIO_DPRINTF
//#define SMARTAUDIO_DEBUG_MONITOR
//#define USE_SMARTAUDIO_DPRINTF
//#define DPRINTF_SERIAL_PORT SERIAL_PORT_USART1
#ifdef SMARTAUDIO_DPRINTF
#ifdef USE_SMARTAUDIO_DPRINTF
serialPort_t *debugSerialPort = NULL;
#endif // SMARTAUDIO_DPRINTF
#endif // USE_SMARTAUDIO_DPRINTF
static serialPort_t *smartAudioSerialPort = NULL;
@ -180,7 +180,7 @@ static uint8_t CRC8(const uint8_t *data, const int8_t len)
}
#ifdef SMARTAUDIO_DPRINTF
#ifdef USE_SMARTAUDIO_DPRINTF
static void saPrintSettings(void)
{
dprintf(("Current status: version: %d\r\n", saDevice.version));
@ -290,12 +290,10 @@ static void saProcessResponse(uint8_t *buf, int len)
saDevice.mode = buf[4];
saDevice.freq = (buf[5] << 8)|buf[6];
#ifdef SMARTAUDIO_DEBUG_MONITOR
debug[0] = saDevice.version * 100 + saDevice.mode;
debug[1] = saDevice.channel;
debug[2] = saDevice.freq;
debug[3] = saDevice.power;
#endif
DEBUG_SET(DEBUG_SMARTAUDIO, 0, saDevice.version * 100 + saDevice.mode);
DEBUG_SET(DEBUG_SMARTAUDIO, 1, saDevice.channel);
DEBUG_SET(DEBUG_SMARTAUDIO, 2, saDevice.freq);
DEBUG_SET(DEBUG_SMARTAUDIO, 3, saDevice.power);
break;
case SA_CMD_SET_POWER: // Set Power
@ -336,7 +334,7 @@ static void saProcessResponse(uint8_t *buf, int len)
#ifdef USE_CMS //if changes then trigger saCms update
saCmsResetOpmodel();
#endif
#ifdef SMARTAUDIO_DPRINTF // Debug
#ifdef USE_SMARTAUDIO_DPRINTF // Debug
saPrintSettings();
#endif
}
@ -503,7 +501,7 @@ static saCmdQueue_t sa_queue[SA_QSIZE];
static uint8_t sa_qhead = 0;
static uint8_t sa_qtail = 0;
#ifdef DPRINTF_SMARTAUDIO
#ifdef USE_DPRINTF_SMARTAUDIO
static int saQueueLength(void)
{
if (sa_qhead >= sa_qtail) {
@ -667,7 +665,7 @@ void saSetPowerByIndex(uint8_t index)
bool vtxSmartAudioInit(void)
{
#ifdef SMARTAUDIO_DPRINTF
#ifdef USE_SMARTAUDIO_DPRINTF
// Setup debugSerialPort
debugSerialPort = openSerialPort(DPRINTF_SERIAL_PORT, FUNCTION_NONE, NULL, NULL, 115200, MODE_RXTX, 0);

View File

@ -103,14 +103,9 @@ void saSetFreq(uint16_t freq);
void saSetPitFreq(uint16_t freq);
bool vtxSmartAudioInit(void);
#ifdef SMARTAUDIO_DPRINTF
#ifdef OMNIBUSF4
#define DPRINTF_SERIAL_PORT SERIAL_PORT_USART3
#else
#define DPRINTF_SERIAL_PORT SERIAL_PORT_USART1
#endif
#ifdef USE_SMARTAUDIO_DPRINTF
extern serialPort_t *debugSerialPort;
#define dprintf(x) if (debugSerialPort) printf x
#else
#define dprintf(x)
#endif // SMARTAUDIO_DPRINTF
#endif // USE_SMARTAUDIO_DPRINTF