From d7f79bc3ca2429f1deda5ad7f93ca6d9a8cfd561 Mon Sep 17 00:00:00 2001 From: jflyper Date: Fri, 10 Feb 2017 22:07:29 +0900 Subject: [PATCH] Complete KISSCC and fix simplex TX case --- src/main/drivers/serial_softserial.c | 12 ++++++++++-- src/main/target/KISSFC/target.h | 11 +++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/drivers/serial_softserial.c b/src/main/drivers/serial_softserial.c index 906c70d95..491cc0999 100644 --- a/src/main/drivers/serial_softserial.c +++ b/src/main/drivers/serial_softserial.c @@ -260,7 +260,16 @@ serialPort_t *openSoftSerial(softSerialPortIndex_e portIndex, serialReceiveCallb return NULL; softSerial->txIO = txIO; - softSerial->exTimerHardware = timerTx; + + if (!(mode & MODE_RX)) { + // TX Simplex, must have a timer + if (!timerTx) + return NULL; + softSerial->timerHardware = timerTx; + } else { + // Duplex + softSerial->exTimerHardware = timerTx; + } IOInit(txIO, OWNER_SERIAL_TX, RESOURCE_INDEX(portIndex) + RESOURCE_SOFT_OFFSET); } } @@ -449,7 +458,6 @@ void processRxState(softSerial_t *softSerial) void onSerialTimerOverflow(timerOvrHandlerRec_t *cbRec, captureCompare_t capture) { UNUSED(capture); - softSerial_t *self = container_of(cbRec, softSerial_t, overCb); if (self->port.mode & MODE_TX) diff --git a/src/main/target/KISSFC/target.h b/src/main/target/KISSFC/target.h index eeb4abc21..bf97dc015 100644 --- a/src/main/target/KISSFC/target.h +++ b/src/main/target/KISSFC/target.h @@ -64,7 +64,6 @@ #define USE_UART1 #define USE_UART2 #define USE_UART3 -#define SERIAL_PORT_COUNT 4 #define UART1_TX_PIN PA9 #define UART1_RX_PIN PA10 @@ -75,13 +74,13 @@ #define UART3_TX_PIN PB10 // PB10 (AF7) #define UART3_RX_PIN PB11 // PB11 (AF7) -// XXX 11 is out of bound -/* #ifdef KISSCC -#define SOFTSERIAL_1_TIMER_RX_HARDWARE 11 -#define SOFTSERIAL_1_TIMER_TX_HARDWARE 11 +#define USE_SOFTSERIAL1 +#define SOFTSERIAL1_TX_PIN PA13 +#define SERIAL_PORT_COUNT 5 +#else +#define SERIAL_PORT_COUNT 4 #endif -*/ #define USE_I2C #define I2C_DEVICE (I2CDEV_1) // PB6/SCL, PB7/SDA