r g / SX1276GenericLib-us915

Dependents:   DISCO-L072CZ-LRWAN1_LoRa_PingPong

Fork of SX1276GenericLib by Helmut Tschemernjak

Files at this revision

API Documentation at this revision

Comitter:
Helmut Tschemernjak
Date:
Mon May 01 11:43:25 2017 +0200
Parent:
30:d7e36d83ec9d
Child:
32:f6f0bff38543
Commit message:
Merged from head, Semtech mbed changes of 24.4.17
- Timeouts are now in ms.
- In sync with github lora-net/LoRaMac-Node

Changed in this revision

enums/enums.h Show annotated file Show diff for this revision Revisions of this file
radio/radio.h Show annotated file Show diff for this revision Revisions of this file
registers/sx1276Regs-Fsk.h Show annotated file Show diff for this revision Revisions of this file
sx1276/sx1276-hal.cpp Show annotated file Show diff for this revision Revisions of this file
sx1276/sx1276-hal.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
sx1276/sx1276.h Show annotated file Show diff for this revision Revisions of this file
--- a/enums/enums.h	Thu Apr 27 22:33:38 2017 +0200
+++ b/enums/enums.h	Mon May 01 11:43:25 2017 +0200
@@ -62,6 +62,7 @@
     bool     IqInverted;
     bool     RxContinuous;
     uint32_t TxTimeout;
+    uint32_t RxSingleTimeout;
 }RadioFskSettings_t;
 
 /*!
@@ -99,6 +100,7 @@
     bool     IqInverted;
     bool     RxContinuous;
     uint32_t TxTimeout;
+    bool     PublicNetwork;
 }RadioLoRaSettings_t;
 
 /*!
--- a/radio/radio.h	Thu Apr 27 22:33:38 2017 +0200
+++ b/radio/radio.h	Mon May 01 11:43:25 2017 +0200
@@ -162,8 +162,8 @@
      * @param [IN] preambleLen  Sets the Preamble length ( LoRa only )
      *                          FSK : N/A ( set to 0 )
      *                          LoRa: Length in symbols ( the hardware adds 4 more symbols )
-     * @param [IN] symbTimeout  Sets the RxSingle timeout value ( LoRa only )
-     *                          FSK : N/A ( set to 0 )
+     * @param [IN] symbTimeout  Sets the RxSingle timeout value
+     *                          FSK : timeout number of bytes
      *                          LoRa: timeout in symbols
      * @param [IN] fixLen       Fixed length packets [0: variable, 1: fixed]
      * @param [IN] payloadLen   Sets payload length when fixed lenght is used
@@ -183,7 +183,7 @@
                                uint8_t payloadLen,
                                bool crcOn, bool freqHopOn, uint8_t hopPeriod,
                                bool iqInverted, bool rxContinuous ) = 0;
-    
+
     /*!
      * @brief Sets the transmission parameters
      *
@@ -218,7 +218,7 @@
                               uint8_t coderate, uint16_t preambleLen,
                               bool fixLen, bool crcOn, bool freqHopOn,
                               uint8_t hopPeriod, bool iqInverted, uint32_t timeout ) = 0;
-    
+
     /*!
      * @brief Checks if the given RF frequency is supported by the hardware
      *
@@ -237,7 +237,7 @@
      *
      * @retval airTime        Computed airTime for the given packet payload length
      */
-    virtual double TimeOnAir ( RadioModems_t modem, uint8_t pktLen ) = 0;
+    virtual uint32_t TimeOnAir ( RadioModems_t modem, uint8_t pktLen ) = 0;
     
     /*!
      * @brief Sends the buffer of size. Prepares the packet to be sent and sets
@@ -247,43 +247,52 @@
      * @param [IN]: size       Buffer size
      */
     virtual void Send( uint8_t *buffer, uint8_t size ) = 0;
-    
+
     /*!
      * @brief Sets the radio in sleep mode
      */
     virtual void Sleep( void ) = 0;
-    
+
     /*!
      * @brief Sets the radio in standby mode
      */
     virtual void Standby( void ) = 0;
-    
+
     /*!
      * @brief Sets the radio in CAD mode
      */
     virtual void StartCad( void ) = 0;
-    
+
     /*!
      * @brief Sets the radio in reception mode for the given time
      * @param [IN] timeout Reception timeout [us]
      *                     [0: continuous, others timeout]
      */
     virtual void Rx( uint32_t timeout ) = 0;
-    
+
     /*!
      * @brief Sets the radio in transmission mode for the given time
      * @param [IN] timeout Transmission timeout [us]
      *                     [0: continuous, others timeout]
      */
     virtual void Tx( uint32_t timeout ) = 0;
-    
+
+    /*!
+     * @brief Sets the radio in continuous wave transmission mode
+     *
+     * @param [IN]: freq       Channel RF frequency
+     * @param [IN]: power      Sets the output power [dBm]
+     * @param [IN]: time       Transmission mode timeout [s]
+     */
+    virtual void SetTxContinuousWave( uint32_t freq, int8_t power, uint16_t time ) = 0;
+
     /*!
      * @brief Reads the current RSSI value
      *
      * @retval rssiValue Current RSSI value in [dBm]
      */
     virtual int16_t GetRssi ( RadioModems_t modem ) = 0;
-    
+
     /*!
      * @brief Writes the radio register at the specified address
      *
@@ -291,7 +300,7 @@
      * @param [IN]: data New register value
      */
     virtual void Write ( uint8_t addr, uint8_t data ) = 0;
-    
+
     /*!
      * @brief Reads the radio register at the specified address
      *
@@ -299,7 +308,7 @@
      * @retval data Register value
      */
     virtual uint8_t Read ( uint8_t addr ) = 0;
-    
+
     /*!
      * @brief Writes multiple radio registers starting at address
      *
@@ -308,7 +317,7 @@
      * @param [IN] size   Number of registers to be written
      */
     virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) = 0;
-    
+
     /*!
      * @brief Reads multiple radio registers starting at address
      *
@@ -317,9 +326,9 @@
      * @param [IN] size Number of registers to be read
      */
     virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) = 0;
-    
+
     /*!
-     * @brief Writes the buffer contents to the SX1276 FIFO
+     * @brief Writes the buffer contents to the Radio FIFO
      *
      * @param [IN] buffer Buffer containing data to be put on the FIFO.
      * @param [IN] size Number of bytes to be written to the FIFO
@@ -327,13 +336,13 @@
     virtual void WriteFifo( uint8_t *buffer, uint8_t size ) = 0;
 
     /*!
-     * @brief Reads the contents of the SX1276 FIFO
+     * @brief Reads the contents of the Radio FIFO
      *
      * @param [OUT] buffer Buffer where to copy the FIFO read data.
      * @param [IN] size Number of bytes to be read from the FIFO
      */
     virtual void ReadFifo( uint8_t *buffer, uint8_t size ) = 0;
