Skip to content

Commit 749abc8

Browse files
committed
v4.0.0
* HAL: Added "Listen-Before-Talk" support for Semtech SX1301AP2 Ref Design. A description of the feature implementation can be found in libloragw/readme.md. * HAL: Updated FSK RSSI calculation for better linearization * util_lbt_test: New utility provided for basic "Listen-Before-Talk" testing. * util_tx_test: Extended to configure and test "LBT" through the HAL. * Added a reset_lgw.sh script to be used with IoT Starter Kit (v1.0) to reset the concentrator through the HOST GPIO pin.
1 parent 73f05ed commit 749abc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+7360
-5825
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ all:
1010
$(MAKE) all -e -C libloragw
1111
$(MAKE) all -e -C util_pkt_logger
1212
$(MAKE) all -e -C util_spi_stress
13+
$(MAKE) all -e -C util_lbt_test
1314
$(MAKE) all -e -C util_tx_test
1415
$(MAKE) all -e -C util_tx_continuous
1516
$(MAKE) all -e -C util_spectral_scan
@@ -18,6 +19,7 @@ clean:
1819
$(MAKE) clean -e -C libloragw
1920
$(MAKE) clean -e -C util_pkt_logger
2021
$(MAKE) clean -e -C util_spi_stress
22+
$(MAKE) clean -e -C util_lbt_test
2123
$(MAKE) clean -e -C util_tx_test
2224
$(MAKE) clean -e -C util_tx_continuous
2325
$(MAKE) clean -e -C util_spectral_scan

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.1
1+
4.0.0
31.5 KB
Binary file not shown.
31.5 KB
Binary file not shown.

fpga/readme.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/ _____) _ | |
2+
( (____ _____ ____ _| |_ _____ ____| |__
3+
\____ \| ___ | (_ _) ___ |/ ___) _ \
4+
_____) ) ____| | | || |_| ____( (___| | | |
5+
(______/|_____)_|_|_| \__)_____)\____)_| |_|
6+
(C)2013 Semtech-Cycleo
7+
8+
FPGA images for LoRa Gateway SX1301AP2-PCB_E336
9+
===============================================
10+
11+
1. Content
12+
----------
13+
14+
This directory contains the FPGA images to be programmed in the Semtech's
15+
Reference Design board (SX1301AP2-PCB_E336) flash memory.
16+
17+
The different images contain the following features:
18+
19+
* SX1301_FPGA_125K_NOTCH_LBT_bitmap_v27.bin:
20+
- 125K Notch filter for TX
21+
- Listen-Before-Talk
22+
23+
* SX1301_FPGA_125K_NOTCH_SPECTRAL_SCAN_bitmap_v27.bin:
24+
- 125K Notch filter for TX
25+
- Background Spectral Scan
26+
27+
2. Usage
28+
--------
29+
30+
The following parameters have to be set when using the Lattice Diamond
31+
Programmer software:
32+
33+
Device Family -> iCE40
34+
Device -> iCE40LP1K
35+
Operation -> SPI Flash Programming
36+
-> Programming file: select one of the provided bin image
37+
-> SPI Vendor: Micron
38+
-> SPI Device: SPI-M25P10-A
39+
40+
3. Legal notice
41+
----------------
42+
43+
The information presented in this project documentation does not form part of
44+
any quotation or contract, is believed to be accurate and reliable and may be
45+
changed without notice. No liability will be accepted by the publisher for any
46+
consequence of its use. Publication thereof does not convey nor imply any
47+
license under patent or other industrial or intellectual property rights.
48+
Semtech assumes no responsibility or liability whatsoever for any failure or
49+
unexpected operation resulting from misuse, neglect improper installation,
50+
repair or improper handling or unusual physical or electrical stress
51+
including, but not limited to, exposure to parameters beyond the specified
52+
maximum ratings or operation outside the specified range.
53+
54+
SEMTECH PRODUCTS ARE NOT DESIGNED, INTENDED, AUTHORIZED OR WARRANTED TO BE
55+
SUITABLE FOR USE IN LIFE-SUPPORT APPLICATIONS, DEVICES OR SYSTEMS OR OTHER
56+
CRITICAL APPLICATIONS. INCLUSION OF SEMTECH PRODUCTS IN SUCH APPLICATIONS IS
57+
UNDERSTOOD TO BE UNDERTAKEN SOLELY AT THE CUSTOMER'S OWN RISK. Should a
58+
customer purchase or use Semtech products for any such unauthorized
59+
application, the customer shall indemnify and hold Semtech and its officers,
60+
employees, subsidiaries, affiliates, and distributors harmless against all
61+
claims, costs damages and attorney fees which could arise.
62+
63+
*EOF*

