From a156d915f433745dc5c49f373347a67c5e3f937b Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Tue, 3 Mar 2015 17:30:35 +0000 Subject: [PATCH] Only index into the configurable baud rate list when needed. --- src/main/blackbox/blackbox_io.c | 2 +- src/main/io/serial.c | 4 +--- src/main/io/serial.h | 2 +- src/main/io/serial_msp.c | 2 +- src/main/rx/spektrum.c | 2 +- src/main/telemetry/frsky.c | 2 +- src/main/telemetry/hott.c | 2 +- src/main/telemetry/msp.c | 2 +- src/main/telemetry/smartport.c | 2 +- src/test/unit/telemetry_hott_unittest.cc | 4 ++-- 10 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/blackbox/blackbox_io.c b/src/main/blackbox/blackbox_io.c index 9fbcaa650..4f1fefb1d 100644 --- a/src/main/blackbox/blackbox_io.c +++ b/src/main/blackbox/blackbox_io.c @@ -62,7 +62,7 @@ #ifdef BLACKBOX -#define BLACKBOX_BAUDRATE BAUD_115200 +#define BLACKBOX_BAUDRATE 115200 #define BLACKBOX_INITIAL_PORT_MODE MODE_TX // How many bytes should we transmit per loop iteration? diff --git a/src/main/io/serial.c b/src/main/io/serial.c index cc291bad4..3f358b1d7 100644 --- a/src/main/io/serial.c +++ b/src/main/io/serial.c @@ -236,7 +236,7 @@ serialPort_t *openSerialPort( serialPortIdentifier_e identifier, serialPortFunction_e function, serialReceiveCallbackPtr callback, - baudRate_e baudRateIndex, + uint32_t baudRate, portMode_t mode, serialInversion_e inversion) { @@ -248,8 +248,6 @@ serialPort_t *openSerialPort( serialPort_t *serialPort = NULL; - uint32_t baudRate = baudRates[baudRateIndex]; - switch(identifier) { #ifdef USE_VCP case SERIAL_PORT_USB_VCP: diff --git a/src/main/io/serial.h b/src/main/io/serial.h index 503a25c73..f85eab914 100644 --- a/src/main/io/serial.h +++ b/src/main/io/serial.h @@ -110,7 +110,7 @@ serialPort_t *openSerialPort( serialPortIdentifier_e identifier, serialPortFunction_e function, serialReceiveCallbackPtr callback, - baudRate_e baudrate, + uint32_t baudrate, portMode_t mode, serialInversion_e inversion ); diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index b8a489374..baab01edb 100644 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -602,7 +602,7 @@ void mspAllocateSerialPorts(serialConfig_t *serialConfig) continue; } - serialPort = openSerialPort(portConfig->identifier, FUNCTION_MSP, NULL, portConfig->msp_baudrateIndex, MODE_RXTX, SERIAL_NOT_INVERTED); + serialPort = openSerialPort(portConfig->identifier, FUNCTION_MSP, NULL, baudRates[portConfig->msp_baudrateIndex], MODE_RXTX, SERIAL_NOT_INVERTED); if (serialPort) { resetMspPort(mspPort, serialPort, FOR_GENERAL_MSP); portIndex++; diff --git a/src/main/rx/spektrum.c b/src/main/rx/spektrum.c index 66e12214f..5d037c383 100644 --- a/src/main/rx/spektrum.c +++ b/src/main/rx/spektrum.c @@ -43,7 +43,7 @@ #define SPEK_FRAME_SIZE 16 -#define SPEKTRUM_BAUDRATE BAUD_115200 +#define SPEKTRUM_BAUDRATE 115200 static uint8_t spek_chan_shift; static uint8_t spek_chan_mask; diff --git a/src/main/telemetry/frsky.c b/src/main/telemetry/frsky.c index 0ed04496f..c02eaf756 100644 --- a/src/main/telemetry/frsky.c +++ b/src/main/telemetry/frsky.c @@ -64,7 +64,7 @@ static serialPort_t *frskyPort = NULL; static serialPortConfig_t *portConfig; -#define FRSKY_BAUDRATE BAUD_9600 +#define FRSKY_BAUDRATE 9600 #define FRSKY_INITIAL_PORT_MODE MODE_TX static telemetryConfig_t *telemetryConfig; diff --git a/src/main/telemetry/hott.c b/src/main/telemetry/hott.c index 7c21627ee..748164931 100644 --- a/src/main/telemetry/hott.c +++ b/src/main/telemetry/hott.c @@ -100,7 +100,7 @@ static uint8_t hottMsgCrc; #define HOTT_CRC_SIZE (sizeof(hottMsgCrc)) -#define HOTT_BAUDRATE BAUD_19200 +#define HOTT_BAUDRATE 19200 #define HOTT_INITIAL_PORT_MODE MODE_RX static serialPort_t *hottPort = NULL; diff --git a/src/main/telemetry/msp.c b/src/main/telemetry/msp.c index a5773244e..832fd9449 100644 --- a/src/main/telemetry/msp.c +++ b/src/main/telemetry/msp.c @@ -100,7 +100,7 @@ void configureMSPTelemetryPort(void) baudRateIndex = BAUD_19200; } - mspTelemetryPort = openSerialPort(portConfig->identifier, FUNCTION_MSP_TELEMETRY, NULL, baudRateIndex, MSP_TELEMETRY_INITIAL_PORT_MODE, SERIAL_NOT_INVERTED); + mspTelemetryPort = openSerialPort(portConfig->identifier, FUNCTION_MSP_TELEMETRY, NULL, baudRates[baudRateIndex], MSP_TELEMETRY_INITIAL_PORT_MODE, SERIAL_NOT_INVERTED); if (!mspTelemetryPort) { return; diff --git a/src/main/telemetry/smartport.c b/src/main/telemetry/smartport.c index 8b58d564e..8b1e77506 100644 --- a/src/main/telemetry/smartport.c +++ b/src/main/telemetry/smartport.c @@ -133,7 +133,7 @@ const uint16_t frSkyDataIdTable[] = { }; #define __USE_C99_MATH // for roundf() -#define SMARTPORT_BAUD BAUD_57600 +#define SMARTPORT_BAUD 57600 #define SMARTPORT_UART_MODE MODE_BIDIR #define SMARTPORT_SERVICE_DELAY_MS 5 // telemetry requests comes in at roughly 12 ms intervals, keep this under that #define SMARTPORT_NOT_CONNECTED_TIMEOUT_MS 7000 diff --git a/src/test/unit/telemetry_hott_unittest.cc b/src/test/unit/telemetry_hott_unittest.cc index 009accb84..85edf2a3b 100644 --- a/src/test/unit/telemetry_hott_unittest.cc +++ b/src/test/unit/telemetry_hott_unittest.cc @@ -187,10 +187,10 @@ void serialSetMode(serialPort_t *instance, portMode_t mode) { } -serialPort_t *openSerialPort(serialPortIdentifier_e identifier, serialPortFunction_e functionMask, serialReceiveCallbackPtr callback, baudRate_e baudRateIndex, portMode_t mode, serialInversion_e inversion) { +serialPort_t *openSerialPort(serialPortIdentifier_e identifier, serialPortFunction_e functionMask, serialReceiveCallbackPtr callback, uint32_t baudRate, portMode_t mode, serialInversion_e inversion) { UNUSED(identifier); UNUSED(functionMask); - UNUSED(baudRateIndex); + UNUSED(baudRate); UNUSED(callback); UNUSED(mode); UNUSED(inversion);