Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SX127x sx12xx_hal TSL2561
Diff: radio/sx1276/sx1276.cpp
- Revision:
- 20:42839629a5dc
- Parent:
- 18:9ac71c0eb70d
diff -r c3af34457b6d -r 42839629a5dc radio/sx1276/sx1276.cpp --- a/radio/sx1276/sx1276.cpp Wed Aug 02 18:47:08 2017 +0000 +++ b/radio/sx1276/sx1276.cpp Fri Aug 04 13:23:38 2017 -0700 @@ -17,6 +17,11 @@ extern LowPowerTimer lp_timer; // from LoRaMac +static volatile struct { + uint8_t dio0 : 1; + uint8_t dio1 : 1; +} flags; + const FskBandwidth_t SX1276::FskBandwidths[] = { { 2600 , 0x17 }, @@ -1159,10 +1164,9 @@ } } -void SX1276::OnDio0Irq( void ) +void SX1276::dio0_bh( void ) { volatile uint8_t irqFlags = 0; - unsigned int now_us = lp_timer.read_us(); switch( this->settings.State ) { @@ -1247,7 +1251,7 @@ if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxDone != NULL ) ) { - this->RadioEvents->RxDone(now_us, rxtxBuffer, this->settings.FskPacketHandler.Size, this->settings.FskPacketHandler.RssiValue, 0 ); + this->RadioEvents->RxDone(dio0_us, rxtxBuffer, this->settings.FskPacketHandler.Size, this->settings.FskPacketHandler.RssiValue, 0 ); } this->settings.FskPacketHandler.PreambleDetected = false; this->settings.FskPacketHandler.SyncWordDetected = false; @@ -1330,7 +1334,7 @@ if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxDone != NULL ) ) { - this->RadioEvents->RxDone(now_us, rxtxBuffer, this->settings.LoRaPacketHandler.Size, this->settings.LoRaPacketHandler.RssiValue, this->settings.LoRaPacketHandler.SnrValue ); + this->RadioEvents->RxDone(dio0_us, rxtxBuffer, this->settings.LoRaPacketHandler.Size, this->settings.LoRaPacketHandler.RssiValue, this->settings.LoRaPacketHandler.SnrValue ); } } break; @@ -1352,7 +1356,7 @@ this->settings.State = RF_IDLE; if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->TxDone != NULL ) ) { - this->RadioEvents->TxDone( now_us ); + this->RadioEvents->TxDone( dio0_us ); } break; } @@ -1362,7 +1366,14 @@ } } -void SX1276::OnDio1Irq( void ) +void SX1276::OnDio0Irq( void ) +{ + dio0_us = lp_timer.read_us(); + + flags.dio0 = 1; +} + +void SX1276::dio1_bh( void ) { switch( this->settings.State ) { @@ -1439,6 +1450,11 @@ } } +void SX1276::OnDio1Irq( void ) +{ + flags.dio1 = 1; +} + void SX1276::OnDio2Irq( void ) { switch( this->settings.State ) @@ -1571,4 +1587,17 @@ break; } } + +void SX1276::BottomHalf() +{ + if (flags.dio0) { + dio0_bh(); + flags.dio0 = 0; + } + + if (flags.dio1) { + dio1_bh(); + flags.dio1 = 0; + } +} #endif /* ENABLE_SX1276 */