libloragw/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ inc/config.h: ../VERSION library.cfg
4747
@echo " #define DEBUG_HAL $(DEBUG_HAL)" >> $@
4848
@echo " #define DEBUG_GPS $(DEBUG_GPS)" >> $@
4949
@echo " #define DEBUG_GPIO $(DEBUG_GPIO)" >> $@
50+
@echo " #define DEBUG_LBT $(DEBUG_LBT)" >> $@
5051
# end of file
5152
@echo "#endif" >> $@
5253
@echo "*** Configuration seems ok ***"
@@ -67,7 +68,7 @@ $(OBJDIR)/loragw_hal.o: src/loragw_hal.c $(INCLUDES) src/arb_fw.var src/agc_fw.v
6768

6869
### static library
6970

70-
libloragw.a: $(OBJDIR)/loragw_hal.o $(OBJDIR)/loragw_gps.o $(OBJDIR)/loragw_reg.o $(OBJDIR)/loragw_spi.o $(OBJDIR)/loragw_aux.o
71+
libloragw.a: $(OBJDIR)/loragw_hal.o $(OBJDIR)/loragw_gps.o $(OBJDIR)/loragw_reg.o $(OBJDIR)/loragw_spi.o $(OBJDIR)/loragw_aux.o $(OBJDIR)/loragw_radio.o $(OBJDIR)/loragw_fpga.o $(OBJDIR)/loragw_lbt.o
7172
$(AR) rcs $@ $^
7273

7374
### test programs

libloragw/inc/loragw_aux.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
(C)2013 Semtech-Cycleo
88
99
Description:
10-
LoRa concentrator HAL common auxiliary functions
10+
LoRa concentrator HAL common auxiliary functions
1111
1212
License: Revised BSD License, see LICENSE.TXT file include in the project
1313
Maintainer: Sylvain Miermont
@@ -20,7 +20,19 @@ Maintainer: Sylvain Miermont
2020
/* -------------------------------------------------------------------------- */
2121
/* --- DEPENDANCIES --------------------------------------------------------- */
2222

23-
#include "config.h" /* library configuration options (dynamically generated) */
23+
#include "config.h" /* library configuration options (dynamically generated) */
24+
25+
/* -------------------------------------------------------------------------- */
26+
/* --- PUBLIC MACROS -------------------------------------------------------- */
27+
28+
/**
29+
@brief Get a particular bit value from a byte
30+
@param b [in] Any byte from which we want a bit value
31+
@param p [in] Position of the bit in the byte [0..7]
32+
@param n [in] Number of bits we want to get
33+
@return The value corresponding the requested bits
34+
*/
35+
#define TAKE_N_BITS_FROM(b, p, n) (((b) >> (p)) & ((1 << (n)) - 1))
2436

2537
/* -------------------------------------------------------------------------- */
2638
/* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */
Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@
77
(C)2013 Semtech-Cycleo
88
99
Description:
10-
Functions used to handle a single LoRa concentrator.
10+
Functions used to handle FPGA register access for LoRa concentrator.
1111
Registers are addressed by name.
1212
Multi-bytes registers are handled automatically.
1313
Read-modify-write is handled automatically.
1414
1515
License: Revised BSD License, see LICENSE.TXT file include in the project
16-
Maintainer: Matthieu Leurent
16+
Maintainer: Michael Coracin
1717
*/
1818

19-
20-
#ifndef _LORAGW_REG_H
21-
#define _LORAGW_REG_H
19+
#ifndef _LORAGW_FPGA_REG_H
20+
#define _LORAGW_FPGA_REG_H
2221

2322
/* -------------------------------------------------------------------------- */
2423
/* --- DEPENDANCIES --------------------------------------------------------- */
2524

26-
#include <stdint.h> /* C99 types */
25+
#include <stdint.h> /* C99 types */
2726
#include <stdbool.h> /* bool type */
2827

