Fork with intent to refactor and add support for American 902-928(915) Frequency Bands
radio/radio.h@51:aef3234bcb71, 2017-05-17 (annotated)
- Committer:
- Helmut Tschemernjak
- Date:
- Wed May 17 15:40:13 2017 +0200
- Revision:
- 51:aef3234bcb71
- Parent:
- 50:43f7160e869c
- Child:
- 53:6d3adad59633
Added proper void * type from sending data, uint8_t * is not appropriate.
Use also void pointer for FiFo Write/Read and regular SPI Read/Write
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: Interface for the radios, contains the main functions that a radio needs, and 5 callback functions |
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 | */ |
GregCr | 0:e6ceb13d2d05 | 15 | #ifndef __RADIO_H__ |
GregCr | 0:e6ceb13d2d05 | 16 | #define __RADIO_H__ |
GregCr | 0:e6ceb13d2d05 | 17 | |
GregCr | 0:e6ceb13d2d05 | 18 | #include "mbed.h" |
GregCr | 0:e6ceb13d2d05 | 19 | |
Helmut Tschemernjak | 39:706c32eda7e7 | 20 | |
Helmut Tschemernjak | 39:706c32eda7e7 | 21 | /* |
Helmut Tschemernjak | 39:706c32eda7e7 | 22 | ! |
Helmut Tschemernjak | 39:706c32eda7e7 | 23 | * Radio driver internal state machine states definition |
Helmut Tschemernjak | 39:706c32eda7e7 | 24 | */ |
Helmut Tschemernjak | 39:706c32eda7e7 | 25 | typedef enum RadioState |
Helmut Tschemernjak | 39:706c32eda7e7 | 26 | { |
Helmut Tschemernjak | 39:706c32eda7e7 | 27 | RF_IDLE = 0, |
Helmut Tschemernjak | 39:706c32eda7e7 | 28 | RF_RX_RUNNING, |
Helmut Tschemernjak | 39:706c32eda7e7 | 29 | RF_TX_RUNNING, |
Helmut Tschemernjak | 39:706c32eda7e7 | 30 | RF_CAD, |
Helmut Tschemernjak | 39:706c32eda7e7 | 31 | }RadioState_t; |
Helmut Tschemernjak | 39:706c32eda7e7 | 32 | |
Helmut Tschemernjak | 39:706c32eda7e7 | 33 | |
Helmut Tschemernjak | 39:706c32eda7e7 | 34 | /*! |
Helmut Tschemernjak | 39:706c32eda7e7 | 35 | * Type of the modem. [LORA / FSK] |
Helmut Tschemernjak | 39:706c32eda7e7 | 36 | */ |
Helmut Tschemernjak | 39:706c32eda7e7 | 37 | typedef enum ModemType |
Helmut Tschemernjak | 39:706c32eda7e7 | 38 | { |
Helmut Tschemernjak | 39:706c32eda7e7 | 39 | MODEM_FSK = 0, |
Helmut Tschemernjak | 39:706c32eda7e7 | 40 | MODEM_LORA |
Helmut Tschemernjak | 39:706c32eda7e7 | 41 | }RadioModems_t; |
Helmut Tschemernjak | 39:706c32eda7e7 | 42 | |
Helmut Tschemernjak | 39:706c32eda7e7 | 43 | |
Helmut Tschemernjak | 39:706c32eda7e7 | 44 | /*! |
Helmut Tschemernjak | 39:706c32eda7e7 | 45 | * Radio LoRa modem parameters |
Helmut Tschemernjak | 39:706c32eda7e7 | 46 | */ |
Helmut Tschemernjak | 39:706c32eda7e7 | 47 | typedef struct |
Helmut Tschemernjak | 39:706c32eda7e7 | 48 | { |
Helmut Tschemernjak | 39:706c32eda7e7 | 49 | int8_t Power; |
Helmut Tschemernjak | 39:706c32eda7e7 | 50 | uint32_t Bandwidth; |
Helmut Tschemernjak | 39:706c32eda7e7 | 51 | uint32_t Datarate; |
Helmut Tschemernjak | 39:706c32eda7e7 | 52 | bool LowDatarateOptimize; |
Helmut Tschemernjak | 39:706c32eda7e7 | 53 | uint8_t Coderate; |
Helmut Tschemernjak | 39:706c32eda7e7 | 54 | uint16_t PreambleLen; |
Helmut Tschemernjak | 39:706c32eda7e7 | 55 | bool FixLen; |
Helmut Tschemernjak | 39:706c32eda7e7 | 56 | uint8_t PayloadLen; |
Helmut Tschemernjak | 39:706c32eda7e7 | 57 | bool CrcOn; |
Helmut Tschemernjak | 39:706c32eda7e7 | 58 | bool FreqHopOn; |
Helmut Tschemernjak | 39:706c32eda7e7 | 59 | uint8_t HopPeriod; |
Helmut Tschemernjak | 39:706c32eda7e7 | 60 | bool IqInverted; |
Helmut Tschemernjak | 39:706c32eda7e7 | 61 | bool RxContinuous; |
Helmut Tschemernjak | 39:706c32eda7e7 | 62 | uint32_t TxTimeout; |
Helmut Tschemernjak | 39:706c32eda7e7 | 63 | bool PublicNetwork; |
Helmut Tschemernjak | 39:706c32eda7e7 | 64 | }RadioLoRaSettings_t; |
Helmut Tschemernjak | 39:706c32eda7e7 | 65 | |
Helmut Tschemernjak | 39:706c32eda7e7 | 66 | /*! |
Helmut Tschemernjak | 39:706c32eda7e7 | 67 | * Radio FSK modem parameters |
Helmut Tschemernjak | 39:706c32eda7e7 | 68 | */ |
Helmut Tschemernjak | 39:706c32eda7e7 | 69 | typedef struct |
Helmut Tschemernjak | 39:706c32eda7e7 | 70 | { |
Helmut Tschemernjak | 39:706c32eda7e7 | 71 | int8_t Power; |
Helmut Tschemernjak | 39:706c32eda7e7 | 72 | uint32_t Fdev; |
Helmut Tschemernjak | 39:706c32eda7e7 | 73 | uint32_t Bandwidth; |
Helmut Tschemernjak | 39:706c32eda7e7 | 74 | uint32_t BandwidthAfc; |
Helmut Tschemernjak | 39:706c32eda7e7 | 75 | uint32_t Datarate; |
Helmut Tschemernjak | 39:706c32eda7e7 | 76 | uint16_t PreambleLen; |
Helmut Tschemernjak | 39:706c32eda7e7 | 77 | bool FixLen; |
Helmut Tschemernjak | 39:706c32eda7e7 | 78 | uint8_t PayloadLen; |
Helmut Tschemernjak | 39:706c32eda7e7 | 79 | bool CrcOn; |
Helmut Tschemernjak | 39:706c32eda7e7 | 80 | bool IqInverted; |
Helmut Tschemernjak | 39:706c32eda7e7 | 81 | bool RxContinuous; |
Helmut Tschemernjak | 39:706c32eda7e7 | 82 | uint32_t TxTimeout; |
Helmut Tschemernjak | 39:706c32eda7e7 | 83 | uint32_t RxSingleTimeout; |
Helmut Tschemernjak | 39:706c32eda7e7 | 84 | }RadioFskSettings_t; |
Helmut Tschemernjak | 39:706c32eda7e7 | 85 | |
Helmut Tschemernjak | 39:706c32eda7e7 | 86 | /*! |
Helmut Tschemernjak | 39:706c32eda7e7 | 87 | * Radio FSK packet handler state |
Helmut Tschemernjak | 39:706c32eda7e7 | 88 | */ |
Helmut Tschemernjak | 39:706c32eda7e7 | 89 | typedef struct |
Helmut Tschemernjak | 39:706c32eda7e7 | 90 | { |
Helmut Tschemernjak | 39:706c32eda7e7 | 91 | uint8_t PreambleDetected; |
Helmut Tschemernjak | 39:706c32eda7e7 | 92 | uint8_t SyncWordDetected; |
Helmut Tschemernjak | 39:706c32eda7e7 | 93 | int8_t RssiValue; |
Helmut Tschemernjak | 39:706c32eda7e7 | 94 | int32_t AfcValue; |
Helmut Tschemernjak | 39:706c32eda7e7 | 95 | uint8_t RxGain; |
Helmut Tschemernjak | 39:706c32eda7e7 | 96 | uint16_t Size; |
Helmut Tschemernjak | 39:706c32eda7e7 | 97 | uint16_t NbBytes; |
Helmut Tschemernjak | 39:706c32eda7e7 | 98 | uint8_t FifoThresh; |
Helmut Tschemernjak | 39:706c32eda7e7 | 99 | uint8_t ChunkSize; |
Helmut Tschemernjak | 39:706c32eda7e7 | 100 | }RadioFskPacketHandler_t; |
Helmut Tschemernjak | 39:706c32eda7e7 | 101 | |
Helmut Tschemernjak | 39:706c32eda7e7 | 102 | /*! |
Helmut Tschemernjak | 39:706c32eda7e7 | 103 | * Radio LoRa packet handler state |
Helmut Tschemernjak | 39:706c32eda7e7 | 104 | */ |
Helmut Tschemernjak | 39:706c32eda7e7 | 105 | typedef struct |
Helmut Tschemernjak | 39:706c32eda7e7 | 106 | { |
Helmut Tschemernjak | 39:706c32eda7e7 | 107 | int8_t SnrValue; |
Helmut Tschemernjak | 39:706c32eda7e7 | 108 | int8_t RssiValue; |
Helmut Tschemernjak | 39:706c32eda7e7 | 109 | uint8_t Size; |
Helmut Tschemernjak | 39:706c32eda7e7 | 110 | }RadioLoRaPacketHandler_t; |
Helmut Tschemernjak | 39:706c32eda7e7 | 111 | |
Helmut Tschemernjak | 39:706c32eda7e7 | 112 | /*! |
Helmut Tschemernjak | 39:706c32eda7e7 | 113 | * Radio Settings |
Helmut Tschemernjak | 39:706c32eda7e7 | 114 | */ |
Helmut Tschemernjak | 39:706c32eda7e7 | 115 | typedef struct |
Helmut Tschemernjak | 39:706c32eda7e7 | 116 | { |
Helmut Tschemernjak | 39:706c32eda7e7 | 117 | RadioState State; |
Helmut Tschemernjak | 39:706c32eda7e7 | 118 | ModemType Modem; |
Helmut Tschemernjak | 39:706c32eda7e7 | 119 | uint32_t Channel; |
Helmut Tschemernjak | 39:706c32eda7e7 | 120 | RadioFskSettings_t Fsk; |
Helmut Tschemernjak | 39:706c32eda7e7 | 121 | RadioFskPacketHandler_t FskPacketHandler; |
Helmut Tschemernjak | 39:706c32eda7e7 | 122 | RadioLoRaSettings_t LoRa; |
Helmut Tschemernjak | 39:706c32eda7e7 | 123 | RadioLoRaPacketHandler_t LoRaPacketHandler; |
Helmut Tschemernjak | 39:706c32eda7e7 | 124 | }RadioSettings_t; |
GregCr | 0:e6ceb13d2d05 | 125 | |
GregCr | 0:e6ceb13d2d05 | 126 | /*! |
mluis | 21:2e496deb7858 | 127 | * @brief Radio driver callback functions |
GregCr | 0:e6ceb13d2d05 | 128 | */ |
mluis | 21:2e496deb7858 | 129 | typedef struct |
GregCr | 0:e6ceb13d2d05 | 130 | { |
mluis | 13:618826a997e2 | 131 | /*! |
GregCr | 0:e6ceb13d2d05 | 132 | * @brief Tx Done callback prototype. |
GregCr | 0:e6ceb13d2d05 | 133 | */ |
Helmut64 | 48:62af1e692f00 | 134 | void ( *TxDone )(void *radio); |
mluis | 13:618826a997e2 | 135 | /*! |
GregCr | 0:e6ceb13d2d05 | 136 | * @brief Tx Timeout callback prototype. |
GregCr | 0:e6ceb13d2d05 | 137 | */ |
Helmut64 | 48:62af1e692f00 | 138 | void ( *TxTimeout )(void *radio); |
mluis | 13:618826a997e2 | 139 | /*! |
GregCr | 0:e6ceb13d2d05 | 140 | * @brief Rx Done callback prototype. |
GregCr | 0:e6ceb13d2d05 | 141 | * |
GregCr | 0:e6ceb13d2d05 | 142 | * @param [IN] payload Received buffer pointer |
GregCr | 0:e6ceb13d2d05 | 143 | * @param [IN] size Received buffer size |
GregCr | 0:e6ceb13d2d05 | 144 | * @param [IN] rssi RSSI value computed while receiving the frame [dBm] |
GregCr | 0:e6ceb13d2d05 | 145 | * @param [IN] snr Raw SNR value given by the radio hardware |
GregCr | 0:e6ceb13d2d05 | 146 | * FSK : N/A ( set to 0 ) |
GregCr | 0:e6ceb13d2d05 | 147 | * LoRa: SNR value in dB |
GregCr | 0:e6ceb13d2d05 | 148 | */ |
Helmut64 | 48:62af1e692f00 | 149 | void ( *RxDone )(void *radio, uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ); |
GregCr | 0:e6ceb13d2d05 | 150 | /*! |
GregCr | 0:e6ceb13d2d05 | 151 | * @brief Rx Timeout callback prototype. |
GregCr | 0:e6ceb13d2d05 | 152 | */ |
Helmut64 | 48:62af1e692f00 | 153 | void ( *RxTimeout )(void *radio); |
GregCr | 0:e6ceb13d2d05 | 154 | /*! |
GregCr | 0:e6ceb13d2d05 | 155 | * @brief Rx Error callback prototype. |
GregCr | 0:e6ceb13d2d05 | 156 | */ |
Helmut64 | 48:62af1e692f00 | 157 | void ( *RxError )(void *radio); |
mluis | 13:618826a997e2 | 158 | /*! |
GregCr | 6:e7f02929cd3d | 159 | * \brief FHSS Change Channel callback prototype. |
GregCr | 6:e7f02929cd3d | 160 | * |
mluis | 21:2e496deb7858 | 161 | * \param [IN] currentChannel Index number of the current channel |
GregCr | 6:e7f02929cd3d | 162 | */ |
Helmut64 | 48:62af1e692f00 | 163 | void ( *FhssChangeChannel )(void *radio, uint8_t currentChannel ); |
GregCr | 7:2b555111463f | 164 | |
GregCr | 7:2b555111463f | 165 | /*! |
GregCr | 7:2b555111463f | 166 | * @brief CAD Done callback prototype. |
GregCr | 12:aa5b3bf7fdf4 | 167 | * |
mluis | 21:2e496deb7858 | 168 | * @param [IN] channelDetected Channel Activity detected during the CAD |
GregCr | 7:2b555111463f | 169 | */ |
Helmut64 | 48:62af1e692f00 | 170 | void ( *CadDone ) (void *radio, bool channelActivityDetected ); |
Helmut64 | 48:62af1e692f00 | 171 | |
mluis | 21:2e496deb7858 | 172 | }RadioEvents_t; |
mluis | 21:2e496deb7858 | 173 | |
mluis | 21:2e496deb7858 | 174 | /*! |
mluis | 21:2e496deb7858 | 175 | * Interface for the radios, contains the main functions that a radio needs, and 5 callback functions |
mluis | 21:2e496deb7858 | 176 | */ |
mluis | 21:2e496deb7858 | 177 | class Radio |
mluis | 21:2e496deb7858 | 178 | { |
mluis | 21:2e496deb7858 | 179 | protected: |
mluis | 21:2e496deb7858 | 180 | RadioEvents_t* RadioEvents; |
mluis | 21:2e496deb7858 | 181 | |
GregCr | 0:e6ceb13d2d05 | 182 | public: |
mluis | 13:618826a997e2 | 183 | //------------------------------------------------------------------------- |
mluis | 13:618826a997e2 | 184 | // Constructor |
mluis | 13:618826a997e2 | 185 | //------------------------------------------------------------------------- |
mluis | 13:618826a997e2 | 186 | /*! |
mluis | 13:618826a997e2 | 187 | * @brief Constructor of the radio object, the parameters are the callback functions described in the header. |
mluis | 21:2e496deb7858 | 188 | * |
mluis | 21:2e496deb7858 | 189 | * @param [IN] events Structure containing the driver callback functions |
mluis | 13:618826a997e2 | 190 | */ |
mluis | 21:2e496deb7858 | 191 | Radio( RadioEvents_t *events ); |
mluis | 13:618826a997e2 | 192 | virtual ~Radio( ) {}; |
GregCr | 0:e6ceb13d2d05 | 193 | |
mluis | 13:618826a997e2 | 194 | //------------------------------------------------------------------------- |
mluis | 13:618826a997e2 | 195 | // Pure virtual functions |
mluis | 13:618826a997e2 | 196 | //------------------------------------------------------------------------- |
GregCr | 0:e6ceb13d2d05 | 197 | |
mluis | 13:618826a997e2 | 198 | /*! |
mluis | 21:2e496deb7858 | 199 | * @brief Initializes the radio |
mluis | 21:2e496deb7858 | 200 | * |
mluis | 21:2e496deb7858 | 201 | * @param [IN] events Structure containing the driver callback functions |
mluis | 21:2e496deb7858 | 202 | */ |
mluis | 21:2e496deb7858 | 203 | virtual void Init( RadioEvents_t *events ) = 0; |
mluis | 21:2e496deb7858 | 204 | |
mluis | 21:2e496deb7858 | 205 | /*! |
mluis | 21:2e496deb7858 | 206 | * @brief Return current radio status |
GregCr | 0:e6ceb13d2d05 | 207 | * |
Helmut Tschemernjak | 50:43f7160e869c | 208 | * @param status Radio status. [RF_IDLE, RX_RUNNING, TX_RUNNING, CAD_RUNNING] |
GregCr | 0:e6ceb13d2d05 | 209 | */ |
GregCr | 19:71a47bb03fbb | 210 | virtual RadioState GetStatus( void ) = 0; |
mluis | 13:618826a997e2 | 211 | |
mluis | 13:618826a997e2 | 212 | /*! |
mluis | 21:2e496deb7858 | 213 | * @brief Configures the radio with the given modem |
mluis | 13:618826a997e2 | 214 | * |
mluis | 21:2e496deb7858 | 215 | * @param [IN] modem Modem to be used [0: FSK, 1: LoRa] |
mluis | 13:618826a997e2 | 216 | */ |
mluis | 22:7f3aab69cca9 | 217 | virtual void SetModem( RadioModems_t modem ) = 0; |
mluis | 13:618826a997e2 | 218 | |
mluis | 13:618826a997e2 | 219 | /*! |
GregCr | 0:e6ceb13d2d05 | 220 | * @brief Sets the channel frequency |
GregCr | 0:e6ceb13d2d05 | 221 | * |
GregCr | 0:e6ceb13d2d05 | 222 | * @param [IN] freq Channel RF frequency |
GregCr | 0:e6ceb13d2d05 | 223 | */ |
GregCr | 0:e6ceb13d2d05 | 224 | virtual void SetChannel( uint32_t freq ) = 0; |
GregCr | 0:e6ceb13d2d05 | 225 | |
mluis | 13:618826a997e2 | 226 | /*! |
GregCr | 0:e6ceb13d2d05 | 227 | * @brief Sets the channels configuration |
GregCr | 0:e6ceb13d2d05 | 228 | * |
GregCr | 0:e6ceb13d2d05 | 229 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
GregCr | 0:e6ceb13d2d05 | 230 | * @param [IN] freq Channel RF frequency |
GregCr | 0:e6ceb13d2d05 | 231 | * @param [IN] rssiThresh RSSI threshold |
GregCr | 0:e6ceb13d2d05 | 232 | * |
GregCr | 0:e6ceb13d2d05 | 233 | * @retval isFree [true: Channel is free, false: Channel is not free] |
GregCr | 0:e6ceb13d2d05 | 234 | */ |
mluis | 22:7f3aab69cca9 | 235 | virtual bool IsChannelFree( RadioModems_t modem, uint32_t freq, int16_t rssiThresh ) = 0; |
GregCr | 0:e6ceb13d2d05 | 236 | |
mluis | 13:618826a997e2 | 237 | /*! |
GregCr | 0:e6ceb13d2d05 | 238 | * @brief Generates a 32 bits random value based on the RSSI readings |
GregCr | 0:e6ceb13d2d05 | 239 | * |
GregCr | 0:e6ceb13d2d05 | 240 | * \remark This function sets the radio in LoRa modem mode and disables |
GregCr | 0:e6ceb13d2d05 | 241 | * all interrupts. |
GregCr | 0:e6ceb13d2d05 | 242 | * After calling this function either Radio.SetRxConfig or |
GregCr | 0:e6ceb13d2d05 | 243 | * Radio.SetTxConfig functions must be called. |
GregCr | 0:e6ceb13d2d05 | 244 | * |
GregCr | 0:e6ceb13d2d05 | 245 | * @retval randomValue 32 bits random value |
GregCr | 0:e6ceb13d2d05 | 246 | */ |
GregCr | 0:e6ceb13d2d05 | 247 | virtual uint32_t Random( void )= 0; |
GregCr | 0:e6ceb13d2d05 | 248 | |
mluis | 13:618826a997e2 | 249 | /*! |
GregCr | 0:e6ceb13d2d05 | 250 | * @brief Sets the reception parameters |
GregCr | 0:e6ceb13d2d05 | 251 | * |
GregCr | 0:e6ceb13d2d05 | 252 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
GregCr | 0:e6ceb13d2d05 | 253 | * @param [IN] bandwidth Sets the bandwidth |
GregCr | 0:e6ceb13d2d05 | 254 | * FSK : >= 2600 and <= 250000 Hz |
GregCr | 0:e6ceb13d2d05 | 255 | * LoRa: [0: 125 kHz, 1: 250 kHz, |
GregCr | 0:e6ceb13d2d05 | 256 | * 2: 500 kHz, 3: Reserved] |
GregCr | 0:e6ceb13d2d05 | 257 | * @param [IN] datarate Sets the Datarate |
GregCr | 0:e6ceb13d2d05 | 258 | * FSK : 600..300000 bits/s |
GregCr | 0:e6ceb13d2d05 | 259 | * LoRa: [6: 64, 7: 128, 8: 256, 9: 512, |
GregCr | 0:e6ceb13d2d05 | 260 | * 10: 1024, 11: 2048, 12: 4096 chips] |
GregCr | 0:e6ceb13d2d05 | 261 | * @param [IN] coderate Sets the coding rate ( LoRa only ) |
GregCr | 0:e6ceb13d2d05 | 262 | * FSK : N/A ( set to 0 ) |
GregCr | 0:e6ceb13d2d05 | 263 | * LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] |
GregCr | 0:e6ceb13d2d05 | 264 | * @param [IN] bandwidthAfc Sets the AFC Bandwidth ( FSK only ) |
GregCr | 0:e6ceb13d2d05 | 265 | * FSK : >= 2600 and <= 250000 Hz |
GregCr | 0:e6ceb13d2d05 | 266 | * LoRa: N/A ( set to 0 ) |
GregCr | 0:e6ceb13d2d05 | 267 | * @param [IN] preambleLen Sets the Preamble length ( LoRa only ) |
GregCr | 0:e6ceb13d2d05 | 268 | * FSK : N/A ( set to 0 ) |
GregCr | 0:e6ceb13d2d05 | 269 | * LoRa: Length in symbols ( the hardware adds 4 more symbols ) |
Helmut Tschemernjak | 31:e50929bd3f32 | 270 | * @param [IN] symbTimeout Sets the RxSingle timeout value |
Helmut Tschemernjak | 31:e50929bd3f32 | 271 | * FSK : timeout number of bytes |
GregCr | 0:e6ceb13d2d05 | 272 | * LoRa: timeout in symbols |
GregCr | 0:e6ceb13d2d05 | 273 | * @param [IN] fixLen Fixed length packets [0: variable, 1: fixed] |
mluis | 13:618826a997e2 | 274 | * @param [IN] payloadLen Sets payload length when fixed lenght is used |
GregCr | 0:e6ceb13d2d05 | 275 | * @param [IN] crcOn Enables/Disables the CRC [0: OFF, 1: ON] |
mluis | 13:618826a997e2 | 276 | * @param [IN] freqHopOn Enables disables the intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only) |
mluis | 13:618826a997e2 | 277 | * @param [IN] hopPeriod Number of symbols bewteen each hop (LoRa only) |
GregCr | 0:e6ceb13d2d05 | 278 | * @param [IN] iqInverted Inverts IQ signals ( LoRa only ) |
GregCr | 0:e6ceb13d2d05 | 279 | * FSK : N/A ( set to 0 ) |
GregCr | 0:e6ceb13d2d05 | 280 | * LoRa: [0: not inverted, 1: inverted] |
GregCr | 0:e6ceb13d2d05 | 281 | * @param [IN] rxContinuous Sets the reception in continuous mode |
GregCr | 0:e6ceb13d2d05 | 282 | * [false: single mode, true: continuous mode] |
GregCr | 0:e6ceb13d2d05 | 283 | */ |
mluis | 22:7f3aab69cca9 | 284 | virtual void SetRxConfig ( RadioModems_t modem, uint32_t bandwidth, |
GregCr | 0:e6ceb13d2d05 | 285 | uint32_t datarate, uint8_t coderate, |
GregCr | 0:e6ceb13d2d05 | 286 | uint32_t bandwidthAfc, uint16_t preambleLen, |
GregCr | 0:e6ceb13d2d05 | 287 | uint16_t symbTimeout, bool fixLen, |
mluis | 13:618826a997e2 | 288 | uint8_t payloadLen, |
mluis | 13:618826a997e2 | 289 | bool crcOn, bool freqHopOn, uint8_t hopPeriod, |
GregCr | 6:e7f02929cd3d | 290 | bool iqInverted, bool rxContinuous ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 291 | |
mluis | 13:618826a997e2 | 292 | /*! |
GregCr | 0:e6ceb13d2d05 | 293 | * @brief Sets the transmission parameters |
GregCr | 0:e6ceb13d2d05 | 294 | * |
GregCr | 0:e6ceb13d2d05 | 295 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
GregCr | 0:e6ceb13d2d05 | 296 | * @param [IN] power Sets the output power [dBm] |
GregCr | 0:e6ceb13d2d05 | 297 | * @param [IN] fdev Sets the frequency deviation ( FSK only ) |
GregCr | 0:e6ceb13d2d05 | 298 | * FSK : [Hz] |
GregCr | 0:e6ceb13d2d05 | 299 | * LoRa: 0 |
GregCr | 0:e6ceb13d2d05 | 300 | * @param [IN] bandwidth Sets the bandwidth ( LoRa only ) |
GregCr | 0:e6ceb13d2d05 | 301 | * FSK : 0 |
GregCr | 0:e6ceb13d2d05 | 302 | * LoRa: [0: 125 kHz, 1: 250 kHz, |
GregCr | 0:e6ceb13d2d05 | 303 | * 2: 500 kHz, 3: Reserved] |
GregCr | 0:e6ceb13d2d05 | 304 | * @param [IN] datarate Sets the Datarate |
GregCr | 0:e6ceb13d2d05 | 305 | * FSK : 600..300000 bits/s |
GregCr | 0:e6ceb13d2d05 | 306 | * LoRa: [6: 64, 7: 128, 8: 256, 9: 512, |
GregCr | 0:e6ceb13d2d05 | 307 | * 10: 1024, 11: 2048, 12: 4096 chips] |
GregCr | 0:e6ceb13d2d05 | 308 | * @param [IN] coderate Sets the coding rate ( LoRa only ) |
GregCr | 0:e6ceb13d2d05 | 309 | * FSK : N/A ( set to 0 ) |
GregCr | 0:e6ceb13d2d05 | 310 | * LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] |
GregCr | 0:e6ceb13d2d05 | 311 | * @param [IN] preambleLen Sets the preamble length |
GregCr | 0:e6ceb13d2d05 | 312 | * @param [IN] fixLen Fixed length packets [0: variable, 1: fixed] |
GregCr | 0:e6ceb13d2d05 | 313 | * @param [IN] crcOn Enables disables the CRC [0: OFF, 1: ON] |
mluis | 13:618826a997e2 | 314 | * @param [IN] freqHopOn Enables disables the intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only) |
mluis | 13:618826a997e2 | 315 | * @param [IN] hopPeriod Number of symbols bewteen each hop (LoRa only) |
GregCr | 0:e6ceb13d2d05 | 316 | * @param [IN] iqInverted Inverts IQ signals ( LoRa only ) |
GregCr | 0:e6ceb13d2d05 | 317 | * FSK : N/A ( set to 0 ) |
GregCr | 0:e6ceb13d2d05 | 318 | * LoRa: [0: not inverted, 1: inverted] |
GregCr | 0:e6ceb13d2d05 | 319 | * @param [IN] timeout Transmission timeout [us] |
GregCr | 0:e6ceb13d2d05 | 320 | */ |
mluis | 22:7f3aab69cca9 | 321 | virtual void SetTxConfig( RadioModems_t modem, int8_t power, uint32_t fdev, |
GregCr | 6:e7f02929cd3d | 322 | uint32_t bandwidth, uint32_t datarate, |
GregCr | 6:e7f02929cd3d | 323 | uint8_t coderate, uint16_t preambleLen, |
mluis | 13:618826a997e2 | 324 | bool fixLen, bool crcOn, bool freqHopOn, |
mluis | 13:618826a997e2 | 325 | uint8_t hopPeriod, bool iqInverted, uint32_t timeout ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 326 | |
mluis | 13:618826a997e2 | 327 | /*! |
GregCr | 0:e6ceb13d2d05 | 328 | * @brief Checks if the given RF frequency is supported by the hardware |
GregCr | 0:e6ceb13d2d05 | 329 | * |
GregCr | 0:e6ceb13d2d05 | 330 | * @param [IN] frequency RF frequency to be checked |
GregCr | 0:e6ceb13d2d05 | 331 | * @retval isSupported [true: supported, false: unsupported] |
GregCr | 0:e6ceb13d2d05 | 332 | */ |
GregCr | 0:e6ceb13d2d05 | 333 | virtual bool CheckRfFrequency( uint32_t frequency ) = 0; |
GregCr | 0:e6ceb13d2d05 | 334 | |
mluis | 13:618826a997e2 | 335 | /*! |
GregCr | 0:e6ceb13d2d05 | 336 | * @brief Computes the packet time on air for the given payload |
GregCr | 0:e6ceb13d2d05 | 337 | * |
GregCr | 0:e6ceb13d2d05 | 338 | * \Remark Can only be called once SetRxConfig or SetTxConfig have been called |
GregCr | 0:e6ceb13d2d05 | 339 | * |
GregCr | 0:e6ceb13d2d05 | 340 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
GregCr | 0:e6ceb13d2d05 | 341 | * @param [IN] pktLen Packet payload length |
GregCr | 0:e6ceb13d2d05 | 342 | * |
GregCr | 0:e6ceb13d2d05 | 343 | * @retval airTime Computed airTime for the given packet payload length |
GregCr | 0:e6ceb13d2d05 | 344 | */ |
Helmut Tschemernjak | 31:e50929bd3f32 | 345 | virtual uint32_t TimeOnAir ( RadioModems_t modem, uint8_t pktLen ) = 0; |
GregCr | 0:e6ceb13d2d05 | 346 | |
mluis | 13:618826a997e2 | 347 | /*! |
GregCr | 0:e6ceb13d2d05 | 348 | * @brief Sends the buffer of size. Prepares the packet to be sent and sets |
GregCr | 0:e6ceb13d2d05 | 349 | * the radio in transmission |
GregCr | 0:e6ceb13d2d05 | 350 | * |
GregCr | 0:e6ceb13d2d05 | 351 | * @param [IN]: buffer Buffer pointer |
GregCr | 0:e6ceb13d2d05 | 352 | * @param [IN]: size Buffer size |
Helmut Tschemernjak | 50:43f7160e869c | 353 | * @param [IN]: buffer Header pointer |
Helmut Tschemernjak | 50:43f7160e869c | 354 | * @param [IN]: size Header size |
GregCr | 0:e6ceb13d2d05 | 355 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 356 | virtual void Send( void *buffer, int16_t size, void *header = NULL, int16_t hsize = 0) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 357 | |
mluis | 13:618826a997e2 | 358 | /*! |
GregCr | 0:e6ceb13d2d05 | 359 | * @brief Sets the radio in sleep mode |
GregCr | 0:e6ceb13d2d05 | 360 | */ |
GregCr | 0:e6ceb13d2d05 | 361 | virtual void Sleep( void ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 362 | |
mluis | 13:618826a997e2 | 363 | /*! |
GregCr | 0:e6ceb13d2d05 | 364 | * @brief Sets the radio in standby mode |
GregCr | 0:e6ceb13d2d05 | 365 | */ |
GregCr | 7:2b555111463f | 366 | virtual void Standby( void ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 367 | |
mluis | 13:618826a997e2 | 368 | /*! |
GregCr | 7:2b555111463f | 369 | * @brief Sets the radio in CAD mode |
GregCr | 7:2b555111463f | 370 | */ |
GregCr | 7:2b555111463f | 371 | virtual void StartCad( void ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 372 | |
mluis | 13:618826a997e2 | 373 | /*! |
GregCr | 0:e6ceb13d2d05 | 374 | * @brief Sets the radio in reception mode for the given time |
GregCr | 0:e6ceb13d2d05 | 375 | * @param [IN] timeout Reception timeout [us] |
GregCr | 0:e6ceb13d2d05 | 376 | * [0: continuous, others timeout] |
GregCr | 0:e6ceb13d2d05 | 377 | */ |
GregCr | 0:e6ceb13d2d05 | 378 | virtual void Rx( uint32_t timeout ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 379 | |
mluis | 13:618826a997e2 | 380 | /*! |
GregCr | 0:e6ceb13d2d05 | 381 | * @brief Sets the radio in transmission mode for the given time |
GregCr | 0:e6ceb13d2d05 | 382 | * @param [IN] timeout Transmission timeout [us] |
GregCr | 0:e6ceb13d2d05 | 383 | * [0: continuous, others timeout] |
GregCr | 0:e6ceb13d2d05 | 384 | */ |
GregCr | 0:e6ceb13d2d05 | 385 | virtual void Tx( uint32_t timeout ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 386 | |
Helmut Tschemernjak | 31:e50929bd3f32 | 387 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 388 | * @brief Sets the radio in continuous wave transmission mode |
Helmut Tschemernjak | 31:e50929bd3f32 | 389 | * |
Helmut Tschemernjak | 31:e50929bd3f32 | 390 | * @param [IN]: freq Channel RF frequency |
Helmut Tschemernjak | 31:e50929bd3f32 | 391 | * @param [IN]: power Sets the output power [dBm] |
Helmut Tschemernjak | 31:e50929bd3f32 | 392 | * @param [IN]: time Transmission mode timeout [s] |
Helmut Tschemernjak | 31:e50929bd3f32 | 393 | */ |
Helmut Tschemernjak | 31:e50929bd3f32 | 394 | virtual void SetTxContinuousWave( uint32_t freq, int8_t power, uint16_t time ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 395 | |
mluis | 13:618826a997e2 | 396 | /*! |
Helmut Tschemernjak | 50:43f7160e869c | 397 | * @brief Returns the maximal transfer unit for a given modem |
Helmut Tschemernjak | 50:43f7160e869c | 398 | * |
Helmut Tschemernjak | 50:43f7160e869c | 399 | * @retval MTU size in bytes |
Helmut Tschemernjak | 50:43f7160e869c | 400 | */ |
Helmut Tschemernjak | 50:43f7160e869c | 401 | virtual int16_t MaxMTUSize( RadioModems_t modem ) = 0; |
Helmut Tschemernjak | 50:43f7160e869c | 402 | |
Helmut Tschemernjak | 50:43f7160e869c | 403 | /*! |
GregCr | 0:e6ceb13d2d05 | 404 | * @brief Reads the current RSSI value |
GregCr | 0:e6ceb13d2d05 | 405 | * |
GregCr | 0:e6ceb13d2d05 | 406 | * @retval rssiValue Current RSSI value in [dBm] |
GregCr | 0:e6ceb13d2d05 | 407 | */ |
mluis | 22:7f3aab69cca9 | 408 | virtual int16_t GetRssi ( RadioModems_t modem ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 409 | |
mluis | 13:618826a997e2 | 410 | /*! |
GregCr | 0:e6ceb13d2d05 | 411 | * @brief Writes the radio register at the specified address |
GregCr | 0:e6ceb13d2d05 | 412 | * |
GregCr | 0:e6ceb13d2d05 | 413 | * @param [IN]: addr Register address |
GregCr | 0:e6ceb13d2d05 | 414 | * @param [IN]: data New register value |
GregCr | 0:e6ceb13d2d05 | 415 | */ |
GregCr | 0:e6ceb13d2d05 | 416 | virtual void Write ( uint8_t addr, uint8_t data ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 417 | |
mluis | 13:618826a997e2 | 418 | /*! |
GregCr | 0:e6ceb13d2d05 | 419 | * @brief Reads the radio register at the specified address |
GregCr | 0:e6ceb13d2d05 | 420 | * |
GregCr | 0:e6ceb13d2d05 | 421 | * @param [IN]: addr Register address |
GregCr | 0:e6ceb13d2d05 | 422 | * @retval data Register value |
GregCr | 0:e6ceb13d2d05 | 423 | */ |
GregCr | 0:e6ceb13d2d05 | 424 | virtual uint8_t Read ( uint8_t addr ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 425 | |
mluis | 13:618826a997e2 | 426 | /*! |
GregCr | 0:e6ceb13d2d05 | 427 | * @brief Writes multiple radio registers starting at address |
GregCr | 0:e6ceb13d2d05 | 428 | * |
GregCr | 0:e6ceb13d2d05 | 429 | * @param [IN] addr First Radio register address |
GregCr | 0:e6ceb13d2d05 | 430 | * @param [IN] buffer Buffer containing the new register's values |
GregCr | 0:e6ceb13d2d05 | 431 | * @param [IN] size Number of registers to be written |
GregCr | 0:e6ceb13d2d05 | 432 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 433 | virtual void Write( uint8_t addr, void *buffer, uint8_t size ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 434 | |
mluis | 13:618826a997e2 | 435 | /*! |
GregCr | 0:e6ceb13d2d05 | 436 | * @brief Reads multiple radio registers starting at address |
GregCr | 0:e6ceb13d2d05 | 437 | * |
GregCr | 0:e6ceb13d2d05 | 438 | * @param [IN] addr First Radio register address |
GregCr | 0:e6ceb13d2d05 | 439 | * @param [OUT] buffer Buffer where to copy the registers data |
GregCr | 0:e6ceb13d2d05 | 440 | * @param [IN] size Number of registers to be read |
GregCr | 0:e6ceb13d2d05 | 441 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 442 | virtual void Read ( uint8_t addr, void *buffer, uint8_t size ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 443 | |
mluis | 13:618826a997e2 | 444 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 445 | * @brief Writes the buffer contents to the Radio FIFO |
mluis | 13:618826a997e2 | 446 | * |
mluis | 13:618826a997e2 | 447 | * @param [IN] buffer Buffer containing data to be put on the FIFO. |
mluis | 13:618826a997e2 | 448 | * @param [IN] size Number of bytes to be written to the FIFO |
mluis | 13:618826a997e2 | 449 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 450 | virtual void WriteFifo( void *buffer, uint8_t size ) = 0; |
GregCr | 0:e6ceb13d2d05 | 451 | |
mluis | 13:618826a997e2 | 452 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 453 | * @brief Reads the contents of the Radio FIFO |
mluis | 13:618826a997e2 | 454 | * |
mluis | 13:618826a997e2 | 455 | * @param [OUT] buffer Buffer where to copy the FIFO read data. |
mluis | 13:618826a997e2 | 456 | * @param [IN] size Number of bytes to be read from the FIFO |
mluis | 13:618826a997e2 | 457 | */ |
Helmut Tschemernjak | 51:aef3234bcb71 | 458 | virtual void ReadFifo( void *buffer, uint8_t size ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 459 | |
mluis | 20:e05596ba4166 | 460 | /*! |
mluis | 20:e05596ba4166 | 461 | * @brief Sets the maximum payload length. |
mluis | 20:e05596ba4166 | 462 | * |
mluis | 20:e05596ba4166 | 463 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
mluis | 20:e05596ba4166 | 464 | * @param [IN] max Maximum payload length in bytes |
mluis | 20:e05596ba4166 | 465 | */ |
mluis | 22:7f3aab69cca9 | 466 | virtual void SetMaxPayloadLength( RadioModems_t modem, uint8_t max ) = 0; |
Helmut Tschemernjak | 31:e50929bd3f32 | 467 | |
Helmut Tschemernjak | 31:e50929bd3f32 | 468 | /*! |
Helmut Tschemernjak | 31:e50929bd3f32 | 469 | * @brief Sets the network to public or private. Updates the sync byte. |
Helmut Tschemernjak | 31:e50929bd3f32 | 470 | * |
Helmut Tschemernjak | 31:e50929bd3f32 | 471 | * @remark Applies to LoRa modem only |
Helmut Tschemernjak | 31:e50929bd3f32 | 472 | * |
Helmut Tschemernjak | 31:e50929bd3f32 | 473 | * @param [IN] enable if true, it enables a public network |
Helmut Tschemernjak | 31:e50929bd3f32 | 474 | */ |
Helmut Tschemernjak | 31:e50929bd3f32 | 475 | virtual void SetPublicNetwork( bool enable ) = 0; |
GregCr | 0:e6ceb13d2d05 | 476 | }; |
GregCr | 0:e6ceb13d2d05 | 477 | |
GregCr | 0:e6ceb13d2d05 | 478 | #endif // __RADIO_H__ |