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