test

Dependents:   LoRaWAN-lmic-app_tjm

Fork of SX1276Lib by Semtech

Committer:
tmulrooney
Date:
Thu Feb 25 21:28:39 2016 +0000
Revision:
25:856779ac8921
Parent:
23:952530fa968d
first successful join

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tmulrooney 23:952530fa968d 1 /*
tmulrooney 23:952530fa968d 2 / _____) _ | |
tmulrooney 23:952530fa968d 3 ( (____ _____ ____ _| |_ _____ ____| |__
tmulrooney 23:952530fa968d 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
tmulrooney 23:952530fa968d 5 _____) ) ____| | | || |_| ____( (___| | | |
tmulrooney 23:952530fa968d 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
tmulrooney 23:952530fa968d 7 (C) 2014 Semtech
tmulrooney 23:952530fa968d 8
tmulrooney 23:952530fa968d 9 Description: -
tmulrooney 23:952530fa968d 10
tmulrooney 23:952530fa968d 11 License: Revised BSD License, see LICENSE.TXT file include in the project
tmulrooney 23:952530fa968d 12
tmulrooney 23:952530fa968d 13 Maintainers: Miguel Luis, Gregory Cristian and Nicolas Huguenin
tmulrooney 23:952530fa968d 14 */
tmulrooney 23:952530fa968d 15 #ifndef __SX1272_HAL_H__
tmulrooney 23:952530fa968d 16 #define __SX1272_HAL_H__
tmulrooney 23:952530fa968d 17 #include "sx1272.h"
tmulrooney 23:952530fa968d 18
tmulrooney 23:952530fa968d 19 /*!
tmulrooney 23:952530fa968d 20 * \brief Radio hardware registers initialization definition
tmulrooney 23:952530fa968d 21 *
tmulrooney 23:952530fa968d 22 * \remark Can be automatically generated by the SX1272 GUI (not yet implemented)
tmulrooney 23:952530fa968d 23 */
tmulrooney 23:952530fa968d 24 #define RADIO_INIT_REGISTERS_VALUE \
tmulrooney 23:952530fa968d 25 { \
tmulrooney 23:952530fa968d 26 { MODEM_FSK , REG_LNA , 0x23 },\
tmulrooney 23:952530fa968d 27 { MODEM_FSK , REG_RXCONFIG , 0x1E },\
tmulrooney 23:952530fa968d 28 { MODEM_FSK , REG_RSSICONFIG , 0xD2 },\
tmulrooney 23:952530fa968d 29 { MODEM_FSK , REG_PREAMBLEDETECT , 0xAA },\
tmulrooney 23:952530fa968d 30 { MODEM_FSK , REG_OSC , 0x07 },\
tmulrooney 23:952530fa968d 31 { MODEM_FSK , REG_SYNCCONFIG , 0x12 },\
tmulrooney 23:952530fa968d 32 { MODEM_FSK , REG_SYNCVALUE1 , 0xC1 },\
tmulrooney 23:952530fa968d 33 { MODEM_FSK , REG_SYNCVALUE2 , 0x94 },\
tmulrooney 23:952530fa968d 34 { MODEM_FSK , REG_SYNCVALUE3 , 0xC1 },\
tmulrooney 23:952530fa968d 35 { MODEM_FSK , REG_PACKETCONFIG1 , 0xD8 },\
tmulrooney 23:952530fa968d 36 { MODEM_FSK , REG_FIFOTHRESH , 0x8F },\
tmulrooney 23:952530fa968d 37 { MODEM_FSK , REG_IMAGECAL , 0x02 },\
tmulrooney 23:952530fa968d 38 { MODEM_FSK , REG_DIOMAPPING1 , 0x00 },\
tmulrooney 23:952530fa968d 39 { MODEM_FSK , REG_DIOMAPPING2 , 0x30 },\
tmulrooney 23:952530fa968d 40 { MODEM_LORA, REG_LR_PAYLOADMAXLENGTH, 0x40 },\
tmulrooney 23:952530fa968d 41 } \
tmulrooney 23:952530fa968d 42
tmulrooney 23:952530fa968d 43 /*!
tmulrooney 23:952530fa968d 44 * Actual implementation of a SX1272 radio, includes some modifications to make it compatible with the MB1 LAS board
tmulrooney 23:952530fa968d 45 */
tmulrooney 23:952530fa968d 46 class SX1272MB1xAS : public SX1272
tmulrooney 23:952530fa968d 47 {
tmulrooney 23:952530fa968d 48 protected:
tmulrooney 23:952530fa968d 49 /*!
tmulrooney 23:952530fa968d 50 * Antenna switch GPIO pins objects
tmulrooney 23:952530fa968d 51 */
tmulrooney 23:952530fa968d 52 DigitalInOut antSwitch;
tmulrooney 23:952530fa968d 53
tmulrooney 23:952530fa968d 54 DigitalIn fake;
tmulrooney 23:952530fa968d 55
tmulrooney 23:952530fa968d 56 private:
tmulrooney 23:952530fa968d 57 static const RadioRegisters_t RadioRegsInit[];
tmulrooney 23:952530fa968d 58
tmulrooney 23:952530fa968d 59 public:
tmulrooney 23:952530fa968d 60 SX1272MB1xAS( RadioEvents_t *events,
tmulrooney 23:952530fa968d 61 PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset,
tmulrooney 23:952530fa968d 62 PinName dio0, PinName dio1, PinName dio2, PinName dio3, PinName dio4, PinName dio5,
tmulrooney 23:952530fa968d 63 PinName antSwitch );
tmulrooney 23:952530fa968d 64
tmulrooney 23:952530fa968d 65 SX1272MB1xAS( RadioEvents_t *events );
tmulrooney 23:952530fa968d 66
tmulrooney 23:952530fa968d 67 virtual ~SX1272MB1xAS( ) { };
tmulrooney 23:952530fa968d 68
tmulrooney 23:952530fa968d 69 protected:
tmulrooney 23:952530fa968d 70 /*!
tmulrooney 23:952530fa968d 71 * @brief Initializes the radio I/Os pins interface
tmulrooney 23:952530fa968d 72 */
tmulrooney 23:952530fa968d 73 virtual void IoInit( void );
tmulrooney 23:952530fa968d 74
tmulrooney 23:952530fa968d 75 /*!
tmulrooney 23:952530fa968d 76 * @brief Initializes the radio registers
tmulrooney 23:952530fa968d 77 */
tmulrooney 23:952530fa968d 78 virtual void RadioRegistersInit( );
tmulrooney 23:952530fa968d 79
tmulrooney 23:952530fa968d 80 /*!
tmulrooney 23:952530fa968d 81 * @brief Initializes the radio SPI
tmulrooney 23:952530fa968d 82 */
tmulrooney 23:952530fa968d 83 virtual void SpiInit( void );
tmulrooney 23:952530fa968d 84
tmulrooney 23:952530fa968d 85 /*!
tmulrooney 23:952530fa968d 86 * @brief Initializes DIO IRQ handlers
tmulrooney 23:952530fa968d 87 *
tmulrooney 23:952530fa968d 88 * @param [IN] irqHandlers Array containing the IRQ callback functions
tmulrooney 23:952530fa968d 89 */
tmulrooney 23:952530fa968d 90 virtual void IoIrqInit( DioIrqHandler *irqHandlers );
tmulrooney 23:952530fa968d 91
tmulrooney 23:952530fa968d 92 /*!
tmulrooney 23:952530fa968d 93 * @brief De-initializes the radio I/Os pins interface.
tmulrooney 23:952530fa968d 94 *
tmulrooney 23:952530fa968d 95 * \remark Useful when going in MCU lowpower modes
tmulrooney 23:952530fa968d 96 */
tmulrooney 23:952530fa968d 97 virtual void IoDeInit( void );
tmulrooney 23:952530fa968d 98
tmulrooney 23:952530fa968d 99 /*!
tmulrooney 23:952530fa968d 100 * @brief Gets the board PA selection configuration
tmulrooney 23:952530fa968d 101 *
tmulrooney 23:952530fa968d 102 * @param [IN] channel Channel frequency in Hz
tmulrooney 23:952530fa968d 103 * @retval PaSelect RegPaConfig PaSelect value
tmulrooney 23:952530fa968d 104 */
tmulrooney 23:952530fa968d 105 virtual uint8_t GetPaSelect( uint32_t channel );
tmulrooney 23:952530fa968d 106
tmulrooney 23:952530fa968d 107 /*!
tmulrooney 23:952530fa968d 108 * @brief Set the RF Switch I/Os pins in Low Power mode
tmulrooney 23:952530fa968d 109 *
tmulrooney 23:952530fa968d 110 * @param [IN] status enable or disable
tmulrooney 23:952530fa968d 111 */
tmulrooney 23:952530fa968d 112 virtual void SetAntSwLowPower( bool status );
tmulrooney 23:952530fa968d 113
tmulrooney 23:952530fa968d 114 /*!
tmulrooney 23:952530fa968d 115 * @brief Initializes the RF Switch I/Os pins interface
tmulrooney 23:952530fa968d 116 */
tmulrooney 23:952530fa968d 117 virtual void AntSwInit( void );
tmulrooney 23:952530fa968d 118
tmulrooney 23:952530fa968d 119 /*!
tmulrooney 23:952530fa968d 120 * @brief De-initializes the RF Switch I/Os pins interface
tmulrooney 23:952530fa968d 121 *
tmulrooney 23:952530fa968d 122 * \remark Needed to decrease the power consumption in MCU lowpower modes
tmulrooney 23:952530fa968d 123 */
tmulrooney 23:952530fa968d 124 virtual void AntSwDeInit( void );
tmulrooney 23:952530fa968d 125
tmulrooney 23:952530fa968d 126 /*!
tmulrooney 23:952530fa968d 127 * @brief Controls the antena switch if necessary.
tmulrooney 23:952530fa968d 128 *
tmulrooney 23:952530fa968d 129 * \remark see errata note
tmulrooney 23:952530fa968d 130 *
tmulrooney 23:952530fa968d 131 * @param [IN] rxTx [1: Tx, 0: Rx]
tmulrooney 23:952530fa968d 132 */
tmulrooney 23:952530fa968d 133 virtual void SetAntSw( uint8_t rxTx );
tmulrooney 23:952530fa968d 134
tmulrooney 23:952530fa968d 135 public:
tmulrooney 23:952530fa968d 136 /*!
tmulrooney 23:952530fa968d 137 * @brief Detect the board connected by reading the value of the antenna switch pin
tmulrooney 23:952530fa968d 138 */
tmulrooney 23:952530fa968d 139 virtual uint8_t DetectBoardType( void );
tmulrooney 23:952530fa968d 140
tmulrooney 23:952530fa968d 141 /*!
tmulrooney 23:952530fa968d 142 * @brief Checks if the given RF frequency is supported by the hardware
tmulrooney 23:952530fa968d 143 *
tmulrooney 23:952530fa968d 144 * @param [IN] frequency RF frequency to be checked
tmulrooney 23:952530fa968d 145 * @retval isSupported [true: supported, false: unsupported]
tmulrooney 23:952530fa968d 146 */
tmulrooney 23:952530fa968d 147 virtual bool CheckRfFrequency( uint32_t frequency );
tmulrooney 23:952530fa968d 148
tmulrooney 23:952530fa968d 149 /*!
tmulrooney 23:952530fa968d 150 * @brief Writes the radio register at the specified address
tmulrooney 23:952530fa968d 151 *
tmulrooney 23:952530fa968d 152 * @param [IN]: addr Register address
tmulrooney 23:952530fa968d 153 * @param [IN]: data New register value
tmulrooney 23:952530fa968d 154 */
tmulrooney 23:952530fa968d 155 virtual void Write ( uint8_t addr, uint8_t data ) ;
tmulrooney 23:952530fa968d 156
tmulrooney 23:952530fa968d 157 /*!
tmulrooney 23:952530fa968d 158 * @brief Reads the radio register at the specified address
tmulrooney 23:952530fa968d 159 *
tmulrooney 23:952530fa968d 160 * @param [IN]: addr Register address
tmulrooney 23:952530fa968d 161 * @retval data Register value
tmulrooney 23:952530fa968d 162 */
tmulrooney 23:952530fa968d 163 virtual uint8_t Read ( uint8_t addr ) ;
tmulrooney 23:952530fa968d 164
tmulrooney 23:952530fa968d 165 /*!
tmulrooney 23:952530fa968d 166 * @brief Writes multiple radio registers starting at address
tmulrooney 23:952530fa968d 167 *
tmulrooney 23:952530fa968d 168 * @param [IN] addr First Radio register address
tmulrooney 23:952530fa968d 169 * @param [IN] buffer Buffer containing the new register's values
tmulrooney 23:952530fa968d 170 * @param [IN] size Number of registers to be written
tmulrooney 23:952530fa968d 171 */
tmulrooney 23:952530fa968d 172 virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) ;
tmulrooney 23:952530fa968d 173
tmulrooney 23:952530fa968d 174 /*!
tmulrooney 23:952530fa968d 175 * @brief Reads multiple radio registers starting at address
tmulrooney 23:952530fa968d 176 *
tmulrooney 23:952530fa968d 177 * @param [IN] addr First Radio register address
tmulrooney 23:952530fa968d 178 * @param [OUT] buffer Buffer where to copy the registers data
tmulrooney 23:952530fa968d 179 * @param [IN] size Number of registers to be read
tmulrooney 23:952530fa968d 180 */
tmulrooney 23:952530fa968d 181 virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) ;
tmulrooney 23:952530fa968d 182
tmulrooney 23:952530fa968d 183 /*!
tmulrooney 23:952530fa968d 184 * @brief Writes the buffer contents to the SX1272 FIFO
tmulrooney 23:952530fa968d 185 *
tmulrooney 23:952530fa968d 186 * @param [IN] buffer Buffer containing data to be put on the FIFO.
tmulrooney 23:952530fa968d 187 * @param [IN] size Number of bytes to be written to the FIFO
tmulrooney 23:952530fa968d 188 */
tmulrooney 23:952530fa968d 189 virtual void WriteFifo( uint8_t *buffer, uint8_t size ) ;
tmulrooney 23:952530fa968d 190
tmulrooney 23:952530fa968d 191 /*!
tmulrooney 23:952530fa968d 192 * @brief Reads the contents of the SX1272 FIFO
tmulrooney 23:952530fa968d 193 *
tmulrooney 23:952530fa968d 194 * @param [OUT] buffer Buffer where to copy the FIFO read data.
tmulrooney 23:952530fa968d 195 * @param [IN] size Number of bytes to be read from the FIFO
tmulrooney 23:952530fa968d 196 */
tmulrooney 23:952530fa968d 197 virtual void ReadFifo( uint8_t *buffer, uint8_t size ) ;
tmulrooney 23:952530fa968d 198
tmulrooney 23:952530fa968d 199 /*!
tmulrooney 23:952530fa968d 200 * @brief Reset the SX1272
tmulrooney 23:952530fa968d 201 */
tmulrooney 23:952530fa968d 202 virtual void Reset( void );
tmulrooney 23:952530fa968d 203 };
tmulrooney 23:952530fa968d 204
tmulrooney 23:952530fa968d 205 #endif // __SX1272_HAL_H__