1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

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", "SDIO",
"CURRENT_SENSOR", "CURRENT_SENSOR",
"USB", "USB",
"SMARTAUDIO",
}; };

View file

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

View file

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