Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
* Initial release for SX1302 CoreCell Reference Design.
  • Loading branch information
mcoracin committed Jul 12, 2019
1 parent c7a5171 commit 4c61c5d
Show file tree
Hide file tree
Showing 79 changed files with 30,157 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
### Environment constants

ARCH ?=
CROSS_COMPILE ?=
export

### general build targets

.PHONY: all clean install install_conf libtools libloragw packet_forwarder util_net_downlink util_chip_id

all: libtools libloragw packet_forwarder util_net_downlink util_chip_id

libtools:
$(MAKE) all -e -C $@

libloragw: libtools
$(MAKE) all -e -C $@

packet_forwarder: libloragw
$(MAKE) all -e -C $@

util_net_downlink: libtools
$(MAKE) all -e -C $@

util_chip_id: libloragw
$(MAKE) all -e -C $@

clean:
$(MAKE) clean -e -C libtools
$(MAKE) clean -e -C libloragw
$(MAKE) clean -e -C packet_forwarder
$(MAKE) clean -e -C util_net_downlink
$(MAKE) clean -e -C util_chip_id

install:
$(MAKE) install -e -C libloragw
$(MAKE) install -e -C packet_forwarder
$(MAKE) install -e -C util_net_downlink
$(MAKE) install -e -C util_chip_id

install_conf:
$(MAKE) install_conf -e -C packet_forwarder

### EOF
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
126 changes: 126 additions & 0 deletions libloragw/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
### get external defined data

LIBLORAGW_VERSION := `cat ../VERSION`
include library.cfg
include ../target.cfg

### constant symbols

ARCH ?=
CROSS_COMPILE ?=
CC := $(CROSS_COMPILE)gcc
AR := $(CROSS_COMPILE)ar

CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I. -I../libtools/inc

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

### linking options

LIBS := -lloragw -ltinymt32 -lrt -lm

### general build targets

all: libloragw.a test_loragw_spi test_loragw_i2c test_loragw_reg test_loragw_hal_tx test_loragw_hal_rx test_loragw_cal test_loragw_capture_ram test_loragw_spi_sx1250 test_loragw_counter test_loragw_gps

clean:
rm -f libloragw.a
rm -f test_loragw_*
rm -f $(OBJDIR)/*.o
rm -f inc/config.h

install:
ifneq ($(strip $(TARGET_IP)),)
ifneq ($(strip $(TARGET_DIR)),)
ifneq ($(strip $(TARGET_USR)),)
@echo "---- Copying libloragw files to $(TARGET_IP):$(TARGET_DIR)"
@ssh $(TARGET_USR)@$(TARGET_IP) "mkdir -p $(TARGET_DIR)"
@scp test_loragw_* $(TARGET_USR)@$(TARGET_IP):$(TARGET_DIR)
@scp ../tools/reset_lgw.sh $(TARGET_USR)@$(TARGET_IP):$(TARGET_DIR)
else
@echo "ERROR: TARGET_USR is not configured in target.cfg"
endif
else
@echo "ERROR: TARGET_DIR is not configured in target.cfg"
endif
else
@echo "ERROR: TARGET_IP is not configured in target.cfg"
endif

### 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
@echo "#ifndef _LORAGW_CONFIGURATION_H" >> $@
@echo "#define _LORAGW_CONFIGURATION_H" >> $@
# Release version
@echo "Release version : $(LIBLORAGW_VERSION)"
@echo " #define LIBLORAGW_VERSION "\"$(LIBLORAGW_VERSION)\""" >> $@
# Debug options
@echo " #define DEBUG_AUX $(DEBUG_AUX)" >> $@
@echo " #define DEBUG_SPI $(DEBUG_SPI)" >> $@
@echo " #define DEBUG_I2C $(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)" >> $@
@echo " #define DEBUG_RAD $(DEBUG_RAD)" >> $@
@echo " #define DEBUG_CAL $(DEBUG_CAL)" >> $@
@echo " #define DEBUG_SX1302 $(DEBUG_SX1302)" >> $@
# Configuration options
@echo " #define BYPASS_FW_INIT $(BYPASS_FW_INIT)" >> $@
@echo " #define FPGA_BOARD_16_CH $(FPGA_BOARD_16_CH)" >> $@
# end of file
@echo "#endif" >> $@
@echo "*** Configuration seems ok ***"

### library module target

$(OBJDIR):
mkdir -p $(OBJDIR)

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

### static library

libloragw.a: $(OBJDIR)/loragw_spi.o $(OBJDIR)/loragw_i2c.o $(OBJDIR)/loragw_aux.o $(OBJDIR)/loragw_reg.o $(OBJDIR)/loragw_sx1250.o $(OBJDIR)/loragw_sx125x.o $(OBJDIR)/loragw_sx1302.o $(OBJDIR)/loragw_cal.o $(OBJDIR)/loragw_debug.o $(OBJDIR)/loragw_hal.o $(OBJDIR)/loragw_stts751.o $(OBJDIR)/loragw_gps.o $(OBJDIR)/loragw_sx1302_timestamp.o $(OBJDIR)/loragw_sx1302_rx.o
$(AR) rcs $@ $^

### test programs

test_loragw_spi: tst/test_loragw_spi.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_i2c: tst/test_loragw_i2c.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_reg: tst/test_loragw_reg.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_hal_tx: tst/test_loragw_hal_tx.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_hal_rx: tst/test_loragw_hal_rx.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_capture_ram: tst/test_loragw_capture_ram.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_cal: tst/test_loragw_cal.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_spi_sx1250: tst/test_loragw_spi_sx1250.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_counter: tst/test_loragw_counter.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

test_loragw_gps: tst/test_loragw_gps.c libloragw.a
$(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS)

### EOF
84 changes: 84 additions & 0 deletions libloragw/inc/loragw_agc_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
/ _____) _ | |
( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
(C)2019 Semtech
Description:
SX1302 AGC parameters definition.
License: Revised BSD License, see LICENSE.TXT file include in the project
*/


