This library update contains changes according to the HW-modification.

Dependents:   LoRaWAN_Serial_port_driven_and_configurable_ELMO_based_on_TxRx_Template

Fork of SX1272lib by Espotel

Changes compared to original SX1272lib:

HW modification was made to remove RFO-output and replaced with PABOOST-output. PASELECT changed accordingly.

Committer:
Daniel_espo
Date:
Mon Jun 27 11:23:29 2016 +0000
Revision:
11:3133174407a2
Parent:
9:f53b11725565
Fix compilation issue

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WGorniak 0:669f3b0e91c8 1 /*
WGorniak 0:669f3b0e91c8 2 / _____) _ | |
WGorniak 0:669f3b0e91c8 3 ( (____ _____ ____ _| |_ _____ ____| |__
WGorniak 0:669f3b0e91c8 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
WGorniak 0:669f3b0e91c8 5 _____) ) ____| | | || |_| ____( (___| | | |
WGorniak 0:669f3b0e91c8 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
WGorniak 0:669f3b0e91c8 7 ( C ) Semtech
WGorniak 0:669f3b0e91c8 8
WGorniak 0:669f3b0e91c8 9 Description: Port of Semtech SX1276 C++ library to support SX1272 chipset performed by Espotel
WGorniak 0:669f3b0e91c8 10
WGorniak 0:669f3b0e91c8 11 License: Revised BSD License, see LICENSE.TXT file include in the project
WGorniak 0:669f3b0e91c8 12
WGorniak 0:669f3b0e91c8 13 Maintainers: www.espotel.com
WGorniak 0:669f3b0e91c8 14
WGorniak 0:669f3b0e91c8 15 */
WGorniak 0:669f3b0e91c8 16 #ifndef __SX1272_H__
WGorniak 0:669f3b0e91c8 17 #define __SX1272_H__
WGorniak 0:669f3b0e91c8 18
WGorniak 0:669f3b0e91c8 19 #include "radio.h"
WGorniak 0:669f3b0e91c8 20 #include "./registers/sx1272Regs-Fsk.h"
WGorniak 0:669f3b0e91c8 21 #include "./registers/sx1272Regs-LoRa.h"
WGorniak 0:669f3b0e91c8 22 #include "./typedefs/typedefs.h"
WGorniak 0:669f3b0e91c8 23 /*!
WGorniak 0:669f3b0e91c8 24 * Radio wakeup time from SLEEP mode
WGorniak 0:669f3b0e91c8 25 */
WGorniak 0:669f3b0e91c8 26 #define RADIO_WAKEUP_TIME 1000 // [us]
WGorniak 0:669f3b0e91c8 27
WGorniak 0:669f3b0e91c8 28 /*!
WGorniak 0:669f3b0e91c8 29 * SX1276 definitions
WGorniak 0:669f3b0e91c8 30 */
WGorniak 0:669f3b0e91c8 31 #define XTAL_FREQ 32000000
WGorniak 0:669f3b0e91c8 32 #define FREQ_STEP 61.03515625
WGorniak 0:669f3b0e91c8 33
WGorniak 0:669f3b0e91c8 34 #define RX_BUFFER_SIZE 256
WGorniak 0:669f3b0e91c8 35
WGorniak 0:669f3b0e91c8 36 #define DEFAULT_TIMEOUT 200 //usec
mleksio 9:f53b11725565 37
WGorniak 0:669f3b0e91c8 38 #define RSSI_OFFSET -139.0
WGorniak 0:669f3b0e91c8 39
WGorniak 0:669f3b0e91c8 40 /*!
WGorniak 0:669f3b0e91c8 41 * Constant values need to compute the RSSI value
WGorniak 0:669f3b0e91c8 42 */
WGorniak 0:669f3b0e91c8 43 //#define RSSI_OFFSET_LF -164.0
WGorniak 0:669f3b0e91c8 44 //#define RSSI_OFFSET_HF -157.0
WGorniak 0:669f3b0e91c8 45
WGorniak 0:669f3b0e91c8 46 //#define RF_MID_BAND_THRESH 525000000
WGorniak 0:669f3b0e91c8 47
WGorniak 0:669f3b0e91c8 48 /*!
WGorniak 0:669f3b0e91c8 49 * Actual implementation of a SX1276 radio, inherits Radio
WGorniak 0:669f3b0e91c8 50 */
WGorniak 0:669f3b0e91c8 51 class SX1272 : public Radio
WGorniak 0:669f3b0e91c8 52 {
WGorniak 0:669f3b0e91c8 53 protected:
WGorniak 0:669f3b0e91c8 54 /*!
WGorniak 0:669f3b0e91c8 55 * SPI Interface
WGorniak 0:669f3b0e91c8 56 */
WGorniak 0:669f3b0e91c8 57 SPI spi; // mosi, miso, sclk
WGorniak 0:669f3b0e91c8 58 DigitalOut nss;
WGorniak 0:669f3b0e91c8 59
WGorniak 0:669f3b0e91c8 60 /*!
WGorniak 0:669f3b0e91c8 61 * SX1276 Reset pin
WGorniak 0:669f3b0e91c8 62 */
WGorniak 0:669f3b0e91c8 63 DigitalInOut reset;
WGorniak 0:669f3b0e91c8 64
WGorniak 0:669f3b0e91c8 65 /*!
WGorniak 0:669f3b0e91c8 66 * SX1276 DIO pins
WGorniak 0:669f3b0e91c8 67 */
WGorniak 0:669f3b0e91c8 68 InterruptIn dio0;
WGorniak 0:669f3b0e91c8 69 InterruptIn dio1;
WGorniak 0:669f3b0e91c8 70 InterruptIn dio2;
WGorniak 0:669f3b0e91c8 71 InterruptIn dio3;
WGorniak 0:669f3b0e91c8 72 InterruptIn dio4;
WGorniak 0:669f3b0e91c8 73 DigitalIn dio5;
WGorniak 0:669f3b0e91c8 74
WGorniak 0:669f3b0e91c8 75 bool isRadioActive;
WGorniak 0:669f3b0e91c8 76
mleksio 9:f53b11725565 77 uint8_t *rxTxBuffer;
WGorniak 0:669f3b0e91c8 78
WGorniak 0:669f3b0e91c8 79 uint8_t previousOpMode;
WGorniak 0:669f3b0e91c8 80
WGorniak 0:669f3b0e91c8 81 /*!
WGorniak 0:669f3b0e91c8 82 * Hardware DIO IRQ functions
WGorniak 0:669f3b0e91c8 83 */
WGorniak 0:669f3b0e91c8 84 DioIrqHandler *dioIrq;
WGorniak 0:669f3b0e91c8 85
WGorniak 0:669f3b0e91c8 86 /*!
WGorniak 0:669f3b0e91c8 87 * Tx and Rx timers
WGorniak 0:669f3b0e91c8 88 */
WGorniak 0:669f3b0e91c8 89 Timeout txTimeoutTimer;
WGorniak 0:669f3b0e91c8 90 Timeout rxTimeoutTimer;
WGorniak 0:669f3b0e91c8 91 Timeout rxTimeoutSyncWord;
WGorniak 0:669f3b0e91c8 92
WGorniak 0:669f3b0e91c8 93 /*!
WGorniak 0:669f3b0e91c8 94 * rxTx: [1: Tx, 0: Rx]
WGorniak 0:669f3b0e91c8 95 */
WGorniak 0:669f3b0e91c8 96 uint8_t rxTx;
WGorniak 0:669f3b0e91c8 97
WGorniak 0:669f3b0e91c8 98 RadioSettings_t settings;
WGorniak 0:669f3b0e91c8 99
WGorniak 0:669f3b0e91c8 100 static const FskBandwidth_t FskBandwidths[] ;
WGorniak 3:81cc2c384b1b 101
WGorniak 0:669f3b0e91c8 102 protected:
WGorniak 0:669f3b0e91c8 103
WGorniak 0:669f3b0e91c8 104 /*!
WGorniak 0:669f3b0e91c8 105 * Performs the Rx chain calibration for LF and HF bands
WGorniak 0:669f3b0e91c8 106 * \remark Must be called just after the reset so all registers are at their
WGorniak 0:669f3b0e91c8 107 * default values
WGorniak 0:669f3b0e91c8 108 */
WGorniak 0:669f3b0e91c8 109 void RxChainCalibration( void );
WGorniak 0:669f3b0e91c8 110
WGorniak 0:669f3b0e91c8 111 public:
WGorniak 0:669f3b0e91c8 112 SX1272( void ( *txDone )( ), void ( *txTimeout ) ( ), void ( *rxDone ) ( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ),
WGorniak 0:669f3b0e91c8 113 void ( *rxTimeout ) ( ), void ( *rxError ) ( ), void ( *fhssChangeChannel ) ( uint8_t channelIndex ), void ( *cadDone ) ( bool channelActivityDetected ),
WGorniak 0:669f3b0e91c8 114 PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset,
WGorniak 0:669f3b0e91c8 115 PinName dio0, PinName dio1, PinName dio2, PinName dio3, PinName dio4, PinName dio5 );
WGorniak 0:669f3b0e91c8 116 SX1272( void ( *txDone )( ), void ( *txTimeout ) ( ), void ( *rxDone ) ( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ),
WGorniak 0:669f3b0e91c8 117 void ( *rxTimeout ) ( ), void ( *rxError ) ( ), void ( *fhssChangeChannel ) ( uint8_t channelIndex ), void ( *cadDone ) ( bool channelActivityDetected ) );
WGorniak 0:669f3b0e91c8 118 virtual ~SX1272( );
WGorniak 0:669f3b0e91c8 119
WGorniak 3:81cc2c384b1b 120 int16_t rssi_last_received_packet;
WGorniak 3:81cc2c384b1b 121 int16_t rssi_current_packet;
WGorniak 3:81cc2c384b1b 122 int8_t snr_value;
WGorniak 3:81cc2c384b1b 123
WGorniak 0:669f3b0e91c8 124 //-------------------------------------------------------------------------
WGorniak 0:669f3b0e91c8 125 // Redefined Radio functions
WGorniak 0:669f3b0e91c8 126 //-------------------------------------------------------------------------
WGorniak 0:669f3b0e91c8 127 /*!
WGorniak 0:669f3b0e91c8 128 * Return current radio status
WGorniak 0:669f3b0e91c8 129 *
WGorniak 0:669f3b0e91c8 130 * @param status Radio status. [IDLE, RX_RUNNING, TX_RUNNING]
WGorniak 0:669f3b0e91c8 131 */
WGorniak 0:669f3b0e91c8 132 virtual RadioState GetState( void );
WGorniak 0:669f3b0e91c8 133
WGorniak 0:669f3b0e91c8 134 /*!
WGorniak 0:669f3b0e91c8 135 * @brief Configures the SX1276 with the given modem
WGorniak 0:669f3b0e91c8 136 *
WGorniak 0:669f3b0e91c8 137 * @param [IN] modem Modem to be used [0: FSK, 1: LoRa]
WGorniak 0:669f3b0e91c8 138 */
WGorniak 0:669f3b0e91c8 139 virtual void SetModem( ModemType modem );
WGorniak 0:669f3b0e91c8 140
WGorniak 0:669f3b0e91c8 141 /*!
WGorniak 0:669f3b0e91c8 142 * @brief Sets the channel frequency
WGorniak 0:669f3b0e91c8 143 *
WGorniak 0:669f3b0e91c8 144 * @param [IN] freq Channel RF frequency
WGorniak 0:669f3b0e91c8 145 */
WGorniak 0:669f3b0e91c8 146 virtual void SetChannel( uint32_t freq );
WGorniak 0:669f3b0e91c8 147
WGorniak 0:669f3b0e91c8 148 /*!
WGorniak 0:669f3b0e91c8 149 * @brief Sets the channels configuration
WGorniak 0:669f3b0e91c8 150 *
WGorniak 0:669f3b0e91c8 151 * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa]
WGorniak 0:669f3b0e91c8 152 * @param [IN] freq Channel RF frequency
WGorniak 0:669f3b0e91c8 153 * @param [IN] rssiThresh RSSI threshold
WGorniak 0:669f3b0e91c8 154 *
WGorniak 0:669f3b0e91c8 155 * @retval isFree [true: Channel is free, false: Channel is not free]
WGorniak 0:669f3b0e91c8 156 */
WGorniak 0:669f3b0e91c8 157 virtual bool IsChannelFree( ModemType modem, uint32_t freq, int8_t rssiThresh );
WGorniak 0:669f3b0e91c8 158
WGorniak 0:669f3b0e91c8 159 /*!
WGorniak 0:669f3b0e91c8 160 * @brief Generates a 32 bits random value based on the RSSI readings
WGorniak 0:669f3b0e91c8 161 *
WGorniak 0:669f3b0e91c8 162 * \remark This function sets the radio in LoRa modem mode and disables
WGorniak 0:669f3b0e91c8 163 * all interrupts.
WGorniak 0:669f3b0e91c8 164 * After calling this function either Radio.SetRxConfig or
WGorniak 0:669f3b0e91c8 165 * Radio.SetTxConfig functions must be called.
WGorniak 0:669f3b0e91c8 166 *
WGorniak 0:669f3b0e91c8 167 * @retval randomValue 32 bits random value
WGorniak 0:669f3b0e91c8 168 */
WGorniak 0:669f3b0e91c8 169 virtual uint32_t Random( void );
WGorniak 0:669f3b0e91c8 170
WGorniak 0:669f3b0e91c8 171 /*!
WGorniak 0:669f3b0e91c8 172 * @brief Sets the reception parameters
WGorniak 0:669f3b0e91c8 173 *
WGorniak 0:669f3b0e91c8 174 * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa]
WGorniak 0:669f3b0e91c8 175 * @param [IN] bandwidth Sets the bandwidth
WGorniak 0:669f3b0e91c8 176 * FSK : >= 2600 and <= 250000 Hz
WGorniak 0:669f3b0e91c8 177 * LoRa: [0: 125 kHz, 1: 250 kHz,
WGorniak 0:669f3b0e91c8 178 * 2: 500 kHz, 3: Reserved]
WGorniak 0:669f3b0e91c8 179 * @param [IN] datarate Sets the Datarate
WGorniak 0:669f3b0e91c8 180 * FSK : 600..300000 bits/s
WGorniak 0:669f3b0e91c8 181 * LoRa: [6: 64, 7: 128, 8: 256, 9: 512,
WGorniak 0:669f3b0e91c8 182 * 10: 1024, 11: 2048, 12: 4096 chips]
WGorniak 0:669f3b0e91c8 183 * @param [IN] coderate Sets the coding rate ( LoRa only )
WGorniak 0:669f3b0e91c8 184 * FSK : N/A ( set to 0 )
WGorniak 0:669f3b0e91c8 185 * LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
WGorniak 0:669f3b0e91c8 186 * @param [IN] bandwidthAfc Sets the AFC Bandwidth ( FSK only )
WGorniak 0:669f3b0e91c8 187 * FSK : >= 2600 and <= 250000 Hz
WGorniak 0:669f3b0e91c8 188 * LoRa: N/A ( set to 0 )
WGorniak 0:669f3b0e91c8 189 * @param [IN] preambleLen Sets the Preamble length ( LoRa only )
mleksio 9:f53b11725565 190 * FSK : Number of bytes
WGorniak 0:669f3b0e91c8 191 * LoRa: Length in symbols ( the hardware adds 4 more symbols )
WGorniak 0:669f3b0e91c8 192 * @param [IN] symbTimeout Sets the RxSingle timeout value ( LoRa only )
WGorniak 0:669f3b0e91c8 193 * FSK : N/A ( set to 0 )
WGorniak 0:669f3b0e91c8 194 * LoRa: timeout in symbols
WGorniak 0:669f3b0e91c8 195 * @param [IN] fixLen Fixed length packets [0: variable, 1: fixed]
WGorniak 0:669f3b0e91c8 196 * @param [IN] payloadLen Sets payload length when fixed lenght is used
WGorniak 0:669f3b0e91c8 197 * @param [IN] crcOn Enables/Disables the CRC [0: OFF, 1: ON]
WGorniak 0:669f3b0e91c8 198 * @param [IN] freqHopOn Enables disables the intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only)
mleksio 9:f53b11725565 199 * FSK : N/A ( set to 0 )
mleksio 9:f53b11725565 200 * LoRa: [0: OFF, 1: ON]
WGorniak 0:669f3b0e91c8 201 * @param [IN] hopPeriod Number of symbols bewteen each hop (LoRa only)
mleksio 9:f53b11725565 202 * FSK : N/A ( set to 0 )
mleksio 9:f53b11725565 203 * LoRa: Number of symbols
WGorniak 0:669f3b0e91c8 204 * @param [IN] iqInverted Inverts IQ signals ( LoRa only )
WGorniak 0:669f3b0e91c8 205 * FSK : N/A ( set to 0 )
WGorniak 0:669f3b0e91c8 206 * LoRa: [0: not inverted, 1: inverted]
WGorniak 0:669f3b0e91c8 207 * @param [IN] rxContinuous Sets the reception in continuous mode
WGorniak 0:669f3b0e91c8 208 * [false: single mode, true: continuous mode]
WGorniak 0:669f3b0e91c8 209 */
WGorniak 0:669f3b0e91c8 210 virtual void SetRxConfig ( ModemType modem, uint32_t bandwidth,
WGorniak 0:669f3b0e91c8 211 uint32_t datarate, uint8_t coderate,
WGorniak 0:669f3b0e91c8 212 uint32_t bandwidthAfc, uint16_t preambleLen,
WGorniak 0:669f3b0e91c8 213 uint16_t symbTimeout, bool fixLen,
WGorniak 0:669f3b0e91c8 214 uint8_t payloadLen,
WGorniak 0:669f3b0e91c8 215 bool crcOn, bool freqHopOn, uint8_t hopPeriod,
WGorniak 0:669f3b0e91c8 216 bool iqInverted, bool rxContinuous );
WGorniak 0:669f3b0e91c8 217
WGorniak 0:669f3b0e91c8 218 /*!
WGorniak 0:669f3b0e91c8 219 * @brief Sets the transmission parameters
WGorniak 0:669f3b0e91c8 220 *
WGorniak 0:669f3b0e91c8 221 * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa]
WGorniak 0:669f3b0e91c8 222 * @param [IN] power Sets the output power [dBm]
WGorniak 0:669f3b0e91c8 223 * @param [IN] fdev Sets the frequency deviation ( FSK only )
WGorniak 0:669f3b0e91c8 224 * FSK : [Hz]
WGorniak 0:669f3b0e91c8 225 * LoRa: 0
WGorniak 0:669f3b0e91c8 226 * @param [IN] bandwidth Sets the bandwidth ( LoRa only )
WGorniak 0:669f3b0e91c8 227 * FSK : 0
WGorniak 0:669f3b0e91c8 228 * LoRa: [0: 125 kHz, 1: 250 kHz,
WGorniak 0:669f3b0e91c8 229 * 2: 500 kHz, 3: Reserved]
WGorniak 0:669f3b0e91c8 230 * @param [IN] datarate Sets the Datarate
WGorniak 0:669f3b0e91c8 231 * FSK : 600..300000 bits/s
WGorniak 0:669f3b0e91c8 232 * LoRa: [6: 64, 7: 128, 8: 256, 9: 512,
WGorniak 0:669f3b0e91c8 233 * 10: 1024, 11: 2048, 12: 4096 chips]
WGorniak 0:669f3b0e91c8 234 * @param [IN] coderate Sets the coding rate ( LoRa only )
WGorniak 0:669f3b0e91c8 235 * FSK : N/A ( set to 0 )
WGorniak 0:669f3b0e91c8 236 * LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
WGorniak 0:669f3b0e91c8 237 * @param [IN] preambleLen Sets the preamble length
mleksio 9:f53b11725565 238 * FSK : Number of bytes
mleksio 9:f53b11725565 239 * LoRa: Length in symbols (the hardware adds 4 more symbols)
WGorniak 0:669f3b0e91c8 240 * @param [IN] fixLen Fixed length packets [0: variable, 1: fixed]
WGorniak 0:669f3b0e91c8 241 * @param [IN] crcOn Enables disables the CRC [0: OFF, 1: ON]
WGorniak 0:669f3b0e91c8 242 * @param [IN] freqHopOn Enables disables the intra-packet frequency hopping [0: OFF, 1: ON] (LoRa only)
mleksio 9:f53b11725565 243 * FSK : N/A ( set to 0 )
mleksio 9:f53b11725565 244 * LoRa: [0: OFF, 1: ON]
WGorniak 0:669f3b0e91c8 245 * @param [IN] hopPeriod Number of symbols bewteen each hop (LoRa only)
mleksio 9:f53b11725565 246 * FSK : N/A ( set to 0 )
mleksio 9:f53b11725565 247 * LoRa: Number of symbols
WGorniak 0:669f3b0e91c8 248 * @param [IN] iqInverted Inverts IQ signals ( LoRa only )
WGorniak 0:669f3b0e91c8 249 * FSK : N/A ( set to 0 )
WGorniak 0:669f3b0e91c8 250 * LoRa: [0: not inverted, 1: inverted]
WGorniak 0:669f3b0e91c8 251 * @param [IN] timeout Transmission timeout [us]
WGorniak 0:669f3b0e91c8 252 */
WGorniak 0:669f3b0e91c8 253 virtual void SetTxConfig( ModemType modem, int8_t power, uint32_t fdev,
WGorniak 0:669f3b0e91c8 254 uint32_t bandwidth, uint32_t datarate,
WGorniak 0:669f3b0e91c8 255 uint8_t coderate, uint16_t preambleLen,
WGorniak 0:669f3b0e91c8 256 bool fixLen, bool crcOn, bool freqHopOn,
WGorniak 0:669f3b0e91c8 257 uint8_t hopPeriod, bool iqInverted, uint32_t timeout );
WGorniak 3:81cc2c384b1b 258
WGorniak 3:81cc2c384b1b 259 /*!
WGorniak 3:81cc2c384b1b 260 * @brief Sets the transmission parameters with forced paBoost
WGorniak 3:81cc2c384b1b 261 *
WGorniak 3:81cc2c384b1b 262 */
WGorniak 3:81cc2c384b1b 263 void SetTxConfig( ModemType modem, int8_t power, uint32_t fdev,
WGorniak 3:81cc2c384b1b 264 uint32_t bandwidth, uint32_t datarate,
WGorniak 3:81cc2c384b1b 265 uint8_t coderate, uint16_t preambleLen,
WGorniak 3:81cc2c384b1b 266 bool fixLen, bool crcOn, bool freqHopOn,
WGorniak 3:81cc2c384b1b 267 uint8_t hopPeriod, bool iqInverted, uint32_t timeout,
WGorniak 3:81cc2c384b1b 268 bool paBoost);
WGorniak 0:669f3b0e91c8 269
WGorniak 0:669f3b0e91c8 270 /*!
WGorniak 0:669f3b0e91c8 271 * @brief Computes the packet time on air for the given payload
WGorniak 0:669f3b0e91c8 272 *
WGorniak 0:669f3b0e91c8 273 * \Remark Can only be called once SetRxConfig or SetTxConfig have been called
WGorniak 0:669f3b0e91c8 274 *
WGorniak 0:669f3b0e91c8 275 * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa]
WGorniak 0:669f3b0e91c8 276 * @param [IN] pktLen Packet payload length
WGorniak 0:669f3b0e91c8 277 *
WGorniak 0:669f3b0e91c8 278 * @retval airTime Computed airTime for the given packet payload length
WGorniak 0:669f3b0e91c8 279 */
WGorniak 0:669f3b0e91c8 280 virtual double TimeOnAir ( ModemType modem, uint8_t pktLen );
WGorniak 0:669f3b0e91c8 281
WGorniak 0:669f3b0e91c8 282 /*!
WGorniak 0:669f3b0e91c8 283 * @brief Sends the buffer of size. Prepares the packet to be sent and sets
WGorniak 0:669f3b0e91c8 284 * the radio in transmission
WGorniak 0:669f3b0e91c8 285 *
WGorniak 0:669f3b0e91c8 286 * @param [IN]: buffer Buffer pointer
WGorniak 0:669f3b0e91c8 287 * @param [IN]: size Buffer size
WGorniak 0:669f3b0e91c8 288 */
WGorniak 0:669f3b0e91c8 289 virtual void Send( uint8_t *buffer, uint8_t size );
WGorniak 0:669f3b0e91c8 290
WGorniak 0:669f3b0e91c8 291 /*!
WGorniak 0:669f3b0e91c8 292 * @brief Sets the radio in sleep mode
WGorniak 0:669f3b0e91c8 293 */
WGorniak 0:669f3b0e91c8 294 virtual void Sleep( void );
WGorniak 0:669f3b0e91c8 295
WGorniak 0:669f3b0e91c8 296 /*!
WGorniak 0:669f3b0e91c8 297 * @brief Sets the radio in standby mode
WGorniak 0:669f3b0e91c8 298 */
WGorniak 0:669f3b0e91c8 299 virtual void Standby( void );
WGorniak 0:669f3b0e91c8 300
WGorniak 0:669f3b0e91c8 301 /*!
WGorniak 0:669f3b0e91c8 302 * @brief Sets the radio in reception mode for the given time
WGorniak 0:669f3b0e91c8 303 * @param [IN] timeout Reception timeout [us]
WGorniak 0:669f3b0e91c8 304 * [0: continuous, others timeout]
WGorniak 0:669f3b0e91c8 305 */
WGorniak 0:669f3b0e91c8 306 virtual void Rx( uint32_t timeout );
WGorniak 0:669f3b0e91c8 307
WGorniak 0:669f3b0e91c8 308 /*!
WGorniak 0:669f3b0e91c8 309 * @brief Sets the radio in transmission mode for the given time
WGorniak 0:669f3b0e91c8 310 * @param [IN] timeout Transmission timeout [us]
WGorniak 0:669f3b0e91c8 311 * [0: continuous, others timeout]
WGorniak 0:669f3b0e91c8 312 */
WGorniak 0:669f3b0e91c8 313 virtual void Tx( uint32_t timeout );
WGorniak 0:669f3b0e91c8 314
WGorniak 0:669f3b0e91c8 315 /*!
WGorniak 0:669f3b0e91c8 316 * @brief Start a Channel Activity Detection
WGorniak 0:669f3b0e91c8 317 */
WGorniak 0:669f3b0e91c8 318 virtual void StartCad( void );
WGorniak 0:669f3b0e91c8 319
WGorniak 0:669f3b0e91c8 320 /*!
WGorniak 0:669f3b0e91c8 321 * @brief Reads the current RSSI value
WGorniak 0:669f3b0e91c8 322 *
WGorniak 0:669f3b0e91c8 323 * @retval rssiValue Current RSSI value in [dBm]
WGorniak 0:669f3b0e91c8 324 */
WGorniak 0:669f3b0e91c8 325 virtual int16_t GetRssi ( ModemType modem );
WGorniak 0:669f3b0e91c8 326
WGorniak 0:669f3b0e91c8 327 /*!
WGorniak 0:669f3b0e91c8 328 * @brief Writes the radio register at the specified address
WGorniak 0:669f3b0e91c8 329 *
WGorniak 0:669f3b0e91c8 330 * @param [IN]: addr Register address
WGorniak 0:669f3b0e91c8 331 * @param [IN]: data New register value
WGorniak 0:669f3b0e91c8 332 */
WGorniak 0:669f3b0e91c8 333 virtual void Write ( uint8_t addr, uint8_t data ) = 0;
WGorniak 0:669f3b0e91c8 334
WGorniak 0:669f3b0e91c8 335 /*!
WGorniak 0:669f3b0e91c8 336 * @brief Reads the radio register at the specified address
WGorniak 0:669f3b0e91c8 337 *
WGorniak 0:669f3b0e91c8 338 * @param [IN]: addr Register address
WGorniak 0:669f3b0e91c8 339 * @retval data Register value
WGorniak 0:669f3b0e91c8 340 */
WGorniak 0:669f3b0e91c8 341 virtual uint8_t Read ( uint8_t addr ) = 0;
WGorniak 0:669f3b0e91c8 342
WGorniak 0:669f3b0e91c8 343 /*!
WGorniak 0:669f3b0e91c8 344 * @brief Writes multiple radio registers starting at address
WGorniak 0:669f3b0e91c8 345 *
WGorniak 0:669f3b0e91c8 346 * @param [IN] addr First Radio register address
WGorniak 0:669f3b0e91c8 347 * @param [IN] buffer Buffer containing the new register's values
WGorniak 0:669f3b0e91c8 348 * @param [IN] size Number of registers to be written
WGorniak 0:669f3b0e91c8 349 */
WGorniak 0:669f3b0e91c8 350 virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) = 0;
WGorniak 0:669f3b0e91c8 351
WGorniak 0:669f3b0e91c8 352 /*!
WGorniak 0:669f3b0e91c8 353 * @brief Reads multiple radio registers starting at address
WGorniak 0:669f3b0e91c8 354 *
WGorniak 0:669f3b0e91c8 355 * @param [IN] addr First Radio register address
WGorniak 0:669f3b0e91c8 356 * @param [OUT] buffer Buffer where to copy the registers data
WGorniak 0:669f3b0e91c8 357 * @param [IN] size Number of registers to be read
WGorniak 0:669f3b0e91c8 358 */
WGorniak 0:669f3b0e91c8 359 virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) = 0;
WGorniak 0:669f3b0e91c8 360
WGorniak 0:669f3b0e91c8 361 /*!
WGorniak 0:669f3b0e91c8 362 * @brief Writes the buffer contents to the SX1276 FIFO
WGorniak 0:669f3b0e91c8 363 *
WGorniak 0:669f3b0e91c8 364 * @param [IN] buffer Buffer containing data to be put on the FIFO.
WGorniak 0:669f3b0e91c8 365 * @param [IN] size Number of bytes to be written to the FIFO
WGorniak 0:669f3b0e91c8 366 */
WGorniak 0:669f3b0e91c8 367 virtual void WriteFifo( uint8_t *buffer, uint8_t size ) = 0;
WGorniak 0:669f3b0e91c8 368
WGorniak 0:669f3b0e91c8 369 /*!
WGorniak 0:669f3b0e91c8 370 * @brief Reads the contents of the SX1276 FIFO
WGorniak 0:669f3b0e91c8 371 *
WGorniak 0:669f3b0e91c8 372 * @param [OUT] buffer Buffer where to copy the FIFO read data.
WGorniak 0:669f3b0e91c8 373 * @param [IN] size Number of bytes to be read from the FIFO
WGorniak 0:669f3b0e91c8 374 */
WGorniak 0:669f3b0e91c8 375 virtual void ReadFifo( uint8_t *buffer, uint8_t size ) = 0;
WGorniak 0:669f3b0e91c8 376 /*!
WGorniak 0:669f3b0e91c8 377 * @brief Resets the SX1276
WGorniak 0:669f3b0e91c8 378 */
WGorniak 0:669f3b0e91c8 379 virtual void Reset( void ) = 0;
WGorniak 0:669f3b0e91c8 380
mleksio 8:ead3f4cc5923 381 /*!
mleksio 8:ead3f4cc5923 382 * @brief Sets the maximum payload length.
mleksio 8:ead3f4cc5923 383 *
mleksio 8:ead3f4cc5923 384 * @param [IN] modem Radio modem to be used [0: FSK, 1: LoRa]
mleksio 8:ead3f4cc5923 385 * @param [IN] max Maximum payload length in bytes
mleksio 8:ead3f4cc5923 386 */
mleksio 8:ead3f4cc5923 387 virtual void SetMaxPayloadLength( ModemType modem, uint8_t max );
mleksio 8:ead3f4cc5923 388
WGorniak 0:669f3b0e91c8 389 //-------------------------------------------------------------------------
WGorniak 0:669f3b0e91c8 390 // Board relative functions
WGorniak 0:669f3b0e91c8 391 //-------------------------------------------------------------------------
WGorniak 0:669f3b0e91c8 392
WGorniak 0:669f3b0e91c8 393 protected:
WGorniak 0:669f3b0e91c8 394 /*!
WGorniak 0:669f3b0e91c8 395 * @brief Initializes the radio I/Os pins interface
WGorniak 0:669f3b0e91c8 396 */
WGorniak 0:669f3b0e91c8 397 virtual void IoInit( void ) = 0;
WGorniak 0:669f3b0e91c8 398
WGorniak 0:669f3b0e91c8 399 /*!
WGorniak 0:669f3b0e91c8 400 * @brief Initializes the radio registers
WGorniak 0:669f3b0e91c8 401 */
WGorniak 0:669f3b0e91c8 402 virtual void RadioRegistersInit( ) = 0;
WGorniak 0:669f3b0e91c8 403
WGorniak 0:669f3b0e91c8 404 /*!
WGorniak 0:669f3b0e91c8 405 * @brief Initializes the radio SPI
WGorniak 0:669f3b0e91c8 406 */
WGorniak 0:669f3b0e91c8 407 virtual void SpiInit( void ) = 0;
WGorniak 0:669f3b0e91c8 408
WGorniak 0:669f3b0e91c8 409 /*!
WGorniak 0:669f3b0e91c8 410 * @brief Initializes DIO IRQ handlers
WGorniak 0:669f3b0e91c8 411 *
WGorniak 0:669f3b0e91c8 412 * @param [IN] irqHandlers Array containing the IRQ callback functions
WGorniak 0:669f3b0e91c8 413 */
WGorniak 0:669f3b0e91c8 414 virtual void IoIrqInit( DioIrqHandler *irqHandlers ) = 0;
WGorniak 0:669f3b0e91c8 415
WGorniak 0:669f3b0e91c8 416 /*!
WGorniak 0:669f3b0e91c8 417 * @brief De-initializes the radio I/Os pins interface.
WGorniak 0:669f3b0e91c8 418 *
WGorniak 0:669f3b0e91c8 419 * \remark Useful when going in MCU lowpower modes
WGorniak 0:669f3b0e91c8 420 */
WGorniak 0:669f3b0e91c8 421 virtual void IoDeInit( void ) = 0;
WGorniak 0:669f3b0e91c8 422
WGorniak 0:669f3b0e91c8 423 /*!
WGorniak 0:669f3b0e91c8 424 * @brief Gets the board PA selection configuration
WGorniak 0:669f3b0e91c8 425 *
WGorniak 0:669f3b0e91c8 426 * @param [IN] channel Channel frequency in Hz
WGorniak 0:669f3b0e91c8 427 * @retval PaSelect RegPaConfig PaSelect value
WGorniak 0:669f3b0e91c8 428 */
WGorniak 0:669f3b0e91c8 429 virtual uint8_t GetPaSelect( uint32_t channel ) = 0;
WGorniak 0:669f3b0e91c8 430
WGorniak 0:669f3b0e91c8 431 /*!
WGorniak 0:669f3b0e91c8 432 * @brief Set the RF Switch I/Os pins in Low Power mode
WGorniak 0:669f3b0e91c8 433 *
WGorniak 0:669f3b0e91c8 434 * @param [IN] status enable or disable
WGorniak 0:669f3b0e91c8 435 */
WGorniak 0:669f3b0e91c8 436 virtual void SetAntSwLowPower( bool status ) = 0;
WGorniak 0:669f3b0e91c8 437
WGorniak 0:669f3b0e91c8 438 /*!
WGorniak 0:669f3b0e91c8 439 * @brief Initializes the RF Switch I/Os pins interface
WGorniak 0:669f3b0e91c8 440 */
WGorniak 0:669f3b0e91c8 441 virtual void AntSwInit( void ) = 0;
WGorniak 0:669f3b0e91c8 442
WGorniak 0:669f3b0e91c8 443 /*!
WGorniak 0:669f3b0e91c8 444 * @brief De-initializes the RF Switch I/Os pins interface
WGorniak 0:669f3b0e91c8 445 *
WGorniak 0:669f3b0e91c8 446 * \remark Needed to decrease the power consumption in MCU lowpower modes
WGorniak 0:669f3b0e91c8 447 */
WGorniak 0:669f3b0e91c8 448 virtual void AntSwDeInit( void ) = 0;
WGorniak 0:669f3b0e91c8 449
WGorniak 0:669f3b0e91c8 450 /*!
WGorniak 0:669f3b0e91c8 451 * @brief Controls the antena switch if necessary.
WGorniak 0:669f3b0e91c8 452 *
WGorniak 0:669f3b0e91c8 453 * \remark see errata note
WGorniak 0:669f3b0e91c8 454 *
WGorniak 0:669f3b0e91c8 455 * @param [IN] rxTx [1: Tx, 0: Rx]
WGorniak 0:669f3b0e91c8 456 */
WGorniak 0:669f3b0e91c8 457 virtual void SetAntSw( uint8_t rxTx ) = 0;
WGorniak 0:669f3b0e91c8 458
WGorniak 0:669f3b0e91c8 459 /*!
WGorniak 0:669f3b0e91c8 460 * @brief Checks if the given RF frequency is supported by the hardware
WGorniak 0:669f3b0e91c8 461 *
WGorniak 0:669f3b0e91c8 462 * @param [IN] frequency RF frequency to be checked
WGorniak 0:669f3b0e91c8 463 * @retval isSupported [true: supported, false: unsupported]
WGorniak 0:669f3b0e91c8 464 */
WGorniak 0:669f3b0e91c8 465 virtual bool CheckRfFrequency( uint32_t frequency ) = 0;
WGorniak 0:669f3b0e91c8 466 protected:
WGorniak 0:669f3b0e91c8 467
WGorniak 0:669f3b0e91c8 468 /*!
WGorniak 0:669f3b0e91c8 469 * @brief Sets the SX1276 operating mode
WGorniak 0:669f3b0e91c8 470 *
WGorniak 0:669f3b0e91c8 471 * @param [IN] opMode New operating mode
WGorniak 0:669f3b0e91c8 472 */
WGorniak 0:669f3b0e91c8 473 virtual void SetOpMode( uint8_t opMode );
WGorniak 0:669f3b0e91c8 474
WGorniak 0:669f3b0e91c8 475 /*
WGorniak 0:669f3b0e91c8 476 * SX1276 DIO IRQ callback functions prototype
WGorniak 0:669f3b0e91c8 477 */
WGorniak 0:669f3b0e91c8 478
WGorniak 0:669f3b0e91c8 479 /*!
WGorniak 0:669f3b0e91c8 480 * @brief DIO 0 IRQ callback
WGorniak 0:669f3b0e91c8 481 */
WGorniak 0:669f3b0e91c8 482 virtual void OnDio0Irq( void );
WGorniak 0:669f3b0e91c8 483
WGorniak 0:669f3b0e91c8 484 /*!
WGorniak 0:669f3b0e91c8 485 * @brief DIO 1 IRQ callback
WGorniak 0:669f3b0e91c8 486 */
WGorniak 0:669f3b0e91c8 487 virtual void OnDio1Irq( void );
WGorniak 0:669f3b0e91c8 488
WGorniak 0:669f3b0e91c8 489 /*!
WGorniak 0:669f3b0e91c8 490 * @brief DIO 2 IRQ callback
WGorniak 0:669f3b0e91c8 491 */
WGorniak 0:669f3b0e91c8 492 virtual void OnDio2Irq( void );
WGorniak 0:669f3b0e91c8 493
WGorniak 0:669f3b0e91c8 494 /*!
WGorniak 0:669f3b0e91c8 495 * @brief DIO 3 IRQ callback
WGorniak 0:669f3b0e91c8 496 */
WGorniak 0:669f3b0e91c8 497 virtual void OnDio3Irq( void );
WGorniak 0:669f3b0e91c8 498
WGorniak 0:669f3b0e91c8 499 /*!
WGorniak 0:669f3b0e91c8 500 * @brief DIO 4 IRQ callback
WGorniak 0:669f3b0e91c8 501 */
WGorniak 0:669f3b0e91c8 502 virtual void OnDio4Irq( void );
WGorniak 0:669f3b0e91c8 503
WGorniak 0:669f3b0e91c8 504 /*!
WGorniak 0:669f3b0e91c8 505 * @brief DIO 5 IRQ callback
WGorniak 0:669f3b0e91c8 506 */
WGorniak 0:669f3b0e91c8 507 virtual void OnDio5Irq( void );
WGorniak 0:669f3b0e91c8 508
WGorniak 0:669f3b0e91c8 509 /*!
WGorniak 0:669f3b0e91c8 510 * @brief Tx & Rx timeout timer callback
WGorniak 0:669f3b0e91c8 511 */
WGorniak 0:669f3b0e91c8 512 virtual void OnTimeoutIrq( void );
WGorniak 0:669f3b0e91c8 513
WGorniak 0:669f3b0e91c8 514 /*!
WGorniak 0:669f3b0e91c8 515 * Returns the known FSK bandwidth registers value
WGorniak 0:669f3b0e91c8 516 *
WGorniak 0:669f3b0e91c8 517 * \param [IN] bandwidth Bandwidth value in Hz
WGorniak 0:669f3b0e91c8 518 * \retval regValue Bandwidth register value.
WGorniak 0:669f3b0e91c8 519 */
WGorniak 0:669f3b0e91c8 520 static uint8_t GetFskBandwidthRegValue( uint32_t bandwidth );
WGorniak 0:669f3b0e91c8 521 };
WGorniak 0:669f3b0e91c8 522
WGorniak 0:669f3b0e91c8 523 #endif //__SX1272_H__