this is the working code for the xdot to read in serial from the pi and send it over LoRa

Committer:
Jenkins@KEILDM1.dc.multitech.prv
Date:
Thu Aug 29 08:40:49 2019 -0500
Revision:
18:d7332302f5f1
Parent:
16:4a382fe8f51b
Child:
19:aa5b1fcd05be
xdot-library revision 3.2.2-19-g285e497 and mbed-os revision mbed-os-5.13.4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 1 /*
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 2 / _____) _ | |
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 3 ( (____ _____ ____ _| |_ _____ ____| |__
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 5 _____) ) ____| | | || |_| ____( (___| | | |
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 7 (C)2013 Semtech
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 8
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 9 Description: Generic radio driver definition
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 10
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 11 License: Revised BSD License, see LICENSE.TXT file include in the project
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 12
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 13 Maintainer: Miguel Luis and Gregory Cristian
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 14 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 15 #ifndef __SXRADIO_H__
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 16 #define __SXRADIO_H__
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 17
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 18 #include <stdint.h>
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 19 #include "SxRadioEvents.h"
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 20
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 21 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 22 * \brief Radio driver definition
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 23 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 24 class SxRadio
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 25 {
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 26 public:
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 27 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 28 * Radio driver supported modems
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 29 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 30 typedef enum
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 31 {
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 32 MODEM_FSK = 0,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 33 MODEM_LORA,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 34 }RadioModems_t;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 35
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 36 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 37 * Radio driver internal state machine states definition
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 38 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 39 typedef enum
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 40 {
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 41 RF_IDLE = 0,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 42 RF_RX_RUNNING,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 43 RF_TX_RUNNING,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 44 RF_CAD,
Jenkins@KEILDM1.dc.multitech.prv 18:d7332302f5f1 45 RF_LBT
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 46 }RadioState_t;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 47
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 48 SxRadio(uint32_t WakeupTime) : WakeupTime(WakeupTime), freq_offset(0), State(RF_IDLE), Modem(MODEM_LORA) { }
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 49 virtual ~SxRadio() {};
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 50
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 51 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 52 * \brief Initializes the radio
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 53 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 54 * \param [IN] events Structure containing the driver callback functions
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 55 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 56 virtual void Init( SxRadioEvents *events ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 57 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 58 * \brief Prepares the radio for destruction
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 59 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 60 virtual void Terminate( void ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 61 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 62 * Return current radio status
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 63 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 64 * \param status Radio status.[RF_IDLE, RF_RX_RUNNING, RF_TX_RUNNING]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 65 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 66 virtual RadioState_t Status( void ) { return State; }
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 67 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 68 * \brief Configures the radio with the given modem
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 69 *
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 70 * \param [IN] modem Modem to be used [0: FSK, 1: LoRa]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 71 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 72 virtual void SetModem( RadioModems_t modem ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 73 virtual RadioModems_t GetModem( void ) { return Modem; }
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 74 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 75 * \brief Sets the channel frequency
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 76 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 77 * \param [IN] freq Channel RF frequency
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 78 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 79 virtual void SetChannel( uint32_t freq ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 80 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 81 * \brief Sets the channels configuration
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 82 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 83 * \param [IN] modem Radio modem to be used [0: FSK, 1: LoRa]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 84 * \param [IN] freq Channel RF frequency
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 85 * \param [IN] rssiThresh RSSI threshold
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 86 * \param [IN] rssiVal pointer to variable to hold RSSI value if desired - ignored if NULL
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 87 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 88 * \retval isFree [true: Channel is free, false: Channel is not free]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 89 */
Jenkins@KEILDM1.dc.multitech.prv 18:d7332302f5f1 90 virtual bool IsChannelFree( RadioModems_t modem, uint32_t freq, int16_t rssiThresh, uint32_t timeout = 5000, int16_t *rssiVal = NULL ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 91 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 92 * \brief Generates a 32 bits random value based on the RSSI readings
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 93 *
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 94 * \remark This function sets the radio in LoRa modem mode and disables
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 95 * all interrupts.
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 96 * After calling this function either Radio.SetRxConfig or
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 97 * Radio.SetTxConfig functions must be called.
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 98 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 99 * \retval randomValue 32 bits random value
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 100 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 101 virtual uint32_t Random( void ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 102 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 103 * \brief Sets the reception parameters
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 104 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 105 * \param [IN] modem Radio modem to be used [0: FSK, 1: LoRa]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 106 * \param [IN] bandwidth Sets the bandwidth
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 107 * FSK : >= 2600 and <= 250000 Hz
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 108 * LoRa: [0: 125 kHz, 1: 250 kHz,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 109 * 2: 500 kHz, 3: Reserved]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 110 * \param [IN] datarate Sets the Datarate
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 111 * FSK : 600..300000 bits/s
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 112 * LoRa: [6: 64, 7: 128, 8: 256, 9: 512,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 113 * 10: 1024, 11: 2048, 12: 4096 chips]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 114 * \param [IN] coderate Sets the coding rate (LoRa only)
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 115 * FSK : N/A ( set to 0 )
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 116 * LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 117 * \param [IN] bandwidthAfc Sets the AFC Bandwidth (FSK only)
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 118 * FSK : >= 2600 and <= 250000 Hz
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 119 * LoRa: N/A ( set to 0 )
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 120 * \param [IN] preambleLen Sets the Preamble length
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 121 * FSK : Number of bytes
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 122 * LoRa: Length in symbols (the hardware adds 4 more symbols)
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 123 * \param [IN] symbTimeout Sets the RxSingle timeout value (LoRa only)
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 124 * FSK : N/A ( set to 0 )
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 125 * LoRa: timeout in symbols
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 126 * \param [IN] fixLen Fixed length packets [0: variable, 1: fixed]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 127 * \param [IN] payloadLen Sets payload length when fixed length is used
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 128 * \param [IN] crcOn Enables/Disables the CRC [0: OFF, 1: ON]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 129 * \param [IN] FreqHopOn Enables disables the intra-packet frequency hopping
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 130 * FSK : N/A ( set to 0 )
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 131 * LoRa: [0: OFF, 1: ON]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 132 * \param [IN] HopPeriod Number of symbols bewteen each hop
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 133 * FSK : N/A ( set to 0 )
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 134 * LoRa: Number of symbols
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 135 * \param [IN] iqInverted Inverts IQ signals (LoRa only)
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 136 * FSK : N/A ( set to 0 )
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 137 * LoRa: [0: not inverted, 1: inverted]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 138 * \param [IN] rxContinuous Sets the reception in continuous mode
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 139 * [false: single mode, true: continuous mode]
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 140 * \param [IN] fskPad Duration in ms to increase FSK rx window
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 141 * FSK: time in ms to increase FSK rx window duration
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 142 * LoRa: N/A
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 143 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 144 virtual void SetRxConfig( RadioModems_t modem, uint32_t bandwidth,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 145 uint32_t datarate, uint8_t coderate,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 146 uint32_t bandwidthAfc, uint16_t preambleLen,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 147 uint16_t symbTimeout, bool fixLen,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 148 uint8_t payloadLen,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 149 bool crcOn, bool FreqHopOn, uint8_t HopPeriod,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 150 bool iqInverted, bool rxContinuous , uint32_t fskPad = 0) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 151 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 152 * \brief Sets the transmission parameters
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 153 *
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 154 * \param [IN] modem Radio modem to be used [0: FSK, 1: LoRa]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 155 * \param [IN] power Sets the output power [dBm]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 156 * \param [IN] fdev Sets the frequency deviation (FSK only)
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 157 * FSK : [Hz]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 158 * LoRa: 0
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 159 * \param [IN] bandwidth Sets the bandwidth (LoRa only)
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 160 * FSK : 0
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 161 * LoRa: [0: 125 kHz, 1: 250 kHz,
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 162 * 2: 500 kHz, 3: Reserved]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 163 * \param [IN] datarate Sets the Datarate
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 164 * FSK : 600..300000 bits/s
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 165 * LoRa: [6: 64, 7: 128, 8: 256, 9: 512,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 166 * 10: 1024, 11: 2048, 12: 4096 chips]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 167 * \param [IN] coderate Sets the coding rate (LoRa only)
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 168 * FSK : N/A ( set to 0 )
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 169 * LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 170 * \param [IN] preambleLen Sets the preamble length
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 171 * FSK : Number of bytes
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 172 * LoRa: Length in symbols (the hardware adds 4 more symbols)
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 173 * \param [IN] fixLen Fixed length packets [0: variable, 1: fixed]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 174 * \param [IN] crcOn Enables disables the CRC [0: OFF, 1: ON]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 175 * \param [IN] FreqHopOn Enables disables the intra-packet frequency hopping
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 176 * FSK : N/A ( set to 0 )
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 177 * LoRa: [0: OFF, 1: ON]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 178 * \param [IN] HopPeriod Number of symbols bewteen each hop
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 179 * FSK : N/A ( set to 0 )
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 180 * LoRa: Number of symbols
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 181 * \param [IN] iqInverted Inverts IQ signals (LoRa only)
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 182 * FSK : N/A ( set to 0 )
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 183 * LoRa: [0: not inverted, 1: inverted]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 184 * \param [IN] timeout Transmission timeout [us]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 185 */
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 186 virtual void SetTxConfig( RadioModems_t modem, int8_t power, uint32_t fdev,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 187 uint32_t bandwidth, uint32_t datarate,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 188 uint8_t coderate, uint16_t preambleLen,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 189 bool fixLen, bool crcOn, bool FreqHopOn,
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 190 uint8_t HopPeriod, bool iqInverted, uint32_t timeout ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 191
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 192 virtual void SetTxPower(int8_t power) = 0;
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 193
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 194 virtual void SetTxContinuousWave( uint32_t freq, int8_t power, uint16_t time ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 195
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 196 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 197 * \brief Checks if the given RF frequency is supported by the hardware
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 198 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 199 * \param [IN] frequency RF frequency to be checked
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 200 * \retval isSupported [true: supported, false: unsupported]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 201 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 202 virtual bool CheckRfFrequency( uint32_t frequency ) { return true; }
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 203 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 204 * \brief Computes the packet time on air for the given payload
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 205 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 206 * \Remark Can only be called once SetRxConfig or SetTxConfig have been called
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 207 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 208 * \param [IN] modem Radio modem to be used [0: FSK, 1: LoRa]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 209 * \param [IN] pktLen Packet payload length
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 210 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 211 * \retval airTime Computed airTime for the given packet payload length
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 212 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 213 virtual double TimeOnAir( RadioModems_t modem, uint8_t pktLen ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 214 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 215 * \brief Sends the buffer of size. Prepares the packet to be sent and sets
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 216 * the radio in transmission
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 217 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 218 * \param [IN]: buffer Buffer pointer
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 219 * \param [IN]: size Buffer size
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 220 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 221 virtual void Send( const uint8_t *buffer, uint8_t size ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 222 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 223 * \brief Sets the radio in sleep mode
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 224 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 225 virtual void Sleep( void ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 226 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 227 * \brief Sets the radio in standby mode
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 228 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 229 virtual void Standby( void ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 230 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 231 * \brief Sets the radio in reception mode for the given time
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 232 * \param [IN] timeout Reception timeout [us]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 233 * [0: continuous, others timeout]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 234 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 235 virtual void Rx( uint32_t timeout ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 236 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 237 * \brief Start a Channel Activity Detection
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 238 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 239 virtual void StartCad( void ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 240 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 241 * \brief Reads the current RSSI value
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 242 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 243 * \retval rssiValue Current RSSI value in [dBm]
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 244 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 245 virtual int16_t Rssi( RadioModems_t modem ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 246 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 247 * \brief Writes the radio register at the specified address
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 248 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 249 * \param [IN]: addr Register address
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 250 * \param [IN]: data New register value
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 251 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 252 virtual void Write( uint8_t addr, uint8_t data ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 253 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 254 * \brief Reads the radio register at the specified address
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 255 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 256 * \param [IN]: addr Register address
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 257 * \retval data Register value
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 258 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 259 virtual uint8_t Read ( uint8_t addr ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 260 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 261 * \brief Writes multiple radio registers starting at address
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 262 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 263 * \param [IN] addr First Radio register address
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 264 * \param [IN] buffer Buffer containing the new register's values
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 265 * \param [IN] size Number of registers to be written
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 266 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 267 virtual void WriteBuffer( uint8_t addr, const uint8_t *buffer, uint8_t size ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 268 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 269 * \brief Reads multiple radio registers starting at address
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 270 *
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 271 * \param [IN] addr First Radio register address
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 272 * \param [OUT] buffer Buffer where to copy the registers data
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 273 * \param [IN] size Number of registers to be read
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 274 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 275 virtual void ReadBuffer( uint8_t addr, uint8_t *buffer, uint8_t size ) = 0;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 276
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 277 virtual void SignalMacEvent(void) {};
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 278 virtual void SignalLinkEvent(void) {};
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 279
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 280 virtual void ResetRadio(void) {};
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 281
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 282 virtual uint32_t GetTimeOnAir(void) = 0;
Jenkins@KEILDM1.dc.multitech.prv 14:f0c24ce93427 283
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 284 void GrabMutex(void) { mutex.lock(); }
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 285 void ReleaseMutex(void) { mutex.unlock(); }
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 286
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 287 int32_t GetFrequencyOffset() { return freq_offset; }
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 288 void SetFrequencyOffset(int32_t offset) { freq_offset = offset; }
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 289
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 290 const uint32_t WakeupTime;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 291
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 292
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 293
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 294
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 295 protected:
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 296 int32_t freq_offset;
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 297
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 298 RadioState_t State;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 299
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 300 RadioModems_t Modem;
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 301
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 302 /*!
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 303 * Access protection
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 304 */
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 305 Mutex mutex;
Jenkins@KEILDM1.dc.multitech.prv 16:4a382fe8f51b 306
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 307 };
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 308
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 309 #endif // __SXRADIO_H__
Jenkins@KEILDM1.dc.multitech.prv 11:be2a6466d680 310