wave spectrum
/
SX126xDevKit
original
CwTransmitter/CwTransmitter.h@8:cdb739697925, 2021-02-15 (annotated)
- Committer:
- wavespectrum
- Date:
- Mon Feb 15 21:03:43 2021 +0000
- Revision:
- 8:cdb739697925
- Parent:
- Demo/DemoApplication.h@7:274ca9fe1080
prep
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GregCr | 0:e5420f1a8a1a | 1 | #ifndef DEMO_APPLICATION_H |
GregCr | 0:e5420f1a8a1a | 2 | #define DEMO_APPLICATION_H |
wavespectrum | 8:cdb739697925 | 3 | #include "sx126x.h" |
GregCr | 0:e5420f1a8a1a | 4 | |
GregCr | 0:e5420f1a8a1a | 5 | /*! |
GregCr | 0:e5420f1a8a1a | 6 | * \brief Used to display firmware version on TFT (Utilities menu) |
GregCr | 0:e5420f1a8a1a | 7 | */ |
GregCr | 2:8e1b4210df6b | 8 | #define FIRMWARE_VERSION ( ( char* )"Firmware Version: 180706" ) |
GregCr | 0:e5420f1a8a1a | 9 | |
GregCr | 0:e5420f1a8a1a | 10 | /*! |
GregCr | 0:e5420f1a8a1a | 11 | * \brief Define range of central frequency [Hz] |
GregCr | 0:e5420f1a8a1a | 12 | */ |
GregCr | 2:8e1b4210df6b | 13 | #define DEMO_CENTRAL_FREQ_MIN 150000000UL |
GregCr | 2:8e1b4210df6b | 14 | #define DEMO_CENTRAL_FREQ_MAX 950000000UL |
GregCr | 0:e5420f1a8a1a | 15 | |
GregCr | 0:e5420f1a8a1a | 16 | /*! |
GregCr | 0:e5420f1a8a1a | 17 | * \brief Define 3 preset central frequencies [Hz] |
GregCr | 0:e5420f1a8a1a | 18 | */ |
GregCr | 2:8e1b4210df6b | 19 | #define DEMO_CENTRAL_FREQ_PRESET1 169000000UL |
GregCr | 2:8e1b4210df6b | 20 | #define DEMO_CENTRAL_FREQ_PRESET2 280000000UL |
GregCr | 2:8e1b4210df6b | 21 | #define DEMO_CENTRAL_FREQ_PRESET3 434000000UL |
GregCr | 2:8e1b4210df6b | 22 | #define DEMO_CENTRAL_FREQ_PRESET4 490000000UL |
GregCr | 2:8e1b4210df6b | 23 | #define DEMO_CENTRAL_FREQ_PRESET5 783000000UL |
GregCr | 2:8e1b4210df6b | 24 | #define DEMO_CENTRAL_FREQ_PRESET6 868000000UL |
GregCr | 2:8e1b4210df6b | 25 | #define DEMO_CENTRAL_FREQ_PRESET7 915000000UL |
GregCr | 2:8e1b4210df6b | 26 | #define DEMO_CENTRAL_FREQ_PRESET8 930000000UL |
GregCr | 2:8e1b4210df6b | 27 | #define DEMO_CENTRAL_FREQ_PRESET9 510000000UL |
GregCr | 0:e5420f1a8a1a | 28 | |
GregCr | 0:e5420f1a8a1a | 29 | /*! |
GregCr | 0:e5420f1a8a1a | 30 | * \brief Define min and max Tx power [dBm] |
GregCr | 0:e5420f1a8a1a | 31 | */ |
GregCr | 0:e5420f1a8a1a | 32 | #define SX1261_POWER_TX_MIN -17 |
GregCr | 0:e5420f1a8a1a | 33 | #define SX1261_POWER_TX_MAX 15 |
GregCr | 0:e5420f1a8a1a | 34 | |
GregCr | 0:e5420f1a8a1a | 35 | #define SX1262_POWER_TX_MIN -10 |
GregCr | 0:e5420f1a8a1a | 36 | #define SX1262_POWER_TX_MAX 22 |
GregCr | 0:e5420f1a8a1a | 37 | |
GregCr | 0:e5420f1a8a1a | 38 | /*! |
GregCr | 0:e5420f1a8a1a | 39 | * \brief Define current demo mode |
GregCr | 0:e5420f1a8a1a | 40 | */ |
GregCr | 0:e5420f1a8a1a | 41 | enum DemoMode |
GregCr | 0:e5420f1a8a1a | 42 | { |
GregCr | 0:e5420f1a8a1a | 43 | MASTER = 0, |
GregCr | 0:e5420f1a8a1a | 44 | SLAVE |
GregCr | 0:e5420f1a8a1a | 45 | }; |
GregCr | 0:e5420f1a8a1a | 46 | |
GregCr | 0:e5420f1a8a1a | 47 | /*! |
GregCr | 0:e5420f1a8a1a | 48 | * \brief Define GFSK bitrate |
GregCr | 0:e5420f1a8a1a | 49 | */ |
GregCr | 0:e5420f1a8a1a | 50 | typedef enum |
GregCr | 0:e5420f1a8a1a | 51 | { |
GregCr | 0:e5420f1a8a1a | 52 | DEMO_BR_100 = 100, |
GregCr | 0:e5420f1a8a1a | 53 | DEMO_BR_600 = 600, |
GregCr | 0:e5420f1a8a1a | 54 | DEMO_BR_4800 = 4800, |
GregCr | 0:e5420f1a8a1a | 55 | DEMO_BR_9600 = 9600, |
GregCr | 0:e5420f1a8a1a | 56 | DEMO_BR_19200 = 19200, |
GregCr | 0:e5420f1a8a1a | 57 | DEMO_BR_57600 = 57600, |
GregCr | 0:e5420f1a8a1a | 58 | DEMO_BR_100000 = 100000, |
GregCr | 0:e5420f1a8a1a | 59 | DEMO_BR_250000 = 250000, |
GregCr | 0:e5420f1a8a1a | 60 | }DemoBitrate_t; |
GregCr | 0:e5420f1a8a1a | 61 | |
GregCr | 0:e5420f1a8a1a | 62 | /*! |
GregCr | 0:e5420f1a8a1a | 63 | * \brief Define GFSK frequency deviation |
GregCr | 0:e5420f1a8a1a | 64 | */ |
GregCr | 0:e5420f1a8a1a | 65 | typedef enum |
GregCr | 0:e5420f1a8a1a | 66 | { |
GregCr | 0:e5420f1a8a1a | 67 | DEMO_FDEV_5000 = 5000, |
GregCr | 0:e5420f1a8a1a | 68 | DEMO_FDEV_10000 = 10000, |
GregCr | 0:e5420f1a8a1a | 69 | DEMO_FDEV_25000 = 25000, |
GregCr | 0:e5420f1a8a1a | 70 | DEMO_FDEV_50000 = 50000, |
GregCr | 0:e5420f1a8a1a | 71 | DEMO_FDEV_75000 = 75000, |
GregCr | 0:e5420f1a8a1a | 72 | DEMO_FDEV_100000 = 100000, |
GregCr | 0:e5420f1a8a1a | 73 | DEMO_FDEV_150000 = 150000, |
GregCr | 0:e5420f1a8a1a | 74 | }DemoFrequencyDev_t; |
GregCr | 0:e5420f1a8a1a | 75 | |
GregCr | 0:e5420f1a8a1a | 76 | /*! |
GregCr | 0:e5420f1a8a1a | 77 | * \brief List of states for demo state machine |
GregCr | 0:e5420f1a8a1a | 78 | */ |
GregCr | 0:e5420f1a8a1a | 79 | enum DemoInternalStates |
GregCr | 0:e5420f1a8a1a | 80 | { |
GregCr | 0:e5420f1a8a1a | 81 | APP_IDLE = 0, // nothing to do (or wait a radio interrupt) |
GregCr | 0:e5420f1a8a1a | 82 | SEND_PING_MSG, |
GregCr | 0:e5420f1a8a1a | 83 | SEND_PONG_MSG, |
GregCr | 0:e5420f1a8a1a | 84 | APP_RX, // Rx done |
GregCr | 0:e5420f1a8a1a | 85 | APP_RX_TIMEOUT, // Rx timeout |
GregCr | 0:e5420f1a8a1a | 86 | APP_RX_ERROR, // Rx error |
GregCr | 0:e5420f1a8a1a | 87 | APP_TX, // Tx done |
GregCr | 0:e5420f1a8a1a | 88 | APP_TX_TIMEOUT, // Tx error |
GregCr | 0:e5420f1a8a1a | 89 | PER_TX_START, // PER master |
GregCr | 0:e5420f1a8a1a | 90 | PER_RX_START, // PER slave |
GregCr | 0:e5420f1a8a1a | 91 | CAD_DONE, // CAD Done |
GregCr | 0:e5420f1a8a1a | 92 | CAD_DONE_CHANNEL_DETECTED // Channel Detected following a CAD |
GregCr | 0:e5420f1a8a1a | 93 | }; |
GregCr | 0:e5420f1a8a1a | 94 | |
GregCr | 0:e5420f1a8a1a | 95 | /*! |
GregCr | 0:e5420f1a8a1a | 96 | * \brief Demo Settings structure of Eeprom structure |
GregCr | 0:e5420f1a8a1a | 97 | */ |
GregCr | 0:e5420f1a8a1a | 98 | typedef struct |
GregCr | 0:e5420f1a8a1a | 99 | { |
GregCr | 0:e5420f1a8a1a | 100 | uint8_t Entity; // Master or Slave |
GregCr | 0:e5420f1a8a1a | 101 | uint8_t HoldDemo; // Put demo in hold status |
GregCr | 0:e5420f1a8a1a | 102 | uint8_t BoostedRx; // Use Boosted Rx if true |
GregCr | 0:e5420f1a8a1a | 103 | uint32_t Frequency; // Demo frequency |
GregCr | 0:e5420f1a8a1a | 104 | uint8_t LastDeviceConnected;// Last Device Connected |
GregCr | 0:e5420f1a8a1a | 105 | int8_t TxPower; // Demo Tx power |
GregCr | 0:e5420f1a8a1a | 106 | uint8_t RadioPowerMode; // Radio Power Mode [0: LDO, 1:DC_DC] |
GregCr | 0:e5420f1a8a1a | 107 | uint8_t PayloadLength; // Demo payload length |
GregCr | 0:e5420f1a8a1a | 108 | uint8_t ModulationType; // Demo modulation type (LORA, GFSK) |
GregCr | 0:e5420f1a8a1a | 109 | uint32_t ModulationParam1; // Demo Mod. Param1 (depend on modulation type) |
GregCr | 0:e5420f1a8a1a | 110 | uint32_t ModulationParam2; // Demo Mod. Param2 (depend on modulation type) |
GregCr | 0:e5420f1a8a1a | 111 | uint8_t ModulationParam3; // Demo Mod. Param3 (depend on modulation type) |
GregCr | 0:e5420f1a8a1a | 112 | uint8_t ModulationParam4; // Demo Mod. Param4 (depend on modulation type) |
GregCr | 0:e5420f1a8a1a | 113 | uint16_t PacketParam1; // Demo Pack. Param1 (depend on packet type) |
GregCr | 0:e5420f1a8a1a | 114 | uint8_t PacketParam2; // Demo Pack. Param2 (depend on packet type) |
GregCr | 0:e5420f1a8a1a | 115 | uint8_t PacketParam3; // Demo Pack. Param3 (depend on packet type) |
GregCr | 0:e5420f1a8a1a | 116 | uint8_t PacketParam4; // Demo Pack. Param4 (depend on packet type) |
GregCr | 0:e5420f1a8a1a | 117 | uint8_t PacketParam5; // Demo Pack. Param5 (depend on packet type) |
GregCr | 0:e5420f1a8a1a | 118 | uint8_t PacketParam6; // Demo Pack. Param6 (depend on packet type) |
GregCr | 0:e5420f1a8a1a | 119 | uint8_t PacketParam7; // Demo Pack. Param7 (depend on packet type) |
GregCr | 0:e5420f1a8a1a | 120 | uint8_t PacketParam8; // Demo Pack. Param8 (depend on packet type) |
GregCr | 0:e5420f1a8a1a | 121 | uint32_t MaxNumPacket; // Demo Max Num Packet for PingPong and PER |
GregCr | 0:e5420f1a8a1a | 122 | uint16_t InterPacketDelay; // Demo Inter-Packet Delay for PingPong and PER |
GregCr | 0:e5420f1a8a1a | 123 | uint32_t CntPacketTx; // Tx packet transmitted |
GregCr | 0:e5420f1a8a1a | 124 | uint32_t CntPacketRxOK; // Rx packet received OK |
GregCr | 0:e5420f1a8a1a | 125 | uint32_t CntPacketRxOKSlave;// Rx packet received OK (slave side) |
GregCr | 0:e5420f1a8a1a | 126 | uint32_t CntPacketRxKO; // Rx packet received KO |
GregCr | 0:e5420f1a8a1a | 127 | uint32_t CntPacketRxKOSlave;// Rx packet received KO (slave side) |
GregCr | 0:e5420f1a8a1a | 128 | uint16_t RxTimeOutCount; // Rx packet received KO (by timeout) |
GregCr | 0:e5420f1a8a1a | 129 | int8_t RssiValue; // Demo Rssi Value |
GregCr | 0:e5420f1a8a1a | 130 | int8_t SnrValue; // Demo Snr Value (only for LR24 mod. type) |
GregCr | 0:e5420f1a8a1a | 131 | uint32_t FreqErrorEst; // Estimation of the frequency error on the Rx side |
GregCr | 0:e5420f1a8a1a | 132 | }DemoSettings_t; |
GregCr | 0:e5420f1a8a1a | 133 | |
GregCr | 0:e5420f1a8a1a | 134 | /*! |
GregCr | 0:e5420f1a8a1a | 135 | * \brief Define freq offset for config central freq in "Radio Config Freq" menu |
GregCr | 0:e5420f1a8a1a | 136 | */ |
GregCr | 0:e5420f1a8a1a | 137 | enum FreqBase |
GregCr | 0:e5420f1a8a1a | 138 | { |
GregCr | 0:e5420f1a8a1a | 139 | FB1 = 1, // 1 Hz |
GregCr | 0:e5420f1a8a1a | 140 | FB10 = 10, // 10 Hz |
GregCr | 0:e5420f1a8a1a | 141 | FB100 = 100, // 100 Hz |
GregCr | 0:e5420f1a8a1a | 142 | FB1K = 1000, // 1 kHz |
GregCr | 0:e5420f1a8a1a | 143 | FB10K = 10000, // 10 kHz |
GregCr | 0:e5420f1a8a1a | 144 | FB100K = 100000, // 100 kHz |
GregCr | 0:e5420f1a8a1a | 145 | FB1M = 1000000, // 1 MHz |
GregCr | 0:e5420f1a8a1a | 146 | FB10M = 10000000 // 10 MHz |
GregCr | 0:e5420f1a8a1a | 147 | }; |
GregCr | 0:e5420f1a8a1a | 148 | |
GregCr | 0:e5420f1a8a1a | 149 | |
GregCr | 0:e5420f1a8a1a | 150 | /*! |
GregCr | 0:e5420f1a8a1a | 151 | * \brief Simple Function which return the device connected. |
GregCr | 0:e5420f1a8a1a | 152 | * |
GregCr | 0:e5420f1a8a1a | 153 | * \retval deviceConnected device type connected |
GregCr | 0:e5420f1a8a1a | 154 | */ |
GregCr | 0:e5420f1a8a1a | 155 | uint8_t GetConnectedDevice( void ); |
GregCr | 0:e5420f1a8a1a | 156 | |
GregCr | 0:e5420f1a8a1a | 157 | /*! |
GregCr | 1:b96176a4ccb8 | 158 | * \brief Simple Function which return the board matching frequency |
GregCr | 1:b96176a4ccb8 | 159 | * |
GregCr | 1:b96176a4ccb8 | 160 | * \retval freq 1: 868 MHz 0: 915 MHz |
GregCr | 1:b96176a4ccb8 | 161 | */ |
GregCr | 1:b96176a4ccb8 | 162 | uint8_t GetMatchingFrequency( void ); |
GregCr | 1:b96176a4ccb8 | 163 | |
GregCr | 0:e5420f1a8a1a | 164 | |
GregCr | 1:b96176a4ccb8 | 165 | |
GregCr | 1:b96176a4ccb8 | 166 | /*! |
GregCr | 0:e5420f1a8a1a | 167 | * \brief Run Demo in sleep mode. |
GregCr | 0:e5420f1a8a1a | 168 | * |
GregCr | 0:e5420f1a8a1a | 169 | * \retval demoStatusUpdate page refresh status ( >0 : refresh) |
GregCr | 0:e5420f1a8a1a | 170 | */ |
GregCr | 0:e5420f1a8a1a | 171 | uint8_t RunDemoSleepMode( void ); |
GregCr | 0:e5420f1a8a1a | 172 | |
GregCr | 0:e5420f1a8a1a | 173 | /*! |
GregCr | 0:e5420f1a8a1a | 174 | * \brief Run Demo in standby RC mode. |
GregCr | 0:e5420f1a8a1a | 175 | * |
GregCr | 0:e5420f1a8a1a | 176 | * \retval demoStatusUpdate page refresh status ( >0 : refresh) |
GregCr | 0:e5420f1a8a1a | 177 | */ |
GregCr | 0:e5420f1a8a1a | 178 | uint8_t RunDemoStandbyRcMode( void ); |
GregCr | 0:e5420f1a8a1a | 179 | |
GregCr | 0:e5420f1a8a1a | 180 | /*! |
GregCr | 0:e5420f1a8a1a | 181 | * \brief Run Demo in standby XOSC mode. |
GregCr | 0:e5420f1a8a1a | 182 | * |
GregCr | 0:e5420f1a8a1a | 183 | * \retval demoStatusUpdate page refresh status ( >0 : refresh) |
GregCr | 0:e5420f1a8a1a | 184 | */ |
GregCr | 0:e5420f1a8a1a | 185 | uint8_t RunDemoStandbyXoscMode( void ); |
GregCr | 0:e5420f1a8a1a | 186 | |
GregCr | 0:e5420f1a8a1a | 187 | /*! |
GregCr | 0:e5420f1a8a1a | 188 | * \brief Run Demo Tx in continuous mode without modulation. |
GregCr | 0:e5420f1a8a1a | 189 | * |
GregCr | 0:e5420f1a8a1a | 190 | * \retval demoStatusUpdate page refresh status ( >0 : refresh) |
GregCr | 0:e5420f1a8a1a | 191 | */ |
wavespectrum | 8:cdb739697925 | 192 | uint8_t PrepDemoTxCw( uint32_t rf_frequency,int8_t power, RadioRampTimes_t rampTime ); |
GregCr | 0:e5420f1a8a1a | 193 | uint8_t RunDemoTxCw( void ); |
wavespectrum | 7:274ca9fe1080 | 194 | uint8_t DemoStandby( void ); |
GregCr | 0:e5420f1a8a1a | 195 | /*! |
GregCr | 0:e5420f1a8a1a | 196 | * \brief Run Demo Tx in continuous modulation. |
GregCr | 0:e5420f1a8a1a | 197 | * |
GregCr | 0:e5420f1a8a1a | 198 | * \retval demoStatusUpdate page refresh status ( >0 : refresh) |
GregCr | 0:e5420f1a8a1a | 199 | */ |
GregCr | 0:e5420f1a8a1a | 200 | uint8_t RunDemoTxContinuousModulation( void ); |
GregCr | 0:e5420f1a8a1a | 201 | |
GregCr | 0:e5420f1a8a1a | 202 | /*! |
GregCr | 0:e5420f1a8a1a | 203 | * \brief Run Demo Rx in continuous mode. |
GregCr | 0:e5420f1a8a1a | 204 | * |
GregCr | 0:e5420f1a8a1a | 205 | * \retval demoStatusUpdate page refresh status ( >0 : refresh) |
GregCr | 0:e5420f1a8a1a | 206 | */ |
GregCr | 0:e5420f1a8a1a | 207 | uint8_t RunDemoRxContinuous( void ); |
GregCr | 0:e5420f1a8a1a | 208 | |
GregCr | 0:e5420f1a8a1a | 209 | /*! |
GregCr | 0:e5420f1a8a1a | 210 | * \brief Run demo PingPong. |
GregCr | 0:e5420f1a8a1a | 211 | * |
GregCr | 0:e5420f1a8a1a | 212 | * \retval demoStatusUpdate page refresh status ( >0 : refresh) |
GregCr | 0:e5420f1a8a1a | 213 | */ |
GregCr | 0:e5420f1a8a1a | 214 | uint8_t RunDemoApplicationPingPong( void ); |
GregCr | 0:e5420f1a8a1a | 215 | |
GregCr | 0:e5420f1a8a1a | 216 | /*! |
GregCr | 0:e5420f1a8a1a | 217 | * \brief Compute payload of Rx frame and update current counts and indicators. |
GregCr | 0:e5420f1a8a1a | 218 | * |
GregCr | 0:e5420f1a8a1a | 219 | * \param [in] buffer buffer with frame to compute |
GregCr | 0:e5420f1a8a1a | 220 | * \param [in] buffersize size of frame data in the buffer |
GregCr | 0:e5420f1a8a1a | 221 | */ |
GregCr | 0:e5420f1a8a1a | 222 | void ComputePingPongPayload( uint8_t *buffer, uint8_t bufferSize ); |
GregCr | 0:e5420f1a8a1a | 223 | |
GregCr | 0:e5420f1a8a1a | 224 | /*! |
GregCr | 0:e5420f1a8a1a | 225 | * \brief Run demo PER. |
GregCr | 0:e5420f1a8a1a | 226 | * |
GregCr | 0:e5420f1a8a1a | 227 | * \retval demoStatusUpdate page refresh status ( >0 : refresh) |
GregCr | 0:e5420f1a8a1a | 228 | */ |
GregCr | 0:e5420f1a8a1a | 229 | uint8_t RunDemoApplicationPer( void ); |
GregCr | 0:e5420f1a8a1a | 230 | |
GregCr | 0:e5420f1a8a1a | 231 | /*! |
GregCr | 0:e5420f1a8a1a | 232 | * \brief Compute payload of Rx frame and update current counts and indicators. |
GregCr | 0:e5420f1a8a1a | 233 | * |
GregCr | 0:e5420f1a8a1a | 234 | * \param [in] buffer buffer with frame to compute |
GregCr | 0:e5420f1a8a1a | 235 | * \param [in] buffersize size of frame data in the buffer |
GregCr | 0:e5420f1a8a1a | 236 | */ |
GregCr | 0:e5420f1a8a1a | 237 | void ComputePerPayload( uint8_t *buffer, uint8_t bufferSize ); |
GregCr | 0:e5420f1a8a1a | 238 | |
GregCr | 0:e5420f1a8a1a | 239 | #endif // DEMO_APPLICATION_H |