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:
Tue May 09 11:19:51 2017 +0200
Parent:
42:72deced1a4c4
Commit message:
Added proper TCXO support (being using in the Murata module)

Changed in this revision

LoRa_TODO.txt Show annotated file Show diff for this revision Revisions of this file
sx1276/sx1276-mbed-hal.cpp Show annotated file Show diff for this revision Revisions of this file
sx1276/sx1276-mbed-hal.h Show annotated file Show diff for this revision Revisions of this file
--- a/LoRa_TODO.txt	Mon May 08 22:52:31 2017 +0200
+++ b/LoRa_TODO.txt	Tue May 09 11:19:51 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
@@ -25,4 +24,6 @@
 - 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 if the MURATA TCXO config is correct
+  done: TCXO gets enabled/disabled, in sleep mode it is turned off.
 
--- a/sx1276/sx1276-mbed-hal.cpp	Mon May 08 22:52:31 2017 +0200
+++ b/sx1276/sx1276-mbed-hal.cpp	Tue May 09 11:19:51 2017 +0200
@@ -138,8 +138,10 @@
 
 void SX1276Generic::IoInit( void )
 {
-    if (_tcxo)
+    if (_tcxo) {
         *_tcxo = 1;
+        wait_ms(TCXO_STARTUP_MS);
+    }
     AntSwInit( );
     SpiInit( );
 }
@@ -306,6 +308,15 @@
 
 void SX1276Generic::SetAntSw( uint8_t opMode )
 {
+    /*
+     * Note that the Mode RFLR (LoRa) and Mode RF are using identical
+     * values. Unfortunately booth representations are being used.
+     */
+    if (_tcxo && *_tcxo == 0 && opMode != RFLR_OPMODE_SLEEP) {
+        *_tcxo = 1;
+        wait_ms(TCXO_STARTUP_MS);
+    }
+    
     switch( opMode )
     {
         case RFLR_OPMODE_TRANSMITTER:
@@ -329,10 +340,12 @@
             	*_antSwitchTXBoost = 0;
             } else {
                 if (_antSwitch)
-        			_antSwitch = 0;
+        			*_antSwitch = 0;
             }
             break;
         case RFLR_OPMODE_SLEEP:
+            if (_tcxo)
+                *_tcxo = 0;
         case RFLR_OPMODE_STANDBY:
         default:
             if (boardConnected == MURATA_SX1276) {
--- a/sx1276/sx1276-mbed-hal.h	Mon May 08 22:52:31 2017 +0200
+++ b/sx1276/sx1276-mbed-hal.h	Tue May 09 11:19:51 2017 +0200
@@ -45,6 +45,7 @@
     
     /*!
      * TCXO being used with the Murata Module
+     * 32.768 MHz crystal.
      */
     DigitalOut *_tcxo;
 
@@ -71,6 +72,8 @@
     Timeout rxTimeoutTimer;
     Timeout rxTimeoutSyncWord;
     
+    static const int TCXO_STARTUP_MS = 3;	// crystal startup time
+    
     
 private:
     /*!