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

Some adjustment for debugging on F4 (OMNIBUSF4)

This commit is contained in:
jflyper 2016-11-23 10:52:01 +09:00
parent af6010eb63
commit 2c4e399ca1
3 changed files with 30 additions and 15 deletions

View file

@ -33,7 +33,13 @@
//#define SMARTAUDIO_DEBUG_MONITOR //#define SMARTAUDIO_DEBUG_MONITOR
#ifdef SMARTAUDIO_DPRINTF #ifdef SMARTAUDIO_DPRINTF
#ifdef OMNIBUSF4
#define DPRINTF_SERIAL_PORT SERIAL_PORT_USART3
#else
#define DPRINTF_SERIAL_PORT SERIAL_PORT_USART1 #define DPRINTF_SERIAL_PORT SERIAL_PORT_USART1
#endif
serialPort_t *debugSerialPort = NULL; serialPort_t *debugSerialPort = NULL;
#define dprintf(x) if (debugSerialPort) printf x #define dprintf(x) if (debugSerialPort) printf x
#else #else
@ -90,6 +96,8 @@ enum {
// Statistical counters, for user side trouble shooting. // Statistical counters, for user side trouble shooting.
typedef struct smartAudioStat_s { typedef struct smartAudioStat_s {
uint16_t pktsent;
uint16_t pktrcvd;
uint16_t badpre; uint16_t badpre;
uint16_t badlen; uint16_t badlen;
uint16_t crc; uint16_t crc;
@ -98,6 +106,8 @@ typedef struct smartAudioStat_s {
} smartAudioStat_t; } smartAudioStat_t;
static smartAudioStat_t saStat = { static smartAudioStat_t saStat = {
.pktsent = 0,
.pktrcvd = 0,
.badpre = 0, .badpre = 0,
.badlen = 0, .badlen = 0,
.crc = 0, .crc = 0,
@ -230,26 +240,21 @@ static int sa_baudstep = 50;
#define SMARTAUDIO_CMD_TIMEOUT 120 #define SMARTAUDIO_CMD_TIMEOUT 120
// Statistics for autobauding
static int sa_pktsent = 0;
static int sa_pktrcvd = 0;
static void saAutobaud(void) static void saAutobaud(void)
{ {
if (sa_pktsent < 10) if (saStat.pktsent < 10)
// Not enough samples collected // Not enough samples collected
return; return;
#if 0 #if 0
dprintf(("autobaud: %d rcvd %d/%d (%d)\r\n", dprintf(("autobaud: %d rcvd %d/%d (%d)\r\n",
sa_smartbaud, sa_pktrcvd, sa_pktsent, ((sa_pktrcvd * 100) / sa_pktsent))); sa_smartbaud, saStat.pktrcvd, saStat.pktsent, ((saStat.pktrcvd * 100) / saStat.pktsent)));
#endif #endif
if (((sa_pktrcvd * 100) / sa_pktsent) >= 70) { if (((saStat.pktrcvd * 100) / saStat.pktsent) >= 70) {
// This is okay // This is okay
sa_pktsent = 0; // Should be more moderate? saStat.pktsent = 0; // Should be more moderate?
sa_pktrcvd = 0; saStat.pktrcvd = 0;
return; return;
} }
@ -269,8 +274,8 @@ static void saAutobaud(void)
smartAudioSerialPort->vTable->serialSetBaudRate(smartAudioSerialPort, sa_smartbaud); smartAudioSerialPort->vTable->serialSetBaudRate(smartAudioSerialPort, sa_smartbaud);
sa_pktsent = 0; saStat.pktsent = 0;
sa_pktrcvd = 0; saStat.pktrcvd = 0;
} }
// Transport level variables // Transport level variables
@ -431,7 +436,7 @@ static void saReceiveFramer(uint8_t c)
if (CRC8(sa_rbuf, 2 + len) == c) { if (CRC8(sa_rbuf, 2 + len) == c) {
// Got a response // Got a response
saProcessResponse(sa_rbuf, len + 2); saProcessResponse(sa_rbuf, len + 2);
sa_pktrcvd++; saStat.pktrcvd++;
} else if (sa_rbuf[0] & 1) { } else if (sa_rbuf[0] & 1) {
// Command echo // Command echo
// XXX There is an exceptional case (V2 response) // XXX There is an exceptional case (V2 response)
@ -456,7 +461,7 @@ static void saSendFrame(uint8_t *buf, int len)
serialWrite(smartAudioSerialPort, 0x00); // XXX Probably don't need this serialWrite(smartAudioSerialPort, 0x00); // XXX Probably don't need this
sa_lastTransmission = millis(); sa_lastTransmission = millis();
sa_pktsent++; saStat.pktsent++;
} }
/* /*
@ -925,6 +930,8 @@ static const char * const saCmsDeviceStatusNames[] = {
static OSD_TAB_t saCmsEntOnline = { &saCmsDeviceStatus, 2, saCmsDeviceStatusNames }; static OSD_TAB_t saCmsEntOnline = { &saCmsDeviceStatus, 2, saCmsDeviceStatusNames };
static OSD_UINT16_t saCmsEntBaudrate = { &sa_smartbaud, 0, 0, 0 }; static OSD_UINT16_t saCmsEntBaudrate = { &sa_smartbaud, 0, 0, 0 };
static OSD_UINT16_t saCmsEntStatPktSent = { &saStat.pktsent, 0, 0, 0 };
static OSD_UINT16_t saCmsEntStatPktRcvd = { &saStat.pktrcvd, 0, 0, 0 };
static OSD_UINT16_t saCmsEntStatBadpre = { &saStat.badpre, 0, 0, 0 }; static OSD_UINT16_t saCmsEntStatBadpre = { &saStat.badpre, 0, 0, 0 };
static OSD_UINT16_t saCmsEntStatBadlen = { &saStat.badlen, 0, 0, 0 }; static OSD_UINT16_t saCmsEntStatBadlen = { &saStat.badlen, 0, 0, 0 };
static OSD_UINT16_t saCmsEntStatCrcerr = { &saStat.crc, 0, 0, 0 }; static OSD_UINT16_t saCmsEntStatCrcerr = { &saStat.crc, 0, 0, 0 };
@ -934,6 +941,8 @@ static OSD_Entry menu_smartAudioStatsEntries[] = {
{ "- SA STATS -", OME_Label, NULL, NULL, 0 }, { "- SA STATS -", OME_Label, NULL, NULL, 0 },
{ "STATUS", OME_TAB, NULL, &saCmsEntOnline, DYNAMIC }, { "STATUS", OME_TAB, NULL, &saCmsEntOnline, DYNAMIC },
{ "BAUDRATE", OME_UINT16, NULL, &saCmsEntBaudrate, DYNAMIC }, { "BAUDRATE", OME_UINT16, NULL, &saCmsEntBaudrate, DYNAMIC },
{ "SENT", OME_UINT16, NULL, &saCmsEntStatPktSent, DYNAMIC },
{ "RCVD", OME_UINT16, NULL, &saCmsEntStatPktRcvd, DYNAMIC },
{ "BADPRE", OME_UINT16, NULL, &saCmsEntStatBadpre, DYNAMIC }, { "BADPRE", OME_UINT16, NULL, &saCmsEntStatBadpre, DYNAMIC },
{ "BADLEN", OME_UINT16, NULL, &saCmsEntStatBadlen, DYNAMIC }, { "BADLEN", OME_UINT16, NULL, &saCmsEntStatBadlen, DYNAMIC },
{ "CRCERR", OME_UINT16, NULL, &saCmsEntStatCrcerr, DYNAMIC }, { "CRCERR", OME_UINT16, NULL, &saCmsEntStatCrcerr, DYNAMIC },

View file

@ -101,6 +101,11 @@
#define SERIAL_PORT_COUNT 4 //VCP, USART1, USART3, USART6 #define SERIAL_PORT_COUNT 4 //VCP, USART1, USART3, USART6
// VTX monitor task
#define VTX_CONTROL
// VTX device type
#define VTX_SMARTAUDIO
#define USE_SPI #define USE_SPI
#define USE_SPI_DEVICE_1 #define USE_SPI_DEVICE_1

View file

@ -5,5 +5,6 @@ TARGET_SRC = \
drivers/accgyro_spi_mpu6000.c \ drivers/accgyro_spi_mpu6000.c \
drivers/barometer_ms5611.c \ drivers/barometer_ms5611.c \
drivers/compass_hmc5883l.c \ drivers/compass_hmc5883l.c \
drivers/max7456.c drivers/max7456.c \
io/vtx_smartaudio.c