-    
+
     /*!
      * @brief Sets the maximum payload length.
      *
@@ -341,6 +350,15 @@
      * @param [IN] max        Maximum payload length in bytes
      */
     virtual void SetMaxPayloadLength( RadioModems_t modem, uint8_t max ) = 0;
+
+    /*!
+     * @brief Sets the network to public or private. Updates the sync byte.
+     *
+     * @remark Applies to LoRa modem only
+     *
+     * @param [IN] enable if true, it enables a public network
+     */
+    virtual void SetPublicNetwork( bool enable ) = 0;
 };
 
 #endif // __RADIO_H__
--- a/registers/sx1276Regs-Fsk.h	Thu Apr 27 22:33:38 2017 +0200
+++ b/registers/sx1276Regs-Fsk.h	Mon May 01 11:43:25 2017 +0200
@@ -376,9 +376,15 @@
 /*!
  * RegPaRamp
  */
-#define RF_PARAMP_LOWPNTXPLL_MASK                   0xE0
-#define RF_PARAMP_LOWPNTXPLL_OFF                    0x10  // Default
-#define RF_PARAMP_LOWPNTXPLL_ON                     0x00
+#define RF_PARAMP_MODULATIONSHAPING_MASK            0x9F
+#define RF_PARAMP_MODULATIONSHAPING_00              0x00  // Default
+#define RF_PARAMP_MODULATIONSHAPING_01              0x20
+#define RF_PARAMP_MODULATIONSHAPING_10              0x40
+#define RF_PARAMP_MODULATIONSHAPING_11              0x60
+
+#define RF_PARAMP_LOWPNTXPLL_MASK                   0xEF
+#define RF_PARAMP_LOWPNTXPLL_OFF                    0x10
+#define RF_PARAMP_LOWPNTXPLL_ON                     0x00  // Default
 
 #define RF_PARAMP_MASK                              0xF0
 #define RF_PARAMP_3400_US                           0x00
--- a/sx1276/sx1276-hal.cpp	Thu Apr 27 22:33:38 2017 +0200
+++ b/sx1276/sx1276-hal.cpp	Mon May 01 11:43:25 2017 +0200
@@ -26,14 +26,14 @@
 #endif
                             : SX1276( events, mosi, miso, sclk, nss, reset, dio0, dio1, dio2, dio3, dio4, dio5 ),
 #ifdef MURATA_ANT_SWITCH
-                            antSwitch(antSwitch), antSwitchTX(antSwitchTX), antSwitchTXBoost(antSwitchTXBoost),
+                            AntSwitch(antSwitch), AntSwitchTX(antSwitchTX), AntSwitchTXBoost(antSwitchTXBoost),
 #else
-                            antSwitch( antSwitch ),
+                            AntSwitch( antSwitch ),
 #endif
 #if( defined ( TARGET_NUCLEO_L152RE ) )
-                            fake( D8 )
+                            Fake( D8 )
 #else
