ExpressLRS - Fix an edge-case when a receiver can have both of

it's ISR flags set.

This has not been observed on the bench but is more of a safeguard so that
the task doesn't stall and can decide what to do.
This commit is contained in:
Dominic Clifton 2022-01-23 17:46:23 +01:00
parent 882e216f8a
commit 3c5a5728b2
4 changed files with 12 additions and 4 deletions

View File

@ -445,7 +445,9 @@ uint8_t sx127xGetIrqReason(void)
{
uint8_t irqFlags = sx127xGetIrqFlags();
sx127xClearIrqFlags();
if ((irqFlags & SX127X_CLEAR_IRQ_FLAG_TX_DONE)) {
if ((irqFlags & SX127X_CLEAR_IRQ_FLAG_TX_DONE) && (irqFlags & SX127X_CLEAR_IRQ_FLAG_RX_DONE)) {
return 3;
} else if ((irqFlags & SX127X_CLEAR_IRQ_FLAG_TX_DONE)) {
return 2;
} else if ((irqFlags & SX127X_CLEAR_IRQ_FLAG_RX_DONE)) {
return 1;

View File

@ -418,8 +418,11 @@ void sx1280ClearIrqStatus(const uint16_t irqMask)
uint8_t sx1280GetIrqReason(void)
{
uint16_t irqStatus = sx1280GetIrqStatus();
sx1280ClearIrqStatus(SX1280_IRQ_RADIO_ALL);
if ((irqStatus & SX1280_IRQ_TX_DONE)) {
if ((irqStatus & SX1280_IRQ_TX_DONE) && (irqStatus & SX1280_IRQ_RX_DONE)) {
return 3;
} else if ((irqStatus & SX1280_IRQ_TX_DONE)) {
return 2;
} else if ((irqStatus & SX1280_IRQ_RX_DONE)) {
return 1;

View File

@ -1073,7 +1073,9 @@ rx_spi_received_e expressLrsDataReceived(uint8_t *payload)
}
uint8_t irqReason = receiver.rxISR(&isrTimeStampUs);
if (irqReason == ELRS_DIO_TX_DONE) {
if (irqReason == ELRS_DIO_RX_AND_TX_DONE) {
startReceiving();
} else if (irqReason == ELRS_DIO_TX_DONE) {
startReceiving();
} else if (irqReason == ELRS_DIO_RX_DONE) {
result = processRFPacket(payload, isrTimeStampUs);

View File

@ -33,7 +33,8 @@ typedef enum {
typedef enum {
ELRS_DIO_UNKNOWN = 0,
ELRS_DIO_RX_DONE = 1,
ELRS_DIO_TX_DONE = 2
ELRS_DIO_TX_DONE = 2,
ELRS_DIO_RX_AND_TX_DONE = 3,
} dioReason_e;
typedef enum {