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:
Thu Sep 04 14:35:45 2014 +0000
Revision:
2:c6e6da9fc5e1
Parent:
1:edbca7c3fbad
Child:
3:6a01985db60b
V1

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 2:c6e6da9fc5e1 17 #include "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 2:c6e6da9fc5e1 41
GregCr 0:d5e61ad8edd9 42
GregCr 0:d5e61ad8edd9 43
GregCr 2:c6e6da9fc5e1 44 SX1276MB1xAS Radio( NULL, NULL, NULL, NULL, NULL, NULL );
GregCr 0:d5e61ad8edd9 45
GregCr 0:d5e61ad8edd9 46 /**
GregCr 0:d5e61ad8edd9 47 * Main application entry point.
GregCr 0:d5e61ad8edd9 48 */
GregCr 0:d5e61ad8edd9 49 int main( void )
GregCr 0:d5e61ad8edd9 50 {
GregCr 0:d5e61ad8edd9 51 uint8_t TxOuputPower = 0;
GregCr 0:d5e61ad8edd9 52
GregCr 1:edbca7c3fbad 53 debug("\n\r\n\r SX1276 Continuous Wave at full power Demo Application \n\r");
GregCr 1:edbca7c3fbad 54
GregCr 1:edbca7c3fbad 55 #if defined TARGET_NUCLEO_L152RE
GregCr 1:edbca7c3fbad 56 debug(" > Nucleo-L152RE Platform <\r\n" );
GregCr 1:edbca7c3fbad 57 #elif defined TARGET_KL25Z
GregCr 1:edbca7c3fbad 58 debug(" > KL25Z Platform <\r\n" );
GregCr 1:edbca7c3fbad 59 #elif defined TARGET_LPC11U6X
GregCr 1:edbca7c3fbad 60 debug(" > LPC11U6X Platform <\r\n" );
GregCr 1:edbca7c3fbad 61 #else
GregCr 1:edbca7c3fbad 62 debug(" > Untested Platform <\r\n" );
GregCr 1:edbca7c3fbad 63 #endif
GregCr 1:edbca7c3fbad 64
GregCr 0:d5e61ad8edd9 65 /**********************************************/
GregCr 0:d5e61ad8edd9 66 /* WARNING */
GregCr 0:d5e61ad8edd9 67 /* The below settings can damage the chipset */
GregCr 0:d5e61ad8edd9 68 /* if wrongly used. DO NOT CHANGE THE VALUES! */
GregCr 0:d5e61ad8edd9 69 /* */
GregCr 0:d5e61ad8edd9 70 /**********************************************/
GregCr 0:d5e61ad8edd9 71
GregCr 2:c6e6da9fc5e1 72 #if( TEST_HF_OUTPUT == 1 )
GregCr 0:d5e61ad8edd9 73
GregCr 0:d5e61ad8edd9 74 if( Radio.DetectBoardType( ) == SX1276MB1LAS ) //
GregCr 0:d5e61ad8edd9 75 {
GregCr 1:edbca7c3fbad 76 debug("\r\n TEST_HF_OUTPUT on SX1276MB1LAS: 20 dBm at 915 MHz \r\n" );
GregCr 0:d5e61ad8edd9 77 Radio.SetChannel( 915000000 );
GregCr 0:d5e61ad8edd9 78 TxOuputPower = 14;
GregCr 0:d5e61ad8edd9 79 Radio.Write( 0x01, 0x80 );
GregCr 0:d5e61ad8edd9 80 Radio.Write( 0x44, 0x7B );
GregCr 0:d5e61ad8edd9 81 Radio.Write( 0x3D, 0xA1 );
GregCr 0:d5e61ad8edd9 82 Radio.Write( 0x36, 0x01 );
GregCr 0:d5e61ad8edd9 83 Radio.Write( 0x1e, 0x08 );
GregCr 0:d5e61ad8edd9 84 Radio.Write( 0x45, 0xDF );
GregCr 0:d5e61ad8edd9 85 Radio.Write( 0x46, 0x03 );
GregCr 0:d5e61ad8edd9 86 Radio.Write( 0x4D, 0x87 );
GregCr 0:d5e61ad8edd9 87 Radio.Write( 0x52, 0x60 );
GregCr 1:edbca7c3fbad 88
GregCr 1:edbca7c3fbad 89
GregCr 1:edbca7c3fbad 90 }
GregCr 1:edbca7c3fbad 91 else
GregCr 1:edbca7c3fbad 92 { // SX1276MB1MAS
GregCr 1:edbca7c3fbad 93 debug("\r\n TEST_HF_OUTPUT on SX1276MB1MAS: 14 dBm at 868 MHz \r\n" );
GregCr 1:edbca7c3fbad 94 Radio.SetChannel( 868000000 );
GregCr 1:edbca7c3fbad 95 TxOuputPower = 20;
GregCr 1:edbca7c3fbad 96 Radio.Write( 0x01, 0x88 );
GregCr 1:edbca7c3fbad 97 Radio.Write( 0x3D, 0xA1 );
GregCr 1:edbca7c3fbad 98 Radio.Write( 0x36, 0x01 );
GregCr 1:edbca7c3fbad 99 Radio.Write( 0x1e, 0x08 );
GregCr 0:d5e61ad8edd9 100 }
GregCr 0:d5e61ad8edd9 101
GregCr 2:c6e6da9fc5e1 102 #else //if( TEST_LF_OUTPUT == 1 )
GregCr 0:d5e61ad8edd9 103
GregCr 1:edbca7c3fbad 104 debug("\r\n TEST_LF_OUTPUT on SX1276MB1xAS: 14 dBm at 434 MHz \r\n" );
GregCr 0:d5e61ad8edd9 105 Radio.SetChannel( 433000000 );
GregCr 0:d5e61ad8edd9 106 TxOuputPower = 14;
GregCr 0:d5e61ad8edd9 107 Radio.Write( 0x01, 0x88 );
GregCr 0:d5e61ad8edd9 108 Radio.Write( 0x3D, 0xA1 );
GregCr 0:d5e61ad8edd9 109 Radio.Write( 0x36, 0x01 );
GregCr 0:d5e61ad8edd9 110 Radio.Write( 0x1e, 0x08 );
GregCr 0:d5e61ad8edd9 111
GregCr 0:d5e61ad8edd9 112 #endif
GregCr 0:d5e61ad8edd9 113
GregCr 0:d5e61ad8edd9 114 Radio.SetTxConfig( MODEM_LORA, TxOuputPower, 0, LORA_BANDWIDTH,
GregCr 2:c6e6da9fc5e1 115 LORA_SPREADING_FACTOR, LORA_CODINGRATE,
GregCr 2:c6e6da9fc5e1 116 LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
GregCr 2:c6e6da9fc5e1 117 LORA_CRC_ENABLED, LORA_FHSS_ENABLED, LORA_NB_SYMB_HOP,
GregCr 2:c6e6da9fc5e1 118 LORA_IQ_INVERSION_ON, 3000000 );
GregCr 0:d5e61ad8edd9 119
GregCr 0:d5e61ad8edd9 120 // Sets the radio in Tx mode
GregCr 0:d5e61ad8edd9 121 Radio.Send( NULL, 0 );
GregCr 0:d5e61ad8edd9 122
GregCr 0:d5e61ad8edd9 123 debug( "Start main loop: \r\n" );
GregCr 0:d5e61ad8edd9 124 // Blink LEDs just to show some activity
GregCr 0:d5e61ad8edd9 125 while( 1 )
GregCr 0:d5e61ad8edd9 126 {
GregCr 2:c6e6da9fc5e1 127 debug( "Continuous Wave activated... \r\n" );
GregCr 2:c6e6da9fc5e1 128 wait_ms( 200 );
GregCr 0:d5e61ad8edd9 129 }
GregCr 0:d5e61ad8edd9 130 }
GregCr 0:d5e61ad8edd9 131