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.
Dependents: DISCO-L072CZ-LRWAN1_LoRa_PingPong
Fork of SX1276GenericLib by
Revision 44:544add59b26d, committed 2017-05-09
- Comitter:
- Helmut Tschemernjak
- Date:
- Tue May 09 16:41:16 2017 +0200
- Parent:
- 42:72deced1a4c4
- Child:
- 45:9788b98821a5
- Commit message:
- Updated SetTimeout to include a function pointer for the timeout
Changed SetTimeout parameters function NULL means cancel timer.
Changed in this revision
--- a/LoRa_TODO.txt Mon May 08 22:52:31 2017 +0200 +++ b/LoRa_TODO.txt Tue May 09 16:41:16 2017 +0200 @@ -2,7 +2,6 @@ Tasks we needs to be done. Move finished tasks to Done section: -- Check of the MURATA TCXO config is correct - Make the timers more generic and move the OS code into the HAL layer. - add support for Arduino - add sx1276-Arduino-hal.h/cpp - add support for Linux - add sx1276-Linux-hal.h/cpp @@ -16,7 +15,8 @@ - It is a little bit strange that RX/TX/Cad Timeout Timer calling the some handler OnTimeoutIrq. Maybe we just need a single timer, or it is a good idea to split the OnTimeoutIrq function - +- Test if the SX1276 timeouts (rx(tx/sync really uses three timers or + just one at a time. Done: @@ -25,4 +25,4 @@ - Migrated enum code into sx1276.h/radio.h (7-May-2017 Helmut) - Verify the Murata ANT Switch code - MURATA PA_BOOST case,is _antSwitchTXBoost right? (Same as STM sample code) - +- Check of the MURATA TCXO config is correct (implemented, check JP9 on STM L0 board)
--- a/sx1276/sx1276-mbed-hal.cpp Mon May 08 22:52:31 2017 +0200
+++ b/sx1276/sx1276-mbed-hal.cpp Tue May 09 16:41:16 2017 +0200
@@ -347,25 +347,24 @@
}
}
-void SX1276Generic::SetTimeout(TimeoutTimer_t timer, int timeout_ms)
+void SX1276Generic::SetTimeout(TimeoutTimer_t timer, timeoutFuncPtr func, int timeout_ms)
{
- SX1276 *sx = this;
switch(timer) {
case RXTimeoutTimer:
- if (timeout_ms)
- rxTimeoutTimer.attach_us(callback(sx, &SX1276::OnTimeoutIrq), timeout_ms);
+ if (func)
+ rxTimeoutTimer.attach_us(callback(this, func), timeout_ms);
else
rxTimeoutTimer.detach();
break;
case TXTimeoutTimer:
- if (timeout_ms)
- txTimeoutTimer.attach_us(callback(sx, &SX1276::OnTimeoutIrq), timeout_ms);
+ if (func)
+ txTimeoutTimer.attach_us(callback(this, func), timeout_ms);
else
txTimeoutTimer.detach();
break;
case RXTimeoutSyncWorldTimer:
- if (timeout_ms)
- rxTimeoutSyncWord.attach_us(callback(sx, &SX1276::OnTimeoutIrq), timeout_ms);
+ if (func)
+ rxTimeoutSyncWord.attach_us(callback(this, func), timeout_ms);
else
rxTimeoutSyncWord.detach();
break;
--- a/sx1276/sx1276-mbed-hal.h Mon May 08 22:52:31 2017 +0200
+++ b/sx1276/sx1276-mbed-hal.h Tue May 09 16:41:16 2017 +0200
@@ -161,7 +161,7 @@
/*
* The the Timeout for a given Timer.
*/
- virtual void SetTimeout(TimeoutTimer_t timer, int timeout_ms);
+ virtual void SetTimeout(TimeoutTimer_t timer, timeoutFuncPtr, int timeout_ms = 0);
public:
--- a/sx1276/sx1276.cpp Mon May 08 22:52:31 2017 +0200
+++ b/sx1276/sx1276.cpp Tue May 09 16:41:16 2017 +0200
@@ -709,8 +709,8 @@
void SX1276::Sleep( void )
{
- SetTimeout(TXTimeoutTimer, 0);
- SetTimeout(RXTimeoutTimer, 0);
+ SetTimeout(TXTimeoutTimer, NULL);
+ SetTimeout(RXTimeoutTimer, NULL);
SetOpMode( RF_OPMODE_SLEEP );
this->settings.State = RF_IDLE;
@@ -718,8 +718,8 @@
void SX1276::Standby( void )
{
- SetTimeout(TXTimeoutTimer, 0);
- SetTimeout(RXTimeoutTimer, 0);
+ SetTimeout(TXTimeoutTimer, NULL);
+ SetTimeout(RXTimeoutTimer, NULL);
SetOpMode( RF_OPMODE_STANDBY );
this->settings.State = RF_IDLE;
@@ -864,7 +864,7 @@
this->settings.State = RF_RX_RUNNING;
if( timeout != 0 )
{
- SetTimeout(RXTimeoutTimer, timeout * 1e3 );
+ SetTimeout(RXTimeoutTimer, &SX1276::OnTimeoutIrq, timeout * 1e3);
}
if( this->settings.Modem == MODEM_FSK )
@@ -873,7 +873,7 @@
if( rxContinuous == false )
{
- SetTimeout(RXTimeoutSyncWorldTimer, this->settings.Fsk.RxSingleTimeout * 1e3);
+ SetTimeout(RXTimeoutSyncWorldTimer, &SX1276::OnTimeoutIrq, this->settings.Fsk.RxSingleTimeout * 1e3);
}
}
else
@@ -947,7 +947,7 @@
}
this->settings.State = RF_TX_RUNNING;
- SetTimeout(TXTimeoutTimer, timeout * 1e3);
+ SetTimeout(TXTimeoutTimer, &SX1276::OnTimeoutIrq, timeout * 1e3);
SetOpMode( RF_OPMODE_TRANSMITTER );
}
@@ -998,7 +998,7 @@
Write( REG_DIOMAPPING2, RF_DIOMAPPING2_DIO4_10 | RF_DIOMAPPING2_DIO5_10 );
this->settings.State = RF_TX_RUNNING;
- SetTimeout(TXTimeoutTimer, timeout);
+ SetTimeout(TXTimeoutTimer, &SX1276::OnTimeoutIrq, timeout);
SetOpMode( RF_OPMODE_TRANSMITTER );
}
@@ -1136,12 +1136,12 @@
{
// Continuous mode restart Rx chain
Write( REG_RXCONFIG, Read( REG_RXCONFIG ) | RF_RXCONFIG_RESTARTRXWITHOUTPLLLOCK );
- SetTimeout(RXTimeoutSyncWorldTimer, this->settings.Fsk.RxSingleTimeout * 1e3);
+ SetTimeout(RXTimeoutSyncWorldTimer, &SX1276::OnTimeoutIrq, this->settings.Fsk.RxSingleTimeout * 1e3);
}
else
{
this->settings.State = RF_IDLE;
- SetTimeout(RXTimeoutSyncWorldTimer, 0);
+ SetTimeout(RXTimeoutSyncWorldTimer, NULL);
}
}
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxTimeout != NULL ) )
@@ -1208,18 +1208,18 @@
RF_IRQFLAGS1_SYNCADDRESSMATCH );
Write( REG_IRQFLAGS2, RF_IRQFLAGS2_FIFOOVERRUN );
- SetTimeout(RXTimeoutTimer, 0);
+ SetTimeout(RXTimeoutTimer, NULL);
if( this->settings.Fsk.RxContinuous == false )
{
- SetTimeout(RXTimeoutSyncWorldTimer, 0);
+ SetTimeout(RXTimeoutSyncWorldTimer, NULL);
this->settings.State = RF_IDLE;
}
else
{
// Continuous mode restart Rx chain
Write( REG_RXCONFIG, Read( REG_RXCONFIG ) | RF_RXCONFIG_RESTARTRXWITHOUTPLLLOCK );
- SetTimeout(RXTimeoutSyncWorldTimer, this->settings.Fsk.RxSingleTimeout * 1e3);
+ SetTimeout(RXTimeoutSyncWorldTimer, &SX1276::OnTimeoutIrq, this->settings.Fsk.RxSingleTimeout * 1e3);
}
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxError != NULL ) )
@@ -1254,18 +1254,18 @@
this->settings.FskPacketHandler.NbBytes += ( this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes );
}
- SetTimeout(RXTimeoutTimer, 0);
+ SetTimeout(RXTimeoutTimer, NULL);
if( this->settings.Fsk.RxContinuous == false )
{
this->settings.State = RF_IDLE;
- SetTimeout(RXTimeoutSyncWorldTimer, 0);
+ SetTimeout(RXTimeoutSyncWorldTimer, NULL);
}
else
{
// Continuous mode restart Rx chain
Write( REG_RXCONFIG, Read( REG_RXCONFIG ) | RF_RXCONFIG_RESTARTRXWITHOUTPLLLOCK );
- SetTimeout(RXTimeoutSyncWorldTimer, this->settings.Fsk.RxSingleTimeout * 1e3);
+ SetTimeout(RXTimeoutSyncWorldTimer, &SX1276::OnTimeoutIrq, this->settings.Fsk.RxSingleTimeout * 1e3);
}
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxDone != NULL ) )
@@ -1294,7 +1294,7 @@
{
this->settings.State = RF_IDLE;
}
- SetTimeout(RXTimeoutTimer, 0);
+ SetTimeout(RXTimeoutTimer, NULL);
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxError != NULL ) )
{
@@ -1349,7 +1349,7 @@
{
this->settings.State = RF_IDLE;
}
- SetTimeout(RXTimeoutTimer, 0);
+ SetTimeout(RXTimeoutTimer, NULL);
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxDone != NULL ) )
{
@@ -1362,7 +1362,7 @@
}
break;
case RF_TX_RUNNING:
- SetTimeout(TXTimeoutTimer, 0);
+ SetTimeout(TXTimeoutTimer, NULL);
// TxDone interrupt
switch( this->settings.Modem )
{
@@ -1420,7 +1420,7 @@
break;
case MODEM_LORA:
// Sync time out
- SetTimeout(RXTimeoutTimer, 0);
+ SetTimeout(RXTimeoutTimer, NULL);
// Clear Irq
Write( REG_LR_IRQFLAGS, RFLR_IRQFLAGS_RXTIMEOUT );
@@ -1478,7 +1478,7 @@
if( ( this->settings.FskPacketHandler.PreambleDetected == true ) && ( this->settings.FskPacketHandler.SyncWordDetected == false ) )
{
- SetTimeout(RXTimeoutSyncWorldTimer, 0);
+ SetTimeout(RXTimeoutSyncWorldTimer, NULL);
this->settings.FskPacketHandler.SyncWordDetected = true;
--- a/sx1276/sx1276.h Mon May 08 22:52:31 2017 +0200
+++ b/sx1276/sx1276.h Tue May 09 16:41:16 2017 +0200
@@ -556,10 +556,13 @@
*/
virtual void SetAntSw( uint8_t opMode ) = 0;
+ typedef void ( SX1276::*timeoutFuncPtr)( void );
+
+
/*
* The the Timeout for a given Timer.
*/
- virtual void SetTimeout(TimeoutTimer_t timer, int timeout_ms) = 0;
+ virtual void SetTimeout(TimeoutTimer_t timer, timeoutFuncPtr, int timeout_ms = 0) = 0;
protected:
@@ -605,18 +608,17 @@
virtual void OnDio5Irq( void );
/*!
+ * @brief Tx & Rx timeout timer callback
+ */
+ virtual void OnTimeoutIrq( void );
+
+ /*!
* Returns the known FSK bandwidth registers value
*
* \param [IN] bandwidth Bandwidth value in Hz
* \retval regValue Bandwidth register value.
*/
static uint8_t GetFskBandwidthRegValue( uint32_t bandwidth );
-
-public:
- /*!
- * @brief Tx & Rx timeout timer callback
- */
- virtual void OnTimeoutIrq( void );
};
#endif // __SX1276_H__
