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:
8:8a6702a74031
Parent:
6:86aff5a7af07
--- a/main.cpp	Thu Nov 26 17:01:37 2015 +0000
+++ b/main.cpp	Mon Apr 24 13:24:19 2017 +0000
@@ -33,89 +33,86 @@
 #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_NB_SYMB_HOP                            4         // Symbols
 #define LORA_IQ_INVERSION_ON                        false
 #define LORA_CRC_ENABLED                            true
 
+/*!
+ * Radio events function pointer
+ */
+static RadioEvents_t RadioEvents;
 
+/*!
+ * Tx continuous wave parameters
+ */
+struct
+{
+    uint32_t RfFrequency;
+    uint32_t TxOutputPower;
+}TxCwParams;
+
+/*!
+ * Radio object
+ */
 SX1276MB1xAS Radio( NULL );
 
+/*!
+ * \brief Function executed on Radio Tx Timeout event
+ */
+void OnRadioTxTimeout( void )
+{
+    // Restarts continuous wave transmission when timeout expires after 65535 seconds
+    Radio.SetTxContinuousWave( TxCwParams.RfFrequency, TxCwParams.TxOutputPower, 65535 );
+}
+
 /**
  * Main application entry point.
  */
 int main( void )
 {
-    uint8_t TxOuputPower = 0;
-
-    debug("\n\r\n\r     SX1276 Continuous Wave at full power Demo Application \n\r");
+    debug( "\n\r\n\r     SX1276 Continuous Wave at full power Demo Application \n\r" );
         
 #if defined TARGET_NUCLEO_L152RE
-    debug("         > Nucleo-L152RE Platform <\r\n" );
+    debug( "         > Nucleo-L152RE Platform <\r\n" );
 #elif defined TARGET_KL25Z
-    debug("         > KL25Z Platform <\r\n" );
+    debug( "         > KL25Z Platform <\r\n" );
 #elif defined TARGET_LPC11U6X
-    debug("         > LPC11U6X Platform <\r\n" );
+    debug( "         > LPC11U6X Platform <\r\n" );
 #else
-    debug("         > Untested Platform <\r\n" );
+    debug( "         > Untested Platform <\r\n" );
 #endif
 
-    /**********************************************/
-    /*                  WARNING                   */
-    /* The below settings can damage the chipset  */
-    /* if wrongly used. DO NOT CHANGE THE VALUES! */
-    /*                                            */
-    /**********************************************/
-    
 #if( TEST_HF_OUTPUT == 1 )
 
     if( Radio.DetectBoardType( ) == SX1276MB1LAS ) // 
     {
         debug("\r\n     TEST_HF_OUTPUT on SX1276MB1LAS: 20 dBm at 915 MHz \r\n" );
-        Radio.SetChannel( 915000000 );
-        TxOuputPower = 20;
-        Radio.Write( 0x01, 0x80 );
-        Radio.Write( 0x44, 0x7B );
-        Radio.Write( 0x3D, 0xA1 );
-        Radio.Write( 0x36, 0x01 );
-        Radio.Write( 0x1e, 0x08 );
-        Radio.Write( 0x45, 0xDF );
-        Radio.Write( 0x46, 0x03 );
-        Radio.Write( 0x4D, 0x87 );
-        Radio.Write( 0x52, 0x60 );
-        
-        
+
+        TxCwParams.RfFrequency = 915e6;
+        TxCwParams.TxOutputPower = 20;
     }
     else
     {   // SX1276MB1MAS
         debug("\r\n     TEST_HF_OUTPUT on SX1276MB1MAS: 14 dBm at 868 MHz \r\n" );
-        Radio.SetChannel( 868000000 );
-        TxOuputPower = 14;
-        Radio.Write( 0x01, 0x88 );
-        Radio.Write( 0x3D, 0xA1 );
-        Radio.Write( 0x36, 0x01 );
-        Radio.Write( 0x1e, 0x08 );
+
+        TxCwParams.RfFrequency = 868e6;
+        TxCwParams.TxOutputPower = 14;
     }
     
 #else //if( TEST_LF_OUTPUT == 1 )
 
     debug("\r\n     TEST_LF_OUTPUT on SX1276MB1xAS: 14 dBm at 434 MHz \r\n" );
-    Radio.SetChannel( 433000000 );
-    TxOuputPower = 14;
-    Radio.Write( 0x01, 0x88 );
-    Radio.Write( 0x3D, 0xA1 );
-    Radio.Write( 0x36, 0x01 );
-    Radio.Write( 0x1e, 0x08 );
+    TxCwParams.RfFrequency = 433e6;
+    TxCwParams.TxOutputPower = 14;
 
 #endif
 
-    Radio.SetTxConfig( MODEM_LORA, TxOuputPower, 0, LORA_BANDWIDTH,
-                        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 );
+    // Radio initialization
+    RadioEvents.TxTimeout = OnRadioTxTimeout;
+    Radio.Init( &RadioEvents );
+
+    // Start continuous wave transmission fucntion expires after 65535 seconds
+    Radio.SetTxContinuousWave( TxCwParams.RfFrequency, TxCwParams.TxOutputPower, 65535 );
 
     debug( "Start main loop: \r\n" );
     // Blink LEDs just to show some activity
@@ -125,4 +122,3 @@
         wait_ms( 200 );
     }
 }
-