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