Skip to content

Commit

Permalink
v4.1.0
Browse files Browse the repository at this point in the history
* HAL: Reworked "Listen-Before-Talk" feature to have more flexibility to define
LBT channels frequency, and to be able to have spectral scan running in parallel
* HAL: Updated lgw_time_on_air() function for FSK packets
* HAL: Disabled GPS UART input being re-echoed as output to avoid sending wrong
commands to GPS module
* HAL: Fixed IF frequency configuration check issue for channel bandwidths 250K
and 500HKz.
* FPGA: Updated to v33 for new LBT and and v31 for spectral scan.
* util_spectral_scan: updated to match new spectral scan FPGA sequence
* util_lbt_test: updated to match LBT rework

Note: The provided LBT feature has been validated for Japan only, and supports
8 downlink channels maximum.
  • Loading branch information
mcoracin committed Nov 9, 2016
1 parent a67c7d5 commit 65259a5
Show file tree
Hide file tree
Showing 35 changed files with 7,506 additions and 1,076 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ 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_lbt_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_lbt_test
$(MAKE) clean -e -C util_tx_continuous
$(MAKE) clean -e -C util_spectral_scan

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0
4.1.0
Binary file removed fpga/SX1301_FPGA_125K_NOTCH_LBT_bitmap_v27.bin
Binary file not shown.
Binary file not shown.
1,659 changes: 1,659 additions & 0 deletions fpga/SX1301_FPGA_200K_NOTCH_LBT_SPECTRAL_SCAN_863_v33.hex

Large diffs are not rendered by default.

1,659 changes: 1,659 additions & 0 deletions fpga/SX1301_FPGA_200K_NOTCH_LBT_SPECTRAL_SCAN_915_v33.hex

Large diffs are not rendered by default.

1,659 changes: 1,659 additions & 0 deletions fpga/SX1301_FPGA_NOTCH_PROG_SPECTRAL_SCAN_v31.hex

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions fpga/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ 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_200K_NOTCH_LBT_SPECTRAL_SCAN_863_v33.hex:
- 200KHz Notch filter for TX (not programmable)
- Listen-Before-Talk for 863+MHz frequency range
- Background Spectral Scan (limited)

* SX1301_FPGA_125K_NOTCH_SPECTRAL_SCAN_bitmap_v27.bin:
- 125K Notch filter for TX
- Background Spectral Scan
* SX1301_FPGA_200K_NOTCH_LBT_SPECTRAL_SCAN_915_v33.hex:
- 200KHz Notch filter for TX (not programmable)
- Listen-Before-Talk for 915+MHz frequency range
- Background Spectral Scan (limited)

* SX1301_FPGA_NOTCH_PROG_SPECTRAL_SCAN_v31.hex:
- Programmable notch filter for TX
- Background Spectral Scan (full)

2. Usage
--------
Expand Down
69 changes: 44 additions & 25 deletions libloragw/inc/loragw_fpga.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,60 @@ Maintainer: Michael Coracin
#define LGW_REG_SUCCESS 0
#define LGW_REG_ERROR -1

#define LGW_MIN_NOTCH_FREQ 126000U /* 126 KHz */
#define LGW_MAX_NOTCH_FREQ 250000U /* 250 KHz */
#define LGW_DEFAULT_NOTCH_FREQ 129000U /* 129 KHz */