2928
/* -------------------------------------------------------------------------- */
@@ -38,35 +37,35 @@ this file contains autogenerated C struct used to access the FPGA registers
3837
this file is autogenerated from registers description
3938
*/
4039
#define LGW_FPGA_SOFT_RESET 0
41-
#define LGW_FPGA_VERSION 1
42-
#define LGW_FPGA_FPGA_STATUS 2
43-
#define LGW_FPGA_FPGA_CTRL 3
44-
#define LGW_FPGA_HISTO_RAM_ADDR 4
45-
#define LGW_FPGA_HISTO_RAM_DATA 5
46-
#define LGW_FPGA_HISTO_TEMPO 6
47-
#define LGW_FPGA_HISTO_NB_READ 7
48-
#define LGW_FPGA_TIMESTAMP 8
49-
#define LGW_FPGA_SPI_MUX_CTRL 9
50-
#define LGW_FPGA_TOTALREGS 10
51-
52-
#define FPGA_SPI_MUX_REG 1
53-
#define FPGA_SPI_MUX_RADIO 3
54-
#define FPGA_SPI_MUX_REG_HISTO 5
40+
#define LGW_FPGA_FPGA_FEATURE 1
41+
#define LGW_FPGA_VERSION 2
42+
#define LGW_FPGA_FPGA_STATUS 3
43+
#define LGW_FPGA_CTRL_FEATURE_START 4
44+
#define LGW_FPGA_CTRL_RADIO_RESET 5
45+
#define LGW_FPGA_CTRL_INPUT_SYNC_I 6
46+
#define LGW_FPGA_CTRL_INPUT_SYNC_Q 7
47+
#define LGW_FPGA_CTRL_OUTPUT_SYNC 8
48+
#define LGW_FPGA_CTRL_INVERT_IQ 9
49+
#define LGW_FPGA_HISTO_RAM_ADDR 10
50+
#define LGW_FPGA_HISTO_RAM_DATA 11
51+
#define LGW_FPGA_HISTO_TEMPO 12
52+
#define LGW_FPGA_HISTO_NB_READ 13
53+
#define LGW_FPGA_TIMESTAMP 14
54+
#define LGW_FPGA_LBT_TIMESTAMP_CH 15
55+
#define LGW_FPGA_LBT_TIMESTAMP_SELECT_CH 16
56+
#define LGW_FPGA_LBT_TIMESTAMP_NB_CH 17
57+
#define LGW_FPGA_SPI_MASTER_SPEED_DIVIDER 18
58+
#define LGW_FPGA_NB_READ_RSSI 19
59+
#define LGW_FPGA_PLL_LOCK_TIME 20
60+
#define LGW_FPGA_RSSI_TARGET 21
61+
#define LGW_FPGA_LSB_START_FREQ 22
62+
#define LGW_FPGA_SPI_MUX_CTRL 23
63+
#define LGW_FPGA_TOTALREGS 24
5564

5665
/* -------------------------------------------------------------------------- */
5766
/* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */
5867

59-
/**
60-
@brief Connect LoRa concentrator FPGA by opening SPI link
61-
@return status of register operation (LGW_REG_SUCCESS/LGW_REG_ERROR)
62-
*/
63-
int lgw_fpga_connect(void);
64-
65-
/**
66-
@brief Disconnect LoRa concentrator FPGA by closing SPI link
67-
@return status of register operation (LGW_REG_SUCCESS/LGW_REG_ERROR)
68-
*/
69-
int lgw_fpga_disconnect(void);
68+
int lgw_fpga_configure(void);
7069

7170
/**
7271
@brief LoRa concentrator FPGA register write
@@ -102,10 +101,5 @@ int lgw_fpga_reg_wb(uint16_t register_id, uint8_t *data, uint16_t size);
102101
*/
103102
int lgw_fpga_reg_rb(uint16_t register_id, uint8_t *data, uint16_t size);
104103

105-
int lgw_sx1272_reg_w(uint8_t address, uint8_t reg_value);
106-
107-
int lgw_sx1272_reg_r(uint8_t address, uint8_t *reg_value);
108-
109104
#endif
110-
111105
/* --- EOF ------------------------------------------------------------------ */

libloragw/inc/loragw_gps.h

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
(C)2013 Semtech-Cycleo
88
99
Description:
10-
Library of functions to manage a GNSS module (typically GPS) for accurate
11-
timestamping of packets and synchronisation of gateways.
12-
A limited set of module brands/models are supported.
10+
Library of functions to manage a GNSS module (typically GPS) for accurate
11+
timestamping of packets and synchronisation of gateways.
12+
A limited set of module brands/models are supported.
1313
1414
License: Revised BSD License, see LICENSE.TXT file include in the project
1515
Maintainer: Sylvain Miermont
@@ -23,17 +23,12 @@ Maintainer: Sylvain Miermont
2323
/* --- DEPENDANCIES --------------------------------------------------------- */
2424

