Skip to content

Commit

Permalink
v4.0.0
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
mcoracin committed Jun 6, 2016
1 parent 73f05ed commit 749abc8
Show file tree
Hide file tree
Showing 54 changed files with 7,360 additions and 5,825 deletions.
2 changes: 2 additions & 0 deletions Makefile
Expand Up @@ -10,6 +10,7 @@ all:
$(MAKE) all -e -C libloragw
$(MAKE) all -e -C util_pkt_logger
$(MAKE) all -e -C util_spi_stress
$(MAKE) all -e -C util_lbt_test
$(MAKE) all -e -C util_tx_test
$(MAKE) all -e -C util_tx_continuous
$(MAKE) all -e -C util_spectral_scan
Expand All @@ -18,6 +19,7 @@ clean:
$(MAKE) clean -e -C libloragw
$(MAKE) clean -e -C util_pkt_logger
$(MAKE) clean -e -C util_spi_stress
$(MAKE) clean -e -C util_lbt_test
$(MAKE) clean -e -C util_tx_test
$(MAKE) clean -e -C util_tx_continuous
$(MAKE) clean -e -C util_spectral_scan
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
3.2.1
4.0.0
Binary file added fpga/SX1301_FPGA_125K_NOTCH_LBT_bitmap_v27.bin
Binary file not shown.
Binary file not shown.
63 changes: 63 additions & 0 deletions fpga/readme.md
@@ -0,0 +1,63 @@
/ _____) _ | |
( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
(C)2013 Semtech-Cycleo

FPGA images for LoRa Gateway SX1301AP2-PCB_E336
===============================================

1. Content
----------

This directory contains the FPGA images to be programmed in the Semtech's
Reference Design board (SX1301AP2-PCB_E336) flash memory.

The different images contain the following features:

* SX1301_FPGA_125K_NOTCH_LBT_bitmap_v27.bin:
- 125K Notch filter for TX
- Listen-Before-Talk

* SX1301_FPGA_125K_NOTCH_SPECTRAL_SCAN_bitmap_v27.bin:
- 125K Notch filter for TX
- Background Spectral Scan

2. Usage
--------

The following parameters have to be set when using the Lattice Diamond
Programmer software:

Device Family -> iCE40
Device -> iCE40LP1K
Operation -> SPI Flash Programming
-> Programming file: select one of the provided bin image
-> SPI Vendor: Micron
-> SPI Device: SPI-M25P10-A

3. Legal notice
----------------

The information presented in this project documentation does not form part of
any quotation or contract, is believed to be accurate and reliable and may be
changed without notice. No liability will be accepted by the publisher for any
consequence of its use. Publication thereof does not convey nor imply any
license under patent or other industrial or intellectual property rights.
Semtech assumes no responsibility or liability whatsoever for any failure or
unexpected operation resulting from misuse, neglect improper installation,
repair or improper handling or unusual physical or electrical stress
including, but not limited to, exposure to parameters beyond the specified
maximum ratings or operation outside the specified range.

SEMTECH PRODUCTS ARE NOT DESIGNED, INTENDED, AUTHORIZED OR WARRANTED TO BE
SUITABLE FOR USE IN LIFE-SUPPORT APPLICATIONS, DEVICES OR SYSTEMS OR OTHER
CRITICAL APPLICATIONS. INCLUSION OF SEMTECH PRODUCTS IN SUCH APPLICATIONS IS
UNDERSTOOD TO BE UNDERTAKEN SOLELY AT THE CUSTOMER'S OWN RISK. Should a
customer purchase or use Semtech products for any such unauthorized
application, the customer shall indemnify and hold Semtech and its officers,
employees, subsidiaries, affiliates, and distributors harmless against all
claims, costs damages and attorney fees which could arise.

*EOF*
3 changes: 2 additions & 1 deletion libloragw/Makefile
Expand Up @@ -47,6 +47,7 @@ inc/config.h: ../VERSION library.cfg
@echo " #define DEBUG_HAL $(DEBUG_HAL)" >> $@
@echo " #define DEBUG_GPS $(DEBUG_GPS)" >> $@
@echo " #define DEBUG_GPIO $(DEBUG_GPIO)" >> $@
@echo " #define DEBUG_LBT $(DEBUG_LBT)" >> $@
# end of file
@echo "#endif" >> $@
@echo "*** Configuration seems ok ***"
Expand All @@ -67,7 +68,7 @@ $(OBJDIR)/loragw_hal.o: src/loragw_hal.c $(INCLUDES) src/arb_fw.var src/agc_fw.v

### static library

libloragw.a: $(OBJDIR)/loragw_hal.o $(OBJDIR)/loragw_gps.o $(OBJDIR)/loragw_reg.o $(OBJDIR)/loragw_spi.o $(OBJDIR)/loragw_aux.o
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
$(AR) rcs $@ $^

### test programs
Expand Down
16 changes: 14 additions & 2 deletions libloragw/inc/loragw_aux.h
Expand Up @@ -7,7 +7,7 @@
(C)2013 Semtech-Cycleo
Description:
LoRa concentrator HAL common auxiliary functions
LoRa concentrator HAL common auxiliary functions
License: Revised BSD License, see LICENSE.TXT file include in the project
Maintainer: Sylvain Miermont
Expand All @@ -20,7 +20,19 @@ Maintainer: Sylvain Miermont
/* -------------------------------------------------------------------------- */
/* --- DEPENDANCIES --------------------------------------------------------- */

#include "config.h" /* library configuration options (dynamically generated) */
#include "config.h" /* library configuration options (dynamically generated) */

/* -------------------------------------------------------------------------- */
/* --- PUBLIC MACROS -------------------------------------------------------- */

/**
@brief Get a particular bit value from a byte
@param b [in] Any byte from which we want a bit value
@param p [in] Position of the bit in the byte [0..7]
@param n [in] Number of bits we want to get
@return The value corresponding the requested bits
*/
#define TAKE_N_BITS_FROM(b, p, n) (((b) >> (p)) & ((1 << (n)) - 1))

/* -------------------------------------------------------------------------- */
/* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */
Expand Down
Expand Up @@ -7,23 +7,22 @@
(C)2013 Semtech-Cycleo
Description:
Functions used to handle a single LoRa concentrator.
Functions used to handle FPGA register access for LoRa concentrator.
Registers are addressed by name.
Multi-bytes registers are handled automatically.
Read-modify-write is handled automatically.
License: Revised BSD License, see LICENSE.TXT file include in the project
Maintainer: Matthieu Leurent
Maintainer: Michael Coracin
*/


#ifndef _LORAGW_REG_H
#define _LORAGW_REG_H
#ifndef _LORAGW_FPGA_REG_H
#define _LORAGW_FPGA_REG_H

/* -------------------------------------------------------------------------- */
/* --- DEPENDANCIES --------------------------------------------------------- */

#include <stdint.h> /* C99 types */
#include <stdint.h> /* C99 types */
#include <stdbool.h> /* bool type */

/* -------------------------------------------------------------------------- */
Expand All @@ -38,35 +37,35 @@ this file contains autogenerated C struct used to access the FPGA registers
this file is autogenerated from registers description
*/
#define LGW_FPGA_SOFT_RESET 0
#define LGW_FPGA_VERSION 1
#define LGW_FPGA_FPGA_STATUS 2
#define LGW_FPGA_FPGA_CTRL 3
#define LGW_FPGA_HISTO_RAM_ADDR 4
#define LGW_FPGA_HISTO_RAM_DATA 5
#define LGW_FPGA_HISTO_TEMPO 6
#define LGW_FPGA_HISTO_NB_READ 7
#define LGW_FPGA_TIMESTAMP 8
#define LGW_FPGA_SPI_MUX_CTRL 9
#define LGW_FPGA_TOTALREGS 10

#define FPGA_SPI_MUX_REG 1
#define FPGA_SPI_MUX_RADIO 3
#define FPGA_SPI_MUX_REG_HISTO 5
#define LGW_FPGA_FPGA_FEATURE 1
#define LGW_FPGA_VERSION 2
#define LGW_FPGA_FPGA_STATUS 3
#define LGW_FPGA_CTRL_FEATURE_START 4
#define LGW_FPGA_CTRL_RADIO_RESET 5
#define LGW_FPGA_CTRL_INPUT_SYNC_I 6
#define LGW_FPGA_CTRL_INPUT_SYNC_Q 7
#define LGW_FPGA_CTRL_OUTPUT_SYNC 8
#define LGW_FPGA_CTRL_INVERT_IQ 9
#define LGW_FPGA_HISTO_RAM_ADDR 10
#define LGW_FPGA_HISTO_RAM_DATA 11
#define LGW_FPGA_HISTO_TEMPO 12
#define LGW_FPGA_HISTO_NB_READ 13
#define LGW_FPGA_TIMESTAMP 14
#define LGW_FPGA_LBT_TIMESTAMP_CH 15
#define LGW_FPGA_LBT_TIMESTAMP_SELECT_CH 16
#define LGW_FPGA_LBT_TIMESTAMP_NB_CH 17
#define LGW_FPGA_SPI_MASTER_SPEED_DIVIDER 18
#define LGW_FPGA_NB_READ_RSSI 19
#define LGW_FPGA_PLL_LOCK_TIME 20
#define LGW_FPGA_RSSI_TARGET 21
#define LGW_FPGA_LSB_START_FREQ 22
#define LGW_FPGA_SPI_MUX_CTRL 23
#define LGW_FPGA_TOTALREGS 24

/* -------------------------------------------------------------------------- */
/* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */

/**
@brief Connect LoRa concentrator FPGA by opening SPI link
@return status of register operation (LGW_REG_SUCCESS/LGW_REG_ERROR)
*/
int lgw_fpga_connect(void);

/**
@brief Disconnect LoRa concentrator FPGA by closing SPI link
@return status of register operation (LGW_REG_SUCCESS/LGW_REG_ERROR)
*/
int lgw_fpga_disconnect(void);
int lgw_fpga_configure(void);

/**
@brief LoRa concentrator FPGA register write
Expand Down Expand Up @@ -102,10 +101,5 @@ int lgw_fpga_reg_wb(uint16_t register_id, uint8_t *data, uint16_t size);
*/
int lgw_fpga_reg_rb(uint16_t register_id, uint8_t *data, uint16_t size);

int lgw_sx1272_reg_w(uint8_t address, uint8_t reg_value);

int lgw_sx1272_reg_r(uint8_t address, uint8_t *reg_value);

#endif

/* --- EOF ------------------------------------------------------------------ */
97 changes: 46 additions & 51 deletions libloragw/inc/loragw_gps.h
Expand Up @@ -7,9 +7,9 @@
(C)2013 Semtech-Cycleo
Description:
Library of functions to manage a GNSS module (typically GPS) for accurate
timestamping of packets and synchronisation of gateways.
A limited set of module brands/models are supported.
Library of functions to manage a GNSS module (typically GPS) for accurate
timestamping of packets and synchronisation of gateways.
A limited set of module brands/models are supported.
License: Revised BSD License, see LICENSE.TXT file include in the project
Maintainer: Sylvain Miermont
Expand All @@ -23,17 +23,12 @@ Maintainer: Sylvain Miermont
/* --- DEPENDANCIES --------------------------------------------------------- */

/* fix an issue between POSIX and C99 */
#if __STDC_VERSION__ >= 199901L
#define _XOPEN_SOURCE 600
#else
#define _XOPEN_SOURCE 500
#endif

#include <stdint.h> /* C99 types */
#include <time.h> /* time library */
#include <termios.h> /* speed_t */
#define _GNU_SOURCE
#include <stdint.h> /* C99 types */
#include <time.h> /* time library */
#include <termios.h> /* speed_t */

#include "config.h" /* library configuration options (dynamically generated) */
#include "config.h" /* library configuration options (dynamically generated) */

/* -------------------------------------------------------------------------- */
/* --- PUBLIC TYPES --------------------------------------------------------- */
Expand All @@ -43,54 +38,54 @@ Maintainer: Sylvain Miermont
@brief Time solution required for timestamp to absolute time conversion
*/
struct tref {
time_t systime; /*!> system time when solution was calculated */
uint32_t count_us; /*!> reference concentrator internal timestamp */
struct timespec utc; /*!> reference UTC time (from GPS) */
double xtal_err; /*!> raw clock error (eg. <1 'slow' XTAL) */
time_t systime; /*!> system time when solution was calculated */
uint32_t count_us; /*!> reference concentrator internal timestamp */
struct timespec utc; /*!> reference UTC time (from GPS) */
double xtal_err; /*!> raw clock error (eg. <1 'slow' XTAL) */
};

/**
@struct coord_s
@brief Geodesic coordinates
*/
struct coord_s {
double lat; /*!> latitude [-90,90] (North +, South -) */
double lon; /*!> longitude [-180,180] (East +, West -)*/
short alt; /*!> altitude in meters (WGS 84 geoid ref.) */
double lat; /*!> latitude [-90,90] (North +, South -) */
double lon; /*!> longitude [-180,180] (East +, West -)*/
short alt; /*!> altitude in meters (WGS 84 geoid ref.) */
};

/**
@enum gps_msg
@brief Type of GPS (and other GNSS) sentences
*/
enum gps_msg {
UNKNOWN, /*!> neutral value */
IGNORED, /*!> frame was not parsed by the system */
INVALID, /*!> system try to parse frame but failed */
/* NMEA messages of interest */
NMEA_RMC, /*!> Recommended Minimum data (time + date) */
NMEA_GGA, /*!> Global positioning system fix data (pos + alt) */
NMEA_GNS, /*!> GNSS fix data (pos + alt, sat number) */
NMEA_ZDA, /*!> Time and Date */
/* NMEA message useful for time reference quality assessment */
NMEA_GBS, /*!> GNSS Satellite Fault Detection */
NMEA_GST, /*!> GNSS Pseudo Range Error Statistics */
NMEA_GSA, /*!> GNSS DOP and Active Satellites (sat number) */
NMEA_GSV, /*!> GNSS Satellites in View (sat SNR) */
/* Misc. NMEA messages */
NMEA_GLL, /*!> Latitude and longitude, with time fix and status */
NMEA_TXT, /*!> Text Transmission */
NMEA_VTG, /*!> Course over ground and Ground speed */
/* uBlox proprietary NMEA messages of interest */
UBX_POSITION, /*!> */
UBX_TIME /*!> */
UNKNOWN, /*!> neutral value */
IGNORED, /*!> frame was not parsed by the system */
INVALID, /*!> system try to parse frame but failed */
/* NMEA messages of interest */
NMEA_RMC, /*!> Recommended Minimum data (time + date) */
NMEA_GGA, /*!> Global positioning system fix data (pos + alt) */
NMEA_GNS, /*!> GNSS fix data (pos + alt, sat number) */
NMEA_ZDA, /*!> Time and Date */
/* NMEA message useful for time reference quality assessment */
NMEA_GBS, /*!> GNSS Satellite Fault Detection */
NMEA_GST, /*!> GNSS Pseudo Range Error Statistics */
NMEA_GSA, /*!> GNSS DOP and Active Satellites (sat number) */
NMEA_GSV, /*!> GNSS Satellites in View (sat SNR) */
/* Misc. NMEA messages */
NMEA_GLL, /*!> Latitude and longitude, with time fix and status */
NMEA_TXT, /*!> Text Transmission */
NMEA_VTG, /*!> Course over ground and Ground speed */
/* uBlox proprietary NMEA messages of interest */
UBX_POSITION, /*!> */
UBX_TIME /*!> */
};

/* -------------------------------------------------------------------------- */
/* --- PUBLIC CONSTANTS ----------------------------------------------------- */

#define LGW_GPS_SUCCESS 0
#define LGW_GPS_ERROR -1
#define LGW_GPS_SUCCESS 0
#define LGW_GPS_ERROR -1

/* -------------------------------------------------------------------------- */
/* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */
Expand All @@ -113,9 +108,9 @@ int lgw_gps_enable(char* tty_path, char* gps_familly, speed_t target_brate, int*
@param buff_size maximum string lengths for NMEA parsing (incl. null char)
@return type of frame parsed
The RAW NMEA sentences are parsed to a global set of variables shared with the
The RAW NMEA sentences are parsed to a global set of variables shared with the
lgw_gps_get function.
If the lgw_parse_nmea and lgw_gps_get are used in different threads, a mutex
If the lgw_parse_nmea and lgw_gps_get are used in different threads, a mutex
lock must be acquired before calling either function.
*/
enum gps_msg lgw_parse_nmea(char* serial_buff, int buff_size);
Expand All @@ -128,10 +123,10 @@ enum gps_msg lgw_parse_nmea(char* serial_buff, int buff_size);
@param err pointer to store coordinates standard deviation (NULL to ignore)
@return success if the chosen elements could be returned
This function read the global variables generated by the NMEA parsing function
lgw_parse_nmea. It returns time and location data in a format that is
This function read the global variables generated by the NMEA parsing function
lgw_parse_nmea. It returns time and location data in a format that is
exploitable by other functions in that library sub-module.
If the lgw_parse_nmea and lgw_gps_get are used in different threads, a mutex
If the lgw_parse_nmea and lgw_gps_get are used in different threads, a mutex
lock must be acquired before calling either function.
*/
int lgw_gps_get(struct timespec* utc, struct coord_s* loc, struct coord_s* err);
Expand All @@ -156,8 +151,8 @@ int lgw_gps_sync(struct tref* ref, uint32_t count_us, struct timespec utc);
@param utc pointer to store UTC time, with ns precision (leap seconds ignored)
@return success if the function was able to convert timestamp to UTC
This function is typically used when a packet is received to transform the
internal counter-based timestamp in an absolute timestamp with an accuracy in
This function is typically used when a packet is received to transform the
internal counter-based timestamp in an absolute timestamp with an accuracy in
the order of a couple microseconds (ns resolution).
*/
int lgw_cnt2utc(struct tref ref, uint32_t count_us, struct timespec* utc);
Expand All @@ -170,8 +165,8 @@ int lgw_cnt2utc(struct tref ref, uint32_t count_us, struct timespec* utc);
@param count_us pointer to store internal timestamp counter of LoRa concentrator
@return success if the function was able to convert UTC to timestamp
This function is typically used when a packet must be sent at an accurate time
(eg. to send a piggy-back response after receiving a packet from a node) to
This function is typically used when a packet must be sent at an accurate time
(eg. to send a piggy-back response after receiving a packet from a node) to
transform an absolute UTC time into a matching internal concentrator timestamp.
*/
int lgw_utc2cnt(struct tref ref,struct timespec utc, uint32_t* count_us);
Expand Down

0 comments on commit 749abc8

Please sign in to comment.