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 48:62af1e692f00, committed 2017-05-14
- Comitter:
- Helmut64
- Date:
- Sun May 14 14:22:02 2017 +0000
- Parent:
- 45:9788b98821a5
- Child:
- 49:a41aafb5e12f
- Commit message:
- Added a Radio pointer parameter to the event callback functions, this allows to know the context where the event coming from, specially of interest when using multiple Radios. It also avoids the use of global variables.
Changed in this revision
| radio/radio.h | Show annotated file Show diff for this revision Revisions of this file |
| sx1276/sx1276.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/radio/radio.h Tue May 09 14:46:15 2017 +0000
+++ b/radio/radio.h Sun May 14 14:22:02 2017 +0000
@@ -131,11 +131,11 @@
/*!
* @brief Tx Done callback prototype.
*/
- void ( *TxDone )( void );
+ void ( *TxDone )(void *radio);
/*!
* @brief Tx Timeout callback prototype.
*/
- void ( *TxTimeout )( void );
+ void ( *TxTimeout )(void *radio);
/*!
* @brief Rx Done callback prototype.
*
@@ -146,28 +146,29 @@
* FSK : N/A ( set to 0 )
* LoRa: SNR value in dB
*/
- void ( *RxDone )( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr );
+ void ( *RxDone )(void *radio, uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr );
/*!
* @brief Rx Timeout callback prototype.
*/
- void ( *RxTimeout )( void );
+ void ( *RxTimeout )(void *radio);
/*!
* @brief Rx Error callback prototype.
*/
- void ( *RxError )( void );
+ void ( *RxError )(void *radio);
/*!
* \brief FHSS Change Channel callback prototype.
*
* \param [IN] currentChannel Index number of the current channel
*/
- void ( *FhssChangeChannel )( uint8_t currentChannel );
+ void ( *FhssChangeChannel )(void *radio, uint8_t currentChannel );
/*!
* @brief CAD Done callback prototype.
*
* @param [IN] channelDetected Channel Activity detected during the CAD
*/
- void ( *CadDone ) ( bool channelActivityDetected );
+ void ( *CadDone ) (void *radio, bool channelActivityDetected );
+
}RadioEvents_t;
/*!
--- a/sx1276/sx1276.cpp Tue May 09 14:46:15 2017 +0000
+++ b/sx1276/sx1276.cpp Sun May 14 14:22:02 2017 +0000
@@ -1146,7 +1146,7 @@
}
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxTimeout != NULL ) )
{
- this->RadioEvents->RxTimeout( );
+ this->RadioEvents->RxTimeout(this);
}
break;
case RF_TX_RUNNING:
@@ -1177,7 +1177,7 @@
this->settings.State = RF_IDLE;
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->TxTimeout != NULL ) )
{
- this->RadioEvents->TxTimeout( );
+ this->RadioEvents->TxTimeout(this);
}
break;
default:
@@ -1224,7 +1224,7 @@
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxError != NULL ) )
{
- this->RadioEvents->RxError( );
+ this->RadioEvents->RxError(this);
}
this->settings.FskPacketHandler.PreambleDetected = false;
this->settings.FskPacketHandler.SyncWordDetected = false;
@@ -1270,7 +1270,7 @@
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxDone != NULL ) )
{
- this->RadioEvents->RxDone( rxtxBuffer, this->settings.FskPacketHandler.Size, this->settings.FskPacketHandler.RssiValue, 0 );
+ this->RadioEvents->RxDone(this, rxtxBuffer, this->settings.FskPacketHandler.Size, this->settings.FskPacketHandler.RssiValue, 0 );
}
this->settings.FskPacketHandler.PreambleDetected = false;
this->settings.FskPacketHandler.SyncWordDetected = false;
@@ -1298,7 +1298,7 @@
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxError != NULL ) )
{
- this->RadioEvents->RxError( );
+ this->RadioEvents->RxError(this);
}
break;
}
@@ -1353,7 +1353,7 @@
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxDone != NULL ) )
{
- this->RadioEvents->RxDone( rxtxBuffer, this->settings.LoRaPacketHandler.Size, this->settings.LoRaPacketHandler.RssiValue, this->settings.LoRaPacketHandler.SnrValue );
+ this->RadioEvents->RxDone(this, rxtxBuffer, this->settings.LoRaPacketHandler.Size, this->settings.LoRaPacketHandler.RssiValue, this->settings.LoRaPacketHandler.SnrValue );
}
}
break;
@@ -1375,7 +1375,7 @@
this->settings.State = RF_IDLE;
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->TxDone != NULL ) )
{
- this->RadioEvents->TxDone( );
+ this->RadioEvents->TxDone(this);
}
break;
}
@@ -1427,7 +1427,7 @@
this->settings.State = RF_IDLE;
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxTimeout != NULL ) )
{
- this->RadioEvents->RxTimeout( );
+ this->RadioEvents->RxTimeout(this);
}
break;
default:
@@ -1498,7 +1498,7 @@
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->FhssChangeChannel != NULL ) )
{
- this->RadioEvents->FhssChangeChannel( ( Read( REG_LR_HOPCHANNEL ) & RFLR_HOPCHANNEL_CHANNEL_MASK ) );
+ this->RadioEvents->FhssChangeChannel(this, ( Read( REG_LR_HOPCHANNEL ) & RFLR_HOPCHANNEL_CHANNEL_MASK ) );
}
}
break;
@@ -1519,7 +1519,7 @@
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->FhssChangeChannel != NULL ) )
{
- this->RadioEvents->FhssChangeChannel( ( Read( REG_LR_HOPCHANNEL ) & RFLR_HOPCHANNEL_CHANNEL_MASK ) );
+ this->RadioEvents->FhssChangeChannel(this, ( Read( REG_LR_HOPCHANNEL ) & RFLR_HOPCHANNEL_CHANNEL_MASK ) );
}
}
break;
@@ -1545,7 +1545,7 @@
Write( REG_LR_IRQFLAGS, RFLR_IRQFLAGS_CADDETECTED | RFLR_IRQFLAGS_CADDONE );
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->CadDone != NULL ) )
{
- this->RadioEvents->CadDone( true );
+ this->RadioEvents->CadDone(this, true );
}
}
else
@@ -1554,7 +1554,7 @@
Write( REG_LR_IRQFLAGS, RFLR_IRQFLAGS_CADDONE );
if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->CadDone != NULL ) )
{
- this->RadioEvents->CadDone( false );
+ this->RadioEvents->CadDone(this, false );
}
}
break;
