1 /*! 2 * \file sx1272-board.h 3 * 4 * \brief Target board SX1272 driver implementation 5 * 6 * \copyright Revised BSD License, see section \ref LICENSE. 7 * 8 * \code 9 * ______ _ 10 * / _____) _ | | 11 * ( (____ _____ ____ _| |_ _____ ____| |__ 12 * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 * _____) ) ____| | | || |_| ____( (___| | | | 14 * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 * (C)2013-2017 Semtech 16 * 17 * \endcode 18 * 19 * \author Miguel Luis ( Semtech ) 20 * 21 * \author Gregory Cristian ( Semtech ) 22 */ 23 #ifndef __SX1272_BOARD_H__ 24 #define __SX1272_BOARD_H__ 25 26 #ifdef __cplusplus 27 extern "C" 28 { 29 #endif 30 31 #include <stdint.h> 32 #include <stdbool.h> 33 #include "sx1272/sx1272.h" 34 35 /*! 36 * \brief Radio hardware registers initialization definition 37 * 38 * \remark Can be automatically generated by the SX1272 GUI (not yet implemented) 39 */ 40 #define RADIO_INIT_REGISTERS_VALUE \ 41 { \ 42 { MODEM_FSK , REG_LNA , 0x23 },\ 43 { MODEM_FSK , REG_RXCONFIG , 0x1E },\ 44 { MODEM_FSK , REG_RSSICONFIG , 0xD2 },\ 45 { MODEM_FSK , REG_AFCFEI , 0x01 },\ 46 { MODEM_FSK , REG_PREAMBLEDETECT , 0xAA },\ 47 { MODEM_FSK , REG_OSC , 0x07 },\ 48 { MODEM_FSK , REG_SYNCCONFIG , 0x12 },\ 49 { MODEM_FSK , REG_SYNCVALUE1 , 0xC1 },\ 50 { MODEM_FSK , REG_SYNCVALUE2 , 0x94 },\ 51 { MODEM_FSK , REG_SYNCVALUE3 , 0xC1 },\ 52 { MODEM_FSK , REG_PACKETCONFIG1 , 0xD8 },\ 53 /* FIFO threshold set to 32 (31+1) */ \ 54 { MODEM_FSK , REG_FIFOTHRESH , 0x9F },\ 55 { MODEM_FSK , REG_IMAGECAL , 0x02 },\ 56 { MODEM_FSK , REG_DIOMAPPING1 , 0x00 },\ 57 { MODEM_FSK , REG_DIOMAPPING2 , 0x30 },\ 58 { MODEM_LORA, REG_LR_DETECTOPTIMIZE , 0x43 },\ 59 { MODEM_LORA, REG_LR_PAYLOADMAXLENGTH, 0x40 },\ 60 } \ 61 62 /*! 63 * \brief Initializes the radio I/Os pins interface 64 */ 65 void SX1272IoInit( void ); 66 67 /*! 68 * \brief Initializes DIO IRQ handlers 69 * 70 * \param [IN] irqHandlers Array containing the IRQ callback functions 71 */ 72 void SX1272IoIrqInit( DioIrqHandler **irqHandlers ); 73 74 /*! 75 * \brief De-initializes the radio I/Os pins interface. 76 * 77 * \remark Useful when going in MCU low power modes 78 */ 79 void SX1272IoDeInit( void ); 80 81 /*! 82 * \brief Initializes the TCXO power pin. 83 */ 84 void SX1272IoTcxoInit( void ); 85 86 /*! 87 * \brief Initializes the radio debug pins. 88 */ 89 void SX1272IoDbgInit( void ); 90 91 /*! 92 * \brief Resets the radio 93 */ 94 void SX1272Reset( void ); 95 96 /*! 97 * \brief Sets the radio output power. 98 * 99 * \param [IN] power Sets the RF output power 100 */ 101 void SX1272SetRfTxPower( int8_t power ); 102 103 /*! 104 * \brief Set the RF Switch I/Os pins in low power mode 105 * 106 * \param [IN] status enable or disable 107 */ 108 void SX1272SetAntSwLowPower( bool status ); 109 110 /*! 111 * \brief Initializes the RF Switch I/Os pins interface 112 */ 113 void SX1272AntSwInit( void ); 114 115 /*! 116 * \brief De-initializes the RF Switch I/Os pins interface 117 * 118 * \remark Needed to decrease the power consumption in MCU low power modes 119 */ 120 void SX1272AntSwDeInit( void ); 121 122 /*! 123 * \brief Controls the antenna switch if necessary. 124 * 125 * \remark see errata note 126 * 127 * \param [IN] opMode Current radio operating mode 128 */ 129 void SX1272SetAntSw( uint8_t opMode ); 130 131 /*! 132 * \brief Checks if the given RF frequency is supported by the hardware 133 * 134 * \param [IN] frequency RF frequency to be checked 135 * \retval isSupported [true: supported, false: unsupported] 136 */ 137 bool SX1272CheckRfFrequency( uint32_t frequency ); 138 139 /*! 140 * \brief Enables/disables the TCXO if available on board design. 141 * 142 * \param [IN] state TCXO enabled when true and disabled when false. 143 */ 144 void SX1272SetBoardTcxo( uint8_t state ); 145 146 /*! 147 * \brief Gets the Defines the time required for the TCXO to wakeup [ms]. 148 * 149 * \retval time Board TCXO wakeup time in ms. 150 */ 151 uint32_t SX1272GetBoardTcxoWakeupTime( void ); 152 153 /*! 154 * \brief Gets current state of DIO1 pin state (FifoLevel). 155 * 156 * \retval state DIO1 pin current state. 157 */ 158 uint32_t SX1272GetDio1PinState( void ); 159 160 /*! 161 * \brief Writes new Tx debug pin state 162 * 163 * \param [IN] state Debug pin state 164 */ 165 void SX1272DbgPinTxWrite( uint8_t state ); 166 167 /*! 168 * \brief Writes new Rx debug pin state 169 * 170 * \param [IN] state Debug pin state 171 */ 172 void SX1272DbgPinRxWrite( uint8_t state ); 173 174 /*! 175 * Radio hardware and global parameters 176 */ 177 extern SX1272_t SX1272; 178 179 #ifdef __cplusplus 180 } 181 #endif 182 183 #endif // __SX1272_BOARD_H__ 184