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:
WGorniak
Date:
Thu Sep 17 14:42:20 2015 +0200
Revision:
0:669f3b0e91c8
Child:
3:81cc2c384b1b
first commit

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