Skip to content

Commit

Permalink
fork from TheThingsIndustries/lora_gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Gourlaouen committed May 8, 2017
1 parent f4329a6 commit e8f03fb
Show file tree
Hide file tree
Showing 63 changed files with 9,692 additions and 7,489 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ libloragw/inc/config.h

libloragw/test_*

util_lbt_test/util_lbt_test
util_pkt_logger/util_pkt_logger
util_spectral_scan/util_spectral_scan
util_spi_stress/util_spi_stress
util_tx_continuous/util_tx_continuous
util_tx_test/util_tx_test
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ 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

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

### EOF
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.0
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
Original file line number Diff line number Diff line change
@@ -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*
60 changes: 35 additions & 25 deletions libloragw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,30 @@ CC := $(CROSS_COMPILE)gcc
AR := $(CROSS_COMPILE)ar


### Test if the file has been configured, do not accept the default

ifeq ($(CFG_SPI),???)
$(error Please specify CFG_SPI in lora_gateway/libloragw/library.cfg first!)
endif

ifeq ($(PLATFORM),???)
$(error Please specify PLATFORM in lora_gateway/libloragw/library.cfg first!)
endif


### library.cfg configuration file processing

ifeq ($(CFG_SPI),native)
CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I.
CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I.
CFG_SPI_MSG := Linux native SPI driver
CFG_SPI_OPT := CFG_SPI_NATIVE
else ifeq ($(CFG_SPI),ftdi)
ifeq ($(PLATFORM),multitech)
CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I. -I/opt/mlinux/3.1.0/sysroots/arm926ejste-mlinux-linux-gnueabi/usr/include/libftdi1
ifeq ($(SDKTARGETSYSROOT),)
CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I. -I/opt/mlinux/3.2.0/sysroots/arm926ejste-mlinux-linux-gnueabi/usr/include/libftdi1
else
CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I. -I$(SDKTARGETSYSROOT)/usr/include/libftdi1
endif
else
CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I.
endif
Expand All @@ -33,6 +48,9 @@ else
$(error No SPI physical layer selected, check ../target.cfg file.)
endif

