working demo for Nucleo-L152RE and Nucleo-F446RE with modtronix inair9 module

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
rba90
Date:
Wed May 18 04:37:49 2016 +0000
Parent:
15:8fa03145c5d4
Commit message:
justify bandwidth

Changed in this revision

SX1276Lib_inAir.lib Show annotated file Show diff for this revision Revisions of this file
SX1276Lib_modtronix.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SX1276Lib_inAir.lib	Wed May 18 04:37:49 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/ENEL400/code/SX1276Lib_inAir/#5131ba0d3ace
--- a/SX1276Lib_modtronix.lib	Fri May 13 23:26:07 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/modtronix/code/SX1276Lib_modtronix/#72381be1b0ce
--- a/main.cpp	Fri May 13 23:26:07 2016 +0000
+++ b/main.cpp	Wed May 18 04:37:49 2016 +0000
@@ -1,7 +1,6 @@
 #include "mbed.h"
 #include "main.h"
 #include "sx1276-inAir.h"
-#include "myDebug.h"
 
 /* Set this flag to '1' to display debug messages on the console */
 #define DEBUG_MESSAGE   1
@@ -15,10 +14,7 @@
 
 #if USE_MODEM_LORA == 1
 
-    #define LORA_BANDWIDTH                              2         // [0: 125 kHz,
-                                                                  //  1: 250 kHz,
-                                                                  //  2: 500 kHz,
-                                                                  //  3: Reserved]
+    #define LORA_BANDWIDTH                              9         // 500 KHz
     #define LORA_SPREADING_FACTOR                       7         // [SF7..SF12]
     #define LORA_CODINGRATE                             1         // [1: 4/5,
                                                                   //  2: 4/6,
@@ -82,26 +78,19 @@
     uint8_t i;
     bool isMaster = true;
     
-    debug( "\n\n\r     SX1276 Ping Pong Demo Application \n\n\r" );
+    printf( "\n\n\r     SX1276 Ping Pong Demo Application \n\n\r" );
 
-    
     // verify the connection with the board
     while( Radio.Read( REG_VERSION ) == 0x00  )
     {
-        debug( "Radio could not be detected!\n\r", NULL );
+        printf( "Radio could not be detected!\n\r");
         wait( 1 );
     }
-            
-    debug_if( ( DEBUG_MESSAGE & ( Radio.DetectBoardType( ) == SX1276MB1LAS ) ) , "\n\r > Board Type: SX1276MB1LAS < \n\r" );
-    debug_if( ( DEBUG_MESSAGE & ( Radio.DetectBoardType( ) == SX1276MB1MAS ) ) , "\n\r > Board Type: SX1276MB1MAS < \n\r" );
+    printf("RadioRegVersion: %d\r\n", Radio.Read( REG_VERSION ));
     
     Radio.SetChannel( RF_FREQUENCY ); 
 
 #if USE_MODEM_LORA == 1
-    
-    debug_if( LORA_FHSS_ENABLED, "\n\n\r             > LORA FHSS Mode < \n\n\r");
-    debug_if( !LORA_FHSS_ENABLED, "\n\n\r             > LORA Mode < \n\n\r");
-
     Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
                          LORA_SPREADING_FACTOR, LORA_CODINGRATE,
                          LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
@@ -115,8 +104,6 @@
                          LORA_IQ_INVERSION_ON, true );
                          
 #elif USE_MODEM_FSK == 1
-
-    debug("\n\n\r              > FSK Mode < \n\n\r");
     Radio.SetTxConfig( MODEM_FSK, TX_OUTPUT_POWER, FSK_FDEV, 0,
                          FSK_DATARATE, 0,
                          FSK_PREAMBLE_LENGTH, FSK_FIX_LENGTH_PAYLOAD_ON,
@@ -133,7 +120,7 @@
 
 #endif
      
-    debug_if( DEBUG_MESSAGE, "Starting Ping-Pong loop\r\n" ); 
+    printf( "Starting Ping-Pong loop\r\n" ); 
         
     led = 0;
         
@@ -151,7 +138,7 @@
                     if( strncmp( ( const char* )Buffer, ( const char* )PongMsg, 4 ) == 0 )
                     {
                         led = !led;
-                        debug( "...Pong\r\n" );
+                        printf( "...Pong\r\n" );
                         // Send the next PING frame            
                         strcpy( ( char* )Buffer, ( char* )PingMsg );
                         // We fill the buffer with numbers for the payload 
@@ -164,7 +151,7 @@
                     }
                     else if( strncmp( ( const char* )Buffer, ( const char* )PingMsg, 4 ) == 0 )
                     { // A master already exists then become a slave
-                        debug( "...Ping\r\n" );
+                        printf( "...Ping\r\n" );
                         led = !led;
                         isMaster = false;
                         // Send the next PONG frame            
@@ -191,7 +178,7 @@
                     if( strncmp( ( const char* )Buffer, ( const char* )PingMsg, 4 ) == 0 )
                     {
                         led = !led;
-                        debug( "...Ping\r\n" );
+                        printf( "...Ping\r\n" );
                         // Send the reply to the PING string
                         strcpy( ( char* )Buffer, ( char* )PongMsg );
                         // We fill the buffer with numbers for the payload 
@@ -211,15 +198,15 @@
             }
             State = LOWPOWER;
             break;
-        case TX_DONE:    
+        case TX_DONE:
             led = !led; 
             if( isMaster == true )  
             {
-                debug( "Ping...\r\n" );
+                printf( "Ping...\r\n" );
             }
             else
             {
-                debug( "Pong...\r\n" );
+                printf( "Pong...\r\n" );
             }
             Radio.Rx( RX_TIMEOUT_VALUE );
             State = LOWPOWER;
@@ -285,7 +272,7 @@
 {
     Radio.Sleep( );
     State = TX_DONE;
-    debug_if( DEBUG_MESSAGE, "> OnTxDone\n\r" );
+    printf( "> OnTxDone\n\r" );
 }
 
 void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)
@@ -296,14 +283,14 @@
     RssiValue = rssi;
     SnrValue = snr;
     State = RX_DONE;
-    debug_if( DEBUG_MESSAGE, "> OnRxDone\n\r" );
+    printf( "> OnRxDone\n\r" );
 }
 
 void OnTxTimeout( void )
 {
     Radio.Sleep( );
     State = TX_TIMEOUT;
-    debug_if( DEBUG_MESSAGE, "> OnTxTimeout\n\r" );
+    printf( "> OnTxTimeout\n\r" );
 }
 
 void OnRxTimeout( void )
@@ -311,13 +298,13 @@
     Radio.Sleep( );
     Buffer[ BufferSize ] = 0;
     State = RX_TIMEOUT;
-    debug_if( DEBUG_MESSAGE, "> OnRxTimeout\n\r" );
+    printf( "> OnRxTimeout\n\r" );
 }
 
 void OnRxError( void )
 {
     Radio.Sleep( );
     State = RX_ERROR;
-    debug_if( DEBUG_MESSAGE, "> OnRxError\n\r" );
+    printf( "> OnRxError\n\r" );
 }