1276 hal configured for Ronoth devices
sx1276/sx1276.h@61:08b50780eb91, 2017-05-31 (annotated)
- Committer:
- Helmut Tschemernjak
- Date:
- Wed May 31 14:07:40 2017 +0200
- Revision:
- 61:08b50780eb91
- Parent:
- 59:38e56c85fa44
- Child:
- 64:b721e6ab656a
Made SetRfTxPower public to allow easily power TX changes
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" |
GregCr | 0:e6ceb13d2d05 | 26 | #include "./registers/sx1276Regs-Fsk.h" |
GregCr | 0:e6ceb13d2d05 | 27 | #include "./registers/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 ); |
mluis | 25:3778e6204cc1 | 387 | |
mluis | 13:618826a997e2 | 388 | /*! |
GregCr | 0:e6ceb13d2d05 | 389 | * @brief Writes the radio register at the specified address |
GregCr | 0:e6ceb13d2d05 | 390 | * |
GregCr | 0:e6ceb13d2d05 | 391 | * @param [IN]: addr Register address |
GregCr | 0:e6ceb13d2d05 | 392 | * @param [IN]: data New register value |
GregCr | 0:e6ceb13d2d05 | 393 | */ |
GregCr | 0:e6ceb13d2d05 | 394 | virtual void Write ( uint8_t addr, uint8_t data ) = 0; |
mluis | 25:3778e6204cc1 | 395 | |
mluis | 13:618826a997e2 | 396 | /*! |
GregCr | 0:e6ceb13d2d05 | 397 | * @brief Reads the radio register at the specified address |
GregCr | 0:e6ceb13d2d05 | 398 | * |
GregCr | 0:e6ceb13d2d05 | 399 | * @param [IN]: addr Register address |
GregCr | 0:e6ceb13d2d05 | 400 | * @retval data Register value |
GregCr | 0:e6ceb13d2d05 | 401 | */ |
GregCr | 0:e6ceb13d2d05 | 402 | virtual uint8_t Read ( uint8_t addr ) = 0; |
mluis | 25:3778e6204cc1 | 403 | |
mluis | 13:618826a997e2 | 404 | /*! |
GregCr | 0:e6ceb13d2d05 | 405 | * @brief Writes multiple radio registers starting at address |
GregCr | 0:e6ceb13d2d05 | 406 | * |
GregCr | 0:e6ceb13d2d05 | 407 | * @param [IN] addr First Radio register address |
GregCr | 0:e6ceb13d2d05 | 408 | * @param [IN] buffer Buffer containing the new register's values |
GregCr | 0:e6ceb13d2d05 | 409 | * @param [IN] size Number of registers to be written |
GregCr | 0:e6ceb13d2d05 | 410 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 411 | virtual void Write( uint8_t addr, void *buffer, uint8_t size ) = 0; |
mluis | 25:3778e6204cc1 | 412 | |
mluis | 13:618826a997e2 | 413 | /*! |
GregCr | 0:e6ceb13d2d05 | 414 | * @brief Reads multiple radio registers starting at address |
GregCr | 0:e6ceb13d2d05 | 415 | * |
GregCr | 0:e6ceb13d2d05 | 416 | * @param [IN] addr First Radio register address |
GregCr | 0:e6ceb13d2d05 | 417 | * @param [OUT] buffer Buffer where to copy the registers data |
GregCr | 0:e6ceb13d2d05 | 418 | * @param [IN] size Number of registers to be read |
GregCr | 0:e6ceb13d2d05 | 419 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 420 | virtual void Read ( uint8_t addr, void *buffer, uint8_t size ) = 0; |
mluis | 25:3778e6204cc1 | 421 | |
mluis | 13:618826a997e2 | 422 | /*! |
mluis | 13:618826a997e2 | 423 | * @brief Writes the buffer contents to the SX1276 FIFO |
mluis | 13:618826a997e2 | 424 | * |
mluis | 13:618826a997e2 | 425 | * @param [IN] buffer Buffer containing data to be put on the FIFO. |
mluis | 13:618826a997e2 | 426 | * @param [IN] size Number of bytes to be written to the FIFO |
mluis | 13:618826a997e2 | 427 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 428 | virtual void WriteFifo( void *buffer, uint8_t size ) = 0; |
GregCr | 0:e6ceb13d2d05 | 429 | |
mluis | 13:618826a997e2 | 430 | /*! |
mluis | 13:618826a997e2 | 431 | * @brief Reads the contents of the SX1276 FIFO |
mluis | 13:618826a997e2 | 432 | * |
mluis | 13:618826a997e2 | 433 | * @param [OUT] buffer Buffer where to copy the FIFO read data. |
mluis | 13:618826a997e2 | 434 | * @param [IN] size Number of bytes to be read from the FIFO |
mluis | 13:618826a997e2 | 435 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 436 | virtual void ReadFifo( void *buffer, uint8_t size ) = 0; |
mluis | 13:618826a997e2 | 437 | /*! |
mluis | 13:618826a997e2 | 438 | * @brief Resets the SX1276 |
mluis | 13:618826a997e2 | 439 | */ |
mluis | 13:618826a997e2 | 440 | virtual void Reset( void ) = 0; |
mluis | 25:3778e6204cc1 | 441 | |
mluis | 20:e05596ba4166 | 442 | /*! |
mluis | 20:e05596ba4166 | 443 | * @brief Sets the maximum payload length. |
mluis | 20:e05596ba4166 | 444 | * |
mluis | 20:e05596ba4166 | 445 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
mluis | 20:e05596ba4166 | 446 | * @param [IN] max Maximum payload length in bytes |
mluis | 20:e05596ba4166 | 447 | */ |
mluis | 22:7f3aab69cca9 | 448 | virtual void SetMaxPayloadLength( RadioModems_t modem, uint8_t max ); |
mluis | 25:3778e6204cc1 | 449 | |
Helmut Tschemernjak | 31:e50929bd3f32 | 450 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 451 | * \brief Sets the network to public or private. Updates the sync byte. |
Helmut Tschemernjak | 31:e50929bd3f32 | 452 | * |
Helmut Tschemernjak | 31:e50929bd3f32 | 453 | * \remark Applies to LoRa modem only |
Helmut Tschemernjak | 31:e50929bd3f32 | 454 | * |
Helmut Tschemernjak | 31:e50929bd3f32 | 455 | * \param [IN] enable if true, it enables a public network |
Helmut Tschemernjak | 31:e50929bd3f32 | 456 | */ |
Helmut Tschemernjak | 31:e50929bd3f32 | 457 | virtual void SetPublicNetwork( bool enable ); |
Helmut Tschemernjak | 31:e50929bd3f32 | 458 | |
Helmut Tschemernjak | 61:08b50780eb91 | 459 | /*! |
Helmut Tschemernjak | 61:08b50780eb91 | 460 | * @brief Sets the radio output power. |
Helmut Tschemernjak | 61:08b50780eb91 | 461 | * |
Helmut Tschemernjak | 61:08b50780eb91 | 462 | * @param [IN] power Sets the RF output power |
Helmut Tschemernjak | 61:08b50780eb91 | 463 | */ |
Helmut Tschemernjak | 61:08b50780eb91 | 464 | virtual void SetRfTxPower( int8_t power ) = 0; |
Helmut Tschemernjak | 61:08b50780eb91 | 465 | |
mluis | 13:618826a997e2 | 466 | //------------------------------------------------------------------------- |
mluis | 13:618826a997e2 | 467 | // Board relative functions |
mluis | 13:618826a997e2 | 468 | //------------------------------------------------------------------------- |
Helmut Tschemernjak | 55:00c1f5b83920 | 469 | /*! |
Helmut Tschemernjak | 55:00c1f5b83920 | 470 | * Radio registers definition |
Helmut Tschemernjak | 55:00c1f5b83920 | 471 | */ |
Helmut Tschemernjak | 55:00c1f5b83920 | 472 | struct RadioRegisters { |
Helmut Tschemernjak | 55:00c1f5b83920 | 473 | ModemType Modem; |
Helmut Tschemernjak | 55:00c1f5b83920 | 474 | uint8_t Addr; |
Helmut Tschemernjak | 55:00c1f5b83920 | 475 | uint8_t Value; |
Helmut Tschemernjak | 55:00c1f5b83920 | 476 | }; |
Helmut Tschemernjak | 55:00c1f5b83920 | 477 | |
Helmut Tschemernjak | 55:00c1f5b83920 | 478 | |
Helmut Tschemernjak | 55:00c1f5b83920 | 479 | static const struct RadioRegisters RadioRegsInit[]; |
Helmut Tschemernjak | 42:72deced1a4c4 | 480 | |
Helmut Tschemernjak | 42:72deced1a4c4 | 481 | typedef enum { |
Helmut Tschemernjak | 42:72deced1a4c4 | 482 | RXTimeoutTimer, |
Helmut Tschemernjak | 42:72deced1a4c4 | 483 | TXTimeoutTimer, |
Helmut Tschemernjak | 53:6d3adad59633 | 484 | RXTimeoutSyncWordTimer |
Helmut Tschemernjak | 42:72deced1a4c4 | 485 | } TimeoutTimer_t; |
Helmut Tschemernjak | 42:72deced1a4c4 | 486 | |
Helmut Tschemernjak | 42:72deced1a4c4 | 487 | |
GregCr | 0:e6ceb13d2d05 | 488 | protected: |
mluis | 13:618826a997e2 | 489 | /*! |
mluis | 13:618826a997e2 | 490 | * @brief Initializes the radio I/Os pins interface |
mluis | 13:618826a997e2 | 491 | */ |
mluis | 13:618826a997e2 | 492 | virtual void IoInit( void ) = 0; |
mluis | 13:618826a997e2 | 493 | |
mluis | 13:618826a997e2 | 494 | /*! |
mluis | 13:618826a997e2 | 495 | * @brief Initializes the radio SPI |
mluis | 13:618826a997e2 | 496 | */ |
mluis | 13:618826a997e2 | 497 | virtual void SpiInit( void ) = 0; |
mluis | 25:3778e6204cc1 | 498 | |
mluis | 13:618826a997e2 | 499 | /*! |
mluis | 13:618826a997e2 | 500 | * @brief Initializes DIO IRQ handlers |
mluis | 13:618826a997e2 | 501 | * |
mluis | 13:618826a997e2 | 502 | * @param [IN] irqHandlers Array containing the IRQ callback functions |
mluis | 13:618826a997e2 | 503 | */ |
mluis | 13:618826a997e2 | 504 | virtual void IoIrqInit( DioIrqHandler *irqHandlers ) = 0; |
GregCr | 0:e6ceb13d2d05 | 505 | |
mluis | 13:618826a997e2 | 506 | /*! |
mluis | 13:618826a997e2 | 507 | * @brief De-initializes the radio I/Os pins interface. |
mluis | 13:618826a997e2 | 508 | * |
mluis | 13:618826a997e2 | 509 | * \remark Useful when going in MCU lowpower modes |
mluis | 13:618826a997e2 | 510 | */ |
mluis | 13:618826a997e2 | 511 | virtual void IoDeInit( void ) = 0; |
GregCr | 0:e6ceb13d2d05 | 512 | |
mluis | 13:618826a997e2 | 513 | /*! |
mluis | 13:618826a997e2 | 514 | * @brief Gets the board PA selection configuration |
mluis | 13:618826a997e2 | 515 | * |
mluis | 13:618826a997e2 | 516 | * @param [IN] channel Channel frequency in Hz |
mluis | 13:618826a997e2 | 517 | * @retval PaSelect RegPaConfig PaSelect value |
mluis | 13:618826a997e2 | 518 | */ |
mluis | 13:618826a997e2 | 519 | virtual uint8_t GetPaSelect( uint32_t channel ) = 0; |
GregCr | 0:e6ceb13d2d05 | 520 | |
mluis | 13:618826a997e2 | 521 | /*! |
mluis | 13:618826a997e2 | 522 | * @brief Set the RF Switch I/Os pins in Low Power mode |
mluis | 13:618826a997e2 | 523 | * |
mluis | 13:618826a997e2 | 524 | * @param [IN] status enable or disable |
mluis | 13:618826a997e2 | 525 | */ |
mluis | 13:618826a997e2 | 526 | virtual void SetAntSwLowPower( bool status ) = 0; |
GregCr | 0:e6ceb13d2d05 | 527 | |
mluis | 13:618826a997e2 | 528 | /*! |
mluis | 13:618826a997e2 | 529 | * @brief Initializes the RF Switch I/Os pins interface |
mluis | 13:618826a997e2 | 530 | */ |
mluis | 13:618826a997e2 | 531 | virtual void AntSwInit( void ) = 0; |
GregCr | 0:e6ceb13d2d05 | 532 | |
mluis | 13:618826a997e2 | 533 | /*! |
mluis | 13:618826a997e2 | 534 | * @brief De-initializes the RF Switch I/Os pins interface |
mluis | 13:618826a997e2 | 535 | * |
mluis | 13:618826a997e2 | 536 | * \remark Needed to decrease the power consumption in MCU lowpower modes |
mluis | 13:618826a997e2 | 537 | */ |
mluis | 13:618826a997e2 | 538 | virtual void AntSwDeInit( void ) = 0; |
GregCr | 0:e6ceb13d2d05 | 539 | |
mluis | 13:618826a997e2 | 540 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 541 | * @brief Controls the antenna switch if necessary. |
mluis | 13:618826a997e2 | 542 | * |
mluis | 13:618826a997e2 | 543 | * \remark see errata note |
mluis | 13:618826a997e2 | 544 | * |
Helmut Tschemernjak | 31:e50929bd3f32 | 545 | * @param [IN] opMode Current radio operating mode |
mluis | 13:618826a997e2 | 546 | */ |
Helmut Tschemernjak | 31:e50929bd3f32 | 547 | virtual void SetAntSw( uint8_t opMode ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 548 | |
Helmut Tschemernjak | 44:544add59b26d | 549 | typedef void ( SX1276::*timeoutFuncPtr)( void ); |
Helmut Tschemernjak | 44:544add59b26d | 550 | |
Helmut Tschemernjak | 44:544add59b26d | 551 | |
Helmut Tschemernjak | 38:d9189d958db8 | 552 | /* |
Helmut Tschemernjak | 38:d9189d958db8 | 553 | * The the Timeout for a given Timer. |
Helmut Tschemernjak | 38:d9189d958db8 | 554 | */ |
Helmut Tschemernjak | 44:544add59b26d | 555 | virtual void SetTimeout(TimeoutTimer_t timer, timeoutFuncPtr, int timeout_ms = 0) = 0; |
Helmut Tschemernjak | 42:72deced1a4c4 | 556 | |
GregCr | 0:e6ceb13d2d05 | 557 | protected: |
GregCr | 0:e6ceb13d2d05 | 558 | |
mluis | 13:618826a997e2 | 559 | /*! |
mluis | 13:618826a997e2 | 560 | * @brief Sets the SX1276 operating mode |
mluis | 13:618826a997e2 | 561 | * |
mluis | 13:618826a997e2 | 562 | * @param [IN] opMode New operating mode |
mluis | 13:618826a997e2 | 563 | */ |
mluis | 13:618826a997e2 | 564 | virtual void SetOpMode( uint8_t opMode ); |
GregCr | 0:e6ceb13d2d05 | 565 | |
mluis | 13:618826a997e2 | 566 | /* |
mluis | 13:618826a997e2 | 567 | * SX1276 DIO IRQ callback functions prototype |
mluis | 13:618826a997e2 | 568 | */ |
GregCr | 0:e6ceb13d2d05 | 569 | |
mluis | 13:618826a997e2 | 570 | /*! |
mluis | 13:618826a997e2 | 571 | * @brief DIO 0 IRQ callback |
mluis | 13:618826a997e2 | 572 | */ |
mluis | 13:618826a997e2 | 573 | virtual void OnDio0Irq( void ); |
GregCr | 0:e6ceb13d2d05 | 574 | |
mluis | 13:618826a997e2 | 575 | /*! |
mluis | 13:618826a997e2 | 576 | * @brief DIO 1 IRQ callback |
mluis | 13:618826a997e2 | 577 | */ |
mluis | 13:618826a997e2 | 578 | virtual void OnDio1Irq( void ); |
GregCr | 0:e6ceb13d2d05 | 579 | |
mluis | 13:618826a997e2 | 580 | /*! |
mluis | 13:618826a997e2 | 581 | * @brief DIO 2 IRQ callback |
mluis | 13:618826a997e2 | 582 | */ |
mluis | 13:618826a997e2 | 583 | virtual void OnDio2Irq( void ); |
GregCr | 0:e6ceb13d2d05 | 584 | |
mluis | 13:618826a997e2 | 585 | /*! |
mluis | 13:618826a997e2 | 586 | * @brief DIO 3 IRQ callback |
mluis | 13:618826a997e2 | 587 | */ |
mluis | 13:618826a997e2 | 588 | virtual void OnDio3Irq( void ); |
GregCr | 0:e6ceb13d2d05 | 589 | |
mluis | 13:618826a997e2 | 590 | /*! |
mluis | 13:618826a997e2 | 591 | * @brief DIO 4 IRQ callback |
mluis | 13:618826a997e2 | 592 | */ |
mluis | 13:618826a997e2 | 593 | virtual void OnDio4Irq( void ); |
GregCr | 0:e6ceb13d2d05 | 594 | |
mluis | 13:618826a997e2 | 595 | /*! |
mluis | 13:618826a997e2 | 596 | * @brief DIO 5 IRQ callback |
mluis | 13:618826a997e2 | 597 | */ |
mluis | 13:618826a997e2 | 598 | virtual void OnDio5Irq( void ); |
GregCr | 0:e6ceb13d2d05 | 599 | |
mluis | 13:618826a997e2 | 600 | /*! |
Helmut Tschemernjak | 44:544add59b26d | 601 | * @brief Tx & Rx timeout timer callback |
Helmut Tschemernjak | 44:544add59b26d | 602 | */ |
Helmut Tschemernjak | 44:544add59b26d | 603 | virtual void OnTimeoutIrq( void ); |
Helmut Tschemernjak | 44:544add59b26d | 604 | |
Helmut Tschemernjak | 44:544add59b26d | 605 | /*! |
mluis | 13:618826a997e2 | 606 | * Returns the known FSK bandwidth registers value |
mluis | 13:618826a997e2 | 607 | * |
mluis | 13:618826a997e2 | 608 | * \param [IN] bandwidth Bandwidth value in Hz |
mluis | 13:618826a997e2 | 609 | * \retval regValue Bandwidth register value. |
mluis | 13:618826a997e2 | 610 | */ |
mluis | 13:618826a997e2 | 611 | static uint8_t GetFskBandwidthRegValue( uint32_t bandwidth ); |
Helmut Tschemernjak | 55:00c1f5b83920 | 612 | |
Helmut Tschemernjak | 55:00c1f5b83920 | 613 | static uint8_t GetLoRaBandwidthRegValue( uint32_t bandwidth ); |
Helmut Tschemernjak | 55:00c1f5b83920 | 614 | |
Helmut Tschemernjak | 55:00c1f5b83920 | 615 | enum { |
Helmut Tschemernjak | 55:00c1f5b83920 | 616 | LORA_BANKWIDTH_7kHz = 0, // 7.8 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 617 | LORA_BANKWIDTH_10kHz = 1, // 10.4 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 618 | LORA_BANKWIDTH_15kHz = 2, // 15.6 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 619 | LORA_BANKWIDTH_20kHz = 3, // 20.8 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 620 | LORA_BANKWIDTH_31kHz = 4, // 31.2 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 621 | LORA_BANKWIDTH_41kHz = 5, // 41.4 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 622 | LORA_BANKWIDTH_62kHz = 6, // 62.5 kHz requires TCXO |
Helmut Tschemernjak | 55:00c1f5b83920 | 623 | LORA_BANKWIDTH_125kHz = 7, |
Helmut Tschemernjak | 55:00c1f5b83920 | 624 | LORA_BANKWIDTH_250kHz = 8, |
Helmut Tschemernjak | 55:00c1f5b83920 | 625 | LORA_BANKWIDTH_500kHz = 9, |
Helmut Tschemernjak | 55:00c1f5b83920 | 626 | LORA_BANKWIDTH_RESERVED = 10, |
Helmut Tschemernjak | 55:00c1f5b83920 | 627 | }; |
GregCr | 0:e6ceb13d2d05 | 628 | }; |
GregCr | 0:e6ceb13d2d05 | 629 | |
mluis | 22:7f3aab69cca9 | 630 | #endif // __SX1276_H__ |