SX1276 library for modtronix inair9. Edited for use with NRF51DK board.

Dependents:   InAir9_PingPong

Fork of SX1276Lib_modtronix by modtronix H

Files at this revision

API Documentation at this revision

Comitter:
AMNoll
Date:
Sun Nov 19 18:19:55 2017 +0000
Parent:
25:72381be1b0ce
Commit message:
latest version of pingpong on inair9

Changed in this revision

debug/myDebug.h Show annotated file 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.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 72381be1b0ce -r ad32782125eb debug/myDebug.h
--- a/debug/myDebug.h	Wed Jul 29 12:07:40 2015 +1000
+++ b/debug/myDebug.h	Sun Nov 19 18:19:55 2017 +0000
@@ -29,13 +29,13 @@
 /** Output a debug message
  * 
  * @param format printf-style format string, followed by variables
- */
+ *//*
 static inline void debug(const char *format, ...) {
     va_list args;
     va_start(args, format);
     vfprintf(stderr, format, args);
     va_end(args);
-}
+}*/
 
 /** Conditionally output a debug message
  * 
diff -r 72381be1b0ce -r ad32782125eb sx1276/sx1276-inAir.cpp
--- a/sx1276/sx1276-inAir.cpp	Wed Jul 29 12:07:40 2015 +1000
+++ b/sx1276/sx1276-inAir.cpp	Sun Nov 19 18:19:55 2017 +0000
@@ -75,6 +75,18 @@
                         //For NZ32ST1L board with BOARD_INAIR4 in imod2
                         :   SX1276( txDone, txTimeout, rxDone, rxTimeout, rxError, fhssChangeChannel, cadDone,
                                     PB_5/*MOSI*/, PB_4/*MISO*/, PB_3/*SCLK*/, PC_8/*CS*/, PA_9/*RST*/, PB_0/*DIO0*/, PB_1, PC_6, PA_10),
+                        #elif defined( TARGET_NRF51_DK )
+                        #warning "Target_NRF51_DK_Registered"
+                        //FOLLOWING PINS ARE LISTED IN ORDER OF ARGUMENTS IN SX1276()
+						//FOR SPI INSTANCE 0: mosi -> SPI_PSELMOSI0 = p25, miso -> SPI_PSELMISO0 = p28, sclk -> SPI_PSELSCK0 = p29, nss -> SPI_PSELSS0 = p24
+                        //FOR SPI INSTANCE 1 WHICH IS USED HERE: mosi->SPI_PSELMOSI1 = p13, miso -> SPI_PSELMISO1 = p14, sclk -> SPI_PSELSCK1  = p15, nss -> SPI_PSELSS1   = p12
+                        //FOR RESET: reset -> P0_4 = p4
+                        //FOR GPIO: dio0 -> P0_0  = p0, dio1 ->  P0_1  = p1, dio2 -> P0_2  = p2, dio3 -> P0_3  = p3, 4&5 NOT ATTACHED AND NOT INCLUDED (dio4(NC) -> P0_19 = p19, dio4(NC) -> P0_20 = p20)
+                        //FOR ANTENNA SWITCH: antSwitch -> P0_13=p13
+                        //FOR FAKE: Fake -> P0_14=p14 NOT CONNECTED
+                        :   SX1276( txDone, txTimeout, rxDone, rxTimeout, rxError, fhssChangeChannel, cadDone, SPI_PSELMOSI1, SPI_PSELMISO1, SPI_PSELSCK1, SPI_PSELSS1, P0_4, P0_0, P0_1, P0_2, P0_3),
+                           	//AntSwitch( P0_13 ), 
+                            //Fake( NC )
                         #else
                         :   SX1276( txDone, txTimeout, rxDone, rxTimeout, rxError, fhssChangeChannel, cadDone, D11, D12, D13, D10, A0, D2, D3, D4, D5),
                         #endif
@@ -82,6 +94,7 @@
                             fake( NC )
 
 {
+    
     Reset( );
     
     boardConnected = BOARD_UNKNOWN;
@@ -99,6 +112,7 @@
     SetModem( MODEM_FSK );
 
     this->settings.State = IDLE ;
+	
 }
 
 //-------------------------------------------------------------------------
@@ -135,6 +149,8 @@
         spi.frequency( frequencyToSet );
     #elif( defined ( TARGET_KL25Z ) ) //busclock frequency is halved -> double the spi frequency to compensate
         spi.frequency( frequencyToSet * 2 );
+    #elif( defined ( TARGET_NRF51_DK ) ) //busclock frequency is halved -> double the spi frequency to compensate
+        spi.frequency( frequencyToSet );
     #else
         #warning "Check the board's SPI frequency"
     #endif
diff -r 72381be1b0ce -r ad32782125eb sx1276/sx1276.cpp
--- a/sx1276/sx1276.cpp	Wed Jul 29 12:07:40 2015 +1000
+++ b/sx1276/sx1276.cpp	Sun Nov 19 18:19:55 2017 +0000
@@ -14,6 +14,8 @@
 */
 #include "sx1276.h"
 
+Serial      pc1(USBTX, USBRX); 
+
 const FskBandwidth_t SX1276::FskBandwidths[] =
 {       
     { 2600  , 0x17 },   
@@ -741,6 +743,12 @@
 
 void SX1276::Rx( uint32_t timeout )
 {
+    // configure uart port
+    pc1.baud(9600);
+    pc1.format(8, SerialBase::None, 1);
+    pc1.printf("PC printing enabled\n\r");
+    wait(2);
+    
     bool rxContinuous = false;
 
     switch( this->settings.Modem )
@@ -775,6 +783,9 @@
         break;
     case MODEM_LORA:
         {
+            
+            pc1.printf("MODEM_LORA enabled \n\r");
+            
             if( this->settings.LoRa.IqInverted == true )
             {
                 Write( REG_LR_INVERTIQ, ( ( Read( REG_LR_INVERTIQ ) & RFLR_INVERTIQ_TX_MASK & RFLR_INVERTIQ_RX_MASK ) | RFLR_INVERTIQ_RX_ON | RFLR_INVERTIQ_TX_OFF ) );
@@ -821,9 +832,13 @@
         break;
     }
 
+	//this->settings.State
+	pc1.printf("got to memset and setting RX_DONE\n\r");
+
     memset( rxBuffer, 0, ( size_t )RX_BUFFER_SIZE );
 
     this->settings.State = RX_DONE;
+    
     if( timeout != 0 )
     {
         rxTimeoutTimer.attach_us( this, &SX1276::OnTimeoutIrq, timeout );