2525
/* fix an issue between POSIX and C99 */
26-
#if __STDC_VERSION__ >= 199901L
27-
#define _XOPEN_SOURCE 600
28-
#else
29-
#define _XOPEN_SOURCE 500
30-
#endif
31-
32-
#include <stdint.h> /* C99 types */
33-
#include <time.h> /* time library */
34-
#include <termios.h> /* speed_t */
26+
#define _GNU_SOURCE
27+
#include <stdint.h> /* C99 types */
28+
#include <time.h> /* time library */
29+
#include <termios.h> /* speed_t */
3530

36-
#include "config.h" /* library configuration options (dynamically generated) */
31+
#include "config.h" /* library configuration options (dynamically generated) */
3732

3833
/* -------------------------------------------------------------------------- */
3934
/* --- PUBLIC TYPES --------------------------------------------------------- */
@@ -43,54 +38,54 @@ Maintainer: Sylvain Miermont
4338
@brief Time solution required for timestamp to absolute time conversion
4439
*/
4540
struct tref {
46-
time_t systime; /*!> system time when solution was calculated */
47-
uint32_t count_us; /*!> reference concentrator internal timestamp */
48-
struct timespec utc; /*!> reference UTC time (from GPS) */
49-
double xtal_err; /*!> raw clock error (eg. <1 'slow' XTAL) */
41+
time_t systime; /*!> system time when solution was calculated */
42+
uint32_t count_us; /*!> reference concentrator internal timestamp */
43+
struct timespec utc; /*!> reference UTC time (from GPS) */
44+
double xtal_err; /*!> raw clock error (eg. <1 'slow' XTAL) */
5045
};
5146

5247
/**
5348
@struct coord_s
5449
@brief Geodesic coordinates
5550
*/
5651
struct coord_s {
57-
double lat; /*!> latitude [-90,90] (North +, South -) */
58-
double lon; /*!> longitude [-180,180] (East +, West -)*/
59-
short alt; /*!> altitude in meters (WGS 84 geoid ref.) */
52+
double lat; /*!> latitude [-90,90] (North +, South -) */
53+
double lon; /*!> longitude [-180,180] (East +, West -)*/
54+
short alt; /*!> altitude in meters (WGS 84 geoid ref.) */
6055
};
6156

6257
/**
6358
@enum gps_msg
6459
@brief Type of GPS (and other GNSS) sentences
6560
*/
6661
enum gps_msg {
67-
UNKNOWN, /*!> neutral value */
68-
IGNORED, /*!> frame was not parsed by the system */
69-
INVALID, /*!> system try to parse frame but failed */
70-
/* NMEA messages of interest */
71-
NMEA_RMC, /*!> Recommended Minimum data (time + date) */
72-
NMEA_GGA, /*!> Global positioning system fix data (pos + alt) */
73-
NMEA_GNS, /*!> GNSS fix data (pos + alt, sat number) */
74-
NMEA_ZDA, /*!> Time and Date */
75-
/* NMEA message useful for time reference quality assessment */
76-
NMEA_GBS, /*!> GNSS Satellite Fault Detection */
77-
NMEA_GST, /*!> GNSS Pseudo Range Error Statistics */
78-
NMEA_GSA, /*!> GNSS DOP and Active Satellites (sat number) */
79-
NMEA_GSV, /*!> GNSS Satellites in View (sat SNR) */
80-
/* Misc. NMEA messages */
81-
NMEA_GLL, /*!> Latitude and longitude, with time fix and status */
82-
NMEA_TXT, /*!> Text Transmission */
83-
NMEA_VTG, /*!> Course over ground and Ground speed */
84-
/* uBlox proprietary NMEA messages of interest */
85-
UBX_POSITION, /*!> */
86-
UBX_TIME /*!> */
62+
UNKNOWN, /*!> neutral value */
63+
IGNORED, /*!> frame was not parsed by the system */
64+
INVALID, /*!> system try to parse frame but failed */
65+
/* NMEA messages of interest */
66+
NMEA_RMC, /*!> Recommended Minimum data (time + date) */
67+
NMEA_GGA, /*!> Global positioning system fix data (pos + alt) */
68+
NMEA_GNS, /*!> GNSS fix data (pos + alt, sat number) */
69+
NMEA_ZDA, /*!> Time and Date */
70+
/* NMEA message useful for time reference quality assessment */
71+
NMEA_GBS, /*!> GNSS Satellite Fault Detection */
72+
NMEA_GST, /*!> GNSS Pseudo Range Error Statistics */
73+
NMEA_GSA, /*!> GNSS DOP and Active Satellites (sat number) */
74+
NMEA_GSV, /*!> GNSS Satellites in View (sat SNR) */
75+
/* Misc. NMEA messages */
76+
NMEA_GLL, /*!> Latitude and longitude, with time fix and status */
77+
NMEA_TXT, /*!> Text Transmission */
78+
NMEA_VTG, /*!> Course over ground and Ground speed */
79+
/* uBlox proprietary NMEA messages of interest */
80+
UBX_POSITION, /*!> */
81+
UBX_TIME /*!> */
8782
};
8883

