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 SX1272Lib by
sx1272-hal.h
00001 /* 00002 / _____) _ | | 00003 ( (____ _____ ____ _| |_ _____ ____| |__ 00004 \____ \| ___ | (_ _) ___ |/ ___) _ \ 00005 _____) ) ____| | | || |_| ____( (___| | | | 00006 (______/|_____)_|_|_| \__)_____)\____)_| |_| 00007 (C) 2015 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 __SX1272_HAL_H__ 00016 #define __SX1272_HAL_H__ 00017 #include "sx1272.h" 00018 00019 /*! 00020 * \brief Radio hardware registers initialization definition 00021 * 00022 * \remark Can be automatically generated by the SX1272 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_DETECTOPTIMIZE , 0x43 },\ 00042 { MODEM_LORA, REG_LR_PAYLOADMAXLENGTH, 0x40 },\ 00043 } \ 00044 00045 /*! 00046 * Actual implementation of a SX1272 radio, includes some modifications to make it compatible with the MB1 LAS board 00047 */ 00048 class SX1272MB2xAS : public SX1272 00049 { 00050 protected: 00051 /*! 00052 * Antenna switch GPIO pins objects 00053 */ 00054 #if defined ( TARGET_MOTE_L152RC ) 00055 DigitalOut RfSwitchCntr1 ; 00056 DigitalOut RfSwitchCntr2; 00057 DigitalOut PwrAmpCntr; 00058 #elif defined ( TARGET_MTS_MDOT_F411RE ) 00059 DigitalOut TxCtl; 00060 DigitalOut RxCtl; 00061 #elif defined ( TARGET_MBED_LPC1768 ) 00062 // nothing extra needed 00063 #else 00064 DigitalInOut AntSwitch; 00065 DigitalIn Fake; 00066 #endif 00067 00068 private: 00069 static const RadioRegisters_t RadioRegsInit[]; 00070 00071 public: 00072 SX1272MB2xAS ( RadioEvents_t *events, 00073 PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset , 00074 PinName dio0 , PinName dio1, PinName dio2, PinName dio3, PinName dio4, PinName dio5 00075 #if defined ( TARGET_MOTE_L152RC ) 00076 ,PinName rfSwitchCntr1, PinName rfSwitchCntr2 ); 00077 #elif defined ( TARGET_MTS_MDOT_F411RE ) 00078 ,PinName txctl, PinName rxctl ); 00079 #elif defined ( TARGET_MBED_LPC1768 ) 00080 ); 00081 #else 00082 PinName antSwitch ); 00083 #endif 00084 00085 SX1272MB2xAS ( RadioEvents_t *events ); 00086 00087 virtual ~SX1272MB2xAS ( ) { }; 00088 00089 protected: 00090 /*! 00091 * @brief Initializes the radio I/Os pins interface 00092 */ 00093 virtual void IoInit( void ); 00094 00095 /*! 00096 * @brief Initializes the radio registers 00097 */ 00098 virtual void RadioRegistersInit( ); 00099 00100 /*! 00101 * @brief Initializes the radio SPI 00102 */ 00103 virtual void SpiInit( void ); 00104 00105 /*! 00106 * @brief Initializes DIO IRQ handlers 00107 * 00108 * @param [IN] irqHandlers Array containing the IRQ callback functions 00109 */ 00110 virtual void IoIrqInit( DioIrqHandler *irqHandlers ); 00111 00112 /*! 00113 * @brief De-initializes the radio I/Os pins interface. 00114 * 00115 * \remark Useful when going in MCU lowpower modes 00116 */ 00117 virtual void IoDeInit( void ); 00118 00119 /*! 00120 * @brief Gets the board PA selection configuration 00121 * 00122 * @param [IN] channel Channel frequency in Hz 00123 * @retval PaSelect RegPaConfig PaSelect value 00124 */ 00125 virtual uint8_t GetPaSelect( uint32_t channel ); 00126 00127 /*! 00128 * @brief Set the RF Switch I/Os pins in Low Power mode 00129 * 00130 * @param [IN] status enable or disable 00131 */ 00132 virtual void SetAntSwLowPower( bool status ); 00133 00134 /*! 00135 * @brief Initializes the RF Switch I/Os pins interface 00136 */ 00137 virtual void AntSwInit( void ); 00138 00139 /*! 00140 * @brief De-initializes the RF Switch I/Os pins interface 00141 * 00142 * \remark Needed to decrease the power consumption in MCU lowpower modes 00143 */ 00144 virtual void AntSwDeInit( void ); 00145 00146 /*! 00147 * @brief Controls the antena switch if necessary. 00148 * 00149 * \remark see errata note 00150 * 00151 * @param [IN] rxTx [1: Tx, 0: Rx] 00152 */ 00153 virtual void SetAntSw( uint8_t rxTx ); 00154 00155 public: 00156 /*! 00157 * @brief Detect the board connected by reading the value of the antenna switch pin 00158 */ 00159 virtual uint8_t DetectBoardType( void ); 00160 00161 /*! 00162 * @brief Checks if the given RF frequency is supported by the hardware 00163 * 00164 * @param [IN] frequency RF frequency to be checked 00165 * @retval isSupported [true: supported, false: unsupported] 00166 */ 00167 virtual bool CheckRfFrequency( uint32_t frequency ); 00168 00169 /*! 00170 * @brief Writes the radio register at the specified address 00171 * 00172 * @param [IN]: addr Register address 00173 * @param [IN]: data New register value 00174 */ 00175 virtual void Write ( uint8_t addr, uint8_t data ) ; 00176 00177 /*! 00178 * @brief Reads the radio register at the specified address 00179 * 00180 * @param [IN]: addr Register address 00181 * @retval data Register value 00182 */ 00183 virtual uint8_t Read ( uint8_t addr ) ; 00184 00185 /*! 00186 * @brief Writes multiple radio registers starting at address 00187 * 00188 * @param [IN] addr First Radio register address 00189 * @param [IN] buffer Buffer containing the new register's values 00190 * @param [IN] size Number of registers to be written 00191 */ 00192 virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) ; 00193 00194 /*! 00195 * @brief Reads multiple radio registers starting at address 00196 * 00197 * @param [IN] addr First Radio register address 00198 * @param [OUT] buffer Buffer where to copy the registers data 00199 * @param [IN] size Number of registers to be read 00200 */ 00201 virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) ; 00202 00203 /*! 00204 * @brief Writes the buffer contents to the SX1272 FIFO 00205 * 00206 * @param [IN] buffer Buffer containing data to be put on the FIFO. 00207 * @param [IN] size Number of bytes to be written to the FIFO 00208 */ 00209 virtual void WriteFifo( uint8_t *buffer, uint8_t size ) ; 00210 00211 /*! 00212 * @brief Reads the contents of the SX1272 FIFO 00213 * 00214 * @param [OUT] buffer Buffer where to copy the FIFO read data. 00215 * @param [IN] size Number of bytes to be read from the FIFO 00216 */ 00217 virtual void ReadFifo( uint8_t *buffer, uint8_t size ) ; 00218 00219 /*! 00220 * @brief Reset the SX1272 00221 */ 00222 virtual void Reset( void ); 00223 }; 00224 00225 #endif // __SX1272_HAL_H__
Generated on Fri Jul 15 2022 21:42:05 by
1.7.2
