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

Dependencies:   mbed

Revision:
15:8fa03145c5d4
Parent:
14:c7251480feb9
Child:
16:61684e7fdb08
--- a/main.cpp	Wed Feb 17 09:28:29 2016 +0000
+++ b/main.cpp	Fri May 13 23:26:07 2016 +0000
@@ -1,10 +1,10 @@
 #include "mbed.h"
 #include "main.h"
-#include "sx1276-hal.h"
-#include "debug.h"
+#include "sx1276-inAir.h"
+#include "myDebug.h"
 
 /* Set this flag to '1' to display debug messages on the console */
-#define DEBUG_MESSAGE   0
+#define DEBUG_MESSAGE   1
 
 /* Set this flag to '1' to use the LoRa modulation or to '0' to use FSK modulation */
 #define USE_MODEM_LORA  1
@@ -58,33 +58,15 @@
 /*
  *  Global variables declarations
  */
-typedef enum
-{
-    LOWPOWER = 0,
-    IDLE,
-    
-    RX,
-    RX_TIMEOUT,
-    RX_ERROR,
-    
-    TX,
-    TX_TIMEOUT,
-    
-    CAD,
-    CAD_DONE
-}AppStates_t;
 
-volatile AppStates_t State = LOWPOWER;
+volatile RadioState State = LOWPOWER;
 
-/*!
- * Radio events function pointer
- */
-static RadioEvents_t RadioEvents;
 
 /*
  *  Global variables declarations
  */
-SX1276MB1xAS Radio( NULL );
+
+SX1276inAir Radio(OnTxDone, OnTxTimeout, OnRxDone, OnRxTimeout, OnRxError, NULL, NULL);
 
 const uint8_t PingMsg[] = "PING";
 const uint8_t PongMsg[] = "PONG";
@@ -102,13 +84,6 @@
     
     debug( "\n\n\r     SX1276 Ping Pong Demo Application \n\n\r" );
 
-    // Initialize Radio driver
-    RadioEvents.TxDone = OnTxDone;
-    RadioEvents.RxDone = OnRxDone;
-    RadioEvents.RxError = OnRxError;
-    RadioEvents.TxTimeout = OnTxTimeout;
-    RadioEvents.RxTimeout = OnRxTimeout;
-    Radio.Init( &RadioEvents );
     
     // verify the connection with the board
     while( Radio.Read( REG_VERSION ) == 0x00  )
@@ -168,7 +143,7 @@
     {
         switch( State )
         {
-        case RX:
+        case RX_DONE:
             if( isMaster == true )
             {
                 if( BufferSize > 0 )
@@ -236,7 +211,7 @@
             }
             State = LOWPOWER;
             break;
-        case TX:    
+        case TX_DONE:    
             led = !led; 
             if( isMaster == true )  
             {
@@ -309,7 +284,7 @@
 void OnTxDone( void )
 {
     Radio.Sleep( );
-    State = TX;
+    State = TX_DONE;
     debug_if( DEBUG_MESSAGE, "> OnTxDone\n\r" );
 }
 
@@ -320,7 +295,7 @@
     memcpy( Buffer, payload, BufferSize );
     RssiValue = rssi;
     SnrValue = snr;
-    State = RX;
+    State = RX_DONE;
     debug_if( DEBUG_MESSAGE, "> OnRxDone\n\r" );
 }