With error debug.h

Fork of SX1272Lib by Semtech

Committer:
mluis
Date:
Fri May 13 14:49:34 2016 +0000
Revision:
4:90bd79f1b458
Parent:
2:cd1093b6676f
Synchronized with https://github.com/Lora-net/LoRaMac-node radio drivers git revision 55d16ca8949c09ee241c87b7600e2a8bc90d3743

Who changed what in which revision?

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