This is code is part of a Technion course project in advanced IoT, implementing a device to receive and present sensors data from a Formula racing car built by students at Technion - Israel Institute of Technology.

Dependencies:   mbed Buffer

Fork of DISCO-L072CZ-LRWAN1_LoRa_PingPong by ST

This is code is part of a Technion course project in advanced IoT, implementing a device to receive sensors data from another L072CZ-LRWAN1 installed on a Formula racing car (built by students at Technion - Israel Institute of Technology), and sends it to a GUI presenting the data (GUI project: github.com/ward-mattar/TechnionFormulaGUI).

How to install

  • Create an account on Mbed: https://os.mbed.com/account/signup/
  • Import project into Compiler
  • In the Program Workspace select "Formula_Nucleo_Receiver"
  • Select a Platform like so:
  1. Click button at top-left
  2. Add Board
  3. Search "NUCLEO F103RB" and then "Add to your Mbed Compiler"
  • Finally click "Compile", if the build was successful, the binary would download automatically
  • To install it on device simply plug it in to a PC, open device drive and drag then drop binary file in it
Committer:
wardm
Date:
Sat May 19 15:42:38 2018 +0000
Revision:
12:046346a16ff4
V1.0.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wardm 12:046346a16ff4 1 /*
wardm 12:046346a16ff4 2 / _____) _ | |
wardm 12:046346a16ff4 3 ( (____ _____ ____ _| |_ _____ ____| |__
wardm 12:046346a16ff4 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
wardm 12:046346a16ff4 5 _____) ) ____| | | || |_| ____( (___| | | |
wardm 12:046346a16ff4 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
wardm 12:046346a16ff4 7 (C) 2014 Semtech
wardm 12:046346a16ff4 8
wardm 12:046346a16ff4 9 Description: -
wardm 12:046346a16ff4 10
wardm 12:046346a16ff4 11 License: Revised BSD License, see LICENSE.TXT file include in the project
wardm 12:046346a16ff4 12
wardm 12:046346a16ff4 13 Maintainers: Miguel Luis, Gregory Cristian and Nicolas Huguenin
wardm 12:046346a16ff4 14 */
wardm 12:046346a16ff4 15
wardm 12:046346a16ff4 16 /*
wardm 12:046346a16ff4 17 * additional development to make it more generic across multiple OS versions
wardm 12:046346a16ff4 18 * (c) 2017 Helmut Tschemernjak
wardm 12:046346a16ff4 19 * 30826 Garbsen (Hannover) Germany
wardm 12:046346a16ff4 20 */
wardm 12:046346a16ff4 21
wardm 12:046346a16ff4 22 #ifndef __SX1276_MBED_HAL_H__
wardm 12:046346a16ff4 23 #define __SX1276_MBED_HAL_H__
wardm 12:046346a16ff4 24
wardm 12:046346a16ff4 25
wardm 12:046346a16ff4 26 #include "sx1276.h"
wardm 12:046346a16ff4 27
wardm 12:046346a16ff4 28
wardm 12:046346a16ff4 29 #ifdef __MBED__
wardm 12:046346a16ff4 30 #define XSPI SPI
wardm 12:046346a16ff4 31 #endif
wardm 12:046346a16ff4 32
wardm 12:046346a16ff4 33
wardm 12:046346a16ff4 34 /*!
wardm 12:046346a16ff4 35 * Actual implementation of a SX1276 radio, includes some modifications to make it
wardm 12:046346a16ff4 36 * compatible with the MB1 LAS board
wardm 12:046346a16ff4 37 */
wardm 12:046346a16ff4 38 class SX1276Generic : public SX1276
wardm 12:046346a16ff4 39 {
wardm 12:046346a16ff4 40 protected:
wardm 12:046346a16ff4 41 /*!
wardm 12:046346a16ff4 42 * Antenna switch GPIO pins objects
wardm 12:046346a16ff4 43 */
wardm 12:046346a16ff4 44 DigitalOut *_antSwitch;
wardm 12:046346a16ff4 45 DigitalOut *_antSwitchTX;
wardm 12:046346a16ff4 46 DigitalOut *_antSwitchTXBoost;
wardm 12:046346a16ff4 47
wardm 12:046346a16ff4 48 /*!
wardm 12:046346a16ff4 49 * SX1276 Reset pin
wardm 12:046346a16ff4 50 */
wardm 12:046346a16ff4 51 DigitalInOut *_reset;
wardm 12:046346a16ff4 52
wardm 12:046346a16ff4 53 /*!
wardm 12:046346a16ff4 54 * TCXO being used with the Murata Module
wardm 12:046346a16ff4 55 */
wardm 12:046346a16ff4 56 DigitalOut *_tcxo;
wardm 12:046346a16ff4 57
wardm 12:046346a16ff4 58 /*!
wardm 12:046346a16ff4 59 * SPI Interface
wardm 12:046346a16ff4 60 */
wardm 12:046346a16ff4 61 XSPI *_spi; // mosi, miso, sclk
wardm 12:046346a16ff4 62 DigitalOut *_nss;
wardm 12:046346a16ff4 63
wardm 12:046346a16ff4 64 /*!
wardm 12:046346a16ff4 65 * SX1276 DIO pins
wardm 12:046346a16ff4 66 */
wardm 12:046346a16ff4 67 InterruptIn *_dio0;
wardm 12:046346a16ff4 68 InterruptIn *_dio1;
wardm 12:046346a16ff4 69 InterruptIn *_dio2;
wardm 12:046346a16ff4 70 InterruptIn *_dio3;
wardm 12:046346a16ff4 71 InterruptIn *_dio4;
wardm 12:046346a16ff4 72 DigitalIn *_dio5;
wardm 12:046346a16ff4 73
wardm 12:046346a16ff4 74 /*!
wardm 12:046346a16ff4 75 * Tx and Rx timers
wardm 12:046346a16ff4 76 */
wardm 12:046346a16ff4 77 Timeout txTimeoutTimer;
wardm 12:046346a16ff4 78 Timeout rxTimeoutTimer;
wardm 12:046346a16ff4 79 Timeout rxTimeoutSyncWord;
wardm 12:046346a16ff4 80
wardm 12:046346a16ff4 81
wardm 12:046346a16ff4 82 private:
wardm 12:046346a16ff4 83 /*!
wardm 12:046346a16ff4 84 * triggers definition
wardm 12:046346a16ff4 85 */
wardm 12:046346a16ff4 86 typedef void (SX1276Generic::*Trigger)(void);
wardm 12:046346a16ff4 87
wardm 12:046346a16ff4 88
wardm 12:046346a16ff4 89 public:
wardm 12:046346a16ff4 90 SX1276Generic( RadioEvents_t *events, BoardType_t board,
wardm 12:046346a16ff4 91 PinName mosi, PinName miso, PinName sclk, PinName nss, PinName reset,
wardm 12:046346a16ff4 92 PinName dio0, PinName dio1, PinName dio2, PinName dio3, PinName dio4, PinName dio5,
wardm 12:046346a16ff4 93 PinName antSwitch = NC, PinName antSwitchTX= NC, PinName antSwitchTXBoost = NC, PinName tcxo = NC);
wardm 12:046346a16ff4 94
wardm 12:046346a16ff4 95
wardm 12:046346a16ff4 96 SX1276Generic( RadioEvents_t *events );
wardm 12:046346a16ff4 97
wardm 12:046346a16ff4 98 virtual ~SX1276Generic();
wardm 12:046346a16ff4 99
wardm 12:046346a16ff4 100 protected:
wardm 12:046346a16ff4 101 /*!
wardm 12:046346a16ff4 102 * @brief Initializes the radio I/Os pins interface
wardm 12:046346a16ff4 103 */
wardm 12:046346a16ff4 104 virtual void IoInit( void );
wardm 12:046346a16ff4 105
wardm 12:046346a16ff4 106 /*!
wardm 12:046346a16ff4 107 * @brief Initializes the radio SPI
wardm 12:046346a16ff4 108 */
wardm 12:046346a16ff4 109 virtual void SpiInit( void );
wardm 12:046346a16ff4 110
wardm 12:046346a16ff4 111 /*!
wardm 12:046346a16ff4 112 * @brief Initializes DIO IRQ handlers
wardm 12:046346a16ff4 113 *
wardm 12:046346a16ff4 114 * @param [IN] irqHandlers Array containing the IRQ callback functions
wardm 12:046346a16ff4 115 */
wardm 12:046346a16ff4 116 virtual void IoIrqInit( DioIrqHandler *irqHandlers );
wardm 12:046346a16ff4 117
wardm 12:046346a16ff4 118 /*!
wardm 12:046346a16ff4 119 * @brief De-initializes the radio I/Os pins interface.
wardm 12:046346a16ff4 120 *
wardm 12:046346a16ff4 121 * \remark Useful when going in MCU lowpower modes
wardm 12:046346a16ff4 122 */
wardm 12:046346a16ff4 123 virtual void IoDeInit( void );
wardm 12:046346a16ff4 124
wardm 12:046346a16ff4 125 /*!
wardm 12:046346a16ff4 126 * @brief Gets the board PA selection configuration
wardm 12:046346a16ff4 127 *
wardm 12:046346a16ff4 128 * @param [IN] channel Channel frequency in Hz
wardm 12:046346a16ff4 129 * @retval PaSelect RegPaConfig PaSelect value
wardm 12:046346a16ff4 130 */
wardm 12:046346a16ff4 131 virtual uint8_t GetPaSelect( uint32_t channel );
wardm 12:046346a16ff4 132
wardm 12:046346a16ff4 133 /*!
wardm 12:046346a16ff4 134 * @brief Set the RF Switch I/Os pins in Low Power mode
wardm 12:046346a16ff4 135 *
wardm 12:046346a16ff4 136 * @param [IN] status enable or disable
wardm 12:046346a16ff4 137 */
wardm 12:046346a16ff4 138 virtual void SetAntSwLowPower( bool status );
wardm 12:046346a16ff4 139
wardm 12:046346a16ff4 140 /*!
wardm 12:046346a16ff4 141 * @brief Initializes the RF Switch I/Os pins interface
wardm 12:046346a16ff4 142 */
wardm 12:046346a16ff4 143 virtual void AntSwInit( void );
wardm 12:046346a16ff4 144
wardm 12:046346a16ff4 145 /*!
wardm 12:046346a16ff4 146 * @brief De-initializes the RF Switch I/Os pins interface
wardm 12:046346a16ff4 147 *
wardm 12:046346a16ff4 148 * @remark Needed to decrease the power consumption in MCU lowpower modes
wardm 12:046346a16ff4 149 */
wardm 12:046346a16ff4 150 virtual void AntSwDeInit( void );
wardm 12:046346a16ff4 151
wardm 12:046346a16ff4 152 /*!
wardm 12:046346a16ff4 153 * @brief Controls the antena switch if necessary.
wardm 12:046346a16ff4 154 *
wardm 12:046346a16ff4 155 * @remark see errata note
wardm 12:046346a16ff4 156 *
wardm 12:046346a16ff4 157 * @param [IN] opMode Current radio operating mode
wardm 12:046346a16ff4 158 */
wardm 12:046346a16ff4 159 virtual void SetAntSw( uint8_t opMode );
wardm 12:046346a16ff4 160
wardm 12:046346a16ff4 161 /*
wardm 12:046346a16ff4 162 * The the Timeout for a given Timer.
wardm 12:046346a16ff4 163 */
wardm 12:046346a16ff4 164 virtual void SetTimeout(TimeoutTimer_t timer, timeoutFuncPtr, int timeout_ms = 0);
wardm 12:046346a16ff4 165
wardm 12:046346a16ff4 166 /*
wardm 12:046346a16ff4 167 * A simple ms sleep
wardm 12:046346a16ff4 168 */
wardm 12:046346a16ff4 169 virtual void Sleep_ms(int ms);
wardm 12:046346a16ff4 170
wardm 12:046346a16ff4 171
wardm 12:046346a16ff4 172 public:
wardm 12:046346a16ff4 173
wardm 12:046346a16ff4 174 /*!
wardm 12:046346a16ff4 175 * @brief Detect the board connected by reading the value of the antenna switch pin
wardm 12:046346a16ff4 176 */
wardm 12:046346a16ff4 177 virtual uint8_t DetectBoardType( void );
wardm 12:046346a16ff4 178
wardm 12:046346a16ff4 179 /*!
wardm 12:046346a16ff4 180 * @brief Checks if the given RF frequency is supported by the hardware
wardm 12:046346a16ff4 181 *
wardm 12:046346a16ff4 182 * @param [IN] frequency RF frequency to be checked
wardm 12:046346a16ff4 183 * @retval isSupported [true: supported, false: unsupported]
wardm 12:046346a16ff4 184 */
wardm 12:046346a16ff4 185 virtual bool CheckRfFrequency( uint32_t frequency );
wardm 12:046346a16ff4 186
wardm 12:046346a16ff4 187 /*!
wardm 12:046346a16ff4 188 * @brief Writes the radio register at the specified address
wardm 12:046346a16ff4 189 *
wardm 12:046346a16ff4 190 * @param [IN]: addr Register address
wardm 12:046346a16ff4 191 * @param [IN]: data New register value
wardm 12:046346a16ff4 192 */
wardm 12:046346a16ff4 193 virtual void Write ( uint8_t addr, uint8_t data ) ;
wardm 12:046346a16ff4 194
wardm 12:046346a16ff4 195 /*!
wardm 12:046346a16ff4 196 * @brief Reads the radio register at the specified address
wardm 12:046346a16ff4 197 *
wardm 12:046346a16ff4 198 * @param [IN]: addr Register address
wardm 12:046346a16ff4 199 * @retval data Register value
wardm 12:046346a16ff4 200 */
wardm 12:046346a16ff4 201 virtual uint8_t Read ( uint8_t addr ) ;
wardm 12:046346a16ff4 202
wardm 12:046346a16ff4 203 /*!
wardm 12:046346a16ff4 204 * @brief Writes multiple radio registers starting at address
wardm 12:046346a16ff4 205 *
wardm 12:046346a16ff4 206 * @param [IN] addr First Radio register address
wardm 12:046346a16ff4 207 * @param [IN] buffer Buffer containing the new register's values
wardm 12:046346a16ff4 208 * @param [IN] size Number of registers to be written
wardm 12:046346a16ff4 209 */
wardm 12:046346a16ff4 210 virtual void Write( uint8_t addr, void *buffer, uint8_t size ) ;
wardm 12:046346a16ff4 211
wardm 12:046346a16ff4 212 /*!
wardm 12:046346a16ff4 213 * @brief Reads multiple radio registers starting at address
wardm 12:046346a16ff4 214 *
wardm 12:046346a16ff4 215 * @param [IN] addr First Radio register address
wardm 12:046346a16ff4 216 * @param [OUT] buffer Buffer where to copy the registers data
wardm 12:046346a16ff4 217 * @param [IN] size Number of registers to be read
wardm 12:046346a16ff4 218 */
wardm 12:046346a16ff4 219 virtual void Read ( uint8_t addr, void *buffer, uint8_t size ) ;
wardm 12:046346a16ff4 220
wardm 12:046346a16ff4 221 /*!
wardm 12:046346a16ff4 222 * @brief Writes the buffer contents to the SX1276 FIFO
wardm 12:046346a16ff4 223 *
wardm 12:046346a16ff4 224 * @param [IN] buffer Buffer containing data to be put on the FIFO.
wardm 12:046346a16ff4 225 * @param [IN] size Number of bytes to be written to the FIFO
wardm 12:046346a16ff4 226 */
wardm 12:046346a16ff4 227 virtual void WriteFifo( void *buffer, uint8_t size ) ;
wardm 12:046346a16ff4 228
wardm 12:046346a16ff4 229 /*!
wardm 12:046346a16ff4 230 * @brief Reads the contents of the SX1276 FIFO
wardm 12:046346a16ff4 231 *
wardm 12:046346a16ff4 232 * @param [OUT] buffer Buffer where to copy the FIFO read data.
wardm 12:046346a16ff4 233 * @param [IN] size Number of bytes to be read from the FIFO
wardm 12:046346a16ff4 234 */
wardm 12:046346a16ff4 235 virtual void ReadFifo( void *buffer, uint8_t size ) ;
wardm 12:046346a16ff4 236
wardm 12:046346a16ff4 237 /*!
wardm 12:046346a16ff4 238 * @brief Reset the SX1276
wardm 12:046346a16ff4 239 */
wardm 12:046346a16ff4 240 virtual void Reset( void );
wardm 12:046346a16ff4 241
wardm 12:046346a16ff4 242 /*!
wardm 12:046346a16ff4 243 * \brief Sets the radio output power.
wardm 12:046346a16ff4 244 *
wardm 12:046346a16ff4 245 * @param [IN] power Sets the RF output power
wardm 12:046346a16ff4 246 */
wardm 12:046346a16ff4 247 virtual void SetRfTxPower( int8_t power );
wardm 12:046346a16ff4 248
wardm 12:046346a16ff4 249 };
wardm 12:046346a16ff4 250
wardm 12:046346a16ff4 251 #endif // __SX1276_MBED_HAL_H__