XRange SX1272Lib
Dependents: XRangePingPong XRange-LoRaWAN-lmic-app lora-transceiver
Fork of SX1276Lib by
sx1272-hal.h
00001 /* 00002 / _____) _ | | 00003 ( (____ _____ ____ _| |_ _____ ____| |__ 00004 \____ \| ___ | (_ _) ___ |/ ___) _ \ 00005 _____) ) ____| | | || |_| ____( (___| | | | 00006 (______/|_____)_|_|_| \__)_____)\____)_| |_| 00007 ( C )2014 Semtech 00008 00009 Description: - 00010 00011 License: Revised BSD License, see LICENSE.TXT file include in the project 00012 00013 Maintainers: www.netblocks.eu 00014 SX1272 LoRa RF module : http://www.netblocks.eu/xrange-sx1272-lora-datasheet/ 00015 00016 */ 00017 #ifndef __SX1272_HAL_H__ 00018 #define __SX1272_HAL_H__ 00019 #include "sx1272.h" 00020 00021 /*! 00022 * Actual implementation of a SX1276 radio, includes some modifications to make it compatible with the MB1 LAS board 00023 */ 00024 class XRange : public SX1272 00025 { 00026 protected: 00027 /*! 00028 * Antenna switch GPIO pins objects 00029 */ 00030 DigitalInOut antSwitch ; 00031 00032 // DigitalIn fake; 00033 00034 private: 00035 static const RadioRegisters_t RadioRegsInit[]; 00036 00037 public: 00038 XRange ( void ( *txDone )( ), void ( *txTimeout ) ( ), void ( *rxDone ) ( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ), 00039 void ( *rxTimeout ) ( ), void ( *rxError ) ( ), void ( *fhssChangeChannel ) ( uint8_t channelIndex ), void ( *cadDone ) ( bool ChannelActivityDetected ), 00040 PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset , 00041 PinName dio0 , PinName dio1, PinName dio2, PinName dio3, PinName dio4, PinName dio5, 00042 PinName antSwitch ); 00043 XRange ( void ( *txDone )( ), void ( *txTimeout ) ( ), void ( *rxDone ) ( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ), 00044 void ( *rxTimeout ) ( ), void ( *rxError ) ( ), void ( *fhssChangeChannel ) ( uint8_t channelIndex ), void ( *cadDone ) ( bool ChannelActivityDetected ) ); 00045 virtual ~XRange ( ) { }; 00046 00047 protected: 00048 /*! 00049 * @brief Initializes the radio I/Os pins interface 00050 */ 00051 virtual void IoInit( void ); 00052 00053 /*! 00054 * @brief Initializes the radio registers 00055 */ 00056 virtual void RadioRegistersInit( ); 00057 00058 /*! 00059 * @brief Initializes the radio SPI 00060 */ 00061 virtual void SpiInit( void ); 00062 00063 /*! 00064 * @brief Initializes DIO IRQ handlers 00065 * 00066 * @param [IN] irqHandlers Array containing the IRQ callback functions 00067 */ 00068 virtual void IoIrqInit( DioIrqHandler *irqHandlers ); 00069 00070 /*! 00071 * @brief De-initializes the radio I/Os pins interface. 00072 * 00073 * \remark Useful when going in MCU lowpower modes 00074 */ 00075 virtual void IoDeInit( void ); 00076 00077 /*! 00078 * @brief Gets the board PA selection configuration 00079 * 00080 * @param [IN] channel Channel frequency in Hz 00081 * @retval PaSelect RegPaConfig PaSelect value 00082 */ 00083 virtual uint8_t GetPaSelect( uint32_t channel ); 00084 00085 /*! 00086 * @brief Set the RF Switch I/Os pins in Low Power mode 00087 * 00088 * @param [IN] status enable or disable 00089 */ 00090 virtual void SetAntSwLowPower( bool status ); 00091 00092 /*! 00093 * @brief Initializes the RF Switch I/Os pins interface 00094 */ 00095 virtual void AntSwInit( void ); 00096 00097 /*! 00098 * @brief De-initializes the RF Switch I/Os pins interface 00099 * 00100 * \remark Needed to decrease the power consumption in MCU lowpower modes 00101 */ 00102 virtual void AntSwDeInit( void ); 00103 00104 /*! 00105 * @brief Controls the antena switch if necessary. 00106 * 00107 * \remark see errata note 00108 * 00109 * @param [IN] rxTx [1: Tx, 0: Rx] 00110 */ 00111 virtual void SetAntSw( uint8_t rxTx ); 00112 00113 public: 00114 /*! 00115 * @brief Detect the board connected by reading the value of the antenna switch pin 00116 */ 00117 00118 00119 /*! 00120 * @brief Checks if the given RF frequency is supported by the hardware 00121 * 00122 * @param [IN] frequency RF frequency to be checked 00123 * @retval isSupported [true: supported, false: unsupported] 00124 */ 00125 virtual bool CheckRfFrequency( uint32_t frequency ); 00126 00127 /*! 00128 * @brief Writes the radio register at the specified address 00129 * 00130 * @param [IN]: addr Register address 00131 * @param [IN]: data New register value 00132 */ 00133 virtual void Write ( uint8_t addr, uint8_t data ) ; 00134 00135 /*! 00136 * @brief Reads the radio register at the specified address 00137 * 00138 * @param [IN]: addr Register address 00139 * @retval data Register value 00140 */ 00141 virtual uint8_t Read ( uint8_t addr ) ; 00142 00143 /*! 00144 * @brief Writes multiple radio registers starting at address 00145 * 00146 * @param [IN] addr First Radio register address 00147 * @param [IN] buffer Buffer containing the new register's values 00148 * @param [IN] size Number of registers to be written 00149 */ 00150 virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) ; 00151 00152 /*! 00153 * @brief Reads multiple radio registers starting at address 00154 * 00155 * @param [IN] addr First Radio register address 00156 * @param [OUT] buffer Buffer where to copy the registers data 00157 * @param [IN] size Number of registers to be read 00158 */ 00159 virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) ; 00160 00161 /*! 00162 * @brief Writes the buffer contents to the SX1276 FIFO 00163 * 00164 * @param [IN] buffer Buffer containing data to be put on the FIFO. 00165 * @param [IN] size Number of bytes to be written to the FIFO 00166 */ 00167 virtual void WriteFifo( uint8_t *buffer, uint8_t size ) ; 00168 00169 /*! 00170 * @brief Reads the contents of the SX1276 FIFO 00171 * 00172 * @param [OUT] buffer Buffer where to copy the FIFO read data. 00173 * @param [IN] size Number of bytes to be read from the FIFO 00174 */ 00175 virtual void ReadFifo( uint8_t *buffer, uint8_t size ) ; 00176 00177 /*! 00178 * @brief Reset the SX1276 00179 */ 00180 virtual void Reset( void ); 00181 }; 00182 00183 #endif // __SX1272_HAL_H__
Generated on Wed Jul 13 2022 07:28:43 by
![doxygen](doxygen.png)