OBJDIR = obj
INCLUDES = $(wildcard inc/*.h)

### linking options

ifeq ($(CFG_SPI),native)
Expand All @@ -50,70 +68,62 @@ all: libloragw.a test_loragw_spi test_loragw_reg test_loragw_hal test_loragw_gps
clean:
rm -f libloragw.a
rm -f test_loragw_*
rm -f obj/*.o
rm -f $(OBJDIR)/*.o
rm -f inc/config.h

### transpose library.cfg into a C header file : config.h

inc/config.h: ../VERSION library.cfg
@echo "*** Checking libloragw library configuration ***"
@rm -f $@
# File initialization
#File initialization
@echo "#ifndef _LORAGW_CONFIGURATION_H" >> $@
@echo "#define _LORAGW_CONFIGURATION_H" >> $@
# Release version
# Release version
@echo "Release version : $(LIBLORAGW_VERSION)"
@echo " #define LIBLORAGW_VERSION "\"$(LIBLORAGW_VERSION)\""" >> $@
# SPI interface
@echo "SPI interface : $(CFG_SPI_MSG)"
@echo " #define $(CFG_SPI_OPT) 1" >> $@
# Debug options
# Debug options
@echo " #define DEBUG_AUX $(DEBUG_AUX)" >> $@
@echo " #define DEBUG_SPI $(DEBUG_SPI)" >> $@
@echo " #define DEBUG_REG $(DEBUG_REG)" >> $@
@echo " #define DEBUG_HAL $(DEBUG_HAL)" >> $@
@echo " #define DEBUG_GPS $(DEBUG_GPS)" >> $@
@echo " #define DEBUG_GPIO $(DEBUG_GPIO)" >> $@
@echo " #define DEBUG_LBT $(DEBUG_LBT)" >> $@
# Platform selection
@echo " #include \"$(PLATFORM).h\"" >> $@
# end of file
# end of file
@echo "#endif" >> $@
@echo "*** Configuration seems ok ***"

### library module target

obj/loragw_aux.o: src/loragw_aux.c inc/loragw_aux.h inc/config.h
$(OBJDIR):
mkdir -p $(OBJDIR)

$(OBJDIR)/%.o: src/%.c $(INCLUDES) inc/config.h | $(OBJDIR)
$(CC) -c $(CFLAGS) $< -o $@

ifeq ($(CFG_SPI),native)
obj/loragw_spi.o: src/loragw_spi.native.c inc/loragw_spi.h inc/config.h
$(OBJDIR)/loragw_spi.o: src/loragw_spi.native.c inc/loragw_spi.h inc/config.h | $(OBJDIR)
$(CC) -c $(CFLAGS) $< -o $@
else ifeq ($(CFG_SPI),ftdi)
obj/loragw_spi.o: src/loragw_spi.ftdi.c inc/loragw_spi.h inc/config.h
$(OBJDIR)/loragw_spi.o: src/loragw_spi.ftdi.c inc/loragw_spi.h inc/config.h | $(OBJDIR)
$(CC) -c $(CFLAGS) $< -o $@
else ifeq ($(CFG_SPI),mac)
obj/loragw_spi.o: src/loragw_spi.ftdi.c inc/loragw_spi.h inc/config.h
$(OBJDIR)/loragw_spi.o: src/loragw_spi.ftdi.c inc/loragw_spi.h inc/config.h | $(OBJDIR)
$(CC) -c $(CFLAGS) $< -o $@
endif

obj/loragw_reg.o: src/loragw_reg.c inc/loragw_reg.h inc/loragw_spi.h inc/config.h
$(CC) -c $(CFLAGS) $< -o $@

obj/loragw_hal.o: src/loragw_hal.c inc/loragw_hal.h inc/loragw_reg.h inc/loragw_aux.h src/arb_fw.var src/agc_fw.var src/cal_fw.var inc/config.h
$(CC) -c $(CFLAGS) $< -o $@

obj/loragw_gps.o: src/loragw_gps.c inc/loragw_gps.h inc/config.h
$(OBJDIR)/loragw_hal.o: src/loragw_hal.c $(INCLUDES) src/arb_fw.var src/agc_fw.var src/cal_fw.var inc/config.h | $(OBJDIR)
$(CC) -c $(CFLAGS) $< -o $@

### static library

ifeq ($(CFG_SPI),native)
libloragw.a: obj/loragw_hal.o obj/loragw_gps.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o
else ifeq ($(CFG_SPI),ftdi)
libloragw.a: obj/loragw_hal.o obj/loragw_gps.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o
else ifeq ($(CFG_SPI),mac)
libloragw.a: obj/loragw_hal.o obj/loragw_gps.o obj/loragw_reg.o obj/loragw_spi.o obj/loragw_aux.o
endif
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
Original file line number Diff line number Diff line change
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
105 changes: 105 additions & 0 deletions libloragw/inc/loragw_fpga.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
/ _____) _ | |
( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
(C)2013 Semtech-Cycleo
Description:
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: Michael Coracin
*/

#ifndef _LORAGW_FPGA_REG_H
#define _LORAGW_FPGA_REG_H

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

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

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

#define LGW_REG_SUCCESS 0
#define LGW_REG_ERROR -1

/*
auto generated register mapping for C code
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_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 ------------------------------------------ */

int lgw_fpga_configure(void);

/**
@brief LoRa concentrator FPGA register write
@param register_id register number in the data structure describing registers
@param reg_value signed value to write to the register (for u32, use cast)
@return status of register operation (LGW_REG_SUCCESS/LGW_REG_ERROR)
*/
int lgw_fpga_reg_w(uint16_t register_id, int32_t reg_value);

/**
@brief LoRa concentrator FPGA register read
@param register_id register number in the data structure describing registers
@param reg_value pointer to a variable where to write register read value
@return status of register operation (LGW_REG_SUCCESS/LGW_REG_ERROR)
*/
int lgw_fpga_reg_r(uint16_t register_id, int32_t *reg_value);

/**
@brief LoRa concentrator FPGA register burst write
@param register_id register number in the data structure describing registers
@param data pointer to byte array that will be sent to the LoRa concentrator
@param size size of the transfer, in byte(s)
@return status of register operation (LGW_REG_SUCCESS/LGW_REG_ERROR)
*/
int lgw_fpga_reg_wb(uint16_t register_id, uint8_t *data, uint16_t size);

/**
@brief LoRa concentrator FPGA register burst read
@param register_id register number in the data structure describing registers
@param data pointer to byte array that will be written from the LoRa concentrator
@param size size of the transfer, in byte(s)
@return status of register operation (LGW_REG_SUCCESS/LGW_REG_ERROR)
*/
int lgw_fpga_reg_rb(uint16_t register_id, uint8_t *data, uint16_t size);

#endif
/* --- EOF ------------------------------------------------------------------ */
Loading

0 comments on commit e8f03fb

Please sign in to comment.