ST-DEVKIT-LRWAN

Dependents:   DISCO-L072CZ-LRWAN1-base

Fork of SX1276GenericLib by Helmut Tschemernjak

Revision:
38:d9189d958db8
Parent:
34:07e89f23c734
Child:
42:72deced1a4c4
--- a/sx1276/sx1276.cpp	Sat May 06 12:12:29 2017 +0000
+++ b/sx1276/sx1276.cpp	Sun May 07 18:09:10 2017 +0200
@@ -14,13 +14,15 @@
 */
 
 /*
- * additional development to make it more generic across multiple os versions
+ * additional development to make it more generic across multiple OS versions
  * (c) 2017 Helmut Tschemernjak
  * 30826 Garbsen (Hannover) Germany
  */
 
 #include "sx1276.h"
 
+
+
 const FskBandwidth_t SX1276::FskBandwidths[] =
 {
     { 2600  , 0x17 },   
@@ -48,6 +50,34 @@
 };
 
 
+
+/*!
+ * @brief Radio hardware registers initialization definition
+ *
+ * @remark Can be automatically generated by the SX1276 GUI (not yet implemented)
+ */
+
+const RadioRegisters_t SX1276::RadioRegsInit[] = {
+    { 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 },
+    
+};
+
+
 SX1276::SX1276( RadioEvents_t *events) : Radio( events ), isRadioActive( false )
 {
     wait_ms( 10 );
@@ -78,6 +108,18 @@
     this->RadioEvents = events;
 }
 
+
+void SX1276::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 );
+    }
+}
+
+
 RadioState SX1276::GetStatus( void )
 {
     return this->settings.State;