Committer:
dgabino
Date:
Wed Apr 11 14:42:47 2018 +0000
Revision:
0:c76361bd82e8
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dgabino 0:c76361bd82e8 1 /*
dgabino 0:c76361bd82e8 2 / _____) _ | |
dgabino 0:c76361bd82e8 3 ( (____ _____ ____ _| |_ _____ ____| |__
dgabino 0:c76361bd82e8 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
dgabino 0:c76361bd82e8 5 _____) ) ____| | | || |_| ____( (___| | | |
dgabino 0:c76361bd82e8 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
dgabino 0:c76361bd82e8 7 (C)2017 Semtech-Cycleo
dgabino 0:c76361bd82e8 8
dgabino 0:c76361bd82e8 9 Description:
dgabino 0:c76361bd82e8 10 LoRa concentrator Hardware Abstraction Layer
dgabino 0:c76361bd82e8 11
dgabino 0:c76361bd82e8 12 License: Revised BSD License, see LICENSE.TXT file include in the project
dgabino 0:c76361bd82e8 13
dgabino 0:c76361bd82e8 14 */
dgabino 0:c76361bd82e8 15
dgabino 0:c76361bd82e8 16
dgabino 0:c76361bd82e8 17 #ifndef _LORAGW_HAL_H
dgabino 0:c76361bd82e8 18 #define _LORAGW_HAL_H
dgabino 0:c76361bd82e8 19
dgabino 0:c76361bd82e8 20 /* -------------------------------------------------------------------------- */
dgabino 0:c76361bd82e8 21 /* --- DEPENDANCIES --------------------------------------------------------- */
dgabino 0:c76361bd82e8 22
dgabino 0:c76361bd82e8 23 #include <stdint.h> /* C99 types */
dgabino 0:c76361bd82e8 24 #include <stdbool.h> /* bool type */
dgabino 0:c76361bd82e8 25
dgabino 0:c76361bd82e8 26 /* -------------------------------------------------------------------------- */
dgabino 0:c76361bd82e8 27 /* --- PUBLIC MACROS -------------------------------------------------------- */
dgabino 0:c76361bd82e8 28
dgabino 0:c76361bd82e8 29 #define IS_LORA_BW(bw) ((bw == BW_125KHZ) || (bw == BW_250KHZ) || (bw == BW_500KHZ))
dgabino 0:c76361bd82e8 30 #define IS_LORA_STD_DR(dr) ((dr == DR_LORA_SF7) || (dr == DR_LORA_SF8) || (dr == DR_LORA_SF9) || (dr == DR_LORA_SF10) || (dr == DR_LORA_SF11) || (dr == DR_LORA_SF12))
dgabino 0:c76361bd82e8 31 #define IS_LORA_MULTI_DR(dr) ((dr & ~DR_LORA_MULTI) == 0) /* ones outside of DR_LORA_MULTI bitmask -> not a combination of LoRa datarates */
dgabino 0:c76361bd82e8 32 #define IS_LORA_CR(cr) ((cr == CR_LORA_4_5) || (cr == CR_LORA_4_6) || (cr == CR_LORA_4_7) || (cr == CR_LORA_4_8))
dgabino 0:c76361bd82e8 33
dgabino 0:c76361bd82e8 34 #define IS_FSK_BW(bw) ((bw >= 1) && (bw <= 7))
dgabino 0:c76361bd82e8 35 #define IS_FSK_DR(dr) ((dr >= DR_FSK_MIN) && (dr <= DR_FSK_MAX))
dgabino 0:c76361bd82e8 36
dgabino 0:c76361bd82e8 37 #define IS_TX_MODE(mode) ((mode == IMMEDIATE) || (mode == TIMESTAMPED) || (mode == ON_GPS))
dgabino 0:c76361bd82e8 38
dgabino 0:c76361bd82e8 39 /* -------------------------------------------------------------------------- */
dgabino 0:c76361bd82e8 40 /* --- PUBLIC CONSTANTS ----------------------------------------------------- */
dgabino 0:c76361bd82e8 41
dgabino 0:c76361bd82e8 42 /* return status code */
dgabino 0:c76361bd82e8 43 #define LGW_HAL_SUCCESS 0
dgabino 0:c76361bd82e8 44 #define LGW_HAL_ERROR -1
dgabino 0:c76361bd82e8 45
dgabino 0:c76361bd82e8 46 /* radio-specific parameters */
dgabino 0:c76361bd82e8 47 #define LGW_XTAL_FREQU 32000000 /* frequency of the RF reference oscillator */
dgabino 0:c76361bd82e8 48 #define LGW_RF_CHAIN_NB 2 /* number of RF chains */
dgabino 0:c76361bd82e8 49 #define LGW_RF_RX_BANDWIDTH {1000000, 1000000} /* bandwidth of the radios */
dgabino 0:c76361bd82e8 50
dgabino 0:c76361bd82e8 51 /* type of if_chain + modem */
dgabino 0:c76361bd82e8 52 #define IF_UNDEFINED 0
dgabino 0:c76361bd82e8 53 #define IF_LORA_STD 0x10 /* if + standard single-SF LoRa modem */
dgabino 0:c76361bd82e8 54 #define IF_LORA_MULTI 0x11 /* if + LoRa receiver with multi-SF capability */
dgabino 0:c76361bd82e8 55 #define IF_FSK_STD 0x20 /* if + standard FSK modem */
dgabino 0:c76361bd82e8 56
dgabino 0:c76361bd82e8 57 /* concentrator chipset-specific parameters */
dgabino 0:c76361bd82e8 58 /* to use array parameters, declare a local const and use 'if_chain' as index */
dgabino 0:c76361bd82e8 59 #define LGW_IF_CHAIN_NB 10 /* number of IF+modem RX chains */
dgabino 0:c76361bd82e8 60 #define LGW_PKT_FIFO_SIZE 16 /* depth of the RX packet FIFO */
dgabino 0:c76361bd82e8 61 #define LGW_DATABUFF_SIZE 1024 /* size in bytes of the RX data buffer (contains payload & metadata) */
dgabino 0:c76361bd82e8 62 #define LGW_REF_BW 125000 /* typical bandwidth of data channel */
dgabino 0:c76361bd82e8 63 #define LGW_MULTI_NB 8 /* number of LoRa 'multi SF' chains */
dgabino 0:c76361bd82e8 64 #define LGW_IFMODEM_CONFIG {\
dgabino 0:c76361bd82e8 65 IF_LORA_MULTI, \
dgabino 0:c76361bd82e8 66 IF_LORA_MULTI, \
dgabino 0:c76361bd82e8 67 IF_LORA_MULTI, \
dgabino 0:c76361bd82e8 68 IF_LORA_MULTI, \
dgabino 0:c76361bd82e8 69 IF_LORA_MULTI, \
dgabino 0:c76361bd82e8 70 IF_LORA_MULTI, \
dgabino 0:c76361bd82e8 71 IF_LORA_MULTI, \
dgabino 0:c76361bd82e8 72 IF_LORA_MULTI, \
dgabino 0:c76361bd82e8 73 IF_LORA_STD, \
dgabino 0:c76361bd82e8 74 IF_FSK_STD } /* configuration of available IF chains and modems on the hardware */
dgabino 0:c76361bd82e8 75
dgabino 0:c76361bd82e8 76 /* values available for the 'modulation' parameters */
dgabino 0:c76361bd82e8 77 /* NOTE: arbitrary values */
dgabino 0:c76361bd82e8 78 #define MOD_UNDEFINED 0
dgabino 0:c76361bd82e8 79 #define MOD_LORA 0x10
dgabino 0:c76361bd82e8 80 #define MOD_FSK 0x20
dgabino 0:c76361bd82e8 81
dgabino 0:c76361bd82e8 82 /* values available for the 'bandwidth' parameters (LoRa & FSK) */
dgabino 0:c76361bd82e8 83 /* NOTE: directly encode FSK RX bandwidth, do not change */
dgabino 0:c76361bd82e8 84 #define BW_UNDEFINED 0
dgabino 0:c76361bd82e8 85 #define BW_500KHZ 0x01
dgabino 0:c76361bd82e8 86 #define BW_250KHZ 0x02
dgabino 0:c76361bd82e8 87 #define BW_125KHZ 0x03
dgabino 0:c76361bd82e8 88 #define BW_62K5HZ 0x04
dgabino 0:c76361bd82e8 89 #define BW_31K2HZ 0x05
dgabino 0:c76361bd82e8 90 #define BW_15K6HZ 0x06
dgabino 0:c76361bd82e8 91 #define BW_7K8HZ 0x07
dgabino 0:c76361bd82e8 92
dgabino 0:c76361bd82e8 93 /* values available for the 'datarate' parameters */
dgabino 0:c76361bd82e8 94 /* NOTE: LoRa values used directly to code SF bitmask in 'multi' modem, do not change */
dgabino 0:c76361bd82e8 95 #define DR_UNDEFINED 0
dgabino 0:c76361bd82e8 96 #define DR_LORA_SF7 0x02
dgabino 0:c76361bd82e8 97 #define DR_LORA_SF8 0x04
dgabino 0:c76361bd82e8 98 #define DR_LORA_SF9 0x08
dgabino 0:c76361bd82e8 99 #define DR_LORA_SF10 0x10
dgabino 0:c76361bd82e8 100 #define DR_LORA_SF11 0x20
dgabino 0:c76361bd82e8 101 #define DR_LORA_SF12 0x40
dgabino 0:c76361bd82e8 102 #define DR_LORA_MULTI 0x7E
dgabino 0:c76361bd82e8 103 /* NOTE: for FSK directly use baudrate between 500 bauds and 250 kbauds */
dgabino 0:c76361bd82e8 104 #define DR_FSK_MIN 500
dgabino 0:c76361bd82e8 105 #define DR_FSK_MAX 250000
dgabino 0:c76361bd82e8 106
dgabino 0:c76361bd82e8 107 /* values available for the 'coderate' parameters (LoRa only) */
dgabino 0:c76361bd82e8 108 /* NOTE: arbitrary values */
dgabino 0:c76361bd82e8 109 #define CR_UNDEFINED 0
dgabino 0:c76361bd82e8 110 #define CR_LORA_4_5 0x01
dgabino 0:c76361bd82e8 111 #define CR_LORA_4_6 0x02
dgabino 0:c76361bd82e8 112 #define CR_LORA_4_7 0x03
dgabino 0:c76361bd82e8 113 #define CR_LORA_4_8 0x04
dgabino 0:c76361bd82e8 114
dgabino 0:c76361bd82e8 115 /* values available for the 'status' parameter */
dgabino 0:c76361bd82e8 116 /* NOTE: values according to hardware specification */
dgabino 0:c76361bd82e8 117 #define STAT_UNDEFINED 0x00
dgabino 0:c76361bd82e8 118 #define STAT_NO_CRC 0x01
dgabino 0:c76361bd82e8 119 #define STAT_CRC_BAD 0x11
dgabino 0:c76361bd82e8 120 #define STAT_CRC_OK 0x10
dgabino 0:c76361bd82e8 121
dgabino 0:c76361bd82e8 122 /* values available for the 'tx_mode' parameter */
dgabino 0:c76361bd82e8 123 #define IMMEDIATE 0
dgabino 0:c76361bd82e8 124 #define TIMESTAMPED 1
dgabino 0:c76361bd82e8 125 #define ON_GPS 2
dgabino 0:c76361bd82e8 126 //#define ON_EVENT 3
dgabino 0:c76361bd82e8 127 //#define GPS_DELAYED 4
dgabino 0:c76361bd82e8 128 //#define EVENT_DELAYED 5
dgabino 0:c76361bd82e8 129
dgabino 0:c76361bd82e8 130 /* values available for 'select' in the status function */
dgabino 0:c76361bd82e8 131 #define TX_STATUS 1
dgabino 0:c76361bd82e8 132 #define RX_STATUS 2
dgabino 0:c76361bd82e8 133
dgabino 0:c76361bd82e8 134 /* status code for TX_STATUS */
dgabino 0:c76361bd82e8 135 /* NOTE: arbitrary values */
dgabino 0:c76361bd82e8 136 #define TX_STATUS_UNKNOWN 0
dgabino 0:c76361bd82e8 137 #define TX_OFF 1 /* TX modem disabled, it will ignore commands */
dgabino 0:c76361bd82e8 138 #define TX_FREE 2 /* TX modem is free, ready to receive a command */
dgabino 0:c76361bd82e8 139 #define TX_SCHEDULED 3 /* TX modem is loaded, ready to send the packet after an event and/or delay */
dgabino 0:c76361bd82e8 140 #define TX_EMITTING 4 /* TX modem is emitting */
dgabino 0:c76361bd82e8 141
dgabino 0:c76361bd82e8 142 /* status code for RX_STATUS */
dgabino 0:c76361bd82e8 143 /* NOTE: arbitrary values */
dgabino 0:c76361bd82e8 144 #define RX_STATUS_UNKNOWN 0
dgabino 0:c76361bd82e8 145 #define RX_OFF 1 /* RX modem is disabled, it will ignore commands */
dgabino 0:c76361bd82e8 146 #define RX_ON 2 /* RX modem is receiving */
dgabino 0:c76361bd82e8 147 #define RX_SUSPENDED 3 /* RX is suspended while a TX is ongoing */
dgabino 0:c76361bd82e8 148
dgabino 0:c76361bd82e8 149 /* Maximum size of Tx gain LUT */
dgabino 0:c76361bd82e8 150 #define TX_GAIN_LUT_SIZE_MAX 16
dgabino 0:c76361bd82e8 151
dgabino 0:c76361bd82e8 152 /* -------------------------------------------------------------------------- */
dgabino 0:c76361bd82e8 153 /* --- PUBLIC TYPES --------------------------------------------------------- */
dgabino 0:c76361bd82e8 154
dgabino 0:c76361bd82e8 155 /**
dgabino 0:c76361bd82e8 156 @enum lgw_radio_type_e
dgabino 0:c76361bd82e8 157 @brief Radio types that can be found on the LoRa Gateway
dgabino 0:c76361bd82e8 158 */
dgabino 0:c76361bd82e8 159 enum lgw_radio_type_e {
dgabino 0:c76361bd82e8 160 LGW_RADIO_TYPE_NONE,
dgabino 0:c76361bd82e8 161 LGW_RADIO_TYPE_SX1255,
dgabino 0:c76361bd82e8 162 LGW_RADIO_TYPE_SX1257,
dgabino 0:c76361bd82e8 163 LGW_RADIO_TYPE_SX1272,
dgabino 0:c76361bd82e8 164 LGW_RADIO_TYPE_SX1276
dgabino 0:c76361bd82e8 165 };
dgabino 0:c76361bd82e8 166
dgabino 0:c76361bd82e8 167 /**
dgabino 0:c76361bd82e8 168 @struct lgw_conf_board_s
dgabino 0:c76361bd82e8 169 @brief Configuration structure for board specificities
dgabino 0:c76361bd82e8 170 */
dgabino 0:c76361bd82e8 171 struct lgw_conf_board_s {
dgabino 0:c76361bd82e8 172 bool lorawan_public; /*!> Enable ONLY for *public* networks using the LoRa MAC protocol */
dgabino 0:c76361bd82e8 173 uint8_t clksrc; /*!> Index of RF chain which provides clock to concentrator */
dgabino 0:c76361bd82e8 174 };
dgabino 0:c76361bd82e8 175
dgabino 0:c76361bd82e8 176 /**
dgabino 0:c76361bd82e8 177 @struct lgw_conf_rxrf_s
dgabino 0:c76361bd82e8 178 @brief Configuration structure for a RF chain
dgabino 0:c76361bd82e8 179 */
dgabino 0:c76361bd82e8 180 struct lgw_conf_rxrf_s {
dgabino 0:c76361bd82e8 181 bool enable; /*!> enable or disable that RF chain */
dgabino 0:c76361bd82e8 182 uint32_t freq_hz; /*!> center frequency of the radio in Hz */
dgabino 0:c76361bd82e8 183 float rssi_offset; /*!> Board-specific RSSI correction factor */
dgabino 0:c76361bd82e8 184 enum lgw_radio_type_e type; /*!> Radio type for that RF chain (SX1255, SX1257....) */
dgabino 0:c76361bd82e8 185 uint32_t tx_enable; /*!> enable or disable TX on that RF chain */
dgabino 0:c76361bd82e8 186 };
dgabino 0:c76361bd82e8 187
dgabino 0:c76361bd82e8 188 /**
dgabino 0:c76361bd82e8 189 @struct lgw_conf_rxif_s
dgabino 0:c76361bd82e8 190 @brief Configuration structure for an IF chain
dgabino 0:c76361bd82e8 191 */
dgabino 0:c76361bd82e8 192 struct lgw_conf_rxif_s {
dgabino 0:c76361bd82e8 193 bool enable; /*!> enable or disable that IF chain */
dgabino 0:c76361bd82e8 194 uint8_t rf_chain; /*!> to which RF chain is that IF chain associated */
dgabino 0:c76361bd82e8 195 int32_t freq_hz; /*!> center frequ of the IF chain, relative to RF chain frequency */
dgabino 0:c76361bd82e8 196 uint8_t bandwidth; /*!> RX bandwidth, 0 for default */
dgabino 0:c76361bd82e8 197 uint32_t datarate; /*!> RX datarate, 0 for default */
dgabino 0:c76361bd82e8 198 uint8_t sync_word_size; /*!> size of FSK sync word (number of bytes, 0 for default) */
dgabino 0:c76361bd82e8 199 uint64_t sync_word; /*!> FSK sync word (ALIGN RIGHT, eg. 0xC194C1) */
dgabino 0:c76361bd82e8 200 };
dgabino 0:c76361bd82e8 201
dgabino 0:c76361bd82e8 202 /**
dgabino 0:c76361bd82e8 203 @struct lgw_pkt_rx_s
dgabino 0:c76361bd82e8 204 @brief Structure containing the metadata of a packet that was received and a pointer to the payload
dgabino 0:c76361bd82e8 205 */
dgabino 0:c76361bd82e8 206 struct lgw_pkt_rx_s {
dgabino 0:c76361bd82e8 207 uint32_t freq_hz; /*!> central frequency of the IF chain */
dgabino 0:c76361bd82e8 208 uint8_t if_chain; /*!> by which IF chain was packet received */
dgabino 0:c76361bd82e8 209 uint8_t status; /*!> status of the received packet */
dgabino 0:c76361bd82e8 210 uint32_t count_us; /*!> internal concentrator counter for timestamping, 1 microsecond resolution */
dgabino 0:c76361bd82e8 211 uint8_t rf_chain; /*!> through which RF chain the packet was received */
dgabino 0:c76361bd82e8 212 uint8_t modulation; /*!> modulation used by the packet */
dgabino 0:c76361bd82e8 213 uint8_t bandwidth; /*!> modulation bandwidth (LoRa only) */
dgabino 0:c76361bd82e8 214 uint32_t datarate; /*!> RX datarate of the packet (SF for LoRa) */
dgabino 0:c76361bd82e8 215 uint8_t coderate; /*!> error-correcting code of the packet (LoRa only) */
dgabino 0:c76361bd82e8 216 float rssi; /*!> average packet RSSI in dB */
dgabino 0:c76361bd82e8 217 float snr; /*!> average packet SNR, in dB (LoRa only) */
dgabino 0:c76361bd82e8 218 float snr_min; /*!> minimum packet SNR, in dB (LoRa only) */
dgabino 0:c76361bd82e8 219 float snr_max; /*!> maximum packet SNR, in dB (LoRa only) */
dgabino 0:c76361bd82e8 220 uint16_t crc; /*!> CRC that was received in the payload */
dgabino 0:c76361bd82e8 221 uint16_t size; /*!> payload size in bytes */
dgabino 0:c76361bd82e8 222 uint8_t payload[256]; /*!> buffer containing the payload */
dgabino 0:c76361bd82e8 223 };
dgabino 0:c76361bd82e8 224
dgabino 0:c76361bd82e8 225
dgabino 0:c76361bd82e8 226
dgabino 0:c76361bd82e8 227 /**
dgabino 0:c76361bd82e8 228 @struct lgw_pkt_tx_s
dgabino 0:c76361bd82e8 229 @brief Structure containing the configuration of a packet to send and a pointer to the payload
dgabino 0:c76361bd82e8 230 */
dgabino 0:c76361bd82e8 231 struct lgw_pkt_tx_s {
dgabino 0:c76361bd82e8 232 uint32_t freq_hz; /*!> center frequency of TX */
dgabino 0:c76361bd82e8 233 uint8_t tx_mode; /*!> select on what event/time the TX is triggered */
dgabino 0:c76361bd82e8 234 uint32_t count_us; /*!> timestamp or delay in microseconds for TX trigger */
dgabino 0:c76361bd82e8 235 uint8_t rf_chain; /*!> through which RF chain will the packet be sent */
dgabino 0:c76361bd82e8 236 int8_t rf_power; /*!> TX power, in dBm */
dgabino 0:c76361bd82e8 237 uint8_t modulation; /*!> modulation to use for the packet */
dgabino 0:c76361bd82e8 238 uint8_t bandwidth; /*!> modulation bandwidth (LoRa only) */
dgabino 0:c76361bd82e8 239 uint32_t datarate; /*!> TX datarate (baudrate for FSK, SF for LoRa) */
dgabino 0:c76361bd82e8 240 uint8_t coderate; /*!> error-correcting code of the packet (LoRa only) */
dgabino 0:c76361bd82e8 241 bool invert_pol; /*!> invert signal polarity, for orthogonal downlinks (LoRa only) */
dgabino 0:c76361bd82e8 242 uint8_t f_dev; /*!> frequency deviation, in kHz (FSK only) */
dgabino 0:c76361bd82e8 243 uint16_t preamble; /*!> set the preamble length, 0 for default */
dgabino 0:c76361bd82e8 244 bool no_crc; /*!> if true, do not send a CRC in the packet */
dgabino 0:c76361bd82e8 245 bool no_header; /*!> if true, enable implicit header mode (LoRa), fixed length (FSK) */
dgabino 0:c76361bd82e8 246 uint16_t size; /*!> payload size in bytes */
dgabino 0:c76361bd82e8 247 uint8_t payload[256]; /*!> buffer containing the payload */
dgabino 0:c76361bd82e8 248 };
dgabino 0:c76361bd82e8 249
dgabino 0:c76361bd82e8 250 /**
dgabino 0:c76361bd82e8 251 @struct lgw_tx_gain_s
dgabino 0:c76361bd82e8 252 @brief Structure containing all gains of Tx chain
dgabino 0:c76361bd82e8 253 */
dgabino 0:c76361bd82e8 254 struct lgw_tx_gain_s {
dgabino 0:c76361bd82e8 255 uint8_t dig_gain; /*!> 2 bits, control of the digital gain of SX1308 */
dgabino 0:c76361bd82e8 256 uint8_t pa_gain; /*!> 2 bits, control of the external PA (SX1308 I/O) */
dgabino 0:c76361bd82e8 257 uint8_t dac_gain; /*!> 2 bits, control of the radio DAC */
dgabino 0:c76361bd82e8 258 uint8_t mix_gain; /*!> 4 bits, control of the radio mixer */
dgabino 0:c76361bd82e8 259 int8_t rf_power; /*!> measured TX power at the board connector, in dBm */
dgabino 0:c76361bd82e8 260 };
dgabino 0:c76361bd82e8 261
dgabino 0:c76361bd82e8 262 /**
dgabino 0:c76361bd82e8 263 @struct lgw_tx_gain_lut_s
dgabino 0:c76361bd82e8 264 @brief Structure defining the Tx gain LUT
dgabino 0:c76361bd82e8 265 */
dgabino 0:c76361bd82e8 266 struct lgw_tx_gain_lut_s {
dgabino 0:c76361bd82e8 267 struct lgw_tx_gain_s lut[TX_GAIN_LUT_SIZE_MAX]; /*!> Array of Tx gain struct */
dgabino 0:c76361bd82e8 268 uint8_t size; /*!> Number of LUT indexes */
dgabino 0:c76361bd82e8 269 };
dgabino 0:c76361bd82e8 270
dgabino 0:c76361bd82e8 271 /* -------------------------------------------------------------------------- */
dgabino 0:c76361bd82e8 272 /* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */
dgabino 0:c76361bd82e8 273
dgabino 0:c76361bd82e8 274 /**
dgabino 0:c76361bd82e8 275 @brief Configure the gateway board
dgabino 0:c76361bd82e8 276 @param conf structure containing the configuration parameters
dgabino 0:c76361bd82e8 277 @return LGW_HAL_ERROR id the operation failed, LGW_HAL_SUCCESS else
dgabino 0:c76361bd82e8 278 */
dgabino 0:c76361bd82e8 279 int lgw_board_setconf(struct lgw_conf_board_s conf);
dgabino 0:c76361bd82e8 280
dgabino 0:c76361bd82e8 281 /**
dgabino 0:c76361bd82e8 282 @brief Configure an RF chain (must configure before start)
dgabino 0:c76361bd82e8 283 @param rf_chain number of the RF chain to configure [0, LGW_RF_CHAIN_NB - 1]
dgabino 0:c76361bd82e8 284 @param conf structure containing the configuration parameters
dgabino 0:c76361bd82e8 285 @return LGW_HAL_ERROR id the operation failed, LGW_HAL_SUCCESS else
dgabino 0:c76361bd82e8 286 */
dgabino 0:c76361bd82e8 287 int lgw_rxrf_setconf(uint8_t rf_chain, struct lgw_conf_rxrf_s conf);
dgabino 0:c76361bd82e8 288
dgabino 0:c76361bd82e8 289 /**
dgabino 0:c76361bd82e8 290 @brief Configure an IF chain + modem (must configure before start)
dgabino 0:c76361bd82e8 291 @param if_chain number of the IF chain + modem to configure [0, LGW_IF_CHAIN_NB - 1]
dgabino 0:c76361bd82e8 292 @param conf structure containing the configuration parameters
dgabino 0:c76361bd82e8 293 @return LGW_HAL_ERROR id the operation failed, LGW_HAL_SUCCESS else
dgabino 0:c76361bd82e8 294 */
dgabino 0:c76361bd82e8 295 int lgw_rxif_setconf(uint8_t if_chain, struct lgw_conf_rxif_s conf);
dgabino 0:c76361bd82e8 296
dgabino 0:c76361bd82e8 297 /**
dgabino 0:c76361bd82e8 298 @brief Configure the Tx gain LUT
dgabino 0:c76361bd82e8 299 @param pointer to structure defining the LUT
dgabino 0:c76361bd82e8 300 @return LGW_HAL_ERROR id the operation failed, LGW_HAL_SUCCESS else
dgabino 0:c76361bd82e8 301 */
dgabino 0:c76361bd82e8 302 int lgw_txgain_setconf(struct lgw_tx_gain_lut_s *conf);
dgabino 0:c76361bd82e8 303
dgabino 0:c76361bd82e8 304 /**
dgabino 0:c76361bd82e8 305 @brief Connect to the LoRa concentrator, reset it and configure it according to previously set parameters
dgabino 0:c76361bd82e8 306 @return LGW_HAL_ERROR id the operation failed, LGW_HAL_SUCCESS else
dgabino 0:c76361bd82e8 307 */
dgabino 0:c76361bd82e8 308 int lgw_start(void);
dgabino 0:c76361bd82e8 309
dgabino 0:c76361bd82e8 310 /**
dgabino 0:c76361bd82e8 311 @brief Stop the LoRa concentrator and disconnect it
dgabino 0:c76361bd82e8 312 @return LGW_HAL_ERROR id the operation failed, LGW_HAL_SUCCESS else
dgabino 0:c76361bd82e8 313 */
dgabino 0:c76361bd82e8 314 int lgw_stop(void);
dgabino 0:c76361bd82e8 315
dgabino 0:c76361bd82e8 316 /**
dgabino 0:c76361bd82e8 317 @brief A non-blocking function that will fetch up to 'max_pkt' packets from the LoRa concentrator FIFO and data buffer
dgabino 0:c76361bd82e8 318 @param max_pkt maximum number of packet that must be retrieved (equal to the size of the array of struct)
dgabino 0:c76361bd82e8 319 @param pkt_data pointer to an array of struct that will receive the packet metadata and payload pointers
dgabino 0:c76361bd82e8 320 @return LGW_HAL_ERROR id the operation failed, else the number of packets retrieved
dgabino 0:c76361bd82e8 321 */
dgabino 0:c76361bd82e8 322 int lgw_receive(uint8_t max_pkt, struct lgw_pkt_rx_s *pkt_data);
dgabino 0:c76361bd82e8 323
dgabino 0:c76361bd82e8 324 /**
dgabino 0:c76361bd82e8 325 @brief Schedule a packet to be send immediately or after a delay depending on tx_mode
dgabino 0:c76361bd82e8 326 @param pkt_data structure containing the data and metadata for the packet to send
dgabino 0:c76361bd82e8 327 @return LGW_HAL_ERROR id the operation failed, LGW_HAL_SUCCESS else
dgabino 0:c76361bd82e8 328
dgabino 0:c76361bd82e8 329 /!\ When sending a packet, there is a 1.5 ms delay for the analog circuitry to start and be stable (TX_START_DELAY).
dgabino 0:c76361bd82e8 330 In 'timestamp' mode, this is transparent: the modem is started 1.5ms before the user-set timestamp value is reached, the preamble of the packet start right when the internal timestamp counter reach target value.
dgabino 0:c76361bd82e8 331 In 'immediate' mode, the packet is emitted as soon as possible: transferring the packet (and its parameters) from the host to the concentrator takes some time, then there is the TX_START_DELAY, then the packet is emitted.
dgabino 0:c76361bd82e8 332 In 'triggered' mode (aka PPS/GPS mode), the packet, typically a beacon, is emitted 1.5ms after a rising edge of the trigger signal. Because there is no way to anticipate the triggering event and start the analog circuitry beforehand, that delay must be taken into account in the protocol.
dgabino 0:c76361bd82e8 333 */
dgabino 0:c76361bd82e8 334 int lgw_send(struct lgw_pkt_tx_s pkt_data);
dgabino 0:c76361bd82e8 335
dgabino 0:c76361bd82e8 336 /**
dgabino 0:c76361bd82e8 337 @brief Give the the status of different part of the LoRa concentrator
dgabino 0:c76361bd82e8 338 @param select is used to select what status we want to know
dgabino 0:c76361bd82e8 339 @param code is used to return the status code
dgabino 0:c76361bd82e8 340 @return LGW_HAL_ERROR id the operation failed, LGW_HAL_SUCCESS else
dgabino 0:c76361bd82e8 341 */
dgabino 0:c76361bd82e8 342 int lgw_status(uint8_t select, uint8_t *code);
dgabino 0:c76361bd82e8 343
dgabino 0:c76361bd82e8 344 /**
dgabino 0:c76361bd82e8 345 @brief Abort a currently scheduled or ongoing TX
dgabino 0:c76361bd82e8 346 @return LGW_HAL_ERROR id the operation failed, LGW_HAL_SUCCESS else
dgabino 0:c76361bd82e8 347 */
dgabino 0:c76361bd82e8 348 int lgw_abort_tx(void);
dgabino 0:c76361bd82e8 349
dgabino 0:c76361bd82e8 350 /**
dgabino 0:c76361bd82e8 351 @brief Return value of internal counter when latest event (eg GPS pulse) was captured
dgabino 0:c76361bd82e8 352 @param trig_cnt_us pointer to receive timestamp value
dgabino 0:c76361bd82e8 353 @return LGW_HAL_ERROR id the operation failed, LGW_HAL_SUCCESS else
dgabino 0:c76361bd82e8 354 */
dgabino 0:c76361bd82e8 355 int lgw_get_trigcnt(uint32_t* trig_cnt_us);
dgabino 0:c76361bd82e8 356
dgabino 0:c76361bd82e8 357 /**
dgabino 0:c76361bd82e8 358 @brief Allow user to check the version/options of the library once compiled
dgabino 0:c76361bd82e8 359 @return pointer on a human-readable null terminated string
dgabino 0:c76361bd82e8 360 */
dgabino 0:c76361bd82e8 361 const char* lgw_version_info(void);
dgabino 0:c76361bd82e8 362
dgabino 0:c76361bd82e8 363 /**
dgabino 0:c76361bd82e8 364 @brief Return time on air of given packet, in milliseconds
dgabino 0:c76361bd82e8 365 @param packet is a pointer to the packet structure
dgabino 0:c76361bd82e8 366 @return the packet time on air in milliseconds
dgabino 0:c76361bd82e8 367 */
dgabino 0:c76361bd82e8 368 uint32_t lgw_time_on_air(struct lgw_pkt_tx_s *packet);
dgabino 0:c76361bd82e8 369
dgabino 0:c76361bd82e8 370 /**
dgabino 0:c76361bd82e8 371 @brief Transfer the calibration offsets from the AGC firwmare to the local array
dgabino 0:c76361bd82e8 372 @param idx_start is the start index in the local array where the calibration offset are being copied
dgabino 0:c76361bd82e8 373 @param idx_nb is the number of calibration offsets to be copied in the local array
dgabino 0:c76361bd82e8 374 @return the packet time on air in milliseconds
dgabino 0:c76361bd82e8 375 */
dgabino 0:c76361bd82e8 376 void lgw_calibration_offset_transfer(uint8_t idx_start, uint8_t idx_nb);
dgabino 0:c76361bd82e8 377
dgabino 0:c76361bd82e8 378 #endif
dgabino 0:c76361bd82e8 379
dgabino 0:c76361bd82e8 380 /* --- EOF ------------------------------------------------------------------ */