mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 06:15:16 +03:00
Merge pull request #592 from sherlockflight/blackbox-serial-baud
Support new 230400 baud rate which allows >750Hz Blackbox logging
This commit is contained in:
commit
626bd29dae
7 changed files with 63 additions and 24 deletions
|
@ -62,9 +62,6 @@
|
|||
|
||||
#ifdef BLACKBOX
|
||||
|
||||
#define BLACKBOX_BAUDRATE 115200
|
||||
#define BLACKBOX_INITIAL_PORT_MODE MODE_TX
|
||||
|
||||
// How many bytes should we transmit per loop iteration?
|
||||
uint8_t blackboxWriteChunkSize = 16;
|
||||
|
||||
|
@ -447,12 +444,29 @@ bool blackboxDeviceOpen(void)
|
|||
case BLACKBOX_DEVICE_SERIAL:
|
||||
{
|
||||
serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_BLACKBOX);
|
||||
baudRate_e baudRateIndex;
|
||||
portMode_t portMode;
|
||||
|
||||
if (!portConfig) {
|
||||
return false;
|
||||
}
|
||||
blackboxPortSharing = determinePortSharing(portConfig, FUNCTION_BLACKBOX);
|
||||
|
||||
blackboxPort = openSerialPort(portConfig->identifier, FUNCTION_BLACKBOX, NULL, BLACKBOX_BAUDRATE, BLACKBOX_INITIAL_PORT_MODE, SERIAL_NOT_INVERTED);
|
||||
blackboxPortSharing = determinePortSharing(portConfig, FUNCTION_BLACKBOX);
|
||||
baudRateIndex = portConfig->blackbox_baudrateIndex;
|
||||
|
||||
portMode = MODE_TX;
|
||||
|
||||
if (baudRates[baudRateIndex] == 230400) {
|
||||
/*
|
||||
* OpenLog's 230400 baud rate is very inaccurate, so it requires a larger inter-character gap in
|
||||
* order to maintain synchronization.
|
||||
*/
|
||||
portMode |= MODE_STOPBITS2;
|
||||
}
|
||||
|
||||
blackboxPort = openSerialPort(portConfig->identifier, FUNCTION_BLACKBOX, NULL, baudRates[baudRateIndex],
|
||||
portMode, SERIAL_NOT_INVERTED);
|
||||
|
||||
return blackboxPort != NULL;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -28,6 +28,7 @@ typedef enum portMode_t {
|
|||
MODE_RXTX = MODE_RX | MODE_TX,
|
||||
MODE_SBUS = 1 << 2,
|
||||
MODE_BIDIR = 1 << 3,
|
||||
MODE_STOPBITS2 = 1 << 4,
|
||||
} portMode_t;
|
||||
|
||||
typedef void (*serialReceiveCallbackPtr)(uint16_t data); // used by serial drivers to return frames to app
|
||||
|
|
|
@ -76,7 +76,11 @@ static void uartReconfigure(uartPort_t *uartPort)
|
|||
USART_InitStructure.USART_StopBits = USART_StopBits_2;
|
||||
USART_InitStructure.USART_Parity = USART_Parity_Even;
|
||||
} else {
|
||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||
if (uartPort->port.mode & MODE_STOPBITS2)
|
||||
USART_InitStructure.USART_StopBits = USART_StopBits_2;
|
||||
else
|
||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||
|
||||
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||
}
|
||||
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||
|
|
|
@ -68,7 +68,7 @@ serialPortIdentifier_e serialPortIdentifiers[SERIAL_PORT_COUNT] = {
|
|||
#endif
|
||||
};
|
||||
|
||||
uint32_t baudRates[] = {0, 9600, 19200, 38400, 57600, 115200}; // see baudRate_e
|
||||
uint32_t baudRates[] = {0, 9600, 19200, 38400, 57600, 115200, 230400, 250000}; // see baudRate_e
|
||||
|
||||
#define BAUD_RATE_COUNT (sizeof(baudRates) / sizeof(baudRates[0]))
|
||||
|
||||
|
|
|
@ -41,7 +41,9 @@ typedef enum {
|
|||
BAUD_19200,
|
||||
BAUD_38400,
|
||||
BAUD_57600,
|
||||
BAUD_115200
|
||||
BAUD_115200,
|
||||
BAUD_230400,
|
||||
BAUD_250000,
|
||||
} baudRate_e;
|
||||
|
||||
extern uint32_t baudRates[];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue