Modtronix inAir9 driver based on SX1276 standard driver

Dependents:   SX1276PingPong_inAir Sensors LoRaTerminal

Fork of SX1276Lib by Semtech

Files at this revision

API Documentation at this revision

Comitter:
rba90
Date:
Sat May 28 23:07:55 2016 +0000
Parent:
25:3778e6204cc1
Commit message:
Modtronix inAir9 LoRa transceiver driver based on SX1276

Changed in this revision

enums/enums.h Show annotated file Show diff for this revision Revisions of this file
sx1276/sx1276-hal.cpp Show diff for this revision Revisions of this file
sx1276/sx1276-hal.h Show diff for this revision Revisions of this file
sx1276/sx1276-inAir.cpp Show annotated file Show diff for this revision Revisions of this file
sx1276/sx1276-inAir.h Show annotated file Show diff for this revision Revisions of this file
typedefs/typedefs.h Show annotated file Show diff for this revision Revisions of this file
--- a/enums/enums.h	Fri May 13 15:09:10 2016 +0000
+++ b/enums/enums.h	Sat May 28 23:07:55 2016 +0000
@@ -35,14 +35,16 @@
     MODEM_LORA
 }RadioModems_t;
 
+
 /*!
- * Type of the supported board. [SX1276MB1MAS / SX1276MB1LAS]
+ * Type of the supported board.
  */
