Fork of SX1276Lib for the NiceRF SX1276 module.
Fork of SX1276Lib by
sx1276-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: Miguel Luis, Gregory Cristian and Nicolas Huguenin 00014 */ 00015 #ifndef __SX1276_HAL_H__ 00016 #define __SX1276_HAL_H__ 00017 #include "sx1276.h" 00018 00019 /*! 00020 * \brief Radio hardware registers initialization definition 00021 * 00022 * \remark Can be automatically generated by the SX1276 GUI (not yet implemented) 00023 */ 00024 #define RADIO_INIT_REGISTERS_VALUE \ 00025 { \ 00026 { MODEM_FSK , REG_LNA , 0x23 },\ 00027 { MODEM_FSK , REG_RXCONFIG , 0x1E },\ 00028 { MODEM_FSK , REG_RSSICONFIG , 0xD2 },\ 00029 { MODEM_FSK , REG_AFCFEI , 0x01 },\ 00030 { MODEM_FSK , REG_PREAMBLEDETECT , 0xAA },\ 00031 { MODEM_FSK , REG_OSC , 0x07 },\ 00032 { MODEM_FSK , REG_SYNCCONFIG , 0x12 },\ 00033 { MODEM_FSK , REG_SYNCVALUE1 , 0xC1 },\ 00034 { MODEM_FSK , REG_SYNCVALUE2 , 0x94 },\ 00035 { MODEM_FSK , REG_SYNCVALUE3 , 0xC1 },\ 00036 { MODEM_FSK , REG_PACKETCONFIG1 , 0xD8 },\ 00037 { MODEM_FSK , REG_FIFOTHRESH , 0x8F },\ 00038 { MODEM_FSK , REG_IMAGECAL , 0x02 },\ 00039 { MODEM_FSK , REG_DIOMAPPING1 , 0x00 },\ 00040 { MODEM_FSK , REG_DIOMAPPING2 , 0x30 },\ 00041 { MODEM_LORA, REG_LR_PAYLOADMAXLENGTH, 0x40 },\ 00042 } \ 00043 00044 /*! 00045 * Actual implementation of a SX1276 radio, includes some modifications to make it compatible with the MB1 LAS board 00046 */ 00047 class SX1276MB1xAS : public SX1276 00048 { 00049 protected: 00050 /*! 00051 * Antenna switch GPIO pins objects 00052 */ 00053 DigitalInOut antSwitch ; 00054 00055 DigitalIn fake; 00056 00057 private: 00058 static const RadioRegisters_t RadioRegsInit[]; 00059 00060 public: 00061 SX1276MB1xAS ( RadioEvents_t *events, 00062 PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset , 00063 PinName dio0 , PinName dio1, PinName dio2, PinName dio3, PinName dio4, PinName dio5, 00064 PinName antSwitch ); 00065 00066 SX1276MB1xAS ( RadioEvents_t *events ); 00067 00068 virtual ~SX1276MB1xAS ( ) { }; 00069 00070 protected: 00071 /*! 00072 * @brief Initializes the radio I/Os pins interface 00073 */ 00074 virtual void IoInit( void ); 00075 00076 /*! 00077 * @brief Initializes the radio registers 00078 */ 00079 virtual void RadioRegistersInit( ); 00080 00081 /*! 00082 * @brief Initializes the radio SPI 00083 */ 00084 virtual void SpiInit( void ); 00085 00086 /*! 00087 * @brief Initializes DIO IRQ handlers 00088 * 00089 * @param [IN] irqHandlers Array containing the IRQ callback functions 00090 */ 00091 virtual void IoIrqInit( DioIrqHandler *irqHandlers ); 00092 00093 /*! 00094 * @brief De-initializes the radio I/Os pins interface. 00095 * 00096 * \remark Useful when going in MCU lowpower modes 00097 */ 00098 virtual void IoDeInit( void ); 00099 00100 /*! 00101 * @brief Gets the board PA selection configuration 00102 * 00103 * @param [IN] channel Channel frequency in Hz 00104 * @retval PaSelect RegPaConfig PaSelect value 00105 */ 00106 virtual uint8_t GetPaSelect( uint32_t channel ); 00107 00108 /*! 00109 * @brief Set the RF Switch I/Os pins in Low Power mode 00110 * 00111 * @param [IN] status enable or disable 00112 */ 00113 virtual void SetAntSwLowPower( bool status ); 00114 00115 /*! 00116 * @brief Initializes the RF Switch I/Os pins interface 00117 */ 00118 virtual void AntSwInit( void ); 00119 00120 /*! 00121 * @brief De-initializes the RF Switch I/Os pins interface 00122 * 00123 * \remark Needed to decrease the power consumption in MCU lowpower modes 00124 */ 00125 virtual void AntSwDeInit( void ); 00126 00127 /*! 00128 * @brief Controls the antena switch if necessary. 00129 * 00130 * \remark see errata note 00131 * 00132 * @param [IN] rxTx [1: Tx, 0: Rx] 00133 */ 00134 virtual void SetAntSw( uint8_t rxTx ); 00135 00136 public: 00137 /*! 00138 * @brief Detect the board connected by reading the value of the antenna switch pin 00139 */ 00140 virtual uint8_t DetectBoardType( void ); 00141 00142 /*! 00143 * @brief Checks if the given RF frequency is supported by the hardware 00144 * 00145 * @param [IN] frequency RF frequency to be checked 00146 * @retval isSupported [true: supported, false: unsupported] 00147 */ 00148 virtual bool CheckRfFrequency( uint32_t frequency ); 00149 00150 /*! 00151 * @brief Writes the radio register at the specified address 00152 * 00153 * @param [IN]: addr Register address 00154 * @param [IN]: data New register value 00155 */ 00156 virtual void Write ( uint8_t addr, uint8_t data ) ; 00157 00158 /*! 00159 * @brief Reads the radio register at the specified address 00160 * 00161 * @param [IN]: addr Register address 00162 * @retval data Register value 00163 */ 00164 virtual uint8_t Read ( uint8_t addr ) ; 00165 00166 /*! 00167 * @brief Writes multiple radio registers starting at address 00168 * 00169 * @param [IN] addr First Radio register address 00170 * @param [IN] buffer Buffer containing the new register's values 00171 * @param [IN] size Number of registers to be written 00172 */ 00173 virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) ; 00174 00175 /*! 00176 * @brief Reads multiple radio registers starting at address 00177 * 00178 * @param [IN] addr First Radio register address 00179 * @param [OUT] buffer Buffer where to copy the registers data 00180 * @param [IN] size Number of registers to be read 00181 */ 00182 virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) ; 00183 00184 /*! 00185 * @brief Writes the buffer contents to the SX1276 FIFO 00186 * 00187 * @param [IN] buffer Buffer containing data to be put on the FIFO. 00188 * @param [IN] size Number of bytes to be written to the FIFO 00189 */ 00190 virtual void WriteFifo( uint8_t *buffer, uint8_t size ) ; 00191 00192 /*! 00193 * @brief Reads the contents of the SX1276 FIFO 00194 * 00195 * @param [OUT] buffer Buffer where to copy the FIFO read data. 00196 * @param [IN] size Number of bytes to be read from the FIFO 00197 */ 00198 virtual void ReadFifo( uint8_t *buffer, uint8_t size ) ; 00199 00200 /*! 00201 * @brief Reset the SX1276 00202 */ 00203 virtual void Reset( void ); 00204 }; 00205 00206 #endif // __SX1276_HAL_H__
Generated on Tue Jul 12 2022 21:43:20 by 1.7.2