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

SX1276MB1xAS