-typedef enum BoardType
+typedef enum BoardTypeInAir
 {
-    SX1276MB1MAS = 0,
-    SX1276MB1LAS,
-    UNKNOWN
+    BOARD_INAIR4 = 0,
+    BOARD_INAIR9,
+    BOARD_INAIR9B,
+    BOARD_UNKNOWN
 }BoardType_t;
 
 /*!
--- a/sx1276/sx1276-hal.cpp	Fri May 13 15:09:10 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,286 +0,0 @@
-/*
- / _____)             _              | |
-( (____  _____ ____ _| |_ _____  ____| |__
- \____ \| ___ |    (_   _) ___ |/ ___)  _ \
- _____) ) ____| | | || |_| ____( (___| | | |
-(______/|_____)_|_|_| \__)_____)\____)_| |_|
-    (C) 2014 Semtech
-
-Description: -
-
-License: Revised BSD License, see LICENSE.TXT file include in the project
-
-Maintainers: Miguel Luis, Gregory Cristian and Nicolas Huguenin
-*/
-#include "sx1276-hal.h"
-
-const RadioRegisters_t SX1276MB1xAS::RadioRegsInit[] = RADIO_INIT_REGISTERS_VALUE;
-
-SX1276MB1xAS::SX1276MB1xAS( 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 antSwitch )
-                            : SX1276( events, mosi, miso, sclk, nss, reset, dio0, dio1, dio2, dio3, dio4, dio5 ),
-                            antSwitch( antSwitch ),
-                        #if( defined ( TARGET_NUCLEO_L152RE ) )
-                            fake( D8 )
-                        #else
-                            fake( A3 )
-                        #endif
-{
-    this->RadioEvents = events;
-
-    Reset( );
-
-    RxChainCalibration( );
-
-    IoInit( );
-
-    SetOpMode( RF_OPMODE_SLEEP );
-
-    IoIrqInit( dioIrq );
-
-    RadioRegistersInit( );
-
-    SetModem( MODEM_FSK );
-
-    this->settings.State = RF_IDLE ;
-}
-
-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 )
-                        #elif defined( TARGET_LPC11U6X )
-                        :   SX1276( events, D11, D12, D13, D10, A0, D2, D3, D4, D5, D8, D9 ),
-                            antSwitch( P0_23 ), 
-                            fake( A3 )
-                        #else
-                        :   SX1276( events, D11, D12, D13, D10, A0, D2, D3, D4, D5, D8, D9 ),
-                            antSwitch( A4 ), 
-                            fake( A3 )
-                        #endif
-{
-    this->RadioEvents = events;
-
-    Reset( );
-
-    boardConnected = UNKNOWN;
-
-    DetectBoardType( );
-
-    RxChainCalibration( );
-
-    IoInit( );
-
-    SetOpMode( RF_OPMODE_SLEEP );
-    IoIrqInit( dioIrq );
-
-    RadioRegistersInit( );
-
-    SetModem( MODEM_FSK );
-
-    this->settings.State = RF_IDLE ;
-}
-
-//-------------------------------------------------------------------------
-//                      Board relative functions
-//-------------------------------------------------------------------------
-uint8_t SX1276MB1xAS::DetectBoardType( void )
-{
-    if( boardConnected == UNKNOWN )
-    {
-        antSwitch.input( );
-        wait_ms( 1 );
-        if( antSwitch == 1 )
-        {
-            boardConnected = SX1276MB1LAS;
-        }
-        else
-        {
-            boardConnected = SX1276MB1MAS;
-        }
-        antSwitch.output( );
-        wait_ms( 1 );
-    }
-    return ( boardConnected );
-}
-
-void SX1276MB1xAS::IoInit( void )
-{
-    AntSwInit( );
-    SpiInit( );
-}
-
-void SX1276MB1xAS::RadioRegistersInit( )
-{
-    uint8_t i = 0;
-    for( i = 0; i < sizeof( RadioRegsInit ) / sizeof( RadioRegisters_t ); i++ )
-    {
-        SetModem( RadioRegsInit[i].Modem );
-        Write( RadioRegsInit[i].Addr, RadioRegsInit[i].Value );
-    }    
-}
-
-void SX1276MB1xAS::SpiInit( void )
-{
-    nss = 1;    
-    spi.format( 8,0 );   
-    uint32_t frequencyToSet = 8000000;
-    #if( defined ( TARGET_NUCLEO_L152RE ) ||  defined ( TARGET_LPC11U6X ) )
-        spi.frequency( frequencyToSet );
-    #elif( defined ( TARGET_KL25Z ) ) //busclock frequency is halved -> double the spi frequency to compensate
-        spi.frequency( frequencyToSet * 2 );
-    #else
-        #warning "Check the board's SPI frequency"
-    #endif
-    wait(0.1); 
-}
-
-void SX1276MB1xAS::IoIrqInit( DioIrqHandler *irqHandlers )
-{
-#if( defined ( TARGET_NUCLEO_L152RE ) || defined ( TARGET_LPC11U6X ) )
-    dio0.mode( PullDown );
-    dio1.mode( PullDown );
-    dio2.mode( PullDown );
-    dio3.mode( PullDown );
-    dio4.mode( PullDown );
-#endif
-    dio0.rise( this, static_cast< TriggerMB1xAS > ( irqHandlers[0] ) );
-    dio1.rise( this, static_cast< TriggerMB1xAS > ( irqHandlers[1] ) );
-    dio2.rise( this, static_cast< TriggerMB1xAS > ( irqHandlers[2] ) );
-    dio3.rise( this, static_cast< TriggerMB1xAS > ( irqHandlers[3] ) );
-    dio4.rise( this, static_cast< TriggerMB1xAS > ( irqHandlers[4] ) );
-}
-
-void SX1276MB1xAS::IoDeInit( void )
-{
-    //nothing
-}
-
-uint8_t SX1276MB1xAS::GetPaSelect( uint32_t channel )
-{
-    if( channel > RF_MID_BAND_THRESH )
-    {
-        if( boardConnected == SX1276MB1LAS )
-        {
-            return RF_PACONFIG_PASELECT_PABOOST;
-        }
-        else
-        {
-            return RF_PACONFIG_PASELECT_RFO;
-        }
-    }
-    else
-    {
-        return RF_PACONFIG_PASELECT_RFO;
-    }
-}
-
-void SX1276MB1xAS::SetAntSwLowPower( bool status )
-{
-    if( isRadioActive != status )
-    {
-        isRadioActive = status;
-    
-        if( status == false )
-        {
-            AntSwInit( );
-        }
-        else
-        {
-            AntSwDeInit( );
-        }
-    }
-}
-
-void SX1276MB1xAS::AntSwInit( void )
-{
-    antSwitch = 0;
-}
-
-void SX1276MB1xAS::AntSwDeInit( void )
-{
-    antSwitch = 0;
-}
-
-void SX1276MB1xAS::SetAntSw( uint8_t rxTx )
-{
-
-    this->rxTx = rxTx;
-
-    // 1: Tx, 0: Rx
-    if( rxTx != 0 )
-    {
-        antSwitch = 1;
-    }
-    else
-    {
-        antSwitch = 0;
-    }
-}
-
-bool SX1276MB1xAS::CheckRfFrequency( uint32_t frequency )
-{
-    //TODO: 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 );
-}
-    
-void SX1276MB1xAS::Write( uint8_t addr, uint8_t data )
-{
-    Write( addr, &data, 1 );
-}
-
-uint8_t SX1276MB1xAS::Read( uint8_t addr )
-{
-    uint8_t data;
-    Read( addr, &data, 1 );
-    return data;
-}
-
-void SX1276MB1xAS::Write( uint8_t addr, uint8_t *buffer, uint8_t size )
-{
-    uint8_t i;
-
-    nss = 0;
-    spi.write( addr | 0x80 );
-    for( i = 0; i < size; i++ )
-    {
-        spi.write( buffer[i] );
-    }
-    nss = 1;
-}
-
-void SX1276MB1xAS::Read( uint8_t addr, uint8_t *buffer, uint8_t size )
-{
-    uint8_t i;
-
-    nss = 0;
-    spi.write( addr & 0x7F );
-    for( i = 0; i < size; i++ )
-    {
-        buffer[i] = spi.write( 0 );
-    }
-    nss = 1;
-}
-
-void SX1276MB1xAS::WriteFifo( uint8_t *buffer, uint8_t size )
-{
-    Write( 0, buffer, size );
-}
-
-void SX1276MB1xAS::ReadFifo( uint8_t *buffer, uint8_t size )
-{
-    Read( 0, buffer, size );
-}
--- a/sx1276/sx1276-hal.h	Fri May 13 15:09:10 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,206 +0,0 @@
-/*
- / _____)             _              | |
-( (____  _____ ____ _| |_ _____  ____| |__
- \____ \| ___ |    (_   _) ___ |/ ___)  _ \
- _____) ) ____| | | || |_| ____( (___| | | |
-(______/|_____)_|_|_| \__)_____)\____)_| |_|
-    (C) 2014 Semtech
-
-Description: -
-
-License: Revised BSD License, see LICENSE.TXT file include in the project
-
-Maintainers: Miguel Luis, Gregory Cristian and Nicolas Huguenin
-*/
-#ifndef __SX1276_HAL_H__
-#define __SX1276_HAL_H__
-#include "sx1276.h"
-
-/*!
- * \brief Radio hardware registers initialization definition
- *
- * \remark Can be automatically generated by the SX1276 GUI (not yet implemented)
- */
-#define RADIO_INIT_REGISTERS_VALUE                \
-{                                                 \
-    { MODEM_FSK , REG_LNA                , 0x23 },\
-    { MODEM_FSK , REG_RXCONFIG           , 0x1E },\
-    { MODEM_FSK , REG_RSSICONFIG         , 0xD2 },\
-    { MODEM_FSK , REG_AFCFEI             , 0x01 },\
-    { MODEM_FSK , REG_PREAMBLEDETECT     , 0xAA },\
-    { MODEM_FSK , REG_OSC                , 0x07 },\
-    { MODEM_FSK , REG_SYNCCONFIG         , 0x12 },\
-    { MODEM_FSK , REG_SYNCVALUE1         , 0xC1 },\
-    { MODEM_FSK , REG_SYNCVALUE2         , 0x94 },\
-    { MODEM_FSK , REG_SYNCVALUE3         , 0xC1 },\
-    { MODEM_FSK , REG_PACKETCONFIG1      , 0xD8 },\
-    { MODEM_FSK , REG_FIFOTHRESH         , 0x8F },\
-    { MODEM_FSK , REG_IMAGECAL           , 0x02 },\
-    { MODEM_FSK , REG_DIOMAPPING1        , 0x00 },\
-    { MODEM_FSK , REG_DIOMAPPING2        , 0x30 },\
-    { MODEM_LORA, REG_LR_PAYLOADMAXLENGTH, 0x40 },\
-}                                                 \
-
-/*! 
- * Actual implementation of a SX1276 radio, includes some modifications to make it compatible with the MB1 LAS board
- */
-class SX1276MB1xAS : public SX1276
-{
-protected:
-    /*!
-     * Antenna switch GPIO pins objects
-     */
-    DigitalInOut antSwitch;
-
-    DigitalIn fake;
-
-private:
-    static const RadioRegisters_t RadioRegsInit[];
-
-public:
-    SX1276MB1xAS( 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 antSwitch ); 
-
-    SX1276MB1xAS( RadioEvents_t *events );
-
-    virtual ~SX1276MB1xAS( ) { };
-
-protected:
-    /*!
-     * @brief Initializes the radio I/Os pins interface
-     */
-    virtual void IoInit( void );
-
-    /*!
-     *  @brief Initializes the radio registers
-     */
-    virtual void RadioRegistersInit( );
-    
-    /*!
-     * @brief Initializes the radio SPI
-     */
-    virtual void SpiInit( void );
-
-    /*!
-     * @brief Initializes DIO IRQ handlers
-     *
-     * @param [IN] irqHandlers Array containing the IRQ callback functions
-     */
-    virtual void IoIrqInit( DioIrqHandler *irqHandlers );
-
-    /*!
-     * @brief De-initializes the radio I/Os pins interface. 
-     *
-     * \remark Useful when going in MCU lowpower modes
-     */
-    virtual void IoDeInit( void );
-
-    /*!
-     * @brief Gets the board PA selection configuration
-     *
-     * @param [IN] channel Channel frequency in Hz
-     * @retval PaSelect RegPaConfig PaSelect value
-     */
-    virtual uint8_t GetPaSelect( uint32_t channel );
-
-    /*!
-     * @brief Set the RF Switch I/Os pins in Low Power mode
-     *
-     * @param [IN] status enable or disable
-     */
-    virtual void SetAntSwLowPower( bool status );
-
-    /*!
-     * @brief Initializes the RF Switch I/Os pins interface
-     */
-    virtual void AntSwInit( void );
-
-    /*!
-     * @brief De-initializes the RF Switch I/Os pins interface 
-     *
-     * \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
-     *
-     * @param [IN] rxTx [1: Tx, 0: Rx]
-     */
-    virtual void SetAntSw( uint8_t rxTx );
-
-public:
-    /*!
-     * @brief Detect the board connected by reading the value of the antenna switch pin
-     */
-    virtual uint8_t DetectBoardType( void );    
-
-    /*!
-     * @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 );
-
-    /*!
-     * @brief Writes the radio register at the specified address
-     *
-     * @param [IN]: addr Register address
-     * @param [IN]: data New register value
-     */
-    virtual void Write ( uint8_t addr, uint8_t data ) ;
-
-    /*!
-     * @brief Reads the radio register at the specified address
-     *
-     * @param [IN]: addr Register address
-     * @retval data Register value
-     */
-    virtual uint8_t Read ( uint8_t addr ) ;
-
-    /*!
-     * @brief Writes multiple radio registers starting at address
-     *
-     * @param [IN] addr   First Radio register address
-     * @param [IN] buffer Buffer containing the new register's values
-     * @param [IN] size   Number of registers to be written
-     */
-    virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) ;
-
-    /*!
-     * @brief Reads multiple radio registers starting at address
-     *
-     * @param [IN] addr First Radio register address
-     * @param [OUT] buffer Buffer where to copy the registers data
-     * @param [IN] size Number of registers to be read
-     */
-    virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) ;
-
-    /*!
-     * @brief Writes the buffer contents to the SX1276 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
-     */
-    virtual void WriteFifo( uint8_t *buffer, uint8_t size ) ;
-
-    /*!
-     * @brief Reads the contents of the SX1276 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 ) ;
-
-    /*!
-     * @brief Reset the SX1276
-     */
-    virtual void Reset( void );
-};
-
-#endif // __SX1276_HAL_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sx1276/sx1276-inAir.cpp	Sat May 28 23:07:55 2016 +0000
@@ -0,0 +1,246 @@
+#include "sx1276-inAir.h"
+
+const RadioRegisters_t SX1276inAir::RadioRegsInit[] = RADIO_INIT_REGISTERS_VALUE;
+
+SX1276inAir::SX1276inAir( RadioEvents_t *events,
+                            PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset,
+                            PinName dio0, PinName dio1, PinName dio2, PinName dio3,
+                            PinName antSwitch )
+                            : SX1276( events, mosi, miso, sclk, nss, reset, dio0, dio1, dio2, dio3, NC, NC),
+                            antSwitch( NC ),
+                            fake( NC )
+{
+    this->RadioEvents = events;
+    
+    Reset();
+    
+    RxChainCalibration( );
+    
+    IoInit( );
+    
+    SetOpMode( RF_OPMODE_SLEEP );
+    
+    IoIrqInit( dioIrq );
+    
+    RadioRegistersInit( );
+
+    SetModem( MODEM_FSK );
+
+    this->settings.State = RF_IDLE ;
+}
+
+SX1276inAir::SX1276inAir( RadioEvents_t *events )
+                        :   SX1276( events, D11/*MOSI*/, D12/*MISO*/, D13/*SCLK*/, D7/*CS*/, A5/*RST*/, D2/*DIO0*/, D8, D4, A4, NC, NC ), // For NUCLEO L152RE dio4 is on port A3
+                            antSwitch( A4 ),
+                            fake( D8 )
+{
+    this->RadioEvents = events;
+    
+    Reset();
+    
+    boardConnected = BOARD_UNKNOWN;
+    
+    DetectBoardType();
+    
+    RxChainCalibration( );
+    
+    IoInit( );
+    
+    SetOpMode( RF_OPMODE_SLEEP );
+    
+    IoIrqInit( dioIrq );
+    
+    RadioRegistersInit( );
+
+    SetModem( MODEM_FSK );
+
+    this->settings.State = RF_IDLE ;
+}
+
+//-------------------------------------------------------------------------
+//                      Board relative functions
+//-------------------------------------------------------------------------
+uint8_t SX1276inAir::DetectBoardType( void )
+{
+    //Detect board type NOT possible with inAir4, inAir9 and inAir9B boards. User has to call
+    //the SetBoardType() function to set the board type!
+    return ( boardConnected );
+}
+
+void SX1276inAir::IoInit( void )
+{
+    AntSwInit( );
+    SpiInit( );
+}
+
+void SX1276inAir::RadioRegistersInit( ){
+    uint8_t i = 0;
+    for( i = 0; i < sizeof( RadioRegsInit ) / sizeof( RadioRegisters_t ); i++ )
+    {
+        SetModem( RadioRegsInit[i].Modem );
+        Write( RadioRegsInit[i].Addr, RadioRegsInit[i].Value );
+    }    
+}
+
+void SX1276inAir::SpiInit( void )
+{
+    nss = 1;    
+    spi.format( 8,0 );   
+    uint32_t frequencyToSet = 8000000;
+    #if( defined (TARGET_NUCLEO_F446RE) || defined ( TARGET_NUCLEO_L152RE ) || defined (TARGET_NUCLEO_F401RE) || defined ( TARGET_LPC11U6X ) || defined (TARGET_K64F) || defined ( TARGET_NZ32ST1L ) || defined(TARGET_NZ32SC151) )
+        spi.frequency( frequencyToSet );
+    #elif( defined ( TARGET_KL25Z ) ) //busclock frequency is halved -> double the spi frequency to compensate
+        spi.frequency( frequencyToSet * 2 );
+    #else
+        #warning "Check the board's SPI frequency"
+    #endif
+    wait(0.1); 
+}
+
+void SX1276inAir::IoIrqInit( DioIrqHandler *irqHandlers )
+{
+    //TARGET_KL25Z board does not have pulldown resistors, seems like TARGET_K64F does have them
+    #if( defined (TARGET_NUCLEO_F446RE) || defined ( TARGET_NUCLEO_L152RE )  || defined (TARGET_NUCLEO_F401RE) ||  defined ( TARGET_LPC11U6X ) || defined (TARGET_K64F) || defined ( TARGET_NZ32ST1L ) || defined(TARGET_NZ32SC151))
+        dio0.mode(PullDown);
+        dio1.mode(PullDown);   
+        dio2.mode(PullDown);
+        dio3.mode(PullDown); 
+        //dio4.mode(PullDown);
+    #endif
+    dio0.rise( this, static_cast< TriggerInAir > ( irqHandlers[0] ) );
+    dio1.rise( this, static_cast< TriggerInAir > ( irqHandlers[1] ) );
+    dio2.rise( this, static_cast< TriggerInAir > ( irqHandlers[2] ) );
+    //For SHD3I with BOARD_INAIR4 in imod3, on FRDM-KL25Z board. It uses A4 on FRDM-KL25Z board, which does not have interrupt
+    #if( defined ( TARGET_KL25Z ) && defined(SHIELD_SHD3I_INAIR9) )
+    //Nothing to be done
+    #else
+    dio3.rise( this, static_cast< TriggerInAir > ( irqHandlers[3] ) );
+    #endif
+    //dio4.rise( this, static_cast< TriggerInAir > ( irqHandlers[4] ) );
+}
+
+void SX1276inAir::IoDeInit( void )
+{
+    //nothing
+}
+
+uint8_t SX1276inAir::GetPaSelect( uint32_t channel )
+{
+    if(boardConnected == BOARD_INAIR9B) {
+        return RF_PACONFIG_PASELECT_PABOOST;
+    }
+    else {
+        return RF_PACONFIG_PASELECT_RFO;
+    }
+}
+
+void SX1276inAir::SetAntSwLowPower( bool status )
+{
+    if( isRadioActive != status )
+    {
+        isRadioActive = status;
+    
+        if( status == false )
+        {
+            AntSwInit( );
+        }
+        else
+        {
+            AntSwDeInit( );
+        }
+    }
+}
+
+void SX1276inAir::AntSwInit( void )
+{
+    //antSwitch = 0;
+}
+
+void SX1276inAir::AntSwDeInit( void )
+{
+    //antSwitch = 0;
+}
+
+void SX1276inAir::SetAntSw( uint8_t rxTx )
+{
+    if( this->rxTx == rxTx )
+    {
+        //no need to go further
+        return;
+    }
+
+    this->rxTx = rxTx;
+
+//    if( rxTx != 0 )
+//    {
+//        antSwitch = 1;
+//    }
+//    else
+//    {
+//        antSwitch = 0;
+//    }
+}
+
+bool SX1276inAir::CheckRfFrequency( uint32_t frequency )
+{
+    //TODO: Implement check, currently all frequencies are supported
+    return true;
+}
+
+
+void SX1276inAir::Reset( void )
+{
+    reset.output();
+    reset = 0;
+    wait_ms( 1 );
+    reset.input();
+    wait_ms( 6 );
+}
+    
+void SX1276inAir::Write( uint8_t addr, uint8_t data )
+{
+    Write( addr, &data, 1 );
+}
+
+uint8_t SX1276inAir::Read( uint8_t addr )
+{
+    uint8_t data;
+    Read( addr, &data, 1 );
+    return data;
+}
+
+void SX1276inAir::Write( uint8_t addr, uint8_t *buffer, uint8_t size )
+{
+    uint8_t i;
+
+    nss = 0;
+    spi.write( addr | 0x80 );
+    for( i = 0; i < size; i++ )
+    {
+        spi.write( buffer[i] );
+    }
+    nss = 1;
+}
+
+void SX1276inAir::Read( uint8_t addr, uint8_t *buffer, uint8_t size )
+{
+    uint8_t i;
+
+    nss = 0;
+    spi.write( addr & 0x7F );
+    for( i = 0; i < size; i++ )
+    {
+        buffer[i] = spi.write( 0 );
+    }
+    nss = 1;
+}
+
+void SX1276inAir::WriteFifo( uint8_t *buffer, uint8_t size )
+{
+    Write( 0, buffer, size );
+}
+
+void SX1276inAir::ReadFifo( uint8_t *buffer, uint8_t size )
+{
+    Read( 0, buffer, size );
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sx1276/sx1276-inAir.h	Sat May 28 23:07:55 2016 +0000
@@ -0,0 +1,200 @@
+#ifndef __SX1276_INAIR_H__
+#define __SX1276_INAIR_H__
+#include "sx1276.h"
+
+#define RADIO_INIT_REGISTERS_VALUE                \
+{                                                 \
+    { MODEM_FSK , REG_LNA                , 0x23 },\
+    { MODEM_FSK , REG_RXCONFIG           , 0x1E },\
+    { MODEM_FSK , REG_RSSICONFIG         , 0xD2 },\
+    { MODEM_FSK , REG_AFCFEI             , 0x01 },\
+    { MODEM_FSK , REG_PREAMBLEDETECT     , 0xAA },\
+    { MODEM_FSK , REG_OSC                , 0x07 },\
+    { MODEM_FSK , REG_SYNCCONFIG         , 0x12 },\
+    { MODEM_FSK , REG_SYNCVALUE1         , 0xC1 },\
+    { MODEM_FSK , REG_SYNCVALUE2         , 0x94 },\
+    { MODEM_FSK , REG_SYNCVALUE3         , 0xC1 },\
+    { MODEM_FSK , REG_PACKETCONFIG1      , 0xD8 },\
+    { MODEM_FSK , REG_FIFOTHRESH         , 0x8F },\
+    { MODEM_FSK , REG_IMAGECAL           , 0x02 },\
+    { MODEM_FSK , REG_DIOMAPPING1        , 0x00 },\
+    { MODEM_FSK , REG_DIOMAPPING2        , 0x30 },\
+    { MODEM_LORA, REG_LR_PAYLOADMAXLENGTH, 0x40 },\
+}  
+
+class SX1276inAir : public SX1276
+{
+protected:
+    DigitalInOut antSwitch;
+    DigitalIn fake;
+    
+private: 
+    static const RadioRegisters_t RadioRegsInit[];
+
+public:
+    SX1276inAir( RadioEvents_t *events,
+            PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset,
+            PinName dio0, PinName dio1, PinName dio2, PinName dio3,
+            PinName antSwitch ); 
+    
+    SX1276inAir( RadioEvents_t *events);
+    
+    virtual ~SX1276inAir() {};
+
+protected: 
+    /*!
+     * @brief Initializes the radio I/Os pins interface
+     */
+    virtual void IoInit( void );
+    
+    /*!
+     *  @brief Initializes the radio registers
+     */
+    virtual void RadioRegistersInit( );
+    
+    /*!
+     * @brief Initializes the radio SPI
+     */
+    virtual void SpiInit( void );
+    
+    /*!
+     * @brief Initializes DIO IRQ handlers
+     *
+     * @param [IN] irqHandlers Array containing the IRQ callback functions
+     */
+    virtual void IoIrqInit( DioIrqHandler *irqHandlers );
+
+    /*!
+     * @brief De-initializes the radio I/Os pins interface. 
+     *
+     * \remark Useful when going in MCU lowpower modes
+     */
+    virtual void IoDeInit( void );
+
+    /*!
+     * @brief Gets the board PA selection configuration
+     *
+     * @param [IN] channel Channel frequency in Hz
+     * @retval PaSelect RegPaConfig PaSelect value
+     */
+    virtual uint8_t GetPaSelect( uint32_t channel );
+
+    /*!
+     * @brief Set the RF Switch I/Os pins in Low Power mode
+     *
+     * @param [IN] status enable or disable
+     */
+    virtual void SetAntSwLowPower( bool status );
+
+    /*!
+     * @brief Initializes the RF Switch I/Os pins interface
+     */
+    virtual void AntSwInit( void );
+
+    /*!
+     * @brief De-initializes the RF Switch I/Os pins interface 
+     *
+     * \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
+     *
+     * @param [IN] rxTx [1: Tx, 0: Rx]
+     */
+    virtual void SetAntSw( uint8_t rxTx );
+    
+    public:
+    /*!
+     * @brief Detect the board connected by reading the value of the antenna switch pin
+     */
+    virtual uint8_t DetectBoardType( void );    
+    
+    /*!
+     * @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 );
+    
+        /*!
+     * @brief Writes the radio register at the specified address
+     *
+     * @param [IN]: addr Register address
+     * @param [IN]: data New register value
+     */
+    virtual void Write ( uint8_t addr, uint8_t data ) ;
+    
+    /*!
+     * @brief Reads the radio register at the specified address
+     *
+     * @param [IN]: addr Register address
+     * @retval data Register value
+     */
+    virtual uint8_t Read ( uint8_t addr ) ;
+    
+    /*!
+     * @brief Writes multiple radio registers starting at address
+     *
+     * @param [IN] addr   First Radio register address
+     * @param [IN] buffer Buffer containing the new register's values
+     * @param [IN] size   Number of registers to be written
+     */
+    virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) ;
+    
+    /*!
+     * @brief Reads multiple radio registers starting at address
+     *
+     * @param [IN] addr First Radio register address
+     * @param [OUT] buffer Buffer where to copy the registers data
+     * @param [IN] size Number of registers to be read
+     */
+    virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) ;
+    
+    /*!
+     * @brief Writes the buffer contents to the SX1276 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
+     */
+    virtual void WriteFifo( uint8_t *buffer, uint8_t size ) ;
+
+    /*!
+     * @brief Reads the contents of the SX1276 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 ) ;
+    
+    /*!
+     * @brief Reset the SX1276
+     */
+    virtual void Reset( void );
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- a/typedefs/typedefs.h	Fri May 13 15:09:10 2016 +0000
+++ b/typedefs/typedefs.h	Sat May 28 23:07:55 2016 +0000
@@ -4,7 +4,7 @@
  \____ \| ___ |    (_   _) ___ |/ ___)  _ \
  _____) ) ____| | | || |_| ____( (___| | | |
 (______/|_____)_|_|_| \__)_____)\____)_| |_|
-    (C) 2014 Semtech
+    ( C )2014 Semtech
 
 Description: -
 
@@ -20,6 +20,8 @@
 
 class SX1276;
 class SX1276MB1xAS;
+class SX1276inAir;
+
 /*!
  * Hardware IO IRQ callback function definition
  */
@@ -30,6 +32,7 @@
  */
 typedef void ( SX1276::*Trigger )( void );
 typedef void ( SX1276MB1xAS::*TriggerMB1xAS )( void );
+typedef void ( SX1276inAir::*TriggerInAir )( void );
 
 /*!
  * FSK bandwidth definition
@@ -51,3 +54,4 @@
 }RadioRegisters_t;
 
 #endif //__TYPEDEFS_H__
+