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.
Fork of SX1276GenericLib by
sx1276-mbed-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 00016 /* 00017 * additional development to make it more generic across multiple OS versions 00018 * (c) 2017 Helmut Tschemernjak 00019 * 30826 Garbsen (Hannover) Germany 00020 */ 00021 00022 #ifndef __SX1276_MBED_HAL_H__ 00023 #define __SX1276_MBED_HAL_H__ 00024 00025 00026 #include "sx1276.h" 00027 00028 00029 #ifdef __MBED__ 00030 #define XSPI SPI 00031 #endif 00032 00033 #ifdef DEVICE_LOWPOWERTIMER 00034 #define MyTimeout LowPowerTimeout 00035 #else 00036 #define MyTimeout Timeout 00037 #endif 00038 00039 /*! 00040 * Actual implementation of a SX1276 radio, includes some modifications to make it 00041 * compatible with the MB1 LAS board 00042 */ 00043 class SX1276Generic : public SX1276 00044 { 00045 protected: 00046 /*! 00047 * Antenna switch GPIO pins objects 00048 */ 00049 DigitalOut *_antSwitchPwr ; 00050 DigitalOut *_antSwitch; 00051 DigitalOut *_antSwitchTX; 00052 DigitalOut *_antSwitchTXBoost; 00053 00054 /*! 00055 * SX1276 Reset pin 00056 */ 00057 DigitalInOut *_reset ; 00058 00059 /*! 00060 * TCXO being used with the Murata Module 00061 */ 00062 DigitalOut *_tcxo ; 00063 00064 /*! 00065 * SPI Interface 00066 */ 00067 XSPI *_spi ; // mosi, miso, sclk 00068 DigitalOut *_nss; 00069 00070 /*! 00071 * SX1276 DIO pins 00072 */ 00073 InterruptIn *_dio0 ; 00074 InterruptIn *_dio1; 00075 InterruptIn *_dio2; 00076 InterruptIn *_dio3; 00077 InterruptIn *_dio4; 00078 DigitalIn *_dio5; 00079 00080 /*! 00081 * Tx and Rx timers 00082 */ 00083 MyTimeout txTimeoutTimer ; 00084 MyTimeout rxTimeoutTimer; 00085 MyTimeout rxTimeoutSyncWord; 00086 00087 00088 private: 00089 /*! 00090 * triggers definition 00091 */ 00092 typedef void (SX1276Generic ::*Trigger)(void); 00093 static const int PWR_OFF = 1; 00094 static const int PWR_ON = 0; 00095 00096 00097 public: 00098 SX1276Generic ( RadioEvents_t *events, BoardType_t board, 00099 PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset, 00100 PinName dio0, PinName dio1, PinName dio2, PinName dio3, PinName dio4, PinName dio5, 00101 PinName antSwitch = NC, PinName antSwitchTX = NC, PinName antSwitchTXBoost = NC, PinName tcxo = NC); 00102 00103 00104 SX1276Generic ( RadioEvents_t *events ); 00105 00106 virtual ~SX1276Generic (); 00107 00108 protected: 00109 /*! 00110 * @brief Initializes the radio I/Os pins interface 00111 */ 00112 virtual void IoInit( void ); 00113 00114 /*! 00115 * @brief Initializes the radio SPI 00116 */ 00117 virtual void SpiInit( void ); 00118 00119 /*! 00120 * @brief Initializes DIO IRQ handlers 00121 * 00122 * @param [IN] irqHandlers Array containing the IRQ callback functions 00123 */ 00124 virtual void IoIrqInit( DioIrqHandler *irqHandlers ); 00125 00126 /*! 00127 * @brief De-initializes the radio I/Os pins interface. 00128 * 00129 * \remark Useful when going in MCU lowpower modes 00130 */ 00131 virtual void IoDeInit( void ); 00132 00133 /*! 00134 * @brief Gets the board PA selection configuration 00135 * 00136 * @param [IN] channel Channel frequency in Hz 00137 * @retval PaSelect RegPaConfig PaSelect value 00138 */ 00139 virtual uint8_t GetPaSelect( uint32_t channel ); 00140 00141 /*! 00142 * @brief Set the RF Switch I/Os pins in Low Power mode 00143 * 00144 * @param [IN] status enable or disable 00145 */ 00146 virtual void SetAntSwLowPower( bool status ); 00147 00148 /*! 00149 * @brief Initializes the RF Switch I/Os pins interface 00150 */ 00151 virtual void AntSwInit( void ); 00152 00153 /*! 00154 * @brief De-initializes the RF Switch I/Os pins interface 00155 * 00156 * @remark Needed to decrease the power consumption in MCU lowpower modes 00157 */ 00158 virtual void AntSwDeInit( void ); 00159 00160 /*! 00161 * @brief Controls the antena switch if necessary. 00162 * 00163 * @remark see errata note 00164 * 00165 * @param [IN] opMode Current radio operating mode 00166 */ 00167 virtual void SetAntSw( uint8_t opMode ); 00168 00169 /* 00170 * The the Timeout for a given Timer. 00171 */ 00172 virtual void SetTimeout(TimeoutTimer_t timer, timeoutFuncPtr, int timeout_ms = 0); 00173 00174 /* 00175 * A simple ms sleep 00176 */ 00177 virtual void Sleep_ms(int ms); 00178 00179 00180 public: 00181 00182 /*! 00183 * @brief Detect the board connected by reading the value of the antenna switch pin 00184 */ 00185 virtual uint8_t DetectBoardType( void ); 00186 00187 /*! 00188 * @brief Checks if the given RF frequency is supported by the hardware 00189 * 00190 * @param [IN] frequency RF frequency to be checked 00191 * @retval isSupported [true: supported, false: unsupported] 00192 */ 00193 virtual bool CheckRfFrequency( uint32_t frequency ); 00194 00195 /*! 00196 * @brief Writes the radio register at the specified address 00197 * 00198 * @param [IN]: addr Register address 00199 * @param [IN]: data New register value 00200 */ 00201 virtual void Write ( uint8_t addr, uint8_t data ) ; 00202 00203 /*! 00204 * @brief Reads the radio register at the specified address 00205 * 00206 * @param [IN]: addr Register address 00207 * @retval data Register value 00208 */ 00209 virtual uint8_t Read ( uint8_t addr ) ; 00210 00211 /*! 00212 * @brief Writes multiple radio registers starting at address 00213 * 00214 * @param [IN] addr First Radio register address 00215 * @param [IN] buffer Buffer containing the new register's values 00216 * @param [IN] size Number of registers to be written 00217 */ 00218 virtual void Write( uint8_t addr, void *buffer, uint8_t size ) ; 00219 00220 /*! 00221 * @brief Reads multiple radio registers starting at address 00222 * 00223 * @param [IN] addr First Radio register address 00224 * @param [OUT] buffer Buffer where to copy the registers data 00225 * @param [IN] size Number of registers to be read 00226 */ 00227 virtual void Read ( uint8_t addr, void *buffer, uint8_t size ) ; 00228 00229 /*! 00230 * @brief Writes the buffer contents to the SX1276 FIFO 00231 * 00232 * @param [IN] buffer Buffer containing data to be put on the FIFO. 00233 * @param [IN] size Number of bytes to be written to the FIFO 00234 */ 00235 virtual void WriteFifo( void *buffer, uint8_t size ) ; 00236 00237 /*! 00238 * @brief Reads the contents of the SX1276 FIFO 00239 * 00240 * @param [OUT] buffer Buffer where to copy the FIFO read data. 00241 * @param [IN] size Number of bytes to be read from the FIFO 00242 */ 00243 virtual void ReadFifo( void *buffer, uint8_t size ) ; 00244 00245 /*! 00246 * @brief Reset the SX1276 00247 */ 00248 virtual void Reset( void ); 00249 00250 /*! 00251 * \brief Sets the radio output power. 00252 * 00253 * @param [IN] power Sets the RF output power 00254 */ 00255 virtual void SetRfTxPower( int8_t power ); 00256 00257 }; 00258 00259 #endif // __SX1276_MBED_HAL_H__
Generated on Sat Jul 16 2022 06:25:27 by
1.7.2
