SX1276 Tx Continuous Wave Demo Application

Dependencies:   SX1276Lib mbed

SX1276 Tx Continuous Wave Demo Application

This application is used for test purposes by outputting a continuous wave, at maximum power, at a given frequency.

Revision:
2:c6e6da9fc5e1
Parent:
1:edbca7c3fbad
Child:
3:6a01985db60b
--- a/main.cpp	Tue Aug 19 09:15:10 2014 +0000
+++ b/main.cpp	Thu Sep 04 14:35:45 2014 +0000
@@ -14,7 +14,9 @@
 */
 #include "mbed.h"
 #include "sx1276-hal.h"
+#include "debug.h"
 
+/* Set this flag to '1' to test the HF max output power or '0' to the the LF max output power */
 #define TEST_HF_OUTPUT                              1
 #define TEST_LF_OUTPUT = !TEST_HF_OUTPUT
 
@@ -28,59 +30,18 @@
                                                               //  3: 4/7,
                                                               //  4: 4/8]
 #define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
+#define LORA_SYMBOL_TIMEOUT                         5         // Symbols
 #define LORA_FIX_LENGTH_PAYLOAD_ON                  false
+#define LORA_FHSS_ENABLED                           false  
+#define LORA_NB_SYMB_HOP                            4         // Symbols    
 #define LORA_IQ_INVERSION_ON                        false
-
-SX1276MB1xAS Radio( NULL, NULL, NULL, NULL, NULL );
-
-#if USE_LEDS
-    DigitalOut Led1( LED1 );
-    DigitalOut Led2( LED2 );
-    DigitalOut Led3( LED3 );
-#else
-    bool Led1 = 0;
-    bool Led2 = 0;
-    bool Led3 = 0;
-#endif
-
-static Timeout LedTimer;
-volatile bool Led1TimerEvent = false;
-volatile bool Led2TimerEvent = false;
-volatile bool Led3TimerEvent = false;
+#define LORA_CRC_ENABLED                            true
 
-/*!
- * \brief Function executed on Led 1 Timeout event
- */
-void OnLed1TimerEvent( void )
-{
-    Led1TimerEvent = true;
-}
 
-/*!
- * \brief Function executed on Led 2 Timeout event
- */
-void OnLed2TimerEvent( void )
-{
-    Led2TimerEvent = true;
-}
+
 
-/*!
- * \brief Function executed on Led 3 Timeout event
- */
-void OnLed3TimerEvent( void )
-{
-    Led3TimerEvent = true;
-}
 
-void PrintLeds( )
-{
-    #if !USE_LEDS
-        char charLed1 = ( Led1 == true ) ? '0' : 'x';
-        char charLed2 = ( Led2 == true ) ? '0' : 'x';
-        char charLed3 = ( Led3 == true ) ? '0' : 'x';
-        debug( "%c%c%c\r\n", charLed1, charLed2, charLed3 );
-    #endif
-}
+SX1276MB1xAS Radio( NULL, NULL, NULL, NULL, NULL, NULL );
 
 /**
  * Main application entry point.
@@ -108,7 +69,7 @@
     /*                                            */
     /**********************************************/
     
-#if TEST_HF_OUTPUT == 1
+#if( TEST_HF_OUTPUT == 1 )
 
     if( Radio.DetectBoardType( ) == SX1276MB1LAS ) // 
     {
@@ -138,7 +99,7 @@
         Radio.Write( 0x1e, 0x08 );
     }
     
-#elif TEST_LF_OUTPUT == 1
+#else //if( TEST_LF_OUTPUT == 1 )
 
     debug("\r\n     TEST_LF_OUTPUT on SX1276MB1xAS: 14 dBm at 434 MHz \r\n" );
     Radio.SetChannel( 433000000 );
@@ -151,13 +112,10 @@
 #endif
 
     Radio.SetTxConfig( MODEM_LORA, TxOuputPower, 0, LORA_BANDWIDTH,
-                                   LORA_SPREADING_FACTOR, LORA_CODINGRATE,
-                                   LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
-                                   true, LORA_IQ_INVERSION_ON, 3000000 );
-
-    // Switch LED 1 ON
-    Led1 = 1;
-    LedTimer.attach_us( OnLed1TimerEvent, 90000 );
+                        LORA_SPREADING_FACTOR, LORA_CODINGRATE,
+                        LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
+                        LORA_CRC_ENABLED, LORA_FHSS_ENABLED, LORA_NB_SYMB_HOP, 
+                        LORA_IQ_INVERSION_ON, 3000000 );
     
     // Sets the radio in Tx mode
     Radio.Send( NULL, 0 );
@@ -166,44 +124,8 @@
     // Blink LEDs just to show some activity
     while( 1 )
     {
-        if( Led1TimerEvent == true )
-        {
-            Led1TimerEvent = false;
-            
-            // Switch LED 1 OFF
-            Led1 = 0;
-            // Switch LED 2 ON
-            Led2 = 1;
-            
-            LedTimer.attach_us( OnLed2TimerEvent, 90000 );
-            PrintLeds( );
-        }
-
-        if( Led2TimerEvent == true )
-        {
-            Led2TimerEvent = false;
-            
-            // Switch LED 2 OFF
-            Led2 = 0;
-            // Switch LED 3 ON
-            Led3 = 1;
-            
-            LedTimer.attach_us( OnLed3TimerEvent, 90000 );
-            PrintLeds( );
-        }
-    
-        if( Led3TimerEvent == true )
-        {
-            Led3TimerEvent = false;
-            
-            // Switch LED 3 OFF
-            Led3 = 0;
-            // Switch LED 1 ON
-            Led1 = 1;
-            
-            LedTimer.attach_us( OnLed1TimerEvent, 90000 );
-            PrintLeds( );
-        }    
+        debug( "Continuous Wave activated... \r\n" );
+        wait_ms( 200 );
     }
 }