SX1276 library for modtronix inair9. Edited for use with NRF51DK board.
Fork of SX1276Lib_modtronix by
sx1276/sx1276-inAir.h@16:0927c093fd82, 2015-03-02 (annotated)
- Committer:
- modtronix
- Date:
- Mon Mar 02 23:54:25 2015 +0000
- Revision:
- 16:0927c093fd82
- Child:
- 18:cdb08d710838
Enabled all bandwidths, added Modtronix inAir9 module
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
modtronix | 16:0927c093fd82 | 1 | /* |
modtronix | 16:0927c093fd82 | 2 | Description: - |
modtronix | 16:0927c093fd82 | 3 | |
modtronix | 16:0927c093fd82 | 4 | License: Revised BSD License, see LICENSE.TXT file include in the project |
modtronix | 16:0927c093fd82 | 5 | |
modtronix | 16:0927c093fd82 | 6 | Maintainers: Miguel Luis, Gregory Cristian and Nicolas Huguenin |
modtronix | 16:0927c093fd82 | 7 | */ |
modtronix | 16:0927c093fd82 | 8 | #ifndef __SX1276_HAL_H__ |
modtronix | 16:0927c093fd82 | 9 | #define __SX1276_HAL_H__ |
modtronix | 16:0927c093fd82 | 10 | #include "sx1276.h" |
modtronix | 16:0927c093fd82 | 11 | |
modtronix | 16:0927c093fd82 | 12 | /*! |
modtronix | 16:0927c093fd82 | 13 | * Modtronix inAir9 board with SX1276 radio. This board supports 868MHz and 915MHz at 14dBm (no boost circuit) |
modtronix | 16:0927c093fd82 | 14 | */ |
modtronix | 16:0927c093fd82 | 15 | class SX1276inAir9 : public SX1276 |
modtronix | 16:0927c093fd82 | 16 | { |
modtronix | 16:0927c093fd82 | 17 | protected: |
modtronix | 16:0927c093fd82 | 18 | /*! |
modtronix | 16:0927c093fd82 | 19 | * Antenna switch GPIO pins objects |
modtronix | 16:0927c093fd82 | 20 | */ |
modtronix | 16:0927c093fd82 | 21 | DigitalInOut antSwitch; |
modtronix | 16:0927c093fd82 | 22 | |
modtronix | 16:0927c093fd82 | 23 | DigitalIn fake; |
modtronix | 16:0927c093fd82 | 24 | |
modtronix | 16:0927c093fd82 | 25 | private: |
modtronix | 16:0927c093fd82 | 26 | static const RadioRegisters_t RadioRegsInit[]; |
modtronix | 16:0927c093fd82 | 27 | |
modtronix | 16:0927c093fd82 | 28 | public: |
modtronix | 16:0927c093fd82 | 29 | SX1276inAir9( void ( *txDone )( ), void ( *txTimeout ) ( ), void ( *rxDone ) ( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ), |
modtronix | 16:0927c093fd82 | 30 | void ( *rxTimeout ) ( ), void ( *rxError ) ( ), void ( *fhssChangeChannel ) ( uint8_t channelIndex ), void ( *cadDone ) ( bool ChannelActivityDetected ), |
modtronix | 16:0927c093fd82 | 31 | PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset, |
modtronix | 16:0927c093fd82 | 32 | PinName dio0, PinName dio1, PinName dio2, PinName dio3, PinName dio4, PinName dio5, |
modtronix | 16:0927c093fd82 | 33 | PinName antSwitch ); |
modtronix | 16:0927c093fd82 | 34 | SX1276inAir9( void ( *txDone )( ), void ( *txTimeout ) ( ), void ( *rxDone ) ( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ), |
modtronix | 16:0927c093fd82 | 35 | void ( *rxTimeout ) ( ), void ( *rxError ) ( ), void ( *fhssChangeChannel ) ( uint8_t channelIndex ), void ( *cadDone ) ( bool ChannelActivityDetected ) ); |
modtronix | 16:0927c093fd82 | 36 | virtual ~SX1276inAir9( ) { }; |
modtronix | 16:0927c093fd82 | 37 | |
modtronix | 16:0927c093fd82 | 38 | protected: |
modtronix | 16:0927c093fd82 | 39 | /*! |
modtronix | 16:0927c093fd82 | 40 | * @brief Initializes the radio I/Os pins interface |
modtronix | 16:0927c093fd82 | 41 | */ |
modtronix | 16:0927c093fd82 | 42 | virtual void IoInit( void ); |
modtronix | 16:0927c093fd82 | 43 | |
modtronix | 16:0927c093fd82 | 44 | /*! |
modtronix | 16:0927c093fd82 | 45 | * @brief Initializes the radio registers |
modtronix | 16:0927c093fd82 | 46 | */ |
modtronix | 16:0927c093fd82 | 47 | virtual void RadioRegistersInit( ); |
modtronix | 16:0927c093fd82 | 48 | |
modtronix | 16:0927c093fd82 | 49 | /*! |
modtronix | 16:0927c093fd82 | 50 | * @brief Initializes the radio SPI |
modtronix | 16:0927c093fd82 | 51 | */ |
modtronix | 16:0927c093fd82 | 52 | virtual void SpiInit( void ); |
modtronix | 16:0927c093fd82 | 53 | |
modtronix | 16:0927c093fd82 | 54 | /*! |
modtronix | 16:0927c093fd82 | 55 | * @brief Initializes DIO IRQ handlers |
modtronix | 16:0927c093fd82 | 56 | * |
modtronix | 16:0927c093fd82 | 57 | * @param [IN] irqHandlers Array containing the IRQ callback functions |
modtronix | 16:0927c093fd82 | 58 | */ |
modtronix | 16:0927c093fd82 | 59 | virtual void IoIrqInit( DioIrqHandler *irqHandlers ); |
modtronix | 16:0927c093fd82 | 60 | |
modtronix | 16:0927c093fd82 | 61 | /*! |
modtronix | 16:0927c093fd82 | 62 | * @brief De-initializes the radio I/Os pins interface. |
modtronix | 16:0927c093fd82 | 63 | * |
modtronix | 16:0927c093fd82 | 64 | * \remark Useful when going in MCU lowpower modes |
modtronix | 16:0927c093fd82 | 65 | */ |
modtronix | 16:0927c093fd82 | 66 | virtual void IoDeInit( void ); |
modtronix | 16:0927c093fd82 | 67 | |
modtronix | 16:0927c093fd82 | 68 | /*! |
modtronix | 16:0927c093fd82 | 69 | * @brief Gets the board PA selection configuration |
modtronix | 16:0927c093fd82 | 70 | * |
modtronix | 16:0927c093fd82 | 71 | * @param [IN] channel Channel frequency in Hz |
modtronix | 16:0927c093fd82 | 72 | * @retval PaSelect RegPaConfig PaSelect value |
modtronix | 16:0927c093fd82 | 73 | */ |
modtronix | 16:0927c093fd82 | 74 | virtual uint8_t GetPaSelect( uint32_t channel ); |
modtronix | 16:0927c093fd82 | 75 | |
modtronix | 16:0927c093fd82 | 76 | /*! |
modtronix | 16:0927c093fd82 | 77 | * @brief Set the RF Switch I/Os pins in Low Power mode |
modtronix | 16:0927c093fd82 | 78 | * |
modtronix | 16:0927c093fd82 | 79 | * @param [IN] status enable or disable |
modtronix | 16:0927c093fd82 | 80 | */ |
modtronix | 16:0927c093fd82 | 81 | virtual void SetAntSwLowPower( bool status ); |
modtronix | 16:0927c093fd82 | 82 | |
modtronix | 16:0927c093fd82 | 83 | /*! |
modtronix | 16:0927c093fd82 | 84 | * @brief Initializes the RF Switch I/Os pins interface |
modtronix | 16:0927c093fd82 | 85 | */ |
modtronix | 16:0927c093fd82 | 86 | virtual void AntSwInit( void ); |
modtronix | 16:0927c093fd82 | 87 | |
modtronix | 16:0927c093fd82 | 88 | /*! |
modtronix | 16:0927c093fd82 | 89 | * @brief De-initializes the RF Switch I/Os pins interface |
modtronix | 16:0927c093fd82 | 90 | * |
modtronix | 16:0927c093fd82 | 91 | * \remark Needed to decrease the power consumption in MCU lowpower modes |
modtronix | 16:0927c093fd82 | 92 | */ |
modtronix | 16:0927c093fd82 | 93 | virtual void AntSwDeInit( void ); |
modtronix | 16:0927c093fd82 | 94 | |
modtronix | 16:0927c093fd82 | 95 | /*! |
modtronix | 16:0927c093fd82 | 96 | * @brief Controls the antena switch if necessary. |
modtronix | 16:0927c093fd82 | 97 | * |
modtronix | 16:0927c093fd82 | 98 | * \remark see errata note |
modtronix | 16:0927c093fd82 | 99 | * |
modtronix | 16:0927c093fd82 | 100 | * @param [IN] rxTx [1: Tx, 0: Rx] |
modtronix | 16:0927c093fd82 | 101 | */ |
modtronix | 16:0927c093fd82 | 102 | virtual void SetAntSw( uint8_t rxTx ); |
modtronix | 16:0927c093fd82 | 103 | |
modtronix | 16:0927c093fd82 | 104 | public: |
modtronix | 16:0927c093fd82 | 105 | /*! |
modtronix | 16:0927c093fd82 | 106 | * @brief Detect the board connected by reading the value of the antenna switch pin |
modtronix | 16:0927c093fd82 | 107 | */ |
modtronix | 16:0927c093fd82 | 108 | virtual uint8_t DetectBoardType( void ); |
modtronix | 16:0927c093fd82 | 109 | |
modtronix | 16:0927c093fd82 | 110 | /*! |
modtronix | 16:0927c093fd82 | 111 | * @brief Checks if the given RF frequency is supported by the hardware |
modtronix | 16:0927c093fd82 | 112 | * |
modtronix | 16:0927c093fd82 | 113 | * @param [IN] frequency RF frequency to be checked |
modtronix | 16:0927c093fd82 | 114 | * @retval isSupported [true: supported, false: unsupported] |
modtronix | 16:0927c093fd82 | 115 | */ |
modtronix | 16:0927c093fd82 | 116 | virtual bool CheckRfFrequency( uint32_t frequency ); |
modtronix | 16:0927c093fd82 | 117 | |
modtronix | 16:0927c093fd82 | 118 | /*! |
modtronix | 16:0927c093fd82 | 119 | * @brief Writes the radio register at the specified address |
modtronix | 16:0927c093fd82 | 120 | * |
modtronix | 16:0927c093fd82 | 121 | * @param [IN]: addr Register address |
modtronix | 16:0927c093fd82 | 122 | * @param [IN]: data New register value |
modtronix | 16:0927c093fd82 | 123 | */ |
modtronix | 16:0927c093fd82 | 124 | virtual void Write ( uint8_t addr, uint8_t data ) ; |
modtronix | 16:0927c093fd82 | 125 | |
modtronix | 16:0927c093fd82 | 126 | /*! |
modtronix | 16:0927c093fd82 | 127 | * @brief Reads the radio register at the specified address |
modtronix | 16:0927c093fd82 | 128 | * |
modtronix | 16:0927c093fd82 | 129 | * @param [IN]: addr Register address |
modtronix | 16:0927c093fd82 | 130 | * @retval data Register value |
modtronix | 16:0927c093fd82 | 131 | */ |
modtronix | 16:0927c093fd82 | 132 | virtual uint8_t Read ( uint8_t addr ) ; |
modtronix | 16:0927c093fd82 | 133 | |
modtronix | 16:0927c093fd82 | 134 | /*! |
modtronix | 16:0927c093fd82 | 135 | * @brief Writes multiple radio registers starting at address |
modtronix | 16:0927c093fd82 | 136 | * |
modtronix | 16:0927c093fd82 | 137 | * @param [IN] addr First Radio register address |
modtronix | 16:0927c093fd82 | 138 | * @param [IN] buffer Buffer containing the new register's values |
modtronix | 16:0927c093fd82 | 139 | * @param [IN] size Number of registers to be written |
modtronix | 16:0927c093fd82 | 140 | */ |
modtronix | 16:0927c093fd82 | 141 | virtual void Write( uint8_t addr, uint8_t *buffer, uint8_t size ) ; |
modtronix | 16:0927c093fd82 | 142 | |
modtronix | 16:0927c093fd82 | 143 | /*! |
modtronix | 16:0927c093fd82 | 144 | * @brief Reads multiple radio registers starting at address |
modtronix | 16:0927c093fd82 | 145 | * |
modtronix | 16:0927c093fd82 | 146 | * @param [IN] addr First Radio register address |
modtronix | 16:0927c093fd82 | 147 | * @param [OUT] buffer Buffer where to copy the registers data |
modtronix | 16:0927c093fd82 | 148 | * @param [IN] size Number of registers to be read |
modtronix | 16:0927c093fd82 | 149 | */ |
modtronix | 16:0927c093fd82 | 150 | virtual void Read ( uint8_t addr, uint8_t *buffer, uint8_t size ) ; |
modtronix | 16:0927c093fd82 | 151 | |
modtronix | 16:0927c093fd82 | 152 | /*! |
modtronix | 16:0927c093fd82 | 153 | * @brief Writes the buffer contents to the SX1276 FIFO |
modtronix | 16:0927c093fd82 | 154 | * |
modtronix | 16:0927c093fd82 | 155 | * @param [IN] buffer Buffer containing data to be put on the FIFO. |
modtronix | 16:0927c093fd82 | 156 | * @param [IN] size Number of bytes to be written to the FIFO |
modtronix | 16:0927c093fd82 | 157 | */ |
modtronix | 16:0927c093fd82 | 158 | virtual void WriteFifo( uint8_t *buffer, uint8_t size ) ; |
modtronix | 16:0927c093fd82 | 159 | |
modtronix | 16:0927c093fd82 | 160 | /*! |
modtronix | 16:0927c093fd82 | 161 | * @brief Reads the contents of the SX1276 FIFO |
modtronix | 16:0927c093fd82 | 162 | * |
modtronix | 16:0927c093fd82 | 163 | * @param [OUT] buffer Buffer where to copy the FIFO read data. |
modtronix | 16:0927c093fd82 | 164 | * @param [IN] size Number of bytes to be read from the FIFO |
modtronix | 16:0927c093fd82 | 165 | */ |
modtronix | 16:0927c093fd82 | 166 | virtual void ReadFifo( uint8_t *buffer, uint8_t size ) ; |
modtronix | 16:0927c093fd82 | 167 | |
modtronix | 16:0927c093fd82 | 168 | /*! |
modtronix | 16:0927c093fd82 | 169 | * @brief Reset the SX1276 |
modtronix | 16:0927c093fd82 | 170 | */ |
modtronix | 16:0927c093fd82 | 171 | virtual void Reset( void ); |
modtronix | 16:0927c093fd82 | 172 | }; |
modtronix | 16:0927c093fd82 | 173 | |
modtronix | 16:0927c093fd82 | 174 | #endif // __SX1276_HAL_H__ |