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

Added data parameter to UART RX callback

This commit is contained in:
Martin Budden 2017-11-25 07:06:02 +00:00
parent 4476921cac
commit 8cb7abd15f
49 changed files with 112 additions and 67 deletions

View file

@ -232,7 +232,7 @@ static void resetBuffers(softSerial_t *softSerial)
softSerial->port.txBufferHead = 0;
}
serialPort_t *openSoftSerial(softSerialPortIndex_e portIndex, serialReceiveCallbackPtr rxCallback, uint32_t baud, portMode_e mode, portOptions_e options)
serialPort_t *openSoftSerial(softSerialPortIndex_e portIndex, serialReceiveCallbackPtr rxCallback, void *rxCallbackData, uint32_t baud, portMode_e mode, portOptions_e options)
{
softSerial_t *softSerial = &(softSerialPorts[portIndex]);
@ -296,6 +296,7 @@ serialPort_t *openSoftSerial(softSerialPortIndex_e portIndex, serialReceiveCallb
softSerial->port.mode = mode;
softSerial->port.options = options;
softSerial->port.rxCallback = rxCallback;
softSerial->port.rxCallbackData = rxCallbackData;
resetBuffers(softSerial);
@ -444,7 +445,7 @@ void extractAndStoreRxByte(softSerial_t *softSerial)
uint8_t rxByte = (softSerial->internalRxBuffer >> 1) & 0xFF;
if (softSerial->port.rxCallback) {
softSerial->port.rxCallback(rxByte);
softSerial->port.rxCallback(rxByte, softSerial->port.rxCallbackData);
} else {
softSerial->port.rxBuffer[softSerial->port.rxBufferHead] = rxByte;
softSerial->port.rxBufferHead = (softSerial->port.rxBufferHead + 1) % softSerial->port.rxBufferSize;