8984
/* -------------------------------------------------------------------------- */
9085
/* --- PUBLIC CONSTANTS ----------------------------------------------------- */
9186

92-
#define LGW_GPS_SUCCESS 0
93-
#define LGW_GPS_ERROR -1
87+
#define LGW_GPS_SUCCESS 0
88+
#define LGW_GPS_ERROR -1
9489

9590
/* -------------------------------------------------------------------------- */
9691
/* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */
@@ -113,9 +108,9 @@ int lgw_gps_enable(char* tty_path, char* gps_familly, speed_t target_brate, int*
113108
@param buff_size maximum string lengths for NMEA parsing (incl. null char)
114109
@return type of frame parsed
115110
116-
The RAW NMEA sentences are parsed to a global set of variables shared with the
111+
The RAW NMEA sentences are parsed to a global set of variables shared with the
117112
lgw_gps_get function.
118-
If the lgw_parse_nmea and lgw_gps_get are used in different threads, a mutex
113+
If the lgw_parse_nmea and lgw_gps_get are used in different threads, a mutex
119114
lock must be acquired before calling either function.
120115
*/
121116
enum gps_msg lgw_parse_nmea(char* serial_buff, int buff_size);
@@ -128,10 +123,10 @@ enum gps_msg lgw_parse_nmea(char* serial_buff, int buff_size);
128123
@param err pointer to store coordinates standard deviation (NULL to ignore)
129124
@return success if the chosen elements could be returned
130125
131-
This function read the global variables generated by the NMEA parsing function
132-
lgw_parse_nmea. It returns time and location data in a format that is
126+
This function read the global variables generated by the NMEA parsing function
127+
lgw_parse_nmea. It returns time and location data in a format that is
133128
exploitable by other functions in that library sub-module.
134-
If the lgw_parse_nmea and lgw_gps_get are used in different threads, a mutex
129+
If the lgw_parse_nmea and lgw_gps_get are used in different threads, a mutex
135130
lock must be acquired before calling either function.
136131
*/
137132
int lgw_gps_get(struct timespec* utc, struct coord_s* loc, struct coord_s* err);
@@ -156,8 +151,8 @@ int lgw_gps_sync(struct tref* ref, uint32_t count_us, struct timespec utc);
156151
@param utc pointer to store UTC time, with ns precision (leap seconds ignored)
157152
@return success if the function was able to convert timestamp to UTC
158153
159-
This function is typically used when a packet is received to transform the
160-
internal counter-based timestamp in an absolute timestamp with an accuracy in
154+
This function is typically used when a packet is received to transform the
155+
internal counter-based timestamp in an absolute timestamp with an accuracy in
161156
the order of a couple microseconds (ns resolution).
162157
*/
163158
int lgw_cnt2utc(struct tref ref, uint32_t count_us, struct timespec* utc);
@@ -170,8 +165,8 @@ int lgw_cnt2utc(struct tref ref, uint32_t count_us, struct timespec* utc);
170165
@param count_us pointer to store internal timestamp counter of LoRa concentrator
171166
@return success if the function was able to convert UTC to timestamp
172167
173-
This function is typically used when a packet must be sent at an accurate time
174-
(eg. to send a piggy-back response after receiving a packet from a node) to
168+
This function is typically used when a packet must be sent at an accurate time
169+
(eg. to send a piggy-back response after receiving a packet from a node) to
175170
transform an absolute UTC time into a matching internal concentrator timestamp.
176171
*/
177172
int lgw_utc2cnt(struct tref ref,struct timespec utc, uint32_t* count_us);

0 commit comments

Comments
 (0)