Driver library for SX1272/SX1276 transceivers

Dependents:   LORA_RX LORA_TX WindConcentrator hid_test ... more

/media/uploads/dudmuck/lora.png

Driver library for SX1272 and SX1276 radio transceivers.

This device uses CSS modulation to provide much improved link budget. The RF hardware is same as in FSK devices, just with added LoRa spread-spectrum modem.

This library provides functions to configure radio chip and transmit & receive packets.

Using This Library

Library function service_radio() must be called continuously from main loop, to service interrupts from radio.

/media/uploads/dudmuck/sx1272rf1_connector_300.jpg

Board Specific implementation

FunctionPointer for rf_switch callback allows the program to implement control of RF switch unique to their board. Example options are:

  • SKY13373 for external power amplifier implementation. Requires two DigitalOut pins.
  • SKY13350 using PA_BOOST. requires two DigitalOut pins.
  • PE4259-63: controlled directly by radio chip, no software function needed. However, in the case of SX1276MB1xAS, the RXTX pin on IO2 should be driven by this callback function when R16 is installed (without R15) on this shield board.

Some configurations may need to force the use of RFO or PA_BOOST, or a board could offer both options. The rf_switch function pointer callback should support the implementation choice on the board.

further reading

Revision:
15:3f3fc6792f97
Parent:
14:f39b9bf5290f
Child:
16:3de8e1c465eb
--- a/sx127x_lora.h	Fri Apr 17 01:52:29 2015 +0000
+++ b/sx127x_lora.h	Thu May 14 23:23:13 2015 +0000
@@ -39,7 +39,7 @@
 #define REG_LR_IFFRQL                               0x30    // if_freq(7:0)
 #define REG_LR_TEST31                               0x31    // if_freq_auto, ...
 #define REG_LR_TEST32                               0x32    // 
-#define REG_LR_TEST33                               0x33
+#define REG_LR_TEST33                               0x33    // invert IQ
 #define REG_LR_CAD_PEAK_TO_NOISE_RATIO              0x34
 #define REG_LR_CAD_MIN_PEAK                         0x35
 #define REG_LR_DETECTION_THRESHOLD                  0x37
@@ -135,6 +135,20 @@
     uint8_t octet;
 } RegTest31_t;
 
+typedef union {
+    struct {    // sx127x register 0x33
+        uint8_t chirp_invert_tx    : 1;    // 0  invert TX spreading sequence
+        uint8_t chirp_invert_rx    : 1;    // 1  invert chip direction in RX mode
+        uint8_t sync_detect_th     : 1;    // 2  require 6dB despread SNR during preamble
+        uint8_t invert_coef_phase  : 1;    // 3  
+        uint8_t invert_coef_amp    : 1;    // 4
+        uint8_t quad_correction_en : 1;    // 5  enable IQ compensation
+        uint8_t invert_i_q         : 1;    // 6  RX invert
+        uint8_t start_rambist      : 1;    // 7
+    } bits;
+    uint8_t octet;
+} RegTest33_t;
+
 //class SX127x_lora : public SX127x
 class SX127x_lora {
     public:
@@ -205,6 +219,12 @@
         
         void set_nb_trig_peaks(int);
         
+        /** get receiver difference in RF frequency 
+          * @returns hertz
+          * @note if receiver is lower in frequency than transmitter, a negative Hz will be returned
+          */
+        int get_freq_error_Hz(void);
+        
         RegIrqFlags_t       RegIrqFlags;            // 0x12
         uint8_t             RegRxNbBytes;           // 0x13
         RegModemStatus_t    RegModemStatus;         // 0x18