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