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.

Committer:
GregCr
Date:
Fri Sep 19 14:22:21 2014 +0000
Revision:
3:6a01985db60b
Parent:
2:c6e6da9fc5e1
Child:
4:e143703ffc4e
match library update

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GregCr 0:d5e61ad8edd9 1 /*
GregCr 0:d5e61ad8edd9 2 / _____) _ | |
GregCr 0:d5e61ad8edd9 3 ( (____ _____ ____ _| |_ _____ ____| |__
GregCr 0:d5e61ad8edd9 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
GregCr 0:d5e61ad8edd9 5 _____) ) ____| | | || |_| ____( (___| | | |
GregCr 0:d5e61ad8edd9 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
GregCr 0:d5e61ad8edd9 7 ( C )2014 Semtech
GregCr 0:d5e61ad8edd9 8
GregCr 0:d5e61ad8edd9 9 Description: Tx Continuous Wave implementation
GregCr 0:d5e61ad8edd9 10
GregCr 0:d5e61ad8edd9 11 License: Revised BSD License, see LICENSE.TXT file include in the project
GregCr 0:d5e61ad8edd9 12
GregCr 0:d5e61ad8edd9 13 Maintainers: Miguel Luis, Gregory Cristian and Nicolas Huguenin
GregCr 0:d5e61ad8edd9 14 */
GregCr 0:d5e61ad8edd9 15 #include "mbed.h"
GregCr 0:d5e61ad8edd9 16 #include "sx1276-hal.h"
GregCr 3:6a01985db60b 17 #include "mbed_debug.h"
GregCr 0:d5e61ad8edd9 18
GregCr 2:c6e6da9fc5e1 19 /* Set this flag to '1' to test the HF max output power or '0' to the the LF max output power */
GregCr 0:d5e61ad8edd9 20 #define TEST_HF_OUTPUT 1
GregCr 0:d5e61ad8edd9 21 #define TEST_LF_OUTPUT = !TEST_HF_OUTPUT
GregCr 0:d5e61ad8edd9 22
GregCr 0:d5e61ad8edd9 23 #define LORA_BANDWIDTH 0 // [0: 125 kHz,
GregCr 0:d5e61ad8edd9 24 // 1: 250 kHz,
GregCr 0:d5e61ad8edd9 25 // 2: 500 kHz,
GregCr 0:d5e61ad8edd9 26 // 3: Reserved]
GregCr 0:d5e61ad8edd9 27 #define LORA_SPREADING_FACTOR 9 // [SF7..SF12]
GregCr 0:d5e61ad8edd9 28 #define LORA_CODINGRATE 1 // [1: 4/5,
GregCr 0:d5e61ad8edd9 29 // 2: 4/6,
GregCr 0:d5e61ad8edd9 30 // 3: 4/7,
GregCr 0:d5e61ad8edd9 31 // 4: 4/8]
GregCr 0:d5e61ad8edd9 32 #define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
GregCr 2:c6e6da9fc5e1 33 #define LORA_SYMBOL_TIMEOUT 5 // Symbols
GregCr 0:d5e61ad8edd9 34 #define LORA_FIX_LENGTH_PAYLOAD_ON false
GregCr 2:c6e6da9fc5e1 35 #define LORA_FHSS_ENABLED false
GregCr 2:c6e6da9fc5e1 36 #define LORA_NB_SYMB_HOP 4 // Symbols
GregCr 0:d5e61ad8edd9 37 #define LORA_IQ_INVERSION_ON false
GregCr 2:c6e6da9fc5e1 38 #define LORA_CRC_ENABLED true
GregCr 0:d5e61ad8edd9 39
GregCr 0:d5e61ad8edd9 40
GregCr 3:6a01985db60b 41 SX1276MB1xAS Radio( NULL, NULL, NULL, NULL, NULL, NULL, NULL );
GregCr 0:d5e61ad8edd9 42
GregCr 0:d5e61ad8edd9 43 /**
GregCr 0:d5e61ad8edd9 44 * Main application entry point.
GregCr 0:d5e61ad8edd9 45 */
GregCr 0:d5e61ad8edd9 46 int main( void )
GregCr 0:d5e61ad8edd9 47 {
GregCr 0:d5e61ad8edd9 48 uint8_t TxOuputPower = 0;
GregCr 0:d5e61ad8edd9 49
GregCr 1:edbca7c3fbad 50 debug("\n\r\n\r SX1276 Continuous Wave at full power Demo Application \n\r");
GregCr 1:edbca7c3fbad 51
GregCr 1:edbca7c3fbad 52 #if defined TARGET_NUCLEO_L152RE
GregCr 1:edbca7c3fbad 53 debug(" > Nucleo-L152RE Platform <\r\n" );
GregCr 1:edbca7c3fbad 54 #elif defined TARGET_KL25Z
GregCr 1:edbca7c3fbad 55 debug(" > KL25Z Platform <\r\n" );
GregCr 1:edbca7c3fbad 56 #elif defined TARGET_LPC11U6X
GregCr 1:edbca7c3fbad 57 debug(" > LPC11U6X Platform <\r\n" );
GregCr 1:edbca7c3fbad 58 #else
GregCr 1:edbca7c3fbad 59 debug(" > Untested Platform <\r\n" );
GregCr 1:edbca7c3fbad 60 #endif
GregCr 1:edbca7c3fbad 61
GregCr 0:d5e61ad8edd9 62 /**********************************************/
GregCr 0:d5e61ad8edd9 63 /* WARNING */
GregCr 0:d5e61ad8edd9 64 /* The below settings can damage the chipset */
GregCr 0:d5e61ad8edd9 65 /* if wrongly used. DO NOT CHANGE THE VALUES! */
GregCr 0:d5e61ad8edd9 66 /* */
GregCr 0:d5e61ad8edd9 67 /**********************************************/
GregCr 0:d5e61ad8edd9 68
GregCr 2:c6e6da9fc5e1 69 #if( TEST_HF_OUTPUT == 1 )
GregCr 0:d5e61ad8edd9 70
GregCr 0:d5e61ad8edd9 71 if( Radio.DetectBoardType( ) == SX1276MB1LAS ) //
GregCr 0:d5e61ad8edd9 72 {
GregCr 1:edbca7c3fbad 73 debug("\r\n TEST_HF_OUTPUT on SX1276MB1LAS: 20 dBm at 915 MHz \r\n" );
GregCr 0:d5e61ad8edd9 74 Radio.SetChannel( 915000000 );
GregCr 0:d5e61ad8edd9 75 TxOuputPower = 14;
GregCr 0:d5e61ad8edd9 76 Radio.Write( 0x01, 0x80 );
GregCr 0:d5e61ad8edd9 77 Radio.Write( 0x44, 0x7B );
GregCr 0:d5e61ad8edd9 78 Radio.Write( 0x3D, 0xA1 );
GregCr 0:d5e61ad8edd9 79 Radio.Write( 0x36, 0x01 );
GregCr 0:d5e61ad8edd9 80 Radio.Write( 0x1e, 0x08 );
GregCr 0:d5e61ad8edd9 81 Radio.Write( 0x45, 0xDF );
GregCr 0:d5e61ad8edd9 82 Radio.Write( 0x46, 0x03 );
GregCr 0:d5e61ad8edd9 83 Radio.Write( 0x4D, 0x87 );
GregCr 0:d5e61ad8edd9 84 Radio.Write( 0x52, 0x60 );
GregCr 1:edbca7c3fbad 85
GregCr 1:edbca7c3fbad 86
GregCr 1:edbca7c3fbad 87 }
GregCr 1:edbca7c3fbad 88 else
GregCr 1:edbca7c3fbad 89 { // SX1276MB1MAS
GregCr 1:edbca7c3fbad 90 debug("\r\n TEST_HF_OUTPUT on SX1276MB1MAS: 14 dBm at 868 MHz \r\n" );
GregCr 1:edbca7c3fbad 91 Radio.SetChannel( 868000000 );
GregCr 1:edbca7c3fbad 92 TxOuputPower = 20;
GregCr 1:edbca7c3fbad 93 Radio.Write( 0x01, 0x88 );
GregCr 1:edbca7c3fbad 94 Radio.Write( 0x3D, 0xA1 );
GregCr 1:edbca7c3fbad 95 Radio.Write( 0x36, 0x01 );
GregCr 1:edbca7c3fbad 96 Radio.Write( 0x1e, 0x08 );
GregCr 0:d5e61ad8edd9 97 }
GregCr 0:d5e61ad8edd9 98
GregCr 2:c6e6da9fc5e1 99 #else //if( TEST_LF_OUTPUT == 1 )
GregCr 0:d5e61ad8edd9 100
GregCr 1:edbca7c3fbad 101 debug("\r\n TEST_LF_OUTPUT on SX1276MB1xAS: 14 dBm at 434 MHz \r\n" );
GregCr 0:d5e61ad8edd9 102 Radio.SetChannel( 433000000 );
GregCr 0:d5e61ad8edd9 103 TxOuputPower = 14;
GregCr 0:d5e61ad8edd9 104 Radio.Write( 0x01, 0x88 );
GregCr 0:d5e61ad8edd9 105 Radio.Write( 0x3D, 0xA1 );
GregCr 0:d5e61ad8edd9 106 Radio.Write( 0x36, 0x01 );
GregCr 0:d5e61ad8edd9 107 Radio.Write( 0x1e, 0x08 );
GregCr 0:d5e61ad8edd9 108
GregCr 0:d5e61ad8edd9 109 #endif
GregCr 0:d5e61ad8edd9 110
GregCr 0:d5e61ad8edd9 111 Radio.SetTxConfig( MODEM_LORA, TxOuputPower, 0, LORA_BANDWIDTH,
GregCr 2:c6e6da9fc5e1 112 LORA_SPREADING_FACTOR, LORA_CODINGRATE,
GregCr 2:c6e6da9fc5e1 113 LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
GregCr 2:c6e6da9fc5e1 114 LORA_CRC_ENABLED, LORA_FHSS_ENABLED, LORA_NB_SYMB_HOP,
GregCr 2:c6e6da9fc5e1 115 LORA_IQ_INVERSION_ON, 3000000 );
GregCr 0:d5e61ad8edd9 116
GregCr 0:d5e61ad8edd9 117 // Sets the radio in Tx mode
GregCr 0:d5e61ad8edd9 118 Radio.Send( NULL, 0 );
GregCr 0:d5e61ad8edd9 119
GregCr 0:d5e61ad8edd9 120 debug( "Start main loop: \r\n" );
GregCr 0:d5e61ad8edd9 121 // Blink LEDs just to show some activity
GregCr 0:d5e61ad8edd9 122 while( 1 )
GregCr 0:d5e61ad8edd9 123 {
GregCr 2:c6e6da9fc5e1 124 debug( "Continuous Wave activated... \r\n" );
GregCr 2:c6e6da9fc5e1 125 wait_ms( 200 );
GregCr 0:d5e61ad8edd9 126 }
GregCr 0:d5e61ad8edd9 127 }
GregCr 0:d5e61ad8edd9 128