wave spectrum / Mbed 2 deprecated SX126xDevKit

Dependencies:   mbed SX126xLib

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Eeprom.h"
00003 #include "stm32l4xx_hal.h"
00004 
00005 /*!
00006  * \brief Define IO for Unused Pin
00007  */
00008 DigitalOut F_CS( D6 );      // MBED description of pin
00009 InterruptIn tact(USER_BUTTON);
00010 volatile uint8_t tactFlag=0,t1Flag=0,t2Flag=0;
00011 
00012 // RfFrequency
00013 #define SET_RF_FREQUENCY                                915000000 
00014 // Tx power
00015 #define TX_POWER                                        22
00016 // rampTime                                            
00017 #define RAMP_TIME                                       RADIO_RAMP_10_US
00018 // pilotduration, us
00019 #define PILOT_DURATION                                  500          
00020 // pilotdelay, us
00021 #define PILOT_START_DELAY                               271
00022 #define PILOT_STOP_DELAY                                462  
00023 
00024 
00025 
00026 
00027 void baud( int baudrate ) 
00028 {
00029     Serial s( USBTX, USBRX );
00030     s.baud( baudrate );
00031 }
00032 
00033 Ticker cwTrigger;
00034 void cwStop()
00035 {
00036     DemoStandby();
00037     cwTrigger.detach();
00038 }
00039 
00040 void cwStart()
00041 {
00042     RunDemoTxCw( );
00043 
00044 }
00045 
00046 void t2_cbck(void){ t2Flag=1; }  
00047   
00048 void t1_cbck(void){ t1Flag=1; }  
00049   
00050 void tact_cbck(void){ tactFlag=1; }
00051 
00052 
00053 int main( ) 
00054 {
00055     uint8_t deviceConnected = 0;
00056     uint8_t matchingFreq = 0;
00057     tact.fall(&tact_cbck);
00058 
00059     baud( 115200 );     // change here to increase or decrease the speed of the UART print
00060 
00061     F_CS = 1;
00062 
00063     deviceConnected = GetConnectedDevice( );
00064     matchingFreq = GetMatchingFrequency( );
00065 
00066     EepromInit( deviceConnected, matchingFreq );
00067     printf( "Start SX126xDevKit : %s\n\r", FIRMWARE_VERSION );
00068     PrepDemoTxCw(SET_RF_FREQUENCY,TX_POWER,RAMP_TIME);
00069     uint32_t cwTimer = PILOT_DURATION + PILOT_START_DELAY - PILOT_STOP_DELAY;
00070     while( true )
00071     {   
00072         if(tactFlag){
00073             RunDemoTxCw( );
00074             cwTrigger.attach_us(&cwStop, cwTimer);
00075             tactFlag=0;
00076         }
00077         
00078             
00079     }
00080 }