SX1276Lib updated in order to be RTOS aware

Fork of SX1276Lib by Semtech

Revision:
30:3b83eee4e72a
Parent:
27:8a37a9362714
diff -r 716d0216a79a -r 3b83eee4e72a sx1276/sx1276-hal.cpp
--- a/sx1276/sx1276-hal.cpp	Fri Mar 02 15:48:04 2018 +0100
+++ b/sx1276/sx1276-hal.cpp	Fri Mar 02 17:09:27 2018 +0100
@@ -16,7 +16,7 @@
 
 const RadioRegisters_t SX1276MB1xAS::RadioRegsInit[] = RADIO_INIT_REGISTERS_VALUE;
 
-SX1276MB1xAS::SX1276MB1xAS( RadioEvents_t *events,
+SX1276MB1xAS::SX1276MB1xAS( RadioEvents_t *events, BoardType_t board,
                             PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset,
                             PinName dio0, PinName dio1, PinName dio2, PinName dio3, PinName dio4, PinName dio5,
                             PinName antSwitch )
@@ -30,6 +30,8 @@
 {
     this->RadioEvents = events;
 
+    boardConnected = board;
+
     Reset( );
 
     RxChainCalibration( );
@@ -48,10 +50,14 @@
 }
 
 SX1276MB1xAS::SX1276MB1xAS( RadioEvents_t *events )
-                        #if defined ( TARGET_NUCLEO_L152RE ) || defined (TARGET_NUCLEO_L476RG) || defined (TARGET_NUCLEO_F401RE) || defined (TARGET_NUCLEO_L073RZ)
+                        #if defined ( TARGET_NUCLEO_L152RE ) || defined (TARGET_NUCLEO_L476RG) || defined (TARGET_NUCLEO_F401RE)
                         :   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_NUCLEO_L073RZ )
+                        :   SX1276( events, PB_15, PB_14, PB_13, PB_12, PC_6, PC_8, D3, D4, D5, D8, D9 ),
+                            AntSwitch( A4 ), 
+                            Fake( A3 )
                         #elif defined( TARGET_LPC11U6X )
                         :   SX1276( events, D11, D12, D13, D10, A0, D2, D3, D4, D5, D8, D9 ),
                             AntSwitch( P0_23 ), 
@@ -66,7 +72,7 @@
 
     Reset( );
 
-    boardConnected = UNKNOWN;
+    boardConnected = RFM95_SX1276;
 
     DetectBoardType( );
 
@@ -89,22 +95,7 @@
 //-------------------------------------------------------------------------
 uint8_t SX1276MB1xAS::DetectBoardType( void )
 {
-    if( boardConnected == UNKNOWN )
-    {
-        this->AntSwitch.input( );
-        wait_ms( 1 );
-        if( this->AntSwitch == 1 )
-        {
-            boardConnected = SX1276MB1LAS;
-        }
-        else
-        {
-            boardConnected = SX1276MB1MAS;
-        }
-        this->AntSwitch.output( );
-        wait_ms( 1 );
-    }
-    return ( boardConnected );
+    return boardConnected;
 }
 
 void SX1276MB1xAS::IoInit( void )
@@ -128,7 +119,7 @@
     nss = 1;    
     spi.format( 8,0 );   
     uint32_t frequencyToSet = 8000000;
-    #if( defined ( TARGET_NUCLEO_L152RE ) || defined ( TARGET_LPC11U6X ) )
+    #if( defined ( TARGET_NUCLEO_L152RE ) || defined ( TARGET_MOTE_L152RC ) || defined ( TARGET_NUCLEO_L476RG ) ||  defined ( TARGET_LPC11U6X ) || defined ( TARGET_MTS_MDOT_F411RE ) || defined ( TARGET_NUCLEO_L073RZ ))
         spi.frequency( frequencyToSet );
     #elif( defined ( TARGET_KL25Z ) ) //busclock frequency is halved -> double the spi frequency to compensate
         spi.frequency( frequencyToSet * 2 );
@@ -225,7 +216,7 @@
 {
     if( channel > RF_MID_BAND_THRESH )
     {
-        if( boardConnected == SX1276MB1LAS )
+        if( boardConnected == SX1276MB1LAS || boardConnected == RFM95_SX1276 || boardConnected == MURATA_SX1276)
         {
             return RF_PACONFIG_PASELECT_PABOOST;
         }