/*
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
#define LGW_FPGA_FEATURE 1
#define LGW_FPGA_LBT_INITIAL_FREQ 2
#define LGW_FPGA_VERSION 3
#define LGW_FPGA_STATUS 4
#define LGW_FPGA_CTRL_FEATURE_START 5
#define LGW_FPGA_CTRL_RADIO_RESET 6
#define LGW_FPGA_CTRL_INPUT_SYNC_I 7
#define LGW_FPGA_CTRL_INPUT_SYNC_Q 8
#define LGW_FPGA_CTRL_OUTPUT_SYNC 9
#define LGW_FPGA_CTRL_INVERT_IQ 10
#define LGW_FPGA_CTRL_ACCESS_HISTO_MEM 11
#define LGW_FPGA_CTRL_CLEAR_HISTO_MEM 12
#define LGW_FPGA_HISTO_RAM_ADDR 13
#define LGW_FPGA_HISTO_RAM_DATA 14
#define LGW_FPGA_HISTO_NB_READ 15
#define LGW_FPGA_LBT_TIMESTAMP_CH 16
#define LGW_FPGA_LBT_TIMESTAMP_SELECT_CH 17
#define LGW_FPGA_LBT_CH0_FREQ_OFFSET 18
#define LGW_FPGA_LBT_CH1_FREQ_OFFSET 19
#define LGW_FPGA_LBT_CH2_FREQ_OFFSET 20
#define LGW_FPGA_LBT_CH3_FREQ_OFFSET 21
#define LGW_FPGA_LBT_CH4_FREQ_OFFSET 22
#define LGW_FPGA_LBT_CH5_FREQ_OFFSET 23
#define LGW_FPGA_LBT_CH6_FREQ_OFFSET 24
#define LGW_FPGA_LBT_CH7_FREQ_OFFSET 25
#define LGW_FPGA_SCAN_FREQ_OFFSET 26
#define LGW_FPGA_LBT_SCAN_TIME_CH0 27
#define LGW_FPGA_LBT_SCAN_TIME_CH1 28
#define LGW_FPGA_LBT_SCAN_TIME_CH2 29
#define LGW_FPGA_LBT_SCAN_TIME_CH3 30
#define LGW_FPGA_LBT_SCAN_TIME_CH4 31
#define LGW_FPGA_LBT_SCAN_TIME_CH5 32
#define LGW_FPGA_LBT_SCAN_TIME_CH6 33
#define LGW_FPGA_LBT_SCAN_TIME_CH7 34
#define LGW_FPGA_RSSI_TARGET 35
#define LGW_FPGA_HISTO_SCAN_FREQ 36
#define LGW_FPGA_NOTCH_FREQ_OFFSET 37
#define LGW_FPGA_TOTALREGS 38

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

int lgw_fpga_configure(void);
int lgw_fpga_configure(uint32_t tx_notch_freq);

/**
@brief LoRa concentrator FPGA register write
Expand Down
44 changes: 27 additions & 17 deletions libloragw/inc/loragw_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Maintainer: Sylvain Miermont
/* concentrator chipset-specific parameters */
/* to use array parameters, declare a local const and use 'if_chain' as index */
#define LGW_IF_CHAIN_NB 10 /* number of IF+modem RX chains */
#define LGW_PKT_FIFO_SIZE 8 /* depth of the RX packet FIFO */
#define LGW_PKT_FIFO_SIZE 16 /* depth of the RX packet FIFO */
#define LGW_DATABUFF_SIZE 1024 /* size in bytes of the RX data buffer (contains payload & metadata) */
#define LGW_REF_BW 125000 /* typical bandwidth of data channel */
#define LGW_MULTI_NB 8 /* number of LoRa 'multi SF' chains */
Expand Down Expand Up @@ -152,6 +152,9 @@ Maintainer: Sylvain Miermont
/* Maximum size of Tx gain LUT */
#define TX_GAIN_LUT_SIZE_MAX 16

/* LBT constants */
#define LBT_CHANNEL_FREQ_NB 8 /* Number of LBT channels */

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

