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