Driver for the SX1272 RF Transceiver
Dependents: LoRaWAN_mbed_lmic_agriculture_app
Fork of SX1272Lib by
radio/radio.h@8:60c42278731e, 2018-04-02 (annotated)
- Committer:
- GTsapparellas
- Date:
- Mon Apr 02 12:06:02 2018 +0000
- Revision:
- 8:60c42278731e
- Parent:
- 7:b988b60083a1
SX1272MB2xAS LoRa shield attached on FRDM-K64F ARM mbed board.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mluis | 0:45c4f0364ca4 | 1 | /* |
mluis | 0:45c4f0364ca4 | 2 | / _____) _ | | |
mluis | 0:45c4f0364ca4 | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ |
mluis | 0:45c4f0364ca4 | 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ |
mluis | 0:45c4f0364ca4 | 5 | _____) ) ____| | | || |_| ____( (___| | | | |
mluis | 0:45c4f0364ca4 | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| |
mluis | 0:45c4f0364ca4 | 7 | (C) 2015 Semtech |
mluis | 0:45c4f0364ca4 | 8 | |
mluis | 0:45c4f0364ca4 | 9 | Description: Interface for the radios, contains the main functions that a radio needs, and 5 callback functions |
mluis | 0:45c4f0364ca4 | 10 | |
mluis | 0:45c4f0364ca4 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project |
mluis | 0:45c4f0364ca4 | 12 | |
mluis | 0:45c4f0364ca4 | 13 | Maintainers: Miguel Luis, Gregory Cristian and Nicolas Huguenin |
GTsapparellas | 8:60c42278731e | 14 | ///////////////////////////////////////////////////////////////////////////// |
GTsapparellas | 8:60c42278731e | 15 | |
GTsapparellas | 8:60c42278731e | 16 | Used by Giorgos Tsapparellas for Internet of Things (IoT) smart monitoring |
GTsapparellas | 8:60c42278731e | 17 | device for agriculture using LoRaWAN technology. |
GTsapparellas | 8:60c42278731e | 18 | |
GTsapparellas | 8:60c42278731e | 19 | Date of issued copy: 20 January 2018 |
GTsapparellas | 8:60c42278731e | 20 | |
GTsapparellas | 8:60c42278731e | 21 | Modifications: |
GTsapparellas | 8:60c42278731e | 22 | - No external modifications of the existing "AS IT IS" software. |
mluis | 0:45c4f0364ca4 | 23 | */ |
mluis | 0:45c4f0364ca4 | 24 | #ifndef __RADIO_H__ |
mluis | 0:45c4f0364ca4 | 25 | #define __RADIO_H__ |
mluis | 0:45c4f0364ca4 | 26 | |
mluis | 0:45c4f0364ca4 | 27 | #include "mbed.h" |
mluis | 0:45c4f0364ca4 | 28 | |
mluis | 0:45c4f0364ca4 | 29 | #include "./enums/enums.h" |
mluis | 0:45c4f0364ca4 | 30 | |
mluis | 0:45c4f0364ca4 | 31 | /*! |
mluis | 0:45c4f0364ca4 | 32 | * @brief Radio driver callback functions |
mluis | 0:45c4f0364ca4 | 33 | */ |
mluis | 0:45c4f0364ca4 | 34 | typedef struct |
mluis | 0:45c4f0364ca4 | 35 | { |
mluis | 0:45c4f0364ca4 | 36 | /*! |
mluis | 0:45c4f0364ca4 | 37 | * @brief Tx Done callback prototype. |
mluis | 0:45c4f0364ca4 | 38 | */ |
mluis | 0:45c4f0364ca4 | 39 | void ( *TxDone )( void ); |
mluis | 0:45c4f0364ca4 | 40 | /*! |
mluis | 0:45c4f0364ca4 | 41 | * @brief Tx Timeout callback prototype. |
mluis | 0:45c4f0364ca4 | 42 | */ |
mluis | 0:45c4f0364ca4 | 43 | void ( *TxTimeout )( void ); |
mluis | 0:45c4f0364ca4 | 44 | /*! |
mluis | 0:45c4f0364ca4 | 45 | * @brief Rx Done callback prototype. |
mluis | 0:45c4f0364ca4 | 46 | * |
mluis | 0:45c4f0364ca4 | 47 | * @param [IN] payload Received buffer pointer |
mluis | 0:45c4f0364ca4 | 48 | * @param [IN] size Received buffer size |
mluis | 0:45c4f0364ca4 | 49 | * @param [IN] rssi RSSI value computed while receiving the frame [dBm] |
mluis | 0:45c4f0364ca4 | 50 | * @param [IN] snr Raw SNR value given by the radio hardware |
mluis | 0:45c4f0364ca4 | 51 | * FSK : N/A ( set to 0 ) |
mluis | 0:45c4f0364ca4 | 52 | * LoRa: SNR value in dB |
mluis | 0:45c4f0364ca4 | 53 | */ |
mluis | 0:45c4f0364ca4 | 54 | void ( *RxDone )( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ); |
mluis | 0:45c4f0364ca4 | 55 | /*! |
mluis | 0:45c4f0364ca4 | 56 | * @brief Rx Timeout callback prototype. |
mluis | 0:45c4f0364ca4 | 57 | */ |
mluis | 0:45c4f0364ca4 | 58 | void ( *RxTimeout )( void ); |
mluis | 0:45c4f0364ca4 | 59 | /*! |
mluis | 0:45c4f0364ca4 | 60 | * @brief Rx Error callback prototype. |
mluis | 0:45c4f0364ca4 | 61 | */ |
mluis | 0:45c4f0364ca4 | 62 | void ( *RxError )( void ); |
mluis | 0:45c4f0364ca4 | 63 | /*! |
mluis | 0:45c4f0364ca4 | 64 | * \brief FHSS Change Channel callback prototype. |
mluis | 0:45c4f0364ca4 | 65 | * |
mluis | 0:45c4f0364ca4 | 66 | * \param [IN] currentChannel Index number of the current channel |
mluis | 0:45c4f0364ca4 | 67 | */ |
mluis | 0:45c4f0364ca4 | 68 | void ( *FhssChangeChannel )( uint8_t currentChannel ); |
mluis | 0:45c4f0364ca4 | 69 | /*! |
mluis | 0:45c4f0364ca4 | 70 | * @brief CAD Done callback prototype. |
mluis | 0:45c4f0364ca4 | 71 | * |
mluis | 0:45c4f0364ca4 | 72 | * @param [IN] channelDetected Channel Activity detected during the CAD |
mluis | 0:45c4f0364ca4 | 73 | */ |
mluis | 0:45c4f0364ca4 | 74 | void ( *CadDone ) ( bool channelActivityDetected ); |
mluis | 0:45c4f0364ca4 | 75 | }RadioEvents_t; |
mluis | 0:45c4f0364ca4 | 76 | |
mluis | 0:45c4f0364ca4 | 77 | /*! |
mluis | 0:45c4f0364ca4 | 78 | * Interface for the radios, contains the main functions that a radio needs, and 5 callback functions |
mluis | 0:45c4f0364ca4 | 79 | */ |
mluis | 0:45c4f0364ca4 | 80 | class Radio |
mluis | 0:45c4f0364ca4 | 81 | { |
mluis | 0:45c4f0364ca4 | 82 | protected: |
mluis | 0:45c4f0364ca4 | 83 | RadioEvents_t* RadioEvents; |
mluis | 0:45c4f0364ca4 | 84 | |
mluis | 0:45c4f0364ca4 | 85 | public: |
mluis | 0:45c4f0364ca4 | 86 | //------------------------------------------------------------------------- |
mluis | 0:45c4f0364ca4 | 87 | // Constructor |
mluis | 0:45c4f0364ca4 | 88 | //------------------------------------------------------------------------- |
mluis | 0:45c4f0364ca4 | 89 | /*! |
mluis | 0:45c4f0364ca4 | 90 | * @brief Constructor of the radio object, the parameters are the callback functions described in the header. |
mluis | 0:45c4f0364ca4 | 91 | * |
mluis | 0:45c4f0364ca4 | 92 | * @param [IN] events Structure containing the driver callback functions |
mluis | 0:45c4f0364ca4 | 93 | */ |
mluis | 0:45c4f0364ca4 | 94 | Radio( RadioEvents_t *events ); |
mluis | 0:45c4f0364ca4 | 95 | virtual ~Radio( ) {}; |
mluis | 0:45c4f0364ca4 | 96 | |
mluis | 0:45c4f0364ca4 | 97 | //------------------------------------------------------------------------- |
mluis | 0:45c4f0364ca4 | 98 | // Pure virtual functions |
mluis | 0:45c4f0364ca4 | 99 | //------------------------------------------------------------------------- |
mluis | 0:45c4f0364ca4 | 100 | /*! |
mluis | 0:45c4f0364ca4 | 101 | * @brief Initializes the radio |
mluis | 0:45c4f0364ca4 | 102 | * |
mluis | 0:45c4f0364ca4 | 103 | * @param [IN] events Structure containing the driver callback functions |
mluis | 0:45c4f0364ca4 | 104 | */ |
mluis | 0:45c4f0364ca4 | 105 | virtual void Init( RadioEvents_t *events ) = 0; |
mluis | 0:45c4f0364ca4 | 106 | /*! |
mluis | 0:45c4f0364ca4 | 107 | * @brief Return current radio status |
mluis | 0:45c4f0364ca4 | 108 | * |
mluis | 0:45c4f0364ca4 | 109 | * @param status Radio status.[RF_IDLE, RF_RX_RUNNING, RF_TX_RUNNING] |
mluis | 0:45c4f0364ca4 | 110 | */ |
mluis | 0:45c4f0364ca4 | 111 | virtual RadioState GetStatus( void ) = 0; |
mluis | 0:45c4f0364ca4 | 112 | /*! |
mluis | 0:45c4f0364ca4 | 113 | * @brief Configures the radio with the given modem |
mluis | 0:45c4f0364ca4 | 114 | * |
mluis | 0:45c4f0364ca4 | 115 | * @param [IN] modem Modem to be used [0: FSK, 1: LoRa] |
mluis | 0:45c4f0364ca4 | 116 | */ |
mluis | 0:45c4f0364ca4 | 117 | virtual void SetModem( RadioModems_t modem ) = 0; |
mluis | 0:45c4f0364ca4 | 118 | /*! |
mluis | 0:45c4f0364ca4 | 119 | * @brief Sets the channel frequency |
mluis | 0:45c4f0364ca4 | 120 | * |
mluis | 0:45c4f0364ca4 | 121 | * @param [IN] freq Channel RF frequency |
mluis | 0:45c4f0364ca4 | 122 | */ |
mluis | 0:45c4f0364ca4 | 123 | virtual void SetChannel( uint32_t freq ) = 0; |
mluis | 0:45c4f0364ca4 | 124 | /*! |
mluis | 0:45c4f0364ca4 | 125 | * @brief Sets the channels configuration |
mluis | 0:45c4f0364ca4 | 126 | * |
mluis | 0:45c4f0364ca4 | 127 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
mluis | 0:45c4f0364ca4 | 128 | * @param [IN] freq Channel RF frequency |
mluis | 0:45c4f0364ca4 | 129 | * @param [IN] rssiThresh RSSI threshold |
mluis | 0:45c4f0364ca4 | 130 | * |
mluis | 0:45c4f0364ca4 | 131 | * @retval isFree [true: Channel is free, false: Channel is not free] |
mluis | 0:45c4f0364ca4 | 132 | */ |
mluis | 0:45c4f0364ca4 | 133 | virtual bool IsChannelFree( RadioModems_t modem, uint32_t freq, int16_t rssiThresh ) = 0; |
mluis | 0:45c4f0364ca4 | 134 | /*! |
mluis | 0:45c4f0364ca4 | 135 | * @brief Generates a 32 bits random value based on the RSSI readings |
mluis | 0:45c4f0364ca4 | 136 | * |
mluis | 0:45c4f0364ca4 | 137 | * \remark This function sets the radio in LoRa modem mode and disables |
mluis | 0:45c4f0364ca4 | 138 | * all interrupts. |
mluis | 0:45c4f0364ca4 | 139 | * After calling this function either Radio.SetRxConfig or |
mluis | 0:45c4f0364ca4 | 140 | * Radio.SetTxConfig functions must be called. |
mluis | 0:45c4f0364ca4 | 141 | * |
mluis | 0:45c4f0364ca4 | 142 | * @retval randomValue 32 bits random value |
mluis | 0:45c4f0364ca4 | 143 | */ |
mluis | 0:45c4f0364ca4 | 144 | virtual uint32_t Random( void )= 0; |
mluis | 0:45c4f0364ca4 | 145 | /*! |
mluis | 0:45c4f0364ca4 | 146 | * @brief Sets the reception parameters |
mluis | 0:45c4f0364ca4 | 147 | * |
mluis | 0:45c4f0364ca4 | 148 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
mluis | 0:45c4f0364ca4 | 149 | * @param [IN] bandwidth Sets the bandwidth |
mluis | 0:45c4f0364ca4 | 150 | * FSK : >= 2600 and <= 250000 Hz |
mluis | 0:45c4f0364ca4 | 151 | * LoRa: [0: 125 kHz, 1: 250 kHz, |
mluis | 0:45c4f0364ca4 | 152 | * 2: 500 kHz, 3: Reserved] |
mluis | 0:45c4f0364ca4 | 153 | * @param [IN] datarate Sets the Datarate |
mluis | 0:45c4f0364ca4 | 154 | * FSK : 600..300000 bits/s |
mluis | 0:45c4f0364ca4 | 155 | * LoRa: [6: 64, 7: 128, 8: 256, 9: 512, |
mluis | 0:45c4f0364ca4 | 156 | * 10: 1024, 11: 2048, 12: 4096 chips] |
mluis | 0:45c4f0364ca4 | 157 | * @param [IN] coderate Sets the coding rate ( LoRa only ) |
mluis | 0:45c4f0364ca4 | 158 | * FSK : N/A ( set to 0 ) |
mluis | 0:45c4f0364ca4 | 159 | * LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] |
mluis | 0:45c4f0364ca4 | 160 | * @param [IN] bandwidthAfc Sets the AFC Bandwidth ( FSK only ) |
mluis | 0:45c4f0364ca4 | 161 | * FSK : >= 2600 and <= 250000 Hz |
mluis | 0:45c4f0364ca4 | 162 | * LoRa: N/A ( set to 0 ) |
mluis | 0:45c4f0364ca4 | 163 | * @param [IN] preambleLen Sets the Preamble length ( LoRa only ) |
mluis | 0:45c4f0364ca4 | 164 | * FSK : N/A ( set to 0 ) |
mluis | 0:45c4f0364ca4 | 165 | * LoRa: Length in symbols ( the hardware adds 4 more symbols ) |
mluis | 7:b988b60083a1 | 166 | * @param [IN] symbTimeout Sets the RxSingle timeout value |
mluis | 7:b988b60083a1 | 167 | * FSK : timeout number of bytes |
mluis | 0:45c4f0364ca4 | 168 | * LoRa: timeout in symbols |
mluis | 0:45c4f0364ca4 | 169 | * @param [IN] fixLen Fixed length packets [0: variable, 1: fixed] |
mluis | 0:45c4f0364ca4 | 170 | * @param [IN] payloadLen Sets payload length when fixed lenght is used |
mluis | 0:45c4f0364ca4 | 171 | * @param [IN] crcOn Enables/Disables the CRC [0: OFF, 1: ON] |
mluis | 0:45c4f0364ca4 | 172 | * @param [IN] freqHopOn Enables disables the intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only) |
mluis | 0:45c4f0364ca4 | 173 | * @param [IN] hopPeriod Number of symbols bewteen each hop (LoRa only) |
mluis | 0:45c4f0364ca4 | 174 | * @param [IN] iqInverted Inverts IQ signals ( LoRa only ) |
mluis | 0:45c4f0364ca4 | 175 | * FSK : N/A ( set to 0 ) |
mluis | 0:45c4f0364ca4 | 176 | * LoRa: [0: not inverted, 1: inverted] |
mluis | 0:45c4f0364ca4 | 177 | * @param [IN] rxContinuous Sets the reception in continuous mode |
mluis | 0:45c4f0364ca4 | 178 | * [false: single mode, true: continuous mode] |
mluis | 0:45c4f0364ca4 | 179 | */ |
mluis | 0:45c4f0364ca4 | 180 | virtual void SetRxConfig ( RadioModems_t modem, uint32_t bandwidth, |
mluis | 0:45c4f0364ca4 | 181 | uint32_t datarate, uint8_t coderate, |
mluis | 0:45c4f0364ca4 | 182 | uint32_t bandwidthAfc, uint16_t preambleLen, |
mluis | 0:45c4f0364ca4 | 183 | uint16_t symbTimeout, bool fixLen, |
mluis | 0:45c4f0364ca4 | 184 | uint8_t payloadLen, |
mluis | 0:45c4f0364ca4 | 185 | bool crcOn, bool freqHopOn, uint8_t hopPeriod, |
mluis | 0:45c4f0364ca4 | 186 | bool iqInverted, bool rxContinuous ) = 0; |
mluis | 0:45c4f0364ca4 | 187 | /*! |
mluis | 0:45c4f0364ca4 | 188 | * @brief Sets the transmission parameters |
mluis | 0:45c4f0364ca4 | 189 | * |
mluis | 0:45c4f0364ca4 | 190 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
mluis | 0:45c4f0364ca4 | 191 | * @param [IN] power Sets the output power [dBm] |
mluis | 0:45c4f0364ca4 | 192 | * @param [IN] fdev Sets the frequency deviation ( FSK only ) |
mluis | 0:45c4f0364ca4 | 193 | * FSK : [Hz] |
mluis | 0:45c4f0364ca4 | 194 | * LoRa: 0 |
mluis | 0:45c4f0364ca4 | 195 | * @param [IN] bandwidth Sets the bandwidth ( LoRa only ) |
mluis | 0:45c4f0364ca4 | 196 | * FSK : 0 |
mluis | 0:45c4f0364ca4 | 197 | * LoRa: [0: 125 kHz, 1: 250 kHz, |
mluis | 0:45c4f0364ca4 | 198 | * 2: 500 kHz, 3: Reserved] |
mluis | 0:45c4f0364ca4 | 199 | * @param [IN] datarate Sets the Datarate |
mluis | 0:45c4f0364ca4 | 200 | * FSK : 600..300000 bits/s |
mluis | 0:45c4f0364ca4 | 201 | * LoRa: [6: 64, 7: 128, 8: 256, 9: 512, |
mluis | 0:45c4f0364ca4 | 202 | * 10: 1024, 11: 2048, 12: 4096 chips] |
mluis | 0:45c4f0364ca4 | 203 | * @param [IN] coderate Sets the coding rate ( LoRa only ) |
mluis | 0:45c4f0364ca4 | 204 | * FSK : N/A ( set to 0 ) |
mluis | 0:45c4f0364ca4 | 205 | * LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] |
mluis | 0:45c4f0364ca4 | 206 | * @param [IN] preambleLen Sets the preamble length |
mluis | 0:45c4f0364ca4 | 207 | * @param [IN] fixLen Fixed length packets [0: variable, 1: fixed] |
mluis | 0:45c4f0364ca4 | 208 | * @param [IN] crcOn Enables disables the CRC [0: OFF, 1: ON] |
mluis | 0:45c4f0364ca4 | 209 | * @param [IN] freqHopOn Enables disables the intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only) |
mluis | 0:45c4f0364ca4 | 210 | * @param [IN] hopPeriod Number of symbols bewteen each hop (LoRa only) |
mluis | 0:45c4f0364ca4 | 211 | * @param [IN] iqInverted Inverts IQ signals ( LoRa only ) |
mluis | 0:45c4f0364ca4 | 212 | * FSK : N/A ( set to 0 ) |
mluis | 0:45c4f0364ca4 | 213 | * LoRa: [0: not inverted, 1: inverted] |
mluis | 0:45c4f0364ca4 | 214 | * @param [IN] timeout Transmission timeout [us] |
mluis | 0:45c4f0364ca4 | 215 | */ |
mluis | 0:45c4f0364ca4 | 216 | virtual void SetTxConfig( RadioModems_t modem, int8_t power, uint32_t fdev, |
mluis | 0:45c4f0364ca4 | 217 | uint32_t bandwidth, uint32_t datarate, |
mluis | 0:45c4f0364ca4 | 218 | uint8_t coderate, uint16_t preambleLen, |
mluis | 0:45c4f0364ca4 | 219 | bool fixLen, bool crcOn, bool freqHopOn, |
mluis | 0:45c4f0364ca4 | 220 | uint8_t hopPeriod, bool iqInverted, uint32_t timeout ) = 0; |
mluis | 0:45c4f0364ca4 | 221 | /*! |
mluis | 0:45c4f0364ca4 | 222 | * @brief Checks if the given RF frequency is supported by the hardware |
mluis | 0:45c4f0364ca4 | 223 | * |
mluis | 0:45c4f0364ca4 | 224 | * @param [IN] frequency RF frequency to be checked |
mluis | 0:45c4f0364ca4 | 225 | * @retval isSupported [true: supported, false: unsupported] |
mluis | 0:45c4f0364ca4 | 226 | */ |
mluis | 0:45c4f0364ca4 | 227 | virtual bool CheckRfFrequency( uint32_t frequency ) = 0; |
mluis | 0:45c4f0364ca4 | 228 | /*! |
mluis | 0:45c4f0364ca4 | 229 | * @brief Computes the packet time on air for the given payload |
mluis | 0:45c4f0364ca4 | 230 | * |
mluis | 0:45c4f0364ca4 | 231 | * \Remark Can only be called once SetRxConfig or SetTxConfig have been called |
mluis | 0:45c4f0364ca4 | 232 | * |
mluis | 0:45c4f0364ca4 | 233 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
mluis | 0:45c4f0364ca4 | 234 | * @param [IN] pktLen Packet payload length |
mluis | 0:45c4f0364ca4 | 235 | * |
mluis | 0:45c4f0364ca4 | 236 | * @retval airTime Computed airTime for the given packet payload length |
mluis | 0:45c4f0364ca4 | 237 | */ |
mluis | 7:b988b60083a1 | 238 | virtual uint32_t TimeOnAir ( RadioModems_t modem, uint8_t pktLen ) = 0; |
mluis | 0:45c4f0364ca4 | 239 | /*! |
mluis | 0:45c4f0364ca4 | 240 | * @brief Sends the buffer of size. Prepares the packet to be sent and sets |
mluis | 0:45c4f0364ca4 | 241 | * the radio in transmission |
mluis | 0:45c4f0364ca4 | 242 | * |
mluis | 0:45c4f0364ca4 | 243 | * @param [IN]: buffer Buffer pointer |
mluis | 0:45c4f0364ca4 | 244 | * @param [IN]: size Buffer size |
mluis | 0:45c4f0364ca4 | 245 | */ |
mluis | 0:45c4f0364ca4 | 246 | virtual void Send( uint8_t *buffer, uint8_t size ) = 0; |
mluis | 0:45c4f0364ca4 | 247 | /*! |
mluis | 0:45c4f0364ca4 | 248 | * @brief Sets the radio in sleep mode |
mluis | 0:45c4f0364ca4 | 249 | */ |
mluis | 0:45c4f0364ca4 | 250 | virtual void Sleep( void ) = 0; |
mluis | 0:45c4f0364ca4 | 251 | /*! |
mluis | 0:45c4f0364ca4 | 252 | * @brief Sets the radio in standby mode |
mluis | 0:45c4f0364ca4 | 253 | */ |
mluis | 0:45c4f0364ca4 | 254 | virtual void Standby( void ) = 0; |
mluis | 0:45c4f0364ca4 | 255 | /*! |
mluis | 0:45c4f0364ca4 | 256 | * @brief Sets the radio in CAD mode |
mluis | 0:45c4f0364ca4 | 257 | */ |
mluis | 0:45c4f0364ca4 | 258 | virtual void StartCad( void ) = 0; |
mluis | 0:45c4f0364ca4 | 259 | /*! |
mluis | 0:45c4f0364ca4 | 260 | * @brief Sets the radio in reception mode for the given time |
mluis | 0:45c4f0364ca4 | 261 | * @param [IN] timeout Reception timeout [us] |
mluis | 0:45c4f0364ca4 | 262 | * [0: continuous, others timeout] |
mluis | 0:45c4f0364ca4 | 263 | */ |
mluis | 0:45c4f0364ca4 | 264 | virtual void Rx( uint32_t timeout ) = 0; |
mluis | 0:45c4f0364ca4 | 265 | /*! |
mluis | 0:45c4f0364ca4 | 266 | * @brief Sets the radio in transmission mode for the given time |
mluis | 0:45c4f0364ca4 | 267 | * @param [IN] timeout Transmission timeout [us] |
mluis | 0:45c4f0364ca4 | 268 | * [0: continuous, others timeout] |
mluis | 0:45c4f0364ca4 | 269 | */ |
mluis | 0:45c4f0364ca4 | 270 | virtual void Tx( uint32_t timeout ) = 0; |
mluis | 7:b988b60083a1 | 271 | /*! |
mluis | 7:b988b60083a1 | 272 | * @brief Sets the radio in continuous wave transmission mode |
mluis | 7:b988b60083a1 | 273 | * |
mluis | 7:b988b60083a1 | 274 | * @param [IN]: freq Channel RF frequency |
mluis | 7:b988b60083a1 | 275 | * @param [IN]: power Sets the output power [dBm] |
mluis | 7:b988b60083a1 | 276 | * @param [IN]: time Transmission mode timeout [s] |
mluis | 7:b988b60083a1 | 277 | */ |
mluis | 7:b988b60083a1 | 278 | virtual void SetTxContinuousWave( uint32_t freq, int8_t power, uint16_t time ) = 0; |
mluis | 0:45c4f0364ca4 | 279 | /*! |
mluis | 0:45c4f0364ca4 | 280 | * @brief Reads the current RSSI value |
mluis | 0:45c4f0364ca4 | 281 | * |
mluis | 0:45c4f0364ca4 | 282 | * @retval rssiValue Current RSSI value in [dBm] |
mluis | 0:45c4f0364ca4 | 283 | */ |
mluis | 0:45c4f0364ca4 | 284 | virtual int16_t GetRssi ( RadioModems_t modem ) = 0; |
mluis | 0:45c4f0364ca4 | 285 | /*! |
mluis | 0:45c4f0364ca4 | 286 | * @brief Writes the radio register at the specified address |
mluis | 0:45c4f0364ca4 | 287 | * |
mluis | 0:45c4f0364ca4 | 288 | * @param [IN]: addr Register address |
mluis | 0:45c4f0364ca4 | 289 | * @param [IN]: data New register value |
mluis | 0:45c4f0364ca4 | 290 | */ |
mluis | 0:45c4f0364ca4 | 291 | virtual void Write ( uint8_t addr, uint8_t data ) = 0; |
mluis | 0:45c4f0364ca4 | 292 | /*! |
mluis | 0:45c4f0364ca4 | 293 | * @brief Reads the radio register at the specified address |
mluis | 0:45c4f0364ca4 | 294 | * |
mluis | 0:45c4f0364ca4 | 295 | * @param [IN]: addr Register address |
mluis | 0:45c4f0364ca4 | 296 | * @retval data Register value |
mluis | 0:45c4f0364ca4 | 297 | */ |
mluis | 0:45c4f0364ca4 | 298 | virtual uint8_t Read ( uint8_t addr ) = 0; |
mluis | 0:45c4f0364ca4 | 299 | /*! |
mluis | 0:45c4f0364ca4 | 300 | * @brief Writes multiple radio registers starting at address |
mluis | 0:45c4f0364ca4 | 301 | * |
mluis | 0:45c4f0364ca4 | 302 | * @param [IN] addr First Radio register address |
mluis | 0:45c4f0364ca4 | 303 | * @param [IN] buffer Buffer containing the new register's values |
mluis | 0:45c4f0364ca4 | 304 | * @param [IN] size Number of registers to be written |
mluis | 0:45c4f0364ca4 | 305 | */ |
mluis | 0:45c4f0364ca4 | 306 | virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) = 0; |
mluis | 0:45c4f0364ca4 | 307 | /*! |
mluis | 0:45c4f0364ca4 | 308 | * @brief Reads multiple radio registers starting at address |
mluis | 0:45c4f0364ca4 | 309 | * |
mluis | 0:45c4f0364ca4 | 310 | * @param [IN] addr First Radio register address |
mluis | 0:45c4f0364ca4 | 311 | * @param [OUT] buffer Buffer where to copy the registers data |
mluis | 0:45c4f0364ca4 | 312 | * @param [IN] size Number of registers to be read |
mluis | 0:45c4f0364ca4 | 313 | */ |
mluis | 0:45c4f0364ca4 | 314 | virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) = 0; |
mluis | 0:45c4f0364ca4 | 315 | /*! |
mluis | 7:b988b60083a1 | 316 | * @brief Writes the buffer contents to the Radio FIFO |
mluis | 0:45c4f0364ca4 | 317 | * |
mluis | 0:45c4f0364ca4 | 318 | * @param [IN] buffer Buffer containing data to be put on the FIFO. |
mluis | 0:45c4f0364ca4 | 319 | * @param [IN] size Number of bytes to be written to the FIFO |
mluis | 0:45c4f0364ca4 | 320 | */ |
mluis | 0:45c4f0364ca4 | 321 | virtual void WriteFifo( uint8_t *buffer, uint8_t size ) = 0; |
mluis | 0:45c4f0364ca4 | 322 | /*! |
mluis | 7:b988b60083a1 | 323 | * @brief Reads the contents of the Radio FIFO |
mluis | 0:45c4f0364ca4 | 324 | * |
mluis | 0:45c4f0364ca4 | 325 | * @param [OUT] buffer Buffer where to copy the FIFO read data. |
mluis | 0:45c4f0364ca4 | 326 | * @param [IN] size Number of bytes to be read from the FIFO |
mluis | 0:45c4f0364ca4 | 327 | */ |
mluis | 0:45c4f0364ca4 | 328 | virtual void ReadFifo( uint8_t *buffer, uint8_t size ) = 0; |
mluis | 0:45c4f0364ca4 | 329 | /*! |
mluis | 0:45c4f0364ca4 | 330 | * @brief Sets the maximum payload length. |
mluis | 0:45c4f0364ca4 | 331 | * |
mluis | 0:45c4f0364ca4 | 332 | * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa] |
mluis | 0:45c4f0364ca4 | 333 | * @param [IN] max Maximum payload length in bytes |
mluis | 0:45c4f0364ca4 | 334 | */ |
mluis | 0:45c4f0364ca4 | 335 | virtual void SetMaxPayloadLength( RadioModems_t modem, uint8_t max ) = 0; |
mluis | 7:b988b60083a1 | 336 | /*! |
mluis | 7:b988b60083a1 | 337 | * @brief Sets the network to public or private. Updates the sync byte. |
mluis | 7:b988b60083a1 | 338 | * |
mluis | 7:b988b60083a1 | 339 | * @remark Applies to LoRa modem only |
mluis | 7:b988b60083a1 | 340 | * |
mluis | 7:b988b60083a1 | 341 | * @param [IN] enable if true, it enables a public network |
mluis | 7:b988b60083a1 | 342 | */ |
mluis | 7:b988b60083a1 | 343 | virtual void SetPublicNetwork( bool enable ) = 0; |
mluis | 0:45c4f0364ca4 | 344 | }; |
mluis | 0:45c4f0364ca4 | 345 | |
mluis | 0:45c4f0364ca4 | 346 | #endif // __RADIO_H__ |