pin pong

Dependents:   SX1272PingPong

Fork of SX1276Lib by Semtech

Committer:
tmulrooney
Date:
Tue Feb 09 02:05:06 2016 +0000
Revision:
23:273a2f93ae99
Child:
24:9100348e6c28
ping pong

Who changed what in which revision?

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