Skip to content

Commit

Permalink
minor optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
JyeSmith committed Jun 6, 2022
1 parent 0722fb6 commit 8e2b2ee
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/lib/SX1280Driver/SX1280.cpp
Expand Up @@ -406,8 +406,15 @@ void ICACHE_RAM_ATTR SX1280Driver::TXnb()

if (GPIO_PIN_NSS_2 != UNDEF_PIN)
{
if (lastSuccessfulPacketRadio == SX1280_Radio_1) instance->SetMode(SX1280_MODE_FS, SX1280_Radio_2); // Make sure the unused radio is in FS mode and will not receive the tx packet.
if (lastSuccessfulPacketRadio == SX1280_Radio_2) instance->SetMode(SX1280_MODE_FS, SX1280_Radio_1);
// Make sure the unused radio is in FS mode and will not receive the tx packet.
if (lastSuccessfulPacketRadio == SX1280_Radio_1)
{
instance->SetMode(SX1280_MODE_FS, SX1280_Radio_2);
}
else
{
instance->SetMode(SX1280_MODE_FS, SX1280_Radio_1);
}
}

hal.TXenable(lastSuccessfulPacketRadio); // do first to allow PA stablise
Expand All @@ -422,8 +429,8 @@ void ICACHE_RAM_ATTR SX1280Driver::TXnb()
bool ICACHE_RAM_ATTR SX1280Driver::RXnbISR(uint16_t const irqStatus, SX1280_Radio_Number_t radioNumber)
{
rx_status const fail =
((irqStatus & SX1280_IRQ_CRC_ERROR) ? SX12XX_RX_CRC_FAIL : SX12XX_RX_OK) +
((irqStatus & SX1280_IRQ_RX_TX_TIMEOUT) ? SX12XX_RX_TIMEOUT : SX12XX_RX_OK) +
((irqStatus & SX1280_IRQ_CRC_ERROR) ? SX12XX_RX_CRC_FAIL : SX12XX_RX_OK) |
((irqStatus & SX1280_IRQ_RX_TX_TIMEOUT) ? SX12XX_RX_TIMEOUT : SX12XX_RX_OK) |
((irqStatus & SX1280_IRQ_SYNCWORD_ERROR) ? SX12XX_RX_SYNCWORD_ERROR : SX12XX_RX_OK);
// In continuous receive mode, the device stays in Rx mode
if (timeout != 0xFFFF)
Expand Down

0 comments on commit 8e2b2ee

Please sign in to comment.