This library update contains changes according to the HW-modification.

Dependents:   LoRaWAN_Serial_port_driven_and_configurable_ELMO_based_on_TxRx_Template

Fork of SX1272lib by Espotel

Changes compared to original SX1272lib:

HW modification was made to remove RFO-output and replaced with PABOOST-output. PASELECT changed accordingly.

Committer:
KosTee
Date:
Fri Oct 07 11:35:50 2016 +0000
Revision:
13:1af18cdef696
Parent:
1:51fd7a5843e5
RFO & PABOOST transmit modification has been done to some devices.; Selection can be made on sx1272-hal.cpp.; The new transmit route is currently commented on sx1272-hal.cpp, cause majority of devices still use the old route.;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WGorniak 0:669f3b0e91c8 1 /*
WGorniak 0:669f3b0e91c8 2 / _____) _ | |
WGorniak 0:669f3b0e91c8 3 ( (____ _____ ____ _| |_ _____ ____| |__
WGorniak 0:669f3b0e91c8 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
WGorniak 0:669f3b0e91c8 5 _____) ) ____| | | || |_| ____( (___| | | |
WGorniak 0:669f3b0e91c8 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
WGorniak 0:669f3b0e91c8 7 ( C ) Semtech
WGorniak 0:669f3b0e91c8 8
WGorniak 0:669f3b0e91c8 9 Description: Port of Semtech SX1276 C++ library to support SX1272 chipset performed by Espotel
WGorniak 0:669f3b0e91c8 10
WGorniak 0:669f3b0e91c8 11 License: Revised BSD License, see LICENSE.TXT file include in the project
WGorniak 0:669f3b0e91c8 12
WGorniak 0:669f3b0e91c8 13 Maintainers: www.espotel.com
WGorniak 0:669f3b0e91c8 14
WGorniak 0:669f3b0e91c8 15 */
WGorniak 0:669f3b0e91c8 16 #ifndef __SX1272_HAL_H__
WGorniak 0:669f3b0e91c8 17 #define __SX1272_HAL_H__
WGorniak 0:669f3b0e91c8 18 #include "sx1272.h"
WGorniak 0:669f3b0e91c8 19
WGorniak 0:669f3b0e91c8 20 /*!
WGorniak 0:669f3b0e91c8 21 * Actual implementation of a SX1272 radio, includes some modifications to make it compatible with the MB1 LAS board
WGorniak 0:669f3b0e91c8 22 */
WGorniak 1:51fd7a5843e5 23 class SX1272BRD : public SX1272
WGorniak 0:669f3b0e91c8 24 {
WGorniak 0:669f3b0e91c8 25 protected:
WGorniak 0:669f3b0e91c8 26 /*!
WGorniak 0:669f3b0e91c8 27 * Antenna switch GPIO pins objects
WGorniak 0:669f3b0e91c8 28 */
WGorniak 0:669f3b0e91c8 29 DigitalInOut antSwitch;
WGorniak 0:669f3b0e91c8 30
WGorniak 0:669f3b0e91c8 31 private:
WGorniak 0:669f3b0e91c8 32 static const RadioRegisters_t RadioRegsInit[];
WGorniak 0:669f3b0e91c8 33
WGorniak 0:669f3b0e91c8 34 public:
WGorniak 1:51fd7a5843e5 35 SX1272BRD( void ( *txDone )( ), void ( *txTimeout ) ( ), void ( *rxDone ) ( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ),
WGorniak 0:669f3b0e91c8 36 void ( *rxTimeout ) ( ), void ( *rxError ) ( ), void ( *fhssChangeChannel ) ( uint8_t channelIndex ), void ( *cadDone ) ( bool ChannelActivityDetected ),
WGorniak 0:669f3b0e91c8 37 PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset,
WGorniak 0:669f3b0e91c8 38 PinName dio0, PinName dio1, PinName dio2, PinName dio3, PinName dio4, PinName dio5,
WGorniak 0:669f3b0e91c8 39 PinName antSwitch );
WGorniak 0:669f3b0e91c8 40
WGorniak 1:51fd7a5843e5 41 virtual ~SX1272BRD( );
WGorniak 0:669f3b0e91c8 42
WGorniak 0:669f3b0e91c8 43 protected:
WGorniak 0:669f3b0e91c8 44 /*!
WGorniak 0:669f3b0e91c8 45 * @brief Initializes the radio I/Os pins interface
WGorniak 0:669f3b0e91c8 46 */
WGorniak 0:669f3b0e91c8 47 virtual void IoInit( void );
WGorniak 0:669f3b0e91c8 48
WGorniak 0:669f3b0e91c8 49 /*!
WGorniak 0:669f3b0e91c8 50 * @brief Initializes the radio registers
WGorniak 0:669f3b0e91c8 51 */
WGorniak 0:669f3b0e91c8 52 virtual void RadioRegistersInit( );
WGorniak 0:669f3b0e91c8 53
WGorniak 0:669f3b0e91c8 54 /*!
WGorniak 0:669f3b0e91c8 55 * @brief Initializes the radio SPI
WGorniak 0:669f3b0e91c8 56 */
WGorniak 0:669f3b0e91c8 57 virtual void SpiInit( void );
WGorniak 0:669f3b0e91c8 58
WGorniak 0:669f3b0e91c8 59 /*!
WGorniak 0:669f3b0e91c8 60 * @brief Initializes DIO IRQ handlers
WGorniak 0:669f3b0e91c8 61 *
WGorniak 0:669f3b0e91c8 62 * @param [IN] irqHandlers Array containing the IRQ callback functions
WGorniak 0:669f3b0e91c8 63 */
WGorniak 0:669f3b0e91c8 64 virtual void IoIrqInit( DioIrqHandler *irqHandlers );
WGorniak 0:669f3b0e91c8 65
WGorniak 0:669f3b0e91c8 66 /*!
WGorniak 0:669f3b0e91c8 67 * @brief Deinitializes DIO IRQ handlers (switches off interrupts)
WGorniak 0:669f3b0e91c8 68 */
WGorniak 0:669f3b0e91c8 69 virtual void IoIrqDeInit( void );
WGorniak 0:669f3b0e91c8 70
WGorniak 0:669f3b0e91c8 71 /*!
WGorniak 0:669f3b0e91c8 72 * @brief De-initializes the radio I/Os pins interface.
WGorniak 0:669f3b0e91c8 73 *
WGorniak 0:669f3b0e91c8 74 * \remark Useful when going in MCU lowpower modes
WGorniak 0:669f3b0e91c8 75 */
WGorniak 0:669f3b0e91c8 76 virtual void IoDeInit( void );
WGorniak 0:669f3b0e91c8 77
WGorniak 0:669f3b0e91c8 78 /*!
WGorniak 0:669f3b0e91c8 79 * @brief Gets the board PA selection configuration
WGorniak 0:669f3b0e91c8 80 *
WGorniak 0:669f3b0e91c8 81 * @param [IN] channel Channel frequency in Hz
WGorniak 0:669f3b0e91c8 82 * @retval PaSelect RegPaConfig PaSelect value
WGorniak 0:669f3b0e91c8 83 */
WGorniak 0:669f3b0e91c8 84 virtual uint8_t GetPaSelect( uint32_t channel );
WGorniak 0:669f3b0e91c8 85
WGorniak 0:669f3b0e91c8 86 /*!
WGorniak 0:669f3b0e91c8 87 * @brief Set the RF Switch I/Os pins in Low Power mode
WGorniak 0:669f3b0e91c8 88 *
WGorniak 0:669f3b0e91c8 89 * @param [IN] status enable or disable
WGorniak 0:669f3b0e91c8 90 */
WGorniak 0:669f3b0e91c8 91 virtual void SetAntSwLowPower( bool status );
WGorniak 0:669f3b0e91c8 92
WGorniak 0:669f3b0e91c8 93 /*!
WGorniak 0:669f3b0e91c8 94 * @brief Initializes the RF Switch I/Os pins interface
WGorniak 0:669f3b0e91c8 95 */
WGorniak 0:669f3b0e91c8 96 virtual void AntSwInit( void );
WGorniak 0:669f3b0e91c8 97
WGorniak 0:669f3b0e91c8 98 /*!
WGorniak 0:669f3b0e91c8 99 * @brief De-initializes the RF Switch I/Os pins interface
WGorniak 0:669f3b0e91c8 100 *
WGorniak 0:669f3b0e91c8 101 * \remark Needed to decrease the power consumption in MCU lowpower modes
WGorniak 0:669f3b0e91c8 102 */
WGorniak 0:669f3b0e91c8 103 virtual void AntSwDeInit( void );
WGorniak 0:669f3b0e91c8 104
WGorniak 0:669f3b0e91c8 105 /*!
WGorniak 0:669f3b0e91c8 106 * @brief Controls the antena switch if necessary.
WGorniak 0:669f3b0e91c8 107 *
WGorniak 0:669f3b0e91c8 108 * \remark see errata note
WGorniak 0:669f3b0e91c8 109 *
WGorniak 0:669f3b0e91c8 110 * @param [IN] rxTx [1: Tx, 0: Rx]
WGorniak 0:669f3b0e91c8 111 */
WGorniak 0:669f3b0e91c8 112 virtual void SetAntSw( uint8_t rxTx );
WGorniak 0:669f3b0e91c8 113
WGorniak 0:669f3b0e91c8 114 public:
WGorniak 0:669f3b0e91c8 115 /*!
WGorniak 0:669f3b0e91c8 116 * @brief Detect the board connected by reading the value of the antenna switch pin
WGorniak 0:669f3b0e91c8 117 */
WGorniak 0:669f3b0e91c8 118 //virtual uint8_t DetectBoardType( void );
WGorniak 0:669f3b0e91c8 119
WGorniak 0:669f3b0e91c8 120 /*!
WGorniak 0:669f3b0e91c8 121 * @brief Checks if the given RF frequency is supported by the hardware
WGorniak 0:669f3b0e91c8 122 *
WGorniak 0:669f3b0e91c8 123 * @param [IN] frequency RF frequency to be checked
WGorniak 0:669f3b0e91c8 124 * @retval isSupported [true: supported, false: unsupported]
WGorniak 0:669f3b0e91c8 125 */
WGorniak 0:669f3b0e91c8 126 virtual bool CheckRfFrequency( uint32_t frequency );
WGorniak 0:669f3b0e91c8 127
WGorniak 0:669f3b0e91c8 128 /*!
WGorniak 0:669f3b0e91c8 129 * @brief Writes the radio register at the specified address
WGorniak 0:669f3b0e91c8 130 *
WGorniak 0:669f3b0e91c8 131 * @param [IN]: addr Register address
WGorniak 0:669f3b0e91c8 132 * @param [IN]: data New register value
WGorniak 0:669f3b0e91c8 133 */
WGorniak 0:669f3b0e91c8 134 virtual void Write ( uint8_t addr, uint8_t data ) ;
WGorniak 0:669f3b0e91c8 135
WGorniak 0:669f3b0e91c8 136 /*!
WGorniak 0:669f3b0e91c8 137 * @brief Reads the radio register at the specified address
WGorniak 0:669f3b0e91c8 138 *
WGorniak 0:669f3b0e91c8 139 * @param [IN]: addr Register address
WGorniak 0:669f3b0e91c8 140 * @retval data Register value
WGorniak 0:669f3b0e91c8 141 */
WGorniak 0:669f3b0e91c8 142 virtual uint8_t Read ( uint8_t addr ) ;
WGorniak 0:669f3b0e91c8 143
WGorniak 0:669f3b0e91c8 144 /*!
WGorniak 0:669f3b0e91c8 145 * @brief Writes multiple radio registers starting at address
WGorniak 0:669f3b0e91c8 146 *
WGorniak 0:669f3b0e91c8 147 * @param [IN] addr First Radio register address
WGorniak 0:669f3b0e91c8 148 * @param [IN] buffer Buffer containing the new register's values
WGorniak 0:669f3b0e91c8 149 * @param [IN] size Number of registers to be written
WGorniak 0:669f3b0e91c8 150 */
WGorniak 0:669f3b0e91c8 151 virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) ;
WGorniak 0:669f3b0e91c8 152
WGorniak 0:669f3b0e91c8 153 /*!
WGorniak 0:669f3b0e91c8 154 * @brief Reads multiple radio registers starting at address
WGorniak 0:669f3b0e91c8 155 *
WGorniak 0:669f3b0e91c8 156 * @param [IN] addr First Radio register address
WGorniak 0:669f3b0e91c8 157 * @param [OUT] buffer Buffer where to copy the registers data
WGorniak 0:669f3b0e91c8 158 * @param [IN] size Number of registers to be read
WGorniak 0:669f3b0e91c8 159 */
WGorniak 0:669f3b0e91c8 160 virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) ;
WGorniak 0:669f3b0e91c8 161
WGorniak 0:669f3b0e91c8 162 /*!
WGorniak 0:669f3b0e91c8 163 * @brief Writes the buffer contents to the SX1272 FIFO
WGorniak 0:669f3b0e91c8 164 *
WGorniak 0:669f3b0e91c8 165 * @param [IN] buffer Buffer containing data to be put on the FIFO.
WGorniak 0:669f3b0e91c8 166 * @param [IN] size Number of bytes to be written to the FIFO
WGorniak 0:669f3b0e91c8 167 */
WGorniak 0:669f3b0e91c8 168 virtual void WriteFifo( uint8_t *buffer, uint8_t size ) ;
WGorniak 0:669f3b0e91c8 169
WGorniak 0:669f3b0e91c8 170 /*!
WGorniak 0:669f3b0e91c8 171 * @brief Reads the contents of the SX1272 FIFO
WGorniak 0:669f3b0e91c8 172 *
WGorniak 0:669f3b0e91c8 173 * @param [OUT] buffer Buffer where to copy the FIFO read data.
WGorniak 0:669f3b0e91c8 174 * @param [IN] size Number of bytes to be read from the FIFO
WGorniak 0:669f3b0e91c8 175 */
WGorniak 0:669f3b0e91c8 176 virtual void ReadFifo( uint8_t *buffer, uint8_t size ) ;
WGorniak 0:669f3b0e91c8 177
WGorniak 0:669f3b0e91c8 178 /*!
WGorniak 0:669f3b0e91c8 179 * @brief Reset the SX1272
WGorniak 0:669f3b0e91c8 180 */
WGorniak 0:669f3b0e91c8 181 virtual void Reset( void );
WGorniak 0:669f3b0e91c8 182 };
WGorniak 0:669f3b0e91c8 183
WGorniak 0:669f3b0e91c8 184 #endif // __SX1272_HAL_H__