Expand All @@ -172,34 +175,42 @@ enum lgw_radio_type_e {
@brief Configuration structure for board specificities
*/
struct lgw_conf_board_s {
bool lorawan_public; /*!> Enable ONLY for *public* networks using the LoRa MAC protocol */
uint8_t clksrc; /*!> Index of RF chain which provides clock to concentrator */
bool lorawan_public; /*!> Enable ONLY for *public* networks using the LoRa MAC protocol */
uint8_t clksrc; /*!> Index of RF chain which provides clock to concentrator */
};

/**
@struct lgw_conf_lbt_chan_s
@brief Configuration structure for LBT channels
*/
struct lgw_conf_lbt_chan_s {
uint32_t freq_hz;
uint16_t scan_time_us;
};

/**
@struct lgw_conf_lbt_s
@brief Configuration structure for LBT specificities
*/
struct lgw_conf_lbt_s {
bool enable; /*!> enable or disable LBT */
uint8_t rssi_target; /*!> RSSI threshold to detect if channel is busy or not */
uint8_t nb_channel; /*!> number of LBT channels */
uint16_t scan_time_us; /*!> channel activity scan duration, in microseconds */
uint32_t start_freq; /*!> first LBT channel frequency */
uint32_t tx_delay_1ch_us; /*!> maximum time allowed to send a packet since channel was free, when TX is on one channel only */
uint32_t tx_delay_2ch_us; /*!> maximum time allowed to send a packet since channel was free, when TX is on two channels */
bool enable; /*!> enable or disable LBT */
int8_t rssi_target; /*!> RSSI threshold to detect if channel is busy or not (dBm) */
uint8_t nb_channel; /*!> number of LBT channels */
struct lgw_conf_lbt_chan_s channels[LBT_CHANNEL_FREQ_NB];
int8_t rssi_offset; /*!> RSSI offset to be applied to SX127x RSSI values */
};

/**
@struct lgw_conf_rxrf_s
@brief Configuration structure for a RF chain
*/
struct lgw_conf_rxrf_s {
bool enable; /*!> enable or disable that RF chain */
uint32_t freq_hz; /*!> center frequency of the radio in Hz */
float rssi_offset; /*!> Board-specific RSSI correction factor */
enum lgw_radio_type_e type; /*!> Radio type for that RF chain (SX1255, SX1257....) */
bool tx_enable; /*!> enable or disable TX on that RF chain */
bool enable; /*!> enable or disable that RF chain */
uint32_t freq_hz; /*!> center frequency of the radio in Hz */
float rssi_offset; /*!> Board-specific RSSI correction factor */
enum lgw_radio_type_e type; /*!> Radio type for that RF chain (SX1255, SX1257....) */
bool tx_enable; /*!> enable or disable TX on that RF chain */
uint32_t tx_notch_freq; /*!> TX notch filter frequency [126KHz..250KHz] */
};

/**
Expand Down Expand Up @@ -385,10 +396,9 @@ const char* lgw_version_info(void);
/**
@brief Return time on air of given packet, in milliseconds
@param packet is a pointer to the packet structure
@param isBeacon indicates if the packet is a beacon or not
@return the packet time on air in milliseconds
*/
uint32_t lgw_time_on_air(struct lgw_pkt_tx_s *packet, bool isBeacon);
uint32_t lgw_time_on_air(struct lgw_pkt_tx_s *packet);

#endif

Expand Down
12 changes: 7 additions & 5 deletions libloragw/inc/loragw_lbt.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,9 @@ int lbt_setconf(struct lgw_conf_lbt_s * conf);

/**
@brief Configure the concentrator for LBT feature
@param rf_freq frequency in Hz of the first LBT channel
@param rssi_target RSSI threshold used to determine if LBT channel is busy or not
@param scan_time_us duration of channel activity scanning, in microseconds
@param nb_channel number of LBT channels
@return LGW_LBT_ERROR id the operation failed, LGW_LBT_SUCCESS else
*/
int lbt_setup(uint32_t rf_freq, uint8_t rssi_target, uint16_t scan_time_us, uint8_t nb_channel);
int lbt_setup(void);

/**
@brief Start the LBT FSM
Expand All @@ -64,5 +60,11 @@ int lbt_start(void);
*/
int lbt_is_channel_free(struct lgw_pkt_tx_s * pkt_data, bool * tx_allowed);

/**
@brief Check if LBT is enabled
@return true if enabled, false otherwise
*/
bool lbt_is_enabled(void);

#endif
/* --- EOF ------------------------------------------------------------------ */
32 changes: 30 additions & 2 deletions libloragw/inc/loragw_radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,44 @@ Maintainer: Michael Coracin

#define SX125x_32MHz_FRAC 15625 /* irreductible fraction for PLL register caculation */

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

enum lgw_sx127x_rxbw_e {
LGW_SX127X_RXBW_2K6_HZ,
LGW_SX127X_RXBW_3K1_HZ,
LGW_SX127X_RXBW_3K9_HZ,
LGW_SX127X_RXBW_5K2_HZ,
LGW_SX127X_RXBW_6K3_HZ,
LGW_SX127X_RXBW_7K8_HZ,
LGW_SX127X_RXBW_10K4_HZ,
LGW_SX127X_RXBW_12K5_HZ,
LGW_SX127X_RXBW_15K6_HZ,
LGW_SX127X_RXBW_20K8_HZ,
LGW_SX127X_RXBW_25K_HZ,
LGW_SX127X_RXBW_31K3_HZ,
LGW_SX127X_RXBW_41K7_HZ,
LGW_SX127X_RXBW_50K_HZ,
LGW_SX127X_RXBW_62K5_HZ,
LGW_SX127X_RXBW_83K3_HZ,
LGW_SX127X_RXBW_100K_HZ,
LGW_SX127X_RXBW_125K_HZ,
LGW_SX127X_RXBW_166K7_HZ,
LGW_SX127X_RXBW_200K_HZ,
LGW_SX127X_RXBW_250K_HZ
};

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

int setup_sx125x(uint8_t rf_chain, uint8_t rf_clkout, bool rf_enable, uint8_t rf_radio_type, uint32_t freq_hz);
int lgw_setup_sx125x(uint8_t rf_chain, uint8_t rf_clkout, bool rf_enable, uint8_t rf_radio_type, uint32_t freq_hz);

int lgw_setup_sx127x(uint32_t frequency, uint8_t modulation, enum lgw_sx127x_rxbw_e rxbw_khz, int8_t rssi_offset);

int lgw_sx127x_reg_w(uint8_t address, uint8_t reg_value);

int lgw_sx127x_reg_r(uint8_t address, uint8_t *reg_value);

int lgw_setup_sx127x(uint32_t frequency, uint8_t modulation);

#endif
/* --- EOF ------------------------------------------------------------------ */
6 changes: 5 additions & 1 deletion libloragw/inc/loragw_reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,13 @@ this file is autogenerated from registers description

/**
@brief Connect LoRa concentrator by opening SPI link
@param spi_only indicates if we only want to create the SPI connexion to the
concentrator, or if we also want to reset it and configure the FPGA (if present)
@param tx_notch_filter TX notch filter frequency to be set in the FPGA (only
used with SX1301AP2 reference design).
@return status of register operation (LGW_REG_SUCCESS/LGW_REG_ERROR)
*/
int lgw_connect(void);
int lgw_connect(bool spi_only, uint32_t tx_notch_freq);

/**
@brief Disconnect LoRa concentrator by closing SPI link
Expand Down
Loading

0 comments on commit 65259a5

Please sign in to comment.