#ifndef _LORAGW_AGC_PARAMS_H
#define _LORAGW_AGC_PARAMS_H

/* -------------------------------------------------------------------------- */
/* --- PRIVATE TYPES -------------------------------------------------------- */

struct agc_gain_params_s {
uint8_t ana_min;
uint8_t ana_max;
uint8_t ana_thresh_l;
uint8_t ana_thresh_h;
uint8_t dec_attn_min;
uint8_t dec_attn_max;
uint8_t dec_thresh_l;
uint8_t dec_thresh_h1;
uint8_t dec_thresh_h2;
uint8_t chan_attn_min;
uint8_t chan_attn_max;
uint8_t chan_thresh_l;
uint8_t chan_thresh_h;
uint8_t deviceSel; /* sx1250 only */
uint8_t hpMax; /* sx1250 only */
uint8_t paDutyCycle; /* sx1250 only */
};

/* -------------------------------------------------------------------------- */
/* --- PRIVATE CONSTANTS ---------------------------------------------------- */

const struct agc_gain_params_s agc_params_sx1250 = {
.ana_min = 1,
.ana_max = 13,
.ana_thresh_l = 3,
.ana_thresh_h = 12,
.dec_attn_min = 4,
.dec_attn_max = 15,
.dec_thresh_l = 40,
.dec_thresh_h1 = 80,
.dec_thresh_h2 = 90,
.chan_attn_min = 4,
.chan_attn_max = 14,
.chan_thresh_l = 52,
.chan_thresh_h = 132,
.deviceSel = 0,
.hpMax = 7,
.paDutyCycle = 4
};

const struct agc_gain_params_s agc_params_sx125x = {
.ana_min = 0,
.ana_max = 9,
.ana_thresh_l = 16,
.ana_thresh_h = 35,
.dec_attn_min = 7,
.dec_attn_max = 11,
.dec_thresh_l = 45,
.dec_thresh_h1 = 100,
.dec_thresh_h2 = 115,
.chan_attn_min = 4,
.chan_attn_max = 14,
.chan_thresh_l = 52,
.chan_thresh_h = 132,
.deviceSel = 0,
.hpMax = 0,
.paDutyCycle = 0
};

#endif

/* --- EOF ------------------------------------------------------------------ */
47 changes: 47 additions & 0 deletions libloragw/inc/loragw_aux.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
/ _____) _ | |
( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
(C)2019 Semtech
Description:
LoRa concentrator HAL common auxiliary functions
License: Revised BSD License, see LICENSE.TXT file include in the project
*/


#ifndef _LORAGW_AUX_H
#define _LORAGW_AUX_H

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

#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 ------------------------------------------ */

/**
@brief Wait for a certain time (millisecond accuracy)
@param t number of milliseconds to wait.
*/
void wait_ms(unsigned long t);

#endif

/* --- EOF ------------------------------------------------------------------ */
59 changes: 59 additions & 0 deletions libloragw/inc/loragw_cal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
/ _____) _ | |
( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
(C)2019 Semtech
Description:
LoRa concentrator radio calibration functions
License: Revised BSD License, see LICENSE.TXT file include in the project
*/


#ifndef _LORAGW_CAL_H
#define _LORAGW_CAL_H

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

#include <stdint.h> /* C99 types*/

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

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

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

/* -------------------------------------------------------------------------- */
/* --- PUBLIC TYPES --------------------------------------------------------- */

struct lgw_sx125x_cal_rx_result_s {
int8_t amp;
int8_t phi;
uint16_t rej;
uint16_t rej_init;
uint16_t snr;
};

struct lgw_sx125x_cal_tx_result_s {
uint8_t dac_gain;
uint8_t mix_gain;
int8_t offset_i;
int8_t offset_q;
uint16_t rej;
uint16_t sig;
};

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

int sx1302_cal_start(uint8_t version, struct lgw_conf_rxrf_s * rf_chain_cfg, struct lgw_tx_gain_lut_s * txgain_lut);

#endif

/* --- EOF ------------------------------------------------------------------ */
Loading

0 comments on commit 4c61c5d

Please sign in to comment.