-                            fake( A3 )
+                            Fake( A3 )
 #endif
 {
     this->RadioEvents = events;
@@ -58,20 +58,20 @@
 SX1276MB1xAS::SX1276MB1xAS( RadioEvents_t *events )
                         #if defined ( TARGET_NUCLEO_L152RE )
                         :   SX1276( events, D11, D12, D13, D10, A0, D2, D3, D4, D5, A3, D9 ), // For NUCLEO L152RE dio4 is on port A3
-                            antSwitch( A4 ),
-                            fake( D8 )
+                            AntSwitch( A4 ),
+                            Fake( D8 )
                         #elif defined( TARGET_LPC11U6X )
                         :   SX1276( events, D11, D12, D13, D10, A0, D2, D3, D4, D5, D8, D9 ),
-                            antSwitch( P0_23 ), 
-                            fake( A3 )
+                            AntSwitch( P0_23 ),
+                            Fake( A3 )
                         #else
                         :   SX1276( events, D11, D12, D13, D10, A0, D2, D3, D4, D5, D8, D9 ),
 #ifdef MURATA_ANT_SWITCH
-                            antSwitch(A4), antSwitchTX(NC), antSwitchTXBoost(NC),
+                            AntSwitch(A4), AntSwitchTX(NC), AntSwitchTXBoost(NC),
 #else
-                            antSwitch( A4 ), 
+                            AntSwitch( A4 ),
 #endif
-                            fake( A3 )
+                            Fake( A3 )
                         #endif
 {
     this->RadioEvents = events;
@@ -103,9 +103,9 @@
 {
     if( boardConnected == UNKNOWN )
     {
-        antSwitch.input( );
+		this->AntSwitch.input( );
         wait_ms( 1 );
-        if( antSwitch == 1 )
+        if(  this->AntSwitch == 1 )
         {
             boardConnected = SX1276MB1LAS;
         }
@@ -113,7 +113,7 @@
         {
             boardConnected = SX1276MB1MAS;
         }
-        antSwitch.output( );
+         this->AntSwitch.output( );
         wait_ms( 1 );
     }
 #ifdef RFM95_MODULE
@@ -143,7 +143,7 @@
     nss = 1;    
     spi.format( 8,0 );   
     uint32_t frequencyToSet = 8000000;
-    #if( defined ( TARGET_NUCLEO_L152RE ) ||  defined ( TARGET_LPC11U6X ) || defined(TARGET_STM) )
+    #if( defined ( TARGET_NUCLEO_L152RE ) || defined ( TARGET_LPC11U6X ) || defined(TARGET_STM) )
         spi.frequency( frequencyToSet );
     #elif( defined ( TARGET_KL25Z ) ) //busclock frequency is halved -> double the spi frequency to compensate
         spi.frequency( frequencyToSet * 2 );
@@ -174,6 +174,69 @@
     //nothing
 }
 
+void SX1276MB1xAS::SetRfTxPower( int8_t power )
+{
+    uint8_t paConfig = 0;
+    uint8_t paDac = 0;
+    
+    paConfig = Read( REG_PACONFIG );
+    paDac = Read( REG_PADAC );
+    
+    paConfig = ( paConfig & RF_PACONFIG_PASELECT_MASK ) | GetPaSelect( this->settings.Channel );
+    paConfig = ( paConfig & RF_PACONFIG_MAX_POWER_MASK ) | 0x70;
+    
+    if( ( paConfig & RF_PACONFIG_PASELECT_PABOOST ) == RF_PACONFIG_PASELECT_PABOOST )
+    {
+        if( power > 17 )
+        {
+            paDac = ( paDac & RF_PADAC_20DBM_MASK ) | RF_PADAC_20DBM_ON;
+        }
+        else
+        {
+            paDac = ( paDac & RF_PADAC_20DBM_MASK ) | RF_PADAC_20DBM_OFF;
+        }
+        if( ( paDac & RF_PADAC_20DBM_ON ) == RF_PADAC_20DBM_ON )
+        {
+            if( power < 5 )
+            {
+                power = 5;
+            }
+            if( power > 20 )
+            {
+                power = 20;
+            }
+            paConfig = ( paConfig & RF_PACONFIG_OUTPUTPOWER_MASK ) | ( uint8_t )( ( uint16_t )( power - 5 ) & 0x0F );
+        }
+        else
+        {
+            if( power < 2 )
+            {
+                power = 2;
+            }
+            if( power > 17 )
+            {
+                power = 17;
+            }
+            paConfig = ( paConfig & RF_PACONFIG_OUTPUTPOWER_MASK ) | ( uint8_t )( ( uint16_t )( power - 2 ) & 0x0F );
+        }
+    }
+    else
+    {
+        if( power < -1 )
+        {
+            power = -1;
+        }
+        if( power > 14 )
+        {
+            power = 14;
+        }
+        paConfig = ( paConfig & RF_PACONFIG_OUTPUTPOWER_MASK ) | ( uint8_t )( ( uint16_t )( power + 1 ) & 0x0F );
+    }
+    Write( REG_PACONFIG, paConfig );
+    Write( REG_PADAC, paDac );
+}
+
+
 uint8_t SX1276MB1xAS::GetPaSelect( uint32_t channel )
 {
     if( channel > RF_MID_BAND_THRESH )
@@ -212,63 +275,73 @@
 
 void SX1276MB1xAS::AntSwInit( void )
 {
-    antSwitch = 0;
+    this->AntSwitch = 0;
 #ifdef MURATA_ANT_SWITCH
-    antSwitchTX = 0;
-    antSwitchTXBoost = 0;
+    AntSwitchTX = 0;
+    AntSwitchTXBoost = 0;
 #endif
 }
 
 void SX1276MB1xAS::AntSwDeInit( void )
 {
-    antSwitch = 0;
+    this->AntSwitch = 0;
 #ifdef MURATA_ANT_SWITCH
-    antSwitchTX = 0;
-    antSwitchTXBoost = 0;
+    AntSwitchTX = 0;
+    AntSwitchTXBoost = 0;
 #endif
 }
 
-void SX1276MB1xAS::SetAntSw( uint8_t rxTx )
+
+void SX1276MB1xAS::SetAntSw( uint8_t opMode )
 {
-
-    this->rxTx = rxTx;
-
-    // 1: Tx, 0: Rx
-    if( rxTx != 0 )
+    switch( opMode )
     {
+        case RFLR_OPMODE_TRANSMITTER:
+#ifdef MURATA_ANT_SWITCH
+            this->AntSwitch = 0;  // Murata-RX
+            AntSwitchTX = 1; // alternate: antSwitchTXBoost = 1
+#else
+        	this->AntSwitch = 1;
+#endif
+            break;
+        case RFLR_OPMODE_RECEIVER:
+        case RFLR_OPMODE_RECEIVER_SINGLE:
+        case RFLR_OPMODE_CAD:
 #ifdef MURATA_ANT_SWITCH
-        antSwitch = 0;  // RX
-        antSwitchTX = 1; // alternate: antSwitchTXBoost = 1
+            this->AntSwitch = 1;  // Murata-RX
+            AntSwitchTX = 0;
+            AntSwitchTXBoost = 0;
 #else
-        antSwitch = 1;
+        	this->AntSwitch = 0;
 #endif
-    } else {
+            break;
+        default:
 #ifdef MURATA_ANT_SWITCH
-        antSwitch = 1;  // RX
-        antSwitchTX = 0;
-        antSwitchTXBoost = 0;
+            this->AntSwitch = 1;  //Murata-RX
+            AntSwitchTX = 0;
+            AntSwitchTXBoost = 0;
 #else
-        antSwitch = 0;
+            this->AntSwitch = 0;
 #endif
+            break;
     }
 }
 
 bool SX1276MB1xAS::CheckRfFrequency( uint32_t frequency )
 {
-    //TODO: Implement check, currently all frequencies are supported
+    // Implement check. Currently all frequencies are supported
     return true;
 }
 
-
 void SX1276MB1xAS::Reset( void )
 {
-    reset.output();
-    reset = 0;
-    wait_ms( 1 );
-    reset.input();
-    wait_ms( 6 );
+	reset.output();
+	reset = 0;
+	wait_ms( 1 );
+	reset.input();
+	wait_ms( 6 );
 }
-    
+
 void SX1276MB1xAS::Write( uint8_t addr, uint8_t data )
 {
     Write( addr, &data, 1 );
--- a/sx1276/sx1276-hal.h	Thu Apr 27 22:33:38 2017 +0200
+++ b/sx1276/sx1276-hal.h	Mon May 01 11:43:25 2017 +0200
@@ -17,9 +17,9 @@
 #include "sx1276.h"
 
 /*!
- * \brief Radio hardware registers initialization definition
+ * @brief Radio hardware registers initialization definition
  *
- * \remark Can be automatically generated by the SX1276 GUI (not yet implemented)
+ * @remark Can be automatically generated by the SX1276 GUI (not yet implemented)
  */
 #define RADIO_INIT_REGISTERS_VALUE                \
 {                                                 \
@@ -50,13 +50,13 @@
     /*!
      * Antenna switch GPIO pins objects
      */
-    DigitalInOut antSwitch;
+    DigitalInOut AntSwitch;
 #ifdef MURATA_ANT_SWITCH
-    DigitalInOut antSwitchTX;
-    DigitalInOut antSwitchTXBoost;
+    DigitalInOut AntSwitchTX;
+    DigitalInOut AntSwitchTXBoost;
 #endif
 
-    DigitalIn fake;
+    DigitalIn Fake;
 
 private:
     static const RadioRegisters_t RadioRegsInit[];
@@ -106,6 +106,13 @@
     virtual void IoDeInit( void );
 
     /*!
+     * \brief Sets the radio output power.
+     *
+     * @param [IN] power Sets the RF output power
+     */
+    virtual void SetRfTxPower( int8_t power );
+
+    /*!
      * @brief Gets the board PA selection configuration
      *
      * @param [IN] channel Channel frequency in Hz
@@ -128,24 +135,24 @@
     /*!
      * @brief De-initializes the RF Switch I/Os pins interface 
      *
-     * \remark Needed to decrease the power consumption in MCU lowpower modes
+     * @remark Needed to decrease the power consumption in MCU lowpower modes
      */
     virtual void AntSwDeInit( void );
 
     /*!
      * @brief Controls the antena switch if necessary.
      *
-     * \remark see errata note
+     * @remark see errata note
      *
-     * @param [IN] rxTx [1: Tx, 0: Rx]
+     * @param [IN] opMode Current radio operating mode
      */
-    virtual void SetAntSw( uint8_t rxTx );
+    virtual void SetAntSw( uint8_t opMode );
 
 public:
     /*!
      * @brief Detect the board connected by reading the value of the antenna switch pin
      */
-    virtual uint8_t DetectBoardType( void );    
+	virtual uint8_t DetectBoardType( void );
 
     /*!
      * @brief Checks if the given RF frequency is supported by the hardware
--- a/sx1276/sx1276.cpp	Thu Apr 27 22:33:38 2017 +0200
+++ b/sx1276/sx1276.cpp	Mon May 01 11:43:25 2017 +0200
@@ -15,7 +15,7 @@
 #include "sx1276.h"
 
 const FskBandwidth_t SX1276::FskBandwidths[] =
-{       
+{
     { 2600  , 0x17 },   
     { 3100  , 0x0F },
     { 3900  , 0x07 },
@@ -37,7 +37,7 @@
     { 166700, 0x11 },
     { 200000, 0x09 },
     { 250000, 0x01 },
-    { 300000, 0x00 }, // Invalid Badwidth
+    { 300000, 0x00 }, // Invalid Bandwidth
 };
 
 
@@ -52,9 +52,7 @@
                 isRadioActive( false )
 {
     wait_ms( 10 );
-    this->rxTx = 0;
     this->rxtxBuffer = new uint8_t[RX_BUFFER_SIZE];
-    currentOpMode = RF_OPMODE_STANDBY;
     
     this->RadioEvents = events;
     
@@ -182,7 +180,7 @@
     // Sets a Frequency in HF band
     SetChannel( 868000000 );
 
-    // Launch Rx chain calibration for HF band
+	// Launch Rx chain calibration for HF band
     Write ( REG_IMAGECAL, ( Read( REG_IMAGECAL ) & RF_IMAGECAL_IMAGECAL_MASK ) | RF_IMAGECAL_IMAGECAL_START );
     while( ( Read( REG_IMAGECAL ) & RF_IMAGECAL_IMAGECAL_RUNNING ) == RF_IMAGECAL_IMAGECAL_RUNNING )
     {
@@ -237,6 +235,8 @@
             this->settings.Fsk.IqInverted = iqInverted;
             this->settings.Fsk.RxContinuous = rxContinuous;
             this->settings.Fsk.PreambleLen = preambleLen;
+            this->settings.Fsk.RxSingleTimeout = symbTimeout * ( ( 1.0 / ( double )datarate ) * 8.0 ) * 1e3;
+
 
             datarate = ( uint16_t )( ( double )XTAL_FREQ / ( double )datarate );
             Write( REG_BITRATEMSB, ( uint8_t )( datarate >> 8 ) );
@@ -258,11 +258,12 @@
             }
             
             Write( REG_PACKETCONFIG1,
-                         ( Read( REG_PACKETCONFIG1 ) &
+						( Read( REG_PACKETCONFIG1 ) &
                            RF_PACKETCONFIG1_CRC_MASK &
                            RF_PACKETCONFIG1_PACKETFORMAT_MASK ) |
                            ( ( fixLen == 1 ) ? RF_PACKETCONFIG1_PACKETFORMAT_FIXED : RF_PACKETCONFIG1_PACKETFORMAT_VARIABLE ) |
                            ( crcOn << 4 ) );
+            Write( REG_PACKETCONFIG2, ( Read( REG_PACKETCONFIG2 ) | RF_PACKETCONFIG2_DATAMODE_PACKET ) );
         }
         break;
     case MODEM_LORA:
@@ -304,7 +305,7 @@
                 this->settings.LoRa.LowDatarateOptimize = 0x00;
             }
 
-            Write( REG_LR_MODEMCONFIG1,
+			Write( REG_LR_MODEMCONFIG1,
                          ( Read( REG_LR_MODEMCONFIG1 ) &
                            RFLR_MODEMCONFIG1_BW_MASK &
                            RFLR_MODEMCONFIG1_CODINGRATE_MASK &
@@ -320,7 +321,7 @@
                            ( datarate << 4 ) | ( crcOn << 2 ) |
                            ( ( symbTimeout >> 8 ) & ~RFLR_MODEMCONFIG2_SYMBTIMEOUTMSB_MASK ) );
 
-            Write( REG_LR_MODEMCONFIG3,
+			Write( REG_LR_MODEMCONFIG3,
                          ( Read( REG_LR_MODEMCONFIG3 ) &
                            RFLR_MODEMCONFIG3_LOWDATARATEOPTIMIZE_MASK ) |
                            ( this->settings.LoRa.LowDatarateOptimize << 3 ) );
@@ -341,7 +342,7 @@
                 Write( REG_LR_HOPPERIOD, this->settings.LoRa.HopPeriod );
             }
 
-            if( ( bandwidth == 9 ) && ( this->settings.Channel > RF_MID_BAND_THRESH ) )
+			if( ( bandwidth == 9 ) && ( this->settings.Channel > RF_MID_BAND_THRESH ) )
             {
                 // ERRATA 2.1 - Sensitivity Optimization with a 500 kHz Bandwidth
                 Write( REG_LR_TEST36, 0x02 );
@@ -361,7 +362,7 @@
 
             if( datarate == 6 )
             {
-                Write( REG_LR_DETECTOPTIMIZE,
+				Write( REG_LR_DETECTOPTIMIZE,
                              ( Read( REG_LR_DETECTOPTIMIZE ) &
                                RFLR_DETECTIONOPTIMIZE_MASK ) |
                                RFLR_DETECTIONOPTIMIZE_SF6 );
@@ -374,7 +375,7 @@
                              ( Read( REG_LR_DETECTOPTIMIZE ) &
                              RFLR_DETECTIONOPTIMIZE_MASK ) |
                              RFLR_DETECTIONOPTIMIZE_SF7_TO_SF12 );
-                Write( REG_LR_DETECTIONTHRESHOLD,
+				Write( REG_LR_DETECTIONTHRESHOLD,
                              RFLR_DETECTIONTHRESH_SF7_TO_SF12 );
             }
         }
@@ -388,68 +389,10 @@
                         bool fixLen, bool crcOn, bool freqHopOn,
                         uint8_t hopPeriod, bool iqInverted, uint32_t timeout )
 {
-    uint8_t paConfig = 0;
-    uint8_t paDac = 0;
-
     SetModem( modem );
-
-    paConfig = Read( REG_PACONFIG );
-    paDac = Read( REG_PADAC );
-
-    paConfig = ( paConfig & RF_PACONFIG_PASELECT_MASK ) | GetPaSelect( this->settings.Channel );
-    paConfig = ( paConfig & RF_PACONFIG_MAX_POWER_MASK ) | 0x70;
+    SetRfTxPower( power );
 
-    if( ( paConfig & RF_PACONFIG_PASELECT_PABOOST ) == RF_PACONFIG_PASELECT_PABOOST )
-    {
-        if( power > 17 )
-        {
-            paDac = ( paDac & RF_PADAC_20DBM_MASK ) | RF_PADAC_20DBM_ON;
-        }
-        else
-        {
-            paDac = ( paDac & RF_PADAC_20DBM_MASK ) | RF_PADAC_20DBM_OFF;
-        }
-        if( ( paDac & RF_PADAC_20DBM_ON ) == RF_PADAC_20DBM_ON )
-        {
-            if( power < 5 )
-            {
-                power = 5;
-            }
-            if( power > 20 )
-            {
-                power = 20;
-            }
-            paConfig = ( paConfig & RF_PACONFIG_OUTPUTPOWER_MASK ) | ( uint8_t )( ( uint16_t )( power - 5 ) & 0x0F );
-        }
-        else
-        {
-            if( power < 2 )
-            {
-                power = 2;
-            }
-            if( power > 17 )
-            {
-                power = 17;
-            }
-            paConfig = ( paConfig & RF_PACONFIG_OUTPUTPOWER_MASK ) | ( uint8_t )( ( uint16_t )( power - 2 ) & 0x0F );
-        }
-    }
-    else
-    {
-        if( power < -1 )
-        {
-            power = -1;
-        }
-        if( power > 14 )
-        {
-            power = 14;
-        }
-        paConfig = ( paConfig & RF_PACONFIG_OUTPUTPOWER_MASK ) | ( uint8_t )( ( uint16_t )( power + 1 ) & 0x0F );
-    }
-    Write( REG_PACONFIG, paConfig );
-    Write( REG_PADAC, paDac );
-
-    switch( modem )
+	switch( modem )
     {
     case MODEM_FSK:
         {
@@ -480,7 +423,7 @@
                            RF_PACKETCONFIG1_PACKETFORMAT_MASK ) |
                            ( ( fixLen == 1 ) ? RF_PACKETCONFIG1_PACKETFORMAT_FIXED : RF_PACKETCONFIG1_PACKETFORMAT_VARIABLE ) |
                            ( crcOn << 4 ) );
-
+            Write( REG_PACKETCONFIG2, ( Read( REG_PACKETCONFIG2 ) | RF_PACKETCONFIG2_DATAMODE_PACKET ) );
         }
         break;
     case MODEM_LORA:
@@ -541,7 +484,7 @@
                            RFLR_MODEMCONFIG2_RXPAYLOADCRC_MASK ) |
                            ( datarate << 4 ) | ( crcOn << 2 ) );
 
-            Write( REG_LR_MODEMCONFIG3,
+			Write( REG_LR_MODEMCONFIG3,
                          ( Read( REG_LR_MODEMCONFIG3 ) &
                            RFLR_MODEMCONFIG3_LOWDATARATEOPTIMIZE_MASK ) |
                            ( this->settings.LoRa.LowDatarateOptimize << 3 ) );
@@ -572,7 +515,7 @@
     }
 }
 
-double SX1276::TimeOnAir( RadioModems_t modem, uint8_t pktLen )
+uint32_t SX1276::TimeOnAir( RadioModems_t modem, uint8_t pktLen )
 {
     uint32_t airTime = 0;
 
@@ -586,7 +529,7 @@
                                      ( ( ( Read( REG_PACKETCONFIG1 ) & ~RF_PACKETCONFIG1_ADDRSFILTERING_MASK ) != 0x00 ) ? 1.0 : 0 ) +
                                      pktLen +
                                      ( ( this->settings.Fsk.CrcOn == 0x01 ) ? 2.0 : 0 ) ) /
-                                     this->settings.Fsk.Datarate ) * 1e6 );
+                            		 this->settings.Fsk.Datarate ) * 1e3 );
         }
         break;
     case MODEM_LORA:
@@ -636,15 +579,15 @@
             double tmp = ceil( ( 8 * pktLen - 4 * this->settings.LoRa.Datarate +
                                  28 + 16 * this->settings.LoRa.CrcOn -
                                  ( this->settings.LoRa.FixLen ? 20 : 0 ) ) /
-                                 ( double )( 4 * this->settings.LoRa.Datarate -
-                                 ( ( this->settings.LoRa.LowDatarateOptimize > 0 ) ? 2 : 0 ) ) ) *
+                                 ( double )( 4 * ( this->settings.LoRa.Datarate -
+                                 ( ( this->settings.LoRa.LowDatarateOptimize > 0 ) ? 2 : 0 ) ) ) ) *
                                  ( this->settings.LoRa.Coderate + 4 );
             double nPayload = 8 + ( ( tmp > 0 ) ? tmp : 0 );
             double tPayload = nPayload * ts;
             // Time on air
             double tOnAir = tPreamble + tPayload;
-            // return us secs
-            airTime = floor( tOnAir * 1e6 + 0.999 );
+            // return ms secs
+            airTime = floor( tOnAir * 1e3 + 0.999 );
         }
         break;
     }
@@ -669,7 +612,7 @@
             else
             {
                 Write( REG_PAYLOADLENGTH, size );
-            }
+			}
 
             if( ( size > 0 ) && ( size <= 64 ) )
             {
@@ -677,7 +620,7 @@
             }
             else
             {
-                memcpy( rxtxBuffer, buffer, size );
+				memcpy( rxtxBuffer, buffer, size );
                 this->settings.FskPacketHandler.ChunkSize = 32;
             }
 
@@ -727,7 +670,7 @@
 
 void SX1276::Sleep( void )
 {
-    txTimeoutTimer.detach(  );
+    txTimeoutTimer.detach( );
     rxTimeoutTimer.detach( );
 
     SetOpMode( RF_OPMODE_SLEEP );
@@ -736,7 +679,7 @@
 
 void SX1276::Standby( void )
 {
-    txTimeoutTimer.detach(  );
+    txTimeoutTimer.detach( );
     rxTimeoutTimer.detach( );
 
     SetOpMode( RF_OPMODE_STANDBY );
@@ -792,7 +735,7 @@
             {
                 Write( REG_LR_INVERTIQ, ( ( Read( REG_LR_INVERTIQ ) & RFLR_INVERTIQ_TX_MASK & RFLR_INVERTIQ_RX_MASK ) | RFLR_INVERTIQ_RX_OFF | RFLR_INVERTIQ_TX_OFF ) );
                 Write( REG_LR_INVERTIQ2, RFLR_INVERTIQ2_OFF );
-            }
+			}
 
             // ERRATA 2.3 - Receiver Spurious Reception of a LoRa Signal
             if( this->settings.LoRa.Bandwidth < 9 )
@@ -882,7 +825,7 @@
     this->settings.State = RF_RX_RUNNING;
     if( timeout != 0 )
     {
-        rxTimeoutTimer.attach_us(callback(this, &SX1276::OnTimeoutIrq), timeout );
+        rxTimeoutTimer.attach_us(callback( this, &SX1276::OnTimeoutIrq ), timeout * 1e3 );
     }
 
     if( this->settings.Modem == MODEM_FSK )
@@ -891,11 +834,8 @@
 
         if( rxContinuous == false )
         {
-            rxTimeoutSyncWord.attach_us(callback(this, &SX1276::OnTimeoutIrq), ceil( ( 8.0 * ( this->settings.Fsk.PreambleLen +
-                                                             ( ( Read( REG_SYNCCONFIG ) &
-                                                                ~RF_SYNCCONFIG_SYNCSIZE_MASK ) +
-                                                                1.0 ) + 10.0 ) /
-                                                             ( double )this->settings.Fsk.Datarate ) * 1e6 ) + 4000 );
+            rxTimeoutSyncWord.attach_us(callback( this, &SX1276::OnTimeoutIrq ),
+                                        this->settings.Fsk.RxSingleTimeout * 1e3 );
         }
     }
     else
@@ -925,9 +865,9 @@
             // DIO4=LowBat
             // DIO5=ModeReady
             Write( REG_DIOMAPPING1, ( Read( REG_DIOMAPPING1 ) & RF_DIOMAPPING1_DIO0_MASK &
-                                                                            RF_DIOMAPPING1_DIO1_MASK &
-                                                                            RF_DIOMAPPING1_DIO2_MASK ) |
-                                                                            RF_DIOMAPPING1_DIO1_01 );
+                                     RF_DIOMAPPING1_DIO1_MASK &
+                                     RF_DIOMAPPING1_DIO2_MASK ) |
+                                     RF_DIOMAPPING1_DIO1_01 );
 
             Write( REG_DIOMAPPING2, ( Read( REG_DIOMAPPING2 ) & RF_DIOMAPPING2_DIO4_MASK &
                                                                             RF_DIOMAPPING2_MAP_MASK ) );
@@ -969,7 +909,7 @@
     }
 
     this->settings.State = RF_TX_RUNNING;
-    txTimeoutTimer.attach_us(callback(this, &SX1276::OnTimeoutIrq), timeout );
+    txTimeoutTimer.attach_us(callback( this, &SX1276::OnTimeoutIrq ), timeout * 1e3 );
     SetOpMode( RF_OPMODE_TRANSMITTER );
 }
 
@@ -991,11 +931,11 @@
                                         RFLR_IRQFLAGS_TXDONE |
                                         //RFLR_IRQFLAGS_CADDONE |
                                         RFLR_IRQFLAGS_FHSSCHANGEDCHANNEL // |
-                                        //RFLR_IRQFLAGS_CADDETECTED
+                  						//RFLR_IRQFLAGS_CADDETECTED
                                         );
 
             // DIO3=CADDone
-            Write( REG_DIOMAPPING1, ( Read( REG_DIOMAPPING1 ) & RFLR_DIOMAPPING1_DIO0_MASK ) | RFLR_DIOMAPPING1_DIO0_00 );
+			Write( REG_DIOMAPPING1, ( Read( REG_DIOMAPPING1 ) & RFLR_DIOMAPPING1_DIO3_MASK ) | RFLR_DIOMAPPING1_DIO3_00 );
 
             this->settings.State = RF_CAD;
             SetOpMode( RFLR_OPMODE_CAD );
@@ -1006,6 +946,24 @@
     }
 }
 
+void SX1276::SetTxContinuousWave( uint32_t freq, int8_t power, uint16_t time )
+{
+    uint32_t timeout = ( uint32_t )( time * 1e6 );
+    
+    SetChannel( freq );
+    
+    SetTxConfig( MODEM_FSK, power, 0, 0, 4800, 0, 5, false, false, 0, 0, 0, timeout );
+    
+    Write( REG_PACKETCONFIG2, ( Read( REG_PACKETCONFIG2 ) & RF_PACKETCONFIG2_DATAMODE_MASK ) );
+    // Disable radio interrupts
+    Write( REG_DIOMAPPING1, RF_DIOMAPPING1_DIO0_11 | RF_DIOMAPPING1_DIO1_11 );
+    Write( REG_DIOMAPPING2, RF_DIOMAPPING2_DIO4_10 | RF_DIOMAPPING2_DIO5_10 );
+    
+    this->settings.State = RF_TX_RUNNING;
+    txTimeoutTimer.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ), timeout );
+    SetOpMode( RF_OPMODE_TRANSMITTER );
+}
+
 int16_t SX1276::GetRssi( RadioModems_t modem )
 {
     int16_t rssi = 0;
@@ -1041,20 +999,22 @@
     else
     {
         SetAntSwLowPower( false );
-        if( opMode == RF_OPMODE_TRANSMITTER )
-        {
-            SetAntSw( 1 );
-        }
-        else
-        {
-            SetAntSw( 0 );
-        }
+        SetAntSw( opMode );
     }
     Write( REG_OPMODE, ( Read( REG_OPMODE ) & RF_OPMODE_MASK ) | opMode );
 }
 
 void SX1276::SetModem( RadioModems_t modem )
 {
+    if( ( Read( REG_OPMODE ) & RFLR_OPMODE_LONGRANGEMODE_ON ) != 0 )
+    {
+        this->settings.Modem = MODEM_LORA;
+    }
+    else
+    {
+        this->settings.Modem = MODEM_FSK;
+    }
+    
     if( this->settings.Modem == modem )
     {
         return;
@@ -1065,14 +1025,14 @@
     {
     default:
     case MODEM_FSK:
-        SetOpMode( RF_OPMODE_SLEEP );
+        Sleep( );
         Write( REG_OPMODE, ( Read( REG_OPMODE ) & RFLR_OPMODE_LONGRANGEMODE_MASK ) | RFLR_OPMODE_LONGRANGEMODE_OFF );
     
         Write( REG_DIOMAPPING1, 0x00 );
         Write( REG_DIOMAPPING2, 0x30 ); // DIO5=ModeReady
         break;
     case MODEM_LORA:
-        SetOpMode( RF_OPMODE_SLEEP );
+        Sleep( );
         Write( REG_OPMODE, ( Read( REG_OPMODE ) & RFLR_OPMODE_LONGRANGEMODE_MASK ) | RFLR_OPMODE_LONGRANGEMODE_ON );
 
         Write( REG_DIOMAPPING1, 0x00 );
@@ -1099,6 +1059,23 @@
     }
 }
 
+void SX1276::SetPublicNetwork( bool enable )
+{
+    SetModem( MODEM_LORA );
+    this->settings.LoRa.PublicNetwork = enable;
+    if( enable == true )
+    {
+        // Change LoRa modem SyncWord
+        Write( REG_LR_SYNCWORD, LORA_MAC_PUBLIC_SYNCWORD );
+    }
+    else
+    {
+        // Change LoRa modem SyncWord
+        Write( REG_LR_SYNCWORD, LORA_MAC_PRIVATE_SYNCWORD );
+    }
+}
+
+
 void SX1276::OnTimeoutIrq( void )
 {
     switch( this->settings.State )
@@ -1112,7 +1089,7 @@
             this->settings.FskPacketHandler.Size = 0;
 
             // Clear Irqs
-            Write( REG_IRQFLAGS1, RF_IRQFLAGS1_RSSI |
+			Write( REG_IRQFLAGS1, RF_IRQFLAGS1_RSSI |
                                         RF_IRQFLAGS1_PREAMBLEDETECT |
                                         RF_IRQFLAGS1_SYNCADDRESSMATCH );
             Write( REG_IRQFLAGS2, RF_IRQFLAGS2_FIFOOVERRUN );
@@ -1121,11 +1098,8 @@
             {
                 // Continuous mode restart Rx chain
                 Write( REG_RXCONFIG, Read( REG_RXCONFIG ) | RF_RXCONFIG_RESTARTRXWITHOUTPLLLOCK );
-                rxTimeoutSyncWord.attach_us(callback(this, &SX1276::OnTimeoutIrq), ceil( ( 8.0 * ( this->settings.Fsk.PreambleLen +
-                                                             ( ( Read( REG_SYNCCONFIG ) &
-                                                                ~RF_SYNCCONFIG_SYNCSIZE_MASK ) +
-                                                             1.0 ) + 10.0 ) /
-                                                            ( double )this->settings.Fsk.Datarate ) * 1e6 ) + 4000 );
+                rxTimeoutSyncWord.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ),
+                                            this->settings.Fsk.RxSingleTimeout * 1e3 );
             }
             else
             {
@@ -1139,6 +1113,30 @@
         }
         break;
     case RF_TX_RUNNING:
+		// Tx timeout shouldn't happen.
+		// But it has been observed that when it happens it is a result of a corrupted SPI transfer
+		// it depends on the platform design.
+		//
+		// The workaround is to put the radio in a known state. Thus, we re-initialize it.
+		// BEGIN WORKAROUND
+
+		// Reset the radio
+		Reset( );
+
+		// Calibrate Rx chain
+		RxChainCalibration( );
+
+		// Initialize radio default values
+		SetOpMode( RF_OPMODE_SLEEP );
+
+		RadioRegistersInit( );
+
+		SetModem( MODEM_FSK );
+
+		// Restore previous network type setting.
+		SetPublicNetwork( this->settings.LoRa.PublicNetwork );
+		// END WORKAROUND
+            
         this->settings.State = RF_IDLE;
         if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->TxTimeout != NULL ) )
         {
@@ -1184,14 +1182,10 @@
                         {
                             // Continuous mode restart Rx chain
                             Write( REG_RXCONFIG, Read( REG_RXCONFIG ) | RF_RXCONFIG_RESTARTRXWITHOUTPLLLOCK );
-                            rxTimeoutSyncWord.attach_us(callback(this, &SX1276::OnTimeoutIrq), ceil( ( 8.0 * ( this->settings.Fsk.PreambleLen +
-                                                                         ( ( Read( REG_SYNCCONFIG ) &
-                                                                            ~RF_SYNCCONFIG_SYNCSIZE_MASK ) +
-                                                                         1.0 ) + 10.0 ) /
-                                                                        ( double )this->settings.Fsk.Datarate ) * 1e6 ) + 4000 );
+                            rxTimeoutSyncWord.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ),
+                                                        this->settings.Fsk.RxSingleTimeout * 1e3 );
                         }
 
-
                         if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxError != NULL ) )
                         {
                             this->RadioEvents->RxError( );
@@ -1235,12 +1229,9 @@
                 {
                     // Continuous mode restart Rx chain
                     Write( REG_RXCONFIG, Read( REG_RXCONFIG ) | RF_RXCONFIG_RESTARTRXWITHOUTPLLLOCK );
-                    rxTimeoutSyncWord.attach_us(callback(this, &SX1276::OnTimeoutIrq), ceil( ( 8.0 * ( this->settings.Fsk.PreambleLen +
-                                                                 ( ( Read( REG_SYNCCONFIG ) &
-                                                                    ~RF_SYNCCONFIG_SYNCSIZE_MASK ) +
-                                                                 1.0 ) + 10.0 ) /
-                                                                ( double )this->settings.Fsk.Datarate ) * 1e6 ) + 4000 );
-                }
+                    rxTimeoutSyncWord.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ),
+                                                this->settings.Fsk.RxSingleTimeout * 1e3 );
+				}
 
                 if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxDone != NULL ) )
                 {
@@ -1336,7 +1327,7 @@
             }
             break;
         case RF_TX_RUNNING:
-            txTimeoutTimer.detach( );
+			txTimeoutTimer.detach( );
             // TxDone interrupt
             switch( this->settings.Modem )
             {
@@ -1395,6 +1386,9 @@
             case MODEM_LORA:
                 // Sync time out
                 rxTimeoutTimer.detach( );
+				// Clear Irq
+				Write( REG_LR_IRQFLAGS, RFLR_IRQFLAGS_RXTIMEOUT );
+
                 this->settings.State = RF_IDLE;
                 if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxTimeout != NULL ) )
                 {
@@ -1441,6 +1435,12 @@
             switch( this->settings.Modem )
             {
             case MODEM_FSK:
+				// Checks if DIO4 is connected. If it is not PreambleDtected is set to true.
+				if( this->dioIrq[4] == NULL )
+                {
+					this->settings.FskPacketHandler.PreambleDetected = true;
+                }
+
                 if( ( this->settings.FskPacketHandler.PreambleDetected == true ) && ( this->settings.FskPacketHandler.SyncWordDetected == false ) )
                 {
                     rxTimeoutSyncWord.detach( );
--- a/sx1276/sx1276.h	Thu Apr 27 22:33:38 2017 +0200
+++ b/sx1276/sx1276.h	Mon May 01 11:43:25 2017 +0200
@@ -21,9 +21,20 @@
 #include "./typedefs/typedefs.h"
 
 /*!
- * Radio wakeup time from SLEEP mode
+ * Radio wake-up time from sleep
+ */
+#define RADIO_OSC_STARTUP                           1 // [ms]
+
+/*!
+ * Sync word for Private LoRa networks
  */
-#define RADIO_OSC_STARTUP                           1000 // [us]
+#define LORA_MAC_PRIVATE_SYNCWORD                   0x12
+
+/*!
+ * Sync word for Public LoRa networks
+ */
+#define LORA_MAC_PUBLIC_SYNCWORD                    0x34
+
 
 /*!
  * Radio PLL lock and Mode Ready delay which can vary with the temperature
@@ -91,8 +102,6 @@
 
     uint8_t *rxtxBuffer;
     
-    uint8_t currentOpMode;
-
     /*!
      * Hardware DIO IRQ functions
      */
@@ -105,14 +114,9 @@
     Timeout rxTimeoutTimer;
     Timeout rxTimeoutSyncWord;
 
-    /*!
-     *  rxTx: [1: Tx, 0: Rx]
-     */
-    uint8_t rxTx;
-
     RadioSettings_t settings;
 
-    static const FskBandwidth_t FskBandwidths[] ;
+    static const FskBandwidth_t FskBandwidths[];
 protected:
 
     /*!
@@ -124,8 +128,8 @@
 
 public:
     SX1276( RadioEvents_t *events,
-            PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset,
-            PinName dio0, PinName dio1, PinName dio2, PinName dio3, PinName dio4, PinName dio5 ); 
+			PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset,
+			PinName dio0, PinName dio1, PinName dio2, PinName dio3, PinName dio4, PinName dio5 );
     SX1276( RadioEvents_t *events );
     virtual ~SX1276( );
     
@@ -203,8 +207,8 @@
      * @param [IN] preambleLen  Sets the Preamble length ( LoRa only )
      *                          FSK : N/A ( set to 0 )
      *                          LoRa: Length in symbols ( the hardware adds 4 more symbols )
-     * @param [IN] symbTimeout  Sets the RxSingle timeout value ( LoRa only )
-     *                          FSK : N/A ( set to 0 )
+     * @param [IN] symbTimeout  Sets the RxSingle timeout value
+     *                          FSK : timeout number of bytes
      *                          LoRa: timeout in symbols
      * @param [IN] fixLen       Fixed length packets [0: variable, 1: fixed]
      * @param [IN] payloadLen   Sets payload length when fixed lenght is used
@@ -252,7 +256,7 @@
      * @param [IN] iqInverted   Inverts IQ signals ( LoRa only )
      *                          FSK : N/A ( set to 0 )
      *                          LoRa: [0: not inverted, 1: inverted]
-     * @param [IN] timeout      Transmission timeout [us]
+     * @param [IN] timeout      Transmission timeout [ms]
      */
     virtual void SetTxConfig( RadioModems_t modem, int8_t power, uint32_t fdev,
                               uint32_t bandwidth, uint32_t datarate,
@@ -261,6 +265,14 @@
                               uint8_t hopPeriod, bool iqInverted, uint32_t timeout );
 
     /*!
+     * @brief Checks if the given RF frequency is supported by the hardware
+     *
+     * @param [IN] frequency RF frequency to be checked
+     * @retval isSupported [true: supported, false: unsupported]
+     */
+    virtual bool CheckRfFrequency( uint32_t frequency ) = 0;
+    
+    /*!
      * @brief Computes the packet time on air for the given payload
      *
      * \Remark Can only be called once SetRxConfig or SetTxConfig have been called
@@ -270,7 +282,7 @@
      *
      * @retval airTime        Computed airTime for the given packet payload length
      */
-    virtual double TimeOnAir ( RadioModems_t modem, uint8_t pktLen );
+    virtual uint32_t TimeOnAir ( RadioModems_t modem, uint8_t pktLen );
 
     /*!
      * @brief Sends the buffer of size. Prepares the packet to be sent and sets
@@ -290,25 +302,35 @@
      * @brief Sets the radio in standby mode
      */
     virtual void Standby( void );
+    
+    /*!
+     * @brief Sets the radio in CAD mode
+     */
+    virtual void StartCad( void );
 
     /*!
      * @brief Sets the radio in reception mode for the given time
-     * @param [IN] timeout Reception timeout [us]
+     * @param [IN] timeout Reception timeout [ms]
      *                     [0: continuous, others timeout]
      */
     virtual void Rx( uint32_t timeout );
 
     /*!
      * @brief Sets the radio in transmission mode for the given time
-     * @param [IN] timeout Transmission timeout [us]
+     * @param [IN] timeout Transmission timeout [ms]
      *                     [0: continuous, others timeout]
      */
     virtual void Tx( uint32_t timeout );
 
     /*!
-     * @brief Start a Channel Activity Detection
+     * @brief Sets the radio in continuous wave transmission mode
+     *
+     * @param [IN]: freq       Channel RF frequency
+     * @param [IN]: power      Sets the output power [dBm]
+     * @param [IN]: time       Transmission mode timeout [s]
      */
-    virtual void StartCad( void );    
+
+    virtual void SetTxContinuousWave( uint32_t freq, int8_t power, uint16_t time );
 
     /*!
      * @brief Reads the current RSSI value
@@ -379,6 +401,16 @@
      */
     virtual void SetMaxPayloadLength( RadioModems_t modem, uint8_t max );
 
+    /*!
+     * \brief Sets the network to public or private. Updates the sync byte.
+     *
+     * \remark Applies to LoRa modem only
+     *
+     * \param [IN] enable if true, it enables a public network
+     */
+    virtual void SetPublicNetwork( bool enable );
+
+
     //-------------------------------------------------------------------------
     //                        Board relative functions
     //-------------------------------------------------------------------------
@@ -414,6 +446,13 @@
     virtual void IoDeInit( void ) = 0;
 
     /*!
+     * @brief Sets the radio output power.
+     *
+     * @param [IN] power Sets the RF output power
+     */
+    virtual void SetRfTxPower( int8_t power ) = 0;
+
+    /*!
      * @brief Gets the board PA selection configuration
      *
      * @param [IN] channel Channel frequency in Hz
@@ -441,21 +480,14 @@
     virtual void AntSwDeInit( void ) = 0;
 
     /*!
-     * @brief Controls the antena switch if necessary.
+     * @brief Controls the antenna switch if necessary.
      *
      * \remark see errata note
      *
-     * @param [IN] rxTx [1: Tx, 0: Rx]
+     * @param [IN] opMode Current radio operating mode
      */
-    virtual void SetAntSw( uint8_t rxTx ) = 0;
-
-    /*!
-     * @brief Checks if the given RF frequency is supported by the hardware
-     *
-     * @param [IN] frequency RF frequency to be checked
-     * @retval isSupported [true: supported, false: unsupported]
-     */
-    virtual bool CheckRfFrequency( uint32_t frequency ) = 0;
+    virtual void SetAntSw( uint8_t opMode ) = 0;
+    
 protected:
 
     /*!