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