ST-DEVKIT-LRWAN
Dependents: DISCO-L072CZ-LRWAN1-base
Fork of SX1276GenericLib by
sx1276/sx1276.h@91:0bf084e4d983, 2017-12-04 (annotated)
- Committer:
- alphaemmeo
- Date:
- Mon Dec 04 14:21:04 2017 +0000
- Revision:
- 91:0bf084e4d983
- Parent:
- 83:019da451b283
base test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GregCr | 0:e6ceb13d2d05 | 1 | /* |
GregCr | 0:e6ceb13d2d05 | 2 | / _____) _ | | |
GregCr | 0:e6ceb13d2d05 | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ |
GregCr | 0:e6ceb13d2d05 | 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ |
GregCr | 0:e6ceb13d2d05 | 5 | _____) ) ____| | | || |_| ____( (___| | | | |
GregCr | 0:e6ceb13d2d05 | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| |
mluis | 22:7f3aab69cca9 | 7 | (C) 2014 Semtech |
GregCr | 0:e6ceb13d2d05 | 8 | |
GregCr | 0:e6ceb13d2d05 | 9 | Description: Actual implementation of a SX1276 radio, inherits Radio |
GregCr | 0:e6ceb13d2d05 | 10 | |
GregCr | 0:e6ceb13d2d05 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project |
GregCr | 0:e6ceb13d2d05 | 12 | |
GregCr | 0:e6ceb13d2d05 | 13 | Maintainers: Miguel Luis, Gregory Cristian and Nicolas Huguenin |
GregCr | 0:e6ceb13d2d05 | 14 | */ |
Helmut Tschemernjak | 34:07e89f23c734 | 15 | |
Helmut Tschemernjak | 34:07e89f23c734 | 16 | /* |
Helmut Tschemernjak | 38:d9189d958db8 | 17 | * additional development to make it more generic across multiple OS versions |
Helmut Tschemernjak | 34:07e89f23c734 | 18 | * (c) 2017 Helmut Tschemernjak |
Helmut Tschemernjak | 34:07e89f23c734 | 19 | * 30826 Garbsen (Hannover) Germany |
Helmut Tschemernjak | 34:07e89f23c734 | 20 | */ |
Helmut Tschemernjak | 34:07e89f23c734 | 21 | |
GregCr | 0:e6ceb13d2d05 | 22 | #ifndef __SX1276_H__ |
GregCr | 0:e6ceb13d2d05 | 23 | #define __SX1276_H__ |
GregCr | 0:e6ceb13d2d05 | 24 | |
GregCr | 0:e6ceb13d2d05 | 25 | #include "radio.h" |
Helmut Tschemernjak | 65:b2d98328fcba | 26 | #include "sx1276Regs-Fsk.h" |
Helmut Tschemernjak | 65:b2d98328fcba | 27 | #include "sx1276Regs-LoRa.h" |
Helmut Tschemernjak | 38:d9189d958db8 | 28 | |
Helmut Tschemernjak | 38:d9189d958db8 | 29 | |
GregCr | 0:e6ceb13d2d05 | 30 | |
mluis | 16:d447f8d2d2d6 | 31 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 32 | * Radio wake-up time from sleep |
Helmut Tschemernjak | 31:e50929bd3f32 | 33 | */ |
Helmut Tschemernjak | 32:f6f0bff38543 | 34 | #define RADIO_WAKEUP_TIME 1 // [ms] |
Helmut Tschemernjak | 31:e50929bd3f32 | 35 | |
Helmut Tschemernjak | 31:e50929bd3f32 | 36 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 37 | * Sync word for Private LoRa networks |
mluis | 16:d447f8d2d2d6 | 38 | */ |
Helmut Tschemernjak | 31:e50929bd3f32 | 39 | #define LORA_MAC_PRIVATE_SYNCWORD 0x12 |
Helmut Tschemernjak | 31:e50929bd3f32 | 40 | |
Helmut Tschemernjak | 31:e50929bd3f32 | 41 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 42 | * Sync word for Public LoRa networks |
Helmut Tschemernjak | 31:e50929bd3f32 | 43 | */ |
Helmut Tschemernjak | 31:e50929bd3f32 | 44 | #define LORA_MAC_PUBLIC_SYNCWORD 0x34 |
Helmut Tschemernjak | 31:e50929bd3f32 | 45 | |
mluis | 25:3778e6204cc1 | 46 | |
mluis | 25:3778e6204cc1 | 47 | /*! |
mluis | 16:d447f8d2d2d6 | 48 | * SX1276 definitions |
mluis | 16:d447f8d2d2d6 | 49 | */ |
GregCr | 0:e6ceb13d2d05 | 50 | #define XTAL_FREQ 32000000 |
GregCr | 0:e6ceb13d2d05 | 51 | #define FREQ_STEP 61.03515625 |
GregCr | 0:e6ceb13d2d05 | 52 | |
GregCr | 0:e6ceb13d2d05 | 53 | #define RX_BUFFER_SIZE 256 |
GregCr | 0:e6ceb13d2d05 | 54 | |
GregCr | 0:e6ceb13d2d05 | 55 | /*! |
GregCr | 0:e6ceb13d2d05 | 56 | * Constant values need to compute the RSSI value |
GregCr | 0:e6ceb13d2d05 | 57 | */ |
GregCr | 0:e6ceb13d2d05 | 58 | #define RSSI_OFFSET_LF -164.0 |
GregCr | 0:e6ceb13d2d05 | 59 | #define RSSI_OFFSET_HF -157.0 |
GregCr | 0:e6ceb13d2d05 | 60 | |
GregCr | 0:e6ceb13d2d05 | 61 | #define RF_MID_BAND_THRESH 525000000 |
GregCr | 0:e6ceb13d2d05 | 62 | |
Helmut Tschemernjak | 34:07e89f23c734 | 63 | |
Helmut64 | 26:87796ee62589 | 64 | |
Helmut Tschemernjak | 39:706c32eda7e7 | 65 | |
Helmut Tschemernjak | 38:d9189d958db8 | 66 | /*! |
Helmut Tschemernjak | 39:706c32eda7e7 | 67 | * Type of the supported board. [SX1276MB1MAS / SX1276MB1LAS] |
Helmut Tschemernjak | 38:d9189d958db8 | 68 | */ |
Helmut Tschemernjak | 39:706c32eda7e7 | 69 | typedef enum BoardType |
Helmut Tschemernjak | 39:706c32eda7e7 | 70 | { |
Helmut Tschemernjak | 39:706c32eda7e7 | 71 | SX1276MB1MAS = 0, |
Helmut Tschemernjak | 39:706c32eda7e7 | 72 | SX1276MB1LAS, |
Helmut Tschemernjak | 39:706c32eda7e7 | 73 | RFM95_SX1276, |
Helmut Tschemernjak | 39:706c32eda7e7 | 74 | MURATA_SX1276, |
Helmut Tschemernjak | 39:706c32eda7e7 | 75 | UNKNOWN |
Helmut Tschemernjak | 39:706c32eda7e7 | 76 | }BoardType_t; |
Helmut Tschemernjak | 39:706c32eda7e7 | 77 | |
Helmut Tschemernjak | 38:d9189d958db8 | 78 | |
Helmut Tschemernjak | 33:5db0d1e716b1 | 79 | typedef enum { |
Helmut Tschemernjak | 33:5db0d1e716b1 | 80 | LORA_SF6 = 6, // 64 chips/symbol, SF6 requires an TCXO! |
Helmut Tschemernjak | 33:5db0d1e716b1 | 81 | LORA_SF7 = 7, // 128 chips/symbol |
Helmut Tschemernjak | 33:5db0d1e716b1 | 82 | LORA_SF8 = 8, // 256 chips/symbol |
Helmut Tschemernjak | 33:5db0d1e716b1 | 83 | LORA_SF9 = 9, // 512 chips/symbol |
Helmut Tschemernjak | 33:5db0d1e716b1 | 84 | LORA_SF10 = 10, // 1024 chips/symbol |
Helmut Tschemernjak | 33:5db0d1e716b1 | 85 | LORA_SF11 = 11, // 2048 chips/symbol |
Helmut Tschemernjak | 33:5db0d1e716b1 | 86 | LORA_SF12 = 12, // 4096 chips/symbol |
Helmut Tschemernjak | 33:5db0d1e716b1 | 87 | } lora_spreading_factor_t; |
Helmut Tschemernjak | 33:5db0d1e716b1 | 88 | |
Helmut Tschemernjak | 33:5db0d1e716b1 | 89 | |
Helmut Tschemernjak | 33:5db0d1e716b1 | 90 | typedef enum { // cyclic error coding to perform forward error detection and correction |
Helmut Tschemernjak | 33:5db0d1e716b1 | 91 | LORA_ERROR_CODING_RATE_4_5 = 1, // 1.25x overhead |
Helmut Tschemernjak | 33:5db0d1e716b1 | 92 | LORA_ERROR_CODING_RATE_4_6 = 2, // 1.50x overhead |
Helmut Tschemernjak | 33:5db0d1e716b1 | 93 | LORA_ERROR_CODING_RATE_4_7 = 3, // 1.75x overhead |
Helmut Tschemernjak | 33:5db0d1e716b1 | 94 | LORA_ERROR_CODING_RATE_4_8 = 4, // 2.00x overhead |
Helmut Tschemernjak | 33:5db0d1e716b1 | 95 | } lora_coding_rate_t; |
Helmut Tschemernjak | 33:5db0d1e716b1 | 96 | |
Helmut Tschemernjak | 33:5db0d1e716b1 | 97 | |
Helmut Tschemernjak | 33:5db0d1e716b1 | 98 | typedef enum { |
Helmut Tschemernjak | 33:5db0d1e716b1 | 99 | RF_FREQUENCY_868_0 = 868000000, // Hz |
Helmut Tschemernjak | 33:5db0d1e716b1 | 100 | RF_FREQUENCY_868_1 = 868100000, // Hz |
Helmut Tschemernjak | 33:5db0d1e716b1 | 101 | RF_FREQUENCY_868_3 = 868300000, // Hz |
Helmut Tschemernjak | 33:5db0d1e716b1 | 102 | RF_FREQUENCY_868_5 = 868500000, // Hz |
Helmut Tschemernjak | 33:5db0d1e716b1 | 103 | } rf_frequency_t; |
Helmut Tschemernjak | 33:5db0d1e716b1 | 104 | |
Helmut Tschemernjak | 33:5db0d1e716b1 | 105 | |
Helmut Tschemernjak | 33:5db0d1e716b1 | 106 | |
Helmut Tschemernjak | 33:5db0d1e716b1 | 107 | /*! |
GregCr | 0:e6ceb13d2d05 | 108 | * Actual implementation of a SX1276 radio, inherits Radio |
GregCr | 0:e6ceb13d2d05 | 109 | */ |
GregCr | 0:e6ceb13d2d05 | 110 | class SX1276 : public Radio |
GregCr | 0:e6ceb13d2d05 | 111 | { |
GregCr | 0:e6ceb13d2d05 | 112 | protected: |
mluis | 25:3778e6204cc1 | 113 | |
mluis | 13:618826a997e2 | 114 | bool isRadioActive; |
mluis | 25:3778e6204cc1 | 115 | |
Helmut Tschemernjak | 34:07e89f23c734 | 116 | BoardType_t boardConnected; //1 = SX1276MB1LAS; 0 = SX1276MB1MAS |
mluis | 25:3778e6204cc1 | 117 | |
GregCr | 23:1e143575df0f | 118 | uint8_t *rxtxBuffer; |
mluis | 13:618826a997e2 | 119 | |
mluis | 13:618826a997e2 | 120 | /*! |
Helmut Tschemernjak | 39:706c32eda7e7 | 121 | * Hardware IO IRQ callback function definition |
Helmut Tschemernjak | 39:706c32eda7e7 | 122 | */ |
Helmut Tschemernjak | 39:706c32eda7e7 | 123 | typedef void ( SX1276::*DioIrqHandler )( void ); |
Helmut Tschemernjak | 39:706c32eda7e7 | 124 | |
Helmut Tschemernjak | 39:706c32eda7e7 | 125 | /*! |
mluis | 13:618826a997e2 | 126 | * Hardware DIO IRQ functions |
mluis | 13:618826a997e2 | 127 | */ |
mluis | 13:618826a997e2 | 128 | DioIrqHandler *dioIrq; |
mluis | 25:3778e6204cc1 | 129 | |
Helmut Tschemernjak | 39:706c32eda7e7 | 130 | |
mluis | 25:3778e6204cc1 | 131 | |
mluis | 13:618826a997e2 | 132 | RadioSettings_t settings; |
mluis | 25:3778e6204cc1 | 133 | |
Helmut Tschemernjak | 55:00c1f5b83920 | 134 | /*! |
Helmut Tschemernjak | 55:00c1f5b83920 | 135 | * FSK bandwidth definition |
Helmut Tschemernjak | 55:00c1f5b83920 | 136 | */ |
Helmut Tschemernjak | 55:00c1f5b83920 | 137 | struct BandwidthMap { |
Helmut Tschemernjak | 55:00c1f5b83920 | 138 | uint32_t bandwidth; |
Helmut Tschemernjak | 55:00c1f5b83920 | 139 | uint8_t RegValue; |
Helmut Tschemernjak | 55:00c1f5b83920 | 140 | }; |
Helmut Tschemernjak | 55:00c1f5b83920 | 141 | static const struct BandwidthMap FskBandwidths[]; |
Helmut Tschemernjak | 55:00c1f5b83920 | 142 | static const struct BandwidthMap LoRaBandwidths[]; |
Helmut Tschemernjak | 38:d9189d958db8 | 143 | |
GregCr | 0:e6ceb13d2d05 | 144 | protected: |
GregCr | 0:e6ceb13d2d05 | 145 | |
mluis | 13:618826a997e2 | 146 | /*! |
mluis | 13:618826a997e2 | 147 | * Performs the Rx chain calibration for LF and HF bands |
mluis | 13:618826a997e2 | 148 | * \remark Must be called just after the reset so all registers are at their |
mluis | 13:618826a997e2 | 149 | * default values |
mluis | 13:618826a997e2 | 150 | */ |
mluis | 13:618826a997e2 | 151 | void RxChainCalibration( void ); |
GregCr | 0:e6ceb13d2d05 | 152 | |
GregCr | 0:e6ceb13d2d05 | 153 | public: |
Helmut Tschemernjak | 34:07e89f23c734 | 154 | SX1276( RadioEvents_t *events); |
mluis | 13:618826a997e2 | 155 | virtual ~SX1276( ); |
mluis | 13:618826a997e2 | 156 | |
Helmut Tschemernjak | 55:00c1f5b83920 | 157 | |
Helmut Tschemernjak | 55:00c1f5b83920 | 158 | |
Helmut Tschemernjak | 55:00c1f5b83920 | 159 | |
mluis | 13:618826a997e2 | 160 | //------------------------------------------------------------------------- |
mluis | 13:618826a997e2 | 161 | // Redefined Radio functions |
mluis | 13:618826a997e2 | 162 | //------------------------------------------------------------------------- |
mluis | 13:618826a997e2 | 163 | /*! |
Helmut Tschemernjak | 54:0d8ea87fbab9 | 164 | * @brief Return current radio status, returns true if a radios has been found. |
mluis | 21:2e496deb7858 | 165 | * |
mluis | 21:2e496deb7858 | 166 | * @param [IN] events Structure containing the driver callback functions |
mluis | 21:2e496deb7858 | 167 | */ |
Helmut Tschemernjak | 54:0d8ea87fbab9 | 168 | virtual bool Init( RadioEvents_t *events ); |
Helmut Tschemernjak | 38:d9189d958db8 | 169 | |
Helmut Tschemernjak | 38:d9189d958db8 | 170 | /*! |
Helmut Tschemernjak | 38:d9189d958db8 | 171 | * @brief Initializes the radio registers |
Helmut Tschemernjak | 38:d9189d958db8 | 172 | */ |
Helmut Tschemernjak | 38:d9189d958db8 | 173 | virtual void RadioRegistersInit(void); |
Helmut Tschemernjak | 38:d9189d958db8 | 174 | |
mluis | 21:2e496deb7858 | 175 | /*! |
GregCr | 0:e6ceb13d2d05 | 176 | * Return current radio status |
GregCr | 0:e6ceb13d2d05 | 177 | * |
Helmut Tschemernjak | 50:43f7160e869c | 178 | * @param status Radio status. [RF_IDLE, RX_RUNNING, TX_RUNNING, CAD_RUNNING] |
GregCr | 0:e6ceb13d2d05 | 179 | */ |
GregCr | 19:71a47bb03fbb | 180 | virtual RadioState GetStatus( void ); |
mluis | 25:3778e6204cc1 | 181 | |
mluis | 13:618826a997e2 | 182 | /*! |
mluis | 13:618826a997e2 | 183 | * @brief Configures the SX1276 with the given modem |
mluis | 13:618826a997e2 | 184 | * |
mluis | 13:618826a997e2 | 185 | * @param [IN] modem Modem to be used [0: FSK, 1: LoRa] |
mluis | 13:618826a997e2 | 186 | */ |
mluis | 22:7f3aab69cca9 | 187 | virtual void SetModem( RadioModems_t modem ); |
mluis | 13:618826a997e2 | 188 | |
mluis | 13:618826a997e2 | 189 | /*! |
GregCr | 0:e6ceb13d2d05 | 190 | * @brief Sets the channel frequency |
GregCr | 0:e6ceb13d2d05 | 191 | * |
GregCr | 0:e6ceb13d2d05 | 192 | * @param [IN] freq Channel RF frequency |
GregCr | 0:e6ceb13d2d05 | 193 | */ |
GregCr | 0:e6ceb13d2d05 | 194 | virtual void SetChannel( uint32_t freq ); |
mluis | 25:3778e6204cc1 | 195 | |
mluis | 13:618826a997e2 | 196 | /*! |
GregCr | 0:e6ceb13d2d05 | 197 | * @brief Sets the channels configuration |
GregCr | 0:e6ceb13d2d05 | 198 | * |
GregCr | 0:e6ceb13d2d05 | 199 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
GregCr | 0:e6ceb13d2d05 | 200 | * @param [IN] freq Channel RF frequency |
GregCr | 0:e6ceb13d2d05 | 201 | * @param [IN] rssiThresh RSSI threshold |
GregCr | 0:e6ceb13d2d05 | 202 | * |
GregCr | 0:e6ceb13d2d05 | 203 | * @retval isFree [true: Channel is free, false: Channel is not free] |
GregCr | 0:e6ceb13d2d05 | 204 | */ |
mluis | 22:7f3aab69cca9 | 205 | virtual bool IsChannelFree( RadioModems_t modem, uint32_t freq, int16_t rssiThresh ); |
mluis | 25:3778e6204cc1 | 206 | |
mluis | 13:618826a997e2 | 207 | /*! |
GregCr | 0:e6ceb13d2d05 | 208 | * @brief Generates a 32 bits random value based on the RSSI readings |
GregCr | 0:e6ceb13d2d05 | 209 | * |
GregCr | 0:e6ceb13d2d05 | 210 | * \remark This function sets the radio in LoRa modem mode and disables |
GregCr | 0:e6ceb13d2d05 | 211 | * all interrupts. |
GregCr | 0:e6ceb13d2d05 | 212 | * After calling this function either Radio.SetRxConfig or |
GregCr | 0:e6ceb13d2d05 | 213 | * Radio.SetTxConfig functions must be called. |
GregCr | 0:e6ceb13d2d05 | 214 | * |
GregCr | 0:e6ceb13d2d05 | 215 | * @retval randomValue 32 bits random value |
GregCr | 0:e6ceb13d2d05 | 216 | */ |
GregCr | 0:e6ceb13d2d05 | 217 | virtual uint32_t Random( void ); |
mluis | 25:3778e6204cc1 | 218 | |
mluis | 13:618826a997e2 | 219 | /*! |
GregCr | 0:e6ceb13d2d05 | 220 | * @brief Sets the reception parameters |
GregCr | 0:e6ceb13d2d05 | 221 | * |
GregCr | 0:e6ceb13d2d05 | 222 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
GregCr | 0:e6ceb13d2d05 | 223 | * @param [IN] bandwidth Sets the bandwidth |
GregCr | 0:e6ceb13d2d05 | 224 | * FSK : >= 2600 and <= 250000 Hz |
GregCr | 0:e6ceb13d2d05 | 225 | * LoRa: [0: 125 kHz, 1: 250 kHz, |
GregCr | 0:e6ceb13d2d05 | 226 | * 2: 500 kHz, 3: Reserved] |
GregCr | 0:e6ceb13d2d05 | 227 | * @param [IN] datarate Sets the Datarate |
GregCr | 0:e6ceb13d2d05 | 228 | * FSK : 600..300000 bits/s |
GregCr | 0:e6ceb13d2d05 | 229 | * LoRa: [6: 64, 7: 128, 8: 256, 9: 512, |
GregCr | 0:e6ceb13d2d05 | 230 | * 10: 1024, 11: 2048, 12: 4096 chips] |
GregCr | 0:e6ceb13d2d05 | 231 | * @param [IN] coderate Sets the coding rate ( LoRa only ) |
GregCr | 0:e6ceb13d2d05 | 232 | * FSK : N/A ( set to 0 ) |
GregCr | 0:e6ceb13d2d05 | 233 | * LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] |
GregCr | 0:e6ceb13d2d05 | 234 | * @param [IN] bandwidthAfc Sets the AFC Bandwidth ( FSK only ) |
GregCr | 0:e6ceb13d2d05 | 235 | * FSK : >= 2600 and <= 250000 Hz |
GregCr | 0:e6ceb13d2d05 | 236 | * LoRa: N/A ( set to 0 ) |
GregCr | 0:e6ceb13d2d05 | 237 | * @param [IN] preambleLen Sets the Preamble length ( LoRa only ) |
GregCr | 0:e6ceb13d2d05 | 238 | * FSK : N/A ( set to 0 ) |
GregCr | 0:e6ceb13d2d05 | 239 | * LoRa: Length in symbols ( the hardware adds 4 more symbols ) |
Helmut Tschemernjak | 31:e50929bd3f32 | 240 | * @param [IN] symbTimeout Sets the RxSingle timeout value |
Helmut Tschemernjak | 31:e50929bd3f32 | 241 | * FSK : timeout number of bytes |
GregCr | 0:e6ceb13d2d05 | 242 | * LoRa: timeout in symbols |
GregCr | 0:e6ceb13d2d05 | 243 | * @param [IN] fixLen Fixed length packets [0: variable, 1: fixed] |
mluis | 13:618826a997e2 | 244 | * @param [IN] payloadLen Sets payload length when fixed lenght is used |
GregCr | 0:e6ceb13d2d05 | 245 | * @param [IN] crcOn Enables/Disables the CRC [0: OFF, 1: ON] |
mluis | 13:618826a997e2 | 246 | * @param [IN] freqHopOn Enables disables the intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only) |
mluis | 13:618826a997e2 | 247 | * @param [IN] hopPeriod Number of symbols bewteen each hop (LoRa only) |
GregCr | 0:e6ceb13d2d05 | 248 | * @param [IN] iqInverted Inverts IQ signals ( LoRa only ) |
GregCr | 0:e6ceb13d2d05 | 249 | * FSK : N/A ( set to 0 ) |
GregCr | 0:e6ceb13d2d05 | 250 | * LoRa: [0: not inverted, 1: inverted] |
GregCr | 0:e6ceb13d2d05 | 251 | * @param [IN] rxContinuous Sets the reception in continuous mode |
GregCr | 0:e6ceb13d2d05 | 252 | * [false: single mode, true: continuous mode] |
GregCr | 0:e6ceb13d2d05 | 253 | */ |
mluis | 22:7f3aab69cca9 | 254 | virtual void SetRxConfig ( RadioModems_t modem, uint32_t bandwidth, |
GregCr | 0:e6ceb13d2d05 | 255 | uint32_t datarate, uint8_t coderate, |
GregCr | 0:e6ceb13d2d05 | 256 | uint32_t bandwidthAfc, uint16_t preambleLen, |
GregCr | 0:e6ceb13d2d05 | 257 | uint16_t symbTimeout, bool fixLen, |
mluis | 13:618826a997e2 | 258 | uint8_t payloadLen, |
mluis | 13:618826a997e2 | 259 | bool crcOn, bool freqHopOn, uint8_t hopPeriod, |
GregCr | 6:e7f02929cd3d | 260 | bool iqInverted, bool rxContinuous ); |
mluis | 25:3778e6204cc1 | 261 | |
mluis | 13:618826a997e2 | 262 | /*! |
GregCr | 0:e6ceb13d2d05 | 263 | * @brief Sets the transmission parameters |
GregCr | 0:e6ceb13d2d05 | 264 | * |
GregCr | 0:e6ceb13d2d05 | 265 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
GregCr | 0:e6ceb13d2d05 | 266 | * @param [IN] power Sets the output power [dBm] |
GregCr | 0:e6ceb13d2d05 | 267 | * @param [IN] fdev Sets the frequency deviation ( FSK only ) |
GregCr | 0:e6ceb13d2d05 | 268 | * FSK : [Hz] |
GregCr | 0:e6ceb13d2d05 | 269 | * LoRa: 0 |
GregCr | 0:e6ceb13d2d05 | 270 | * @param [IN] bandwidth Sets the bandwidth ( LoRa only ) |
GregCr | 0:e6ceb13d2d05 | 271 | * FSK : 0 |
GregCr | 0:e6ceb13d2d05 | 272 | * LoRa: [0: 125 kHz, 1: 250 kHz, |
GregCr | 0:e6ceb13d2d05 | 273 | * 2: 500 kHz, 3: Reserved] |
GregCr | 0:e6ceb13d2d05 | 274 | * @param [IN] datarate Sets the Datarate |
GregCr | 0:e6ceb13d2d05 | 275 | * FSK : 600..300000 bits/s |
GregCr | 0:e6ceb13d2d05 | 276 | * LoRa: [6: 64, 7: 128, 8: 256, 9: 512, |
GregCr | 0:e6ceb13d2d05 | 277 | * 10: 1024, 11: 2048, 12: 4096 chips] |
GregCr | 0:e6ceb13d2d05 | 278 | * @param [IN] coderate Sets the coding rate ( LoRa only ) |
GregCr | 0:e6ceb13d2d05 | 279 | * FSK : N/A ( set to 0 ) |
GregCr | 0:e6ceb13d2d05 | 280 | * LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] |
GregCr | 0:e6ceb13d2d05 | 281 | * @param [IN] preambleLen Sets the preamble length |
GregCr | 0:e6ceb13d2d05 | 282 | * @param [IN] fixLen Fixed length packets [0: variable, 1: fixed] |
GregCr | 0:e6ceb13d2d05 | 283 | * @param [IN] crcOn Enables disables the CRC [0: OFF, 1: ON] |
mluis | 13:618826a997e2 | 284 | * @param [IN] freqHopOn Enables disables the intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only) |
mluis | 13:618826a997e2 | 285 | * @param [IN] hopPeriod Number of symbols bewteen each hop (LoRa only) |
GregCr | 0:e6ceb13d2d05 | 286 | * @param [IN] iqInverted Inverts IQ signals ( LoRa only ) |
GregCr | 0:e6ceb13d2d05 | 287 | * FSK : N/A ( set to 0 ) |
GregCr | 0:e6ceb13d2d05 | 288 | * LoRa: [0: not inverted, 1: inverted] |
Helmut Tschemernjak | 31:e50929bd3f32 | 289 | * @param [IN] timeout Transmission timeout [ms] |
GregCr | 0:e6ceb13d2d05 | 290 | */ |
mluis | 22:7f3aab69cca9 | 291 | virtual void SetTxConfig( RadioModems_t modem, int8_t power, uint32_t fdev, |
GregCr | 0:e6ceb13d2d05 | 292 | uint32_t bandwidth, uint32_t datarate, |
GregCr | 0:e6ceb13d2d05 | 293 | uint8_t coderate, uint16_t preambleLen, |
mluis | 13:618826a997e2 | 294 | bool fixLen, bool crcOn, bool freqHopOn, |
mluis | 13:618826a997e2 | 295 | uint8_t hopPeriod, bool iqInverted, uint32_t timeout ); |
mluis | 25:3778e6204cc1 | 296 | |
Helmut Tschemernjak | 38:d9189d958db8 | 297 | |
mluis | 13:618826a997e2 | 298 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 299 | * @brief Checks if the given RF frequency is supported by the hardware |
Helmut Tschemernjak | 31:e50929bd3f32 | 300 | * |
Helmut Tschemernjak | 31:e50929bd3f32 | 301 | * @param [IN] frequency RF frequency to be checked |
Helmut Tschemernjak | 31:e50929bd3f32 | 302 | * @retval isSupported [true: supported, false: unsupported] |
Helmut Tschemernjak | 31:e50929bd3f32 | 303 | */ |
Helmut Tschemernjak | 31:e50929bd3f32 | 304 | virtual bool CheckRfFrequency( uint32_t frequency ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 305 | |
Helmut Tschemernjak | 31:e50929bd3f32 | 306 | /*! |
GregCr | 0:e6ceb13d2d05 | 307 | * @brief Computes the packet time on air for the given payload |
GregCr | 0:e6ceb13d2d05 | 308 | * |
GregCr | 0:e6ceb13d2d05 | 309 | * \Remark Can only be called once SetRxConfig or SetTxConfig have been called |
GregCr | 0:e6ceb13d2d05 | 310 | * |
GregCr | 0:e6ceb13d2d05 | 311 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
GregCr | 0:e6ceb13d2d05 | 312 | * @param [IN] pktLen Packet payload length |
GregCr | 0:e6ceb13d2d05 | 313 | * |
GregCr | 0:e6ceb13d2d05 | 314 | * @retval airTime Computed airTime for the given packet payload length |
GregCr | 0:e6ceb13d2d05 | 315 | */ |
Helmut Tschemernjak | 59:38e56c85fa44 | 316 | virtual uint32_t TimeOnAir ( RadioModems_t modem, int16_t pktLen ); |
mluis | 25:3778e6204cc1 | 317 | |
mluis | 13:618826a997e2 | 318 | /*! |
GregCr | 0:e6ceb13d2d05 | 319 | * @brief Sends the buffer of size. Prepares the packet to be sent and sets |
GregCr | 0:e6ceb13d2d05 | 320 | * the radio in transmission |
GregCr | 0:e6ceb13d2d05 | 321 | * |
GregCr | 0:e6ceb13d2d05 | 322 | * @param [IN]: buffer Buffer pointer |
GregCr | 0:e6ceb13d2d05 | 323 | * @param [IN]: size Buffer size |
Helmut Tschemernjak | 50:43f7160e869c | 324 | * @param [IN]: buffer Header pointer |
Helmut Tschemernjak | 50:43f7160e869c | 325 | * @param [IN]: size Header size |
GregCr | 0:e6ceb13d2d05 | 326 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 327 | virtual void Send(void *buffer, int16_t size, void *header = NULL, int16_t hsize = 0); |
mluis | 25:3778e6204cc1 | 328 | |
mluis | 13:618826a997e2 | 329 | /*! |
GregCr | 0:e6ceb13d2d05 | 330 | * @brief Sets the radio in sleep mode |
GregCr | 0:e6ceb13d2d05 | 331 | */ |
GregCr | 0:e6ceb13d2d05 | 332 | virtual void Sleep( void ); |
GregCr | 0:e6ceb13d2d05 | 333 | |
mluis | 13:618826a997e2 | 334 | /*! |
GregCr | 0:e6ceb13d2d05 | 335 | * @brief Sets the radio in standby mode |
GregCr | 0:e6ceb13d2d05 | 336 | */ |
GregCr | 0:e6ceb13d2d05 | 337 | virtual void Standby( void ); |
Helmut Tschemernjak | 31:e50929bd3f32 | 338 | |
Helmut Tschemernjak | 31:e50929bd3f32 | 339 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 340 | * @brief Sets the radio in CAD mode |
Helmut Tschemernjak | 31:e50929bd3f32 | 341 | */ |
Helmut Tschemernjak | 31:e50929bd3f32 | 342 | virtual void StartCad( void ); |
mluis | 25:3778e6204cc1 | 343 | |
mluis | 13:618826a997e2 | 344 | /*! |
GregCr | 0:e6ceb13d2d05 | 345 | * @brief Sets the radio in reception mode for the given time |
Helmut Tschemernjak | 31:e50929bd3f32 | 346 | * @param [IN] timeout Reception timeout [ms] |
GregCr | 0:e6ceb13d2d05 | 347 | * [0: continuous, others timeout] |
GregCr | 0:e6ceb13d2d05 | 348 | */ |
GregCr | 0:e6ceb13d2d05 | 349 | virtual void Rx( uint32_t timeout ); |
Helmut Tschemernjak | 54:0d8ea87fbab9 | 350 | |
Helmut Tschemernjak | 54:0d8ea87fbab9 | 351 | /*! |
Helmut Tschemernjak | 54:0d8ea87fbab9 | 352 | * @brief Check is radio receives a signal |
Helmut Tschemernjak | 54:0d8ea87fbab9 | 353 | */ |
Helmut Tschemernjak | 54:0d8ea87fbab9 | 354 | virtual bool RxSignalPending(); |
Helmut Tschemernjak | 54:0d8ea87fbab9 | 355 | |
mluis | 25:3778e6204cc1 | 356 | |
mluis | 13:618826a997e2 | 357 | /*! |
GregCr | 0:e6ceb13d2d05 | 358 | * @brief Sets the radio in transmission mode for the given time |
Helmut Tschemernjak | 31:e50929bd3f32 | 359 | * @param [IN] timeout Transmission timeout [ms] |
GregCr | 0:e6ceb13d2d05 | 360 | * [0: continuous, others timeout] |
GregCr | 0:e6ceb13d2d05 | 361 | */ |
GregCr | 0:e6ceb13d2d05 | 362 | virtual void Tx( uint32_t timeout ); |
mluis | 25:3778e6204cc1 | 363 | |
mluis | 13:618826a997e2 | 364 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 365 | * @brief Sets the radio in continuous wave transmission mode |
Helmut Tschemernjak | 31:e50929bd3f32 | 366 | * |
Helmut Tschemernjak | 31:e50929bd3f32 | 367 | * @param [IN]: freq Channel RF frequency |
Helmut Tschemernjak | 31:e50929bd3f32 | 368 | * @param [IN]: power Sets the output power [dBm] |
Helmut Tschemernjak | 31:e50929bd3f32 | 369 | * @param [IN]: time Transmission mode timeout [s] |
GregCr | 7:2b555111463f | 370 | */ |
Helmut Tschemernjak | 31:e50929bd3f32 | 371 | |
Helmut Tschemernjak | 31:e50929bd3f32 | 372 | virtual void SetTxContinuousWave( uint32_t freq, int8_t power, uint16_t time ); |
mluis | 25:3778e6204cc1 | 373 | |
mluis | 13:618826a997e2 | 374 | /*! |
Helmut Tschemernjak | 50:43f7160e869c | 375 | * @brief Returns the maximal transfer unit for a given modem |
Helmut Tschemernjak | 50:43f7160e869c | 376 | * |
Helmut Tschemernjak | 50:43f7160e869c | 377 | * @retval MTU size in bytes |
Helmut Tschemernjak | 50:43f7160e869c | 378 | */ |
Helmut Tschemernjak | 50:43f7160e869c | 379 | virtual int16_t MaxMTUSize( RadioModems_t modem ); |
Helmut Tschemernjak | 50:43f7160e869c | 380 | |
Helmut Tschemernjak | 50:43f7160e869c | 381 | /*! |
GregCr | 0:e6ceb13d2d05 | 382 | * @brief Reads the current RSSI value |
GregCr | 0:e6ceb13d2d05 | 383 | * |
GregCr | 0:e6ceb13d2d05 | 384 | * @retval rssiValue Current RSSI value in [dBm] |
GregCr | 0:e6ceb13d2d05 | 385 | */ |
mluis | 22:7f3aab69cca9 | 386 | virtual int16_t GetRssi ( RadioModems_t modem ); |
Helmut Tschemernjak | 83:019da451b283 | 387 | |
Helmut Tschemernjak | 83:019da451b283 | 388 | /*! |
Helmut Tschemernjak | 83:019da451b283 | 389 | * @brief Reads the current frequency error |
Helmut Tschemernjak | 83:019da451b283 | 390 | * |
Helmut Tschemernjak | 83:019da451b283 | 391 | * @retval frequency error value in [Hz] |
Helmut Tschemernjak | 83:019da451b283 | 392 | */ |
Helmut Tschemernjak | 83:019da451b283 | 393 | virtual int32_t GetFrequencyError( RadioModems_t modem ); |
Helmut Tschemernjak | 83:019da451b283 | 394 | |
mluis | 13:618826a997e2 | 395 | /*! |
GregCr | 0:e6ceb13d2d05 | 396 | * @brief Writes the radio register at the specified address |
GregCr | 0:e6ceb13d2d05 | 397 | * |
GregCr | 0:e6ceb13d2d05 | 398 | * @param [IN]: addr Register address |
GregCr | 0:e6ceb13d2d05 | 399 | * @param [IN]: data New register value |
GregCr | 0:e6ceb13d2d05 | 400 | */ |
GregCr | 0:e6ceb13d2d05 | 401 | virtual void Write ( uint8_t addr, uint8_t data ) = 0; |
mluis | 25:3778e6204cc1 | 402 | |
mluis | 13:618826a997e2 | 403 | /*! |
GregCr | 0:e6ceb13d2d05 | 404 | * @brief Reads the radio register at the specified address |
GregCr | 0:e6ceb13d2d05 | 405 | * |
GregCr | 0:e6ceb13d2d05 | 406 | * @param [IN]: addr Register address |
GregCr | 0:e6ceb13d2d05 | 407 | * @retval data Register value |
GregCr | 0:e6ceb13d2d05 | 408 | */ |
GregCr | 0:e6ceb13d2d05 | 409 | virtual uint8_t Read ( uint8_t addr ) = 0; |
mluis | 25:3778e6204cc1 | 410 | |
mluis | 13:618826a997e2 | 411 | /*! |
GregCr | 0:e6ceb13d2d05 | 412 | * @brief Writes multiple radio registers starting at address |
GregCr | 0:e6ceb13d2d05 | 413 | * |
GregCr | 0:e6ceb13d2d05 | 414 | * @param [IN] addr First Radio register address |
GregCr | 0:e6ceb13d2d05 | 415 | * @param [IN] buffer Buffer containing the new register's values |
GregCr | 0:e6ceb13d2d05 | 416 | * @param [IN] size Number of registers to be written |
GregCr | 0:e6ceb13d2d05 | 417 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 418 | virtual void Write( uint8_t addr, void *buffer, uint8_t size ) = 0; |
mluis | 25:3778e6204cc1 | 419 | |
mluis | 13:618826a997e2 | 420 | /*! |
GregCr | 0:e6ceb13d2d05 | 421 | * @brief Reads multiple radio registers starting at address |
GregCr | 0:e6ceb13d2d05 | 422 | * |
GregCr | 0:e6ceb13d2d05 | 423 | * @param [IN] addr First Radio register address |
GregCr | 0:e6ceb13d2d05 | 424 | * @param [OUT] buffer Buffer where to copy the registers data |
GregCr | 0:e6ceb13d2d05 | 425 | * @param [IN] size Number of registers to be read |
GregCr | 0:e6ceb13d2d05 | 426 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 427 | virtual void Read ( uint8_t addr, void *buffer, uint8_t size ) = 0; |
mluis | 25:3778e6204cc1 | 428 | |
mluis | 13:618826a997e2 | 429 | /*! |
mluis | 13:618826a997e2 | 430 | * @brief Writes the buffer contents to the SX1276 FIFO |
mluis | 13:618826a997e2 | 431 | * |
mluis | 13:618826a997e2 | 432 | * @param [IN] buffer Buffer containing data to be put on the FIFO. |
mluis | 13:618826a997e2 | 433 | * @param [IN] size Number of bytes to be written to the FIFO |
mluis | 13:618826a997e2 | 434 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 435 | virtual void WriteFifo( void *buffer, uint8_t size ) = 0; |
GregCr | 0:e6ceb13d2d05 | 436 | |
mluis | 13:618826a997e2 | 437 | /*! |
mluis | 13:618826a997e2 | 438 | * @brief Reads the contents of the SX1276 FIFO |
mluis | 13:618826a997e2 | 439 | * |
mluis | 13:618826a997e2 | 440 | * @param [OUT] buffer Buffer where to copy the FIFO read data. |
mluis | 13:618826a997e2 | 441 | * @param [IN] size Number of bytes to be read from the FIFO |
mluis | 13:618826a997e2 | 442 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 443 | virtual void ReadFifo( void *buffer, uint8_t size ) = 0; |
mluis | 13:618826a997e2 | 444 | /*! |
mluis | 13:618826a997e2 | 445 | * @brief Resets the SX1276 |
mluis | 13:618826a997e2 | 446 | */ |
mluis | 13:618826a997e2 | 447 | virtual void Reset( void ) = 0; |
mluis | 25:3778e6204cc1 | 448 | |
mluis | 20:e05596ba4166 | 449 | /*! |
mluis | 20:e05596ba4166 | 450 | * @brief Sets the maximum payload length. |
mluis | 20:e05596ba4166 | 451 | * |
mluis | 20:e05596ba4166 | 452 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
mluis | 20:e05596ba4166 | 453 | * @param [IN] max Maximum payload length in bytes |
mluis | 20:e05596ba4166 | 454 | */ |
mluis | 22:7f3aab69cca9 | 455 | virtual void SetMaxPayloadLength( RadioModems_t modem, uint8_t max ); |
mluis | 25:3778e6204cc1 | 456 | |
Helmut Tschemernjak | 31:e50929bd3f32 | 457 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 458 | * \brief Sets the network to public or private. Updates the sync byte. |
Helmut Tschemernjak | 31:e50929bd3f32 | 459 | * |
Helmut Tschemernjak | 31:e50929bd3f32 | 460 | * \remark Applies to LoRa modem only |
Helmut Tschemernjak | 31:e50929bd3f32 | 461 | * |
Helmut Tschemernjak | 31:e50929bd3f32 | 462 | * \param [IN] enable if true, it enables a public network |
Helmut Tschemernjak | 31:e50929bd3f32 | 463 | */ |
Helmut Tschemernjak | 31:e50929bd3f32 | 464 | virtual void SetPublicNetwork( bool enable ); |
Helmut Tschemernjak | 31:e50929bd3f32 | 465 | |
Helmut Tschemernjak | 61:08b50780eb91 | 466 | /*! |
Helmut Tschemernjak | 61:08b50780eb91 | 467 | * @brief Sets the radio output power. |
Helmut Tschemernjak | 61:08b50780eb91 | 468 | * |
Helmut Tschemernjak | 61:08b50780eb91 | 469 | * @param [IN] power Sets the RF output power |
Helmut Tschemernjak | 61:08b50780eb91 | 470 | */ |
Helmut Tschemernjak | 61:08b50780eb91 | 471 | virtual void SetRfTxPower( int8_t power ) = 0; |
Helmut Tschemernjak | 61:08b50780eb91 | 472 | |
mluis | 13:618826a997e2 | 473 | //------------------------------------------------------------------------- |
mluis | 13:618826a997e2 | 474 | // Board relative functions |
mluis | 13:618826a997e2 | 475 | //------------------------------------------------------------------------- |
Helmut Tschemernjak | 55:00c1f5b83920 | 476 | /*! |
Helmut Tschemernjak | 55:00c1f5b83920 | 477 | * Radio registers definition |
Helmut Tschemernjak | 55:00c1f5b83920 | 478 | */ |
Helmut Tschemernjak | 55:00c1f5b83920 | 479 | struct RadioRegisters { |
Helmut Tschemernjak | 55:00c1f5b83920 | 480 | ModemType Modem; |
Helmut Tschemernjak | 55:00c1f5b83920 | 481 | uint8_t Addr; |
Helmut Tschemernjak | 55:00c1f5b83920 | 482 | uint8_t Value; |
Helmut Tschemernjak | 55:00c1f5b83920 | 483 | }; |
Helmut Tschemernjak | 55:00c1f5b83920 | 484 | |
Helmut Tschemernjak | 55:00c1f5b83920 | 485 | |
Helmut Tschemernjak | 55:00c1f5b83920 | 486 | static const struct RadioRegisters RadioRegsInit[]; |
Helmut Tschemernjak | 42:72deced1a4c4 | 487 | |
Helmut Tschemernjak | 42:72deced1a4c4 | 488 | typedef enum { |
Helmut Tschemernjak | 42:72deced1a4c4 | 489 | RXTimeoutTimer, |
Helmut Tschemernjak | 42:72deced1a4c4 | 490 | TXTimeoutTimer, |
Helmut Tschemernjak | 53:6d3adad59633 | 491 | RXTimeoutSyncWordTimer |
Helmut Tschemernjak | 42:72deced1a4c4 | 492 | } TimeoutTimer_t; |
Helmut Tschemernjak | 42:72deced1a4c4 | 493 | |
Helmut Tschemernjak | 42:72deced1a4c4 | 494 | |
GregCr | 0:e6ceb13d2d05 | 495 | protected: |
mluis | 13:618826a997e2 | 496 | /*! |
mluis | 13:618826a997e2 | 497 | * @brief Initializes the radio I/Os pins interface |
mluis | 13:618826a997e2 | 498 | */ |
mluis | 13:618826a997e2 | 499 | virtual void IoInit( void ) = 0; |
mluis | 13:618826a997e2 | 500 | |
mluis | 13:618826a997e2 | 501 | /*! |
mluis | 13:618826a997e2 | 502 | * @brief Initializes the radio SPI |
mluis | 13:618826a997e2 | 503 | */ |
mluis | 13:618826a997e2 | 504 | virtual void SpiInit( void ) = 0; |
mluis | 25:3778e6204cc1 | 505 | |
mluis | 13:618826a997e2 | 506 | /*! |
mluis | 13:618826a997e2 | 507 | * @brief Initializes DIO IRQ handlers |
mluis | 13:618826a997e2 | 508 | * |
mluis | 13:618826a997e2 | 509 | * @param [IN] irqHandlers Array containing the IRQ callback functions |
mluis | 13:618826a997e2 | 510 | */ |
mluis | 13:618826a997e2 | 511 | virtual void IoIrqInit( DioIrqHandler *irqHandlers ) = 0; |
GregCr | 0:e6ceb13d2d05 | 512 | |
mluis | 13:618826a997e2 | 513 | /*! |
mluis | 13:618826a997e2 | 514 | * @brief De-initializes the radio I/Os pins interface. |
mluis | 13:618826a997e2 | 515 | * |
mluis | 13:618826a997e2 | 516 | * \remark Useful when going in MCU lowpower modes |
mluis | 13:618826a997e2 | 517 | */ |
mluis | 13:618826a997e2 | 518 | virtual void IoDeInit( void ) = 0; |
GregCr | 0:e6ceb13d2d05 | 519 | |
mluis | 13:618826a997e2 | 520 | /*! |
mluis | 13:618826a997e2 | 521 | * @brief Gets the board PA selection configuration |
mluis | 13:618826a997e2 | 522 | * |
mluis | 13:618826a997e2 | 523 | * @param [IN] channel Channel frequency in Hz |
mluis | 13:618826a997e2 | 524 | * @retval PaSelect RegPaConfig PaSelect value |
mluis | 13:618826a997e2 | 525 | */ |
mluis | 13:618826a997e2 | 526 | virtual uint8_t GetPaSelect( uint32_t channel ) = 0; |
GregCr | 0:e6ceb13d2d05 | 527 | |
mluis | 13:618826a997e2 | 528 | /*! |
mluis | 13:618826a997e2 | 529 | * @brief Set the RF Switch I/Os pins in Low Power mode |
mluis | 13:618826a997e2 | 530 | * |
mluis | 13:618826a997e2 | 531 | * @param [IN] status enable or disable |
mluis | 13:618826a997e2 | 532 | */ |
mluis | 13:618826a997e2 | 533 | virtual void SetAntSwLowPower( bool status ) = 0; |
GregCr | 0:e6ceb13d2d05 | 534 | |
mluis | 13:618826a997e2 | 535 | /*! |
mluis | 13:618826a997e2 | 536 | * @brief Initializes the RF Switch I/Os pins interface |
mluis | 13:618826a997e2 | 537 | */ |
mluis | 13:618826a997e2 | 538 | virtual void AntSwInit( void ) = 0; |
GregCr | 0:e6ceb13d2d05 | 539 | |
mluis | 13:618826a997e2 | 540 | /*! |
mluis | 13:618826a997e2 | 541 | * @brief De-initializes the RF Switch I/Os pins interface |
mluis | 13:618826a997e2 | 542 | * |
mluis | 13:618826a997e2 | 543 | * \remark Needed to decrease the power consumption in MCU lowpower modes |
mluis | 13:618826a997e2 | 544 | */ |
mluis | 13:618826a997e2 | 545 | virtual void AntSwDeInit( void ) = 0; |
GregCr | 0:e6ceb13d2d05 | 546 | |
mluis | 13:618826a997e2 | 547 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 548 | * @brief Controls the antenna switch if necessary. |
mluis | 13:618826a997e2 | 549 | * |
mluis | 13:618826a997e2 | 550 | * \remark see errata note |
mluis | 13:618826a997e2 | 551 | * |
Helmut Tschemernjak | 31:e50929bd3f32 | 552 | * @param [IN] opMode Current radio operating mode |
mluis | 13:618826a997e2 | 553 | */ |
Helmut Tschemernjak | 31:e50929bd3f32 | 554 | virtual void SetAntSw( uint8_t opMode ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 555 | |
Helmut Tschemernjak | 44:544add59b26d | 556 | typedef void ( SX1276::*timeoutFuncPtr)( void ); |
Helmut Tschemernjak | 44:544add59b26d | 557 | |
Helmut Tschemernjak | 44:544add59b26d | 558 | |
Helmut Tschemernjak | 38:d9189d958db8 | 559 | /* |
Helmut Tschemernjak | 38:d9189d958db8 | 560 | * The the Timeout for a given Timer. |
Helmut Tschemernjak | 38:d9189d958db8 | 561 | */ |
Helmut Tschemernjak | 44:544add59b26d | 562 | virtual void SetTimeout(TimeoutTimer_t timer, timeoutFuncPtr, int timeout_ms = 0) = 0; |
Helmut Tschemernjak | 64:b721e6ab656a | 563 | |
Helmut Tschemernjak | 64:b721e6ab656a | 564 | /* |
Helmut Tschemernjak | 64:b721e6ab656a | 565 | * A simple ms sleep |
Helmut Tschemernjak | 64:b721e6ab656a | 566 | */ |
Helmut Tschemernjak | 64:b721e6ab656a | 567 | virtual void Sleep_ms(int ms) = 0; |
Helmut Tschemernjak | 42:72deced1a4c4 | 568 | |
GregCr | 0:e6ceb13d2d05 | 569 | protected: |
GregCr | 0:e6ceb13d2d05 | 570 | |
mluis | 13:618826a997e2 | 571 | /*! |
mluis | 13:618826a997e2 | 572 | * @brief Sets the SX1276 operating mode |
mluis | 13:618826a997e2 | 573 | * |
mluis | 13:618826a997e2 | 574 | * @param [IN] opMode New operating mode |
mluis | 13:618826a997e2 | 575 | */ |
mluis | 13:618826a997e2 | 576 | virtual void SetOpMode( uint8_t opMode ); |
GregCr | 0:e6ceb13d2d05 | 577 | |
mluis | 13:618826a997e2 | 578 | /* |
mluis | 13:618826a997e2 | 579 | * SX1276 DIO IRQ callback functions prototype |
mluis | 13:618826a997e2 | 580 | */ |
GregCr | 0:e6ceb13d2d05 | 581 | |
mluis | 13:618826a997e2 | 582 | /*! |
mluis | 13:618826a997e2 | 583 | * @brief DIO 0 IRQ callback |
mluis | 13:618826a997e2 | 584 | */ |
mluis | 13:618826a997e2 | 585 | virtual void OnDio0Irq( void ); |
GregCr | 0:e6ceb13d2d05 | 586 | |
mluis | 13:618826a997e2 | 587 | /*! |
mluis | 13:618826a997e2 | 588 | * @brief DIO 1 IRQ callback |
mluis | 13:618826a997e2 | 589 | */ |
mluis | 13:618826a997e2 | 590 | virtual void OnDio1Irq( void ); |
GregCr | 0:e6ceb13d2d05 | 591 | |
mluis | 13:618826a997e2 | 592 | /*! |
mluis | 13:618826a997e2 | 593 | * @brief DIO 2 IRQ callback |
mluis | 13:618826a997e2 | 594 | */ |
mluis | 13:618826a997e2 | 595 | virtual void OnDio2Irq( void ); |
GregCr | 0:e6ceb13d2d05 | 596 | |
mluis | 13:618826a997e2 | 597 | /*! |
mluis | 13:618826a997e2 | 598 | * @brief DIO 3 IRQ callback |
mluis | 13:618826a997e2 | 599 | */ |
mluis | 13:618826a997e2 | 600 | virtual void OnDio3Irq( void ); |
GregCr | 0:e6ceb13d2d05 | 601 | |
mluis | 13:618826a997e2 | 602 | /*! |
mluis | 13:618826a997e2 | 603 | * @brief DIO 4 IRQ callback |
mluis | 13:618826a997e2 | 604 | */ |
mluis | 13:618826a997e2 | 605 | virtual void OnDio4Irq( void ); |
GregCr | 0:e6ceb13d2d05 | 606 | |
mluis | 13:618826a997e2 | 607 | /*! |
mluis | 13:618826a997e2 | 608 | * @brief DIO 5 IRQ callback |
mluis | 13:618826a997e2 | 609 | */ |
mluis | 13:618826a997e2 | 610 | virtual void OnDio5Irq( void ); |
GregCr | 0:e6ceb13d2d05 | 611 | |
mluis | 13:618826a997e2 | 612 | /*! |
Helmut Tschemernjak | 44:544add59b26d | 613 | * @brief Tx & Rx timeout timer callback |
Helmut Tschemernjak | 44:544add59b26d | 614 | */ |
Helmut Tschemernjak | 44:544add59b26d | 615 | virtual void OnTimeoutIrq( void ); |
Helmut Tschemernjak | 44:544add59b26d | 616 | |
Helmut Tschemernjak | 44:544add59b26d | 617 | /*! |
mluis | 13:618826a997e2 | 618 | * Returns the known FSK bandwidth registers value |
mluis | 13:618826a997e2 | 619 | * |
mluis | 13:618826a997e2 | 620 | * \param [IN] bandwidth Bandwidth value in Hz |
mluis | 13:618826a997e2 | 621 | * \retval regValue Bandwidth register value. |
mluis | 13:618826a997e2 | 622 | */ |
mluis | 13:618826a997e2 | 623 | static uint8_t GetFskBandwidthRegValue( uint32_t bandwidth ); |
Helmut Tschemernjak | 55:00c1f5b83920 | 624 | |
Helmut Tschemernjak | 55:00c1f5b83920 | 625 | static uint8_t GetLoRaBandwidthRegValue( uint32_t bandwidth ); |
Helmut Tschemernjak | 55:00c1f5b83920 | 626 | |
Helmut Tschemernjak | 55:00c1f5b83920 | 627 | enum { |
Helmut Tschemernjak | 55:00c1f5b83920 | 628 | LORA_BANKWIDTH_7kHz = 0, // 7.8 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 629 | LORA_BANKWIDTH_10kHz = 1, // 10.4 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 630 | LORA_BANKWIDTH_15kHz = 2, // 15.6 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 631 | LORA_BANKWIDTH_20kHz = 3, // 20.8 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 632 | LORA_BANKWIDTH_31kHz = 4, // 31.2 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 633 | LORA_BANKWIDTH_41kHz = 5, // 41.4 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 634 | LORA_BANKWIDTH_62kHz = 6, // 62.5 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 635 | LORA_BANKWIDTH_125kHz = 7, |
Helmut Tschemernjak | 55:00c1f5b83920 | 636 | LORA_BANKWIDTH_250kHz = 8, |
Helmut Tschemernjak | 55:00c1f5b83920 | 637 | LORA_BANKWIDTH_500kHz = 9, |
Helmut Tschemernjak | 55:00c1f5b83920 | 638 | LORA_BANKWIDTH_RESERVED = 10, |
Helmut Tschemernjak | 55:00c1f5b83920 | 639 | }; |
GregCr | 0:e6ceb13d2d05 | 640 | }; |
GregCr | 0:e6ceb13d2d05 | 641 | |
mluis | 22:7f3aab69cca9 | 642 | #endif // __SX1276_H__ |