summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Miermont <smiermont@semtech.com>2013-07-03 17:53:18 +0200
committerSylvain Miermont <smiermont@semtech.com>2013-10-23 10:16:59 +0200
commit1361e7215cd0eb3b38faff1c403cb3077e41b2be (patch)
treec52471c65b0a40b081b7de6a8570757f85c71704
parent3357493e096fc0bd4767d1a3cc0cb7e3e52a4f53 (diff)
downloadlora_gateway-1361e7215cd0eb3b38faff1c403cb3077e41b2be.tar.gz
lora_gateway-1361e7215cd0eb3b38faff1c403cb3077e41b2be.tar.bz2
lora_gateway-1361e7215cd0eb3b38faff1c403cb3077e41b2be.zip
Release Candidate 2v0.rc2
- code cleanup and formating - variable and constants renaming - TX polarity management - fixed bugs thanks to Joe Knapp feedback
-rw-r--r--loragw_hal/README109
-rw-r--r--loragw_hal/inc/loragw_aux.h6
-rw-r--r--loragw_hal/inc/loragw_hal.h205
-rw-r--r--loragw_hal/inc/loragw_reg.h20
-rw-r--r--loragw_hal/inc/loragw_spi.h22
-rw-r--r--loragw_hal/src/agc_fw.var6
-rw-r--r--loragw_hal/src/arb_fw.var6
-rw-r--r--loragw_hal/src/loragw_aux.c44
-rw-r--r--loragw_hal/src/loragw_hal.c1667
-rw-r--r--loragw_hal/src/loragw_reg.c1236
-rw-r--r--loragw_hal/src/loragw_spi.c448
-rw-r--r--loragw_hal/test/test_loragw_hal.c397
-rw-r--r--loragw_hal/test/test_loragw_reg.c208
-rw-r--r--loragw_hal/test/test_loragw_spi.c66
14 files changed, 2247 insertions, 2193 deletions
diff --git a/loragw_hal/README b/loragw_hal/README
index c8ce3d8..1e97a25 100644
--- a/loragw_hal/README
+++ b/loragw_hal/README
@@ -4,9 +4,13 @@ Lora Gateway HAL
1. Introduction
---------------
-The Lora Gateway Hardware Abstraction Layer is a C library that allow you to use a Semtech Lora gateway hardware through a reduced number of high level C functions to configure the hardware, send and receive packets.
+The Lora Gateway Hardware Abstraction Layer is a C library that allow you to
+use a Semtech Lora gateway hardware through a reduced number of high level C
+functions to configure the hardware, send and receive packets.
-The Semtech Lora gateway is a digital multi-channel multi-standard packet radio used to send and receive packets wirelessly using Lora, FSK or GFSK modulations.
+The Semtech Lora gateway is a digital multi-channel multi-standard packet radio
+used to send and receive packets wirelessly using Lora, FSK or GFSK
+modulations.
2. Components of the library
@@ -19,11 +23,13 @@ The library is composed of 4 modules:
* loragw_spi
* loragw_aux
-The library also contains 3 test program to demonstrate code use and check functionality.
-
+The library also contains 3 test program to demonstrate code use and check
+functionality.
+
### 2.1. loragw_hal ###
-This is the main module and contains the high level functions to configure and use the Lora gateway:
+This is the main module and contains the high level functions to configure and
+use the Lora gateway:
* lgw_rxrf_setconf, to set the configuration of the radio channels
* lgw_rxif_setconf, to set the configuration of the IF+modem channels
@@ -37,78 +43,104 @@ The use of this module is detailed on the usage section.
### 2.2. loragw_reg ###
-This module is used to access to the Lora gateway registers by name instead of by address:
+This module is used to access to the Lora gateway registers by name instead of
+by address:
* lgw_connect, to initialise and check the connection with the hardware
* lgw_disconnect, to disconnect the hardware
* lgw_soft_reset, to reset the whole hardware by resetting the register array
-* lgw_reg_check, to check all registers vs. their default value and output the result to a file
+* lgw_reg_check, to check all registers vs. their default value and output the
+result to a file
* lgw_reg_r, read a named register
* lgw_reg_w, write a named register
* lgw_reg_rb, read a name register in burst
* lgw_reg_wb, write a named register in burst
-This module handles pagination, read-only registers protection, multi-byte registers management, signed registers management, read-modify-write routines for sub-byte registers and read/write burst fragmentation to respect SPI maximum burst length constraints.
+This module handles pagination, read-only registers protection, multi-byte
+registers management, signed registers management, read-modify-write routines
+for sub-byte registers and read/write burst fragmentation to respect SPI
+maximum burst length constraints.
It make the code much easier to read and to debug.
-Moreover, if registers are relocated between different hardware revisions but keep the same function, the code written using register names can be reused "as is".
+Moreover, if registers are relocated between different hardware revisions but
+keep the same function, the code written using register names can be reused "as
+is".
-If you need access to all the registers, include this module in your application.
+If you need access to all the registers, include this module in your
+application.
-**/!\ Warning** please be sure to have a good understanding of the Lora gateway inner working before accessing the internal registers directly.
+**/!\ Warning** please be sure to have a good understanding of the Lora gateway
+inner working before accessing the internal registers directly.
### 2.3. loragw_spi ###
-This module contains the functions to access the Lora gateway register array through the SPI interface:
+This module contains the functions to access the Lora gateway register array
+through the SPI interface:
* lgw_spi_r to read one byte
* lgw_spi_w to write one byte
* lgw_spi_rb to read two bytes or more
* lgw_spi_wb to write two bytes or more
-
+
Please *do not* include that module directly into your application.
-**/!\ Warning** Accessing the Lora gateway register array without the checks and safety provided by the functions in loragw_reg is not recommended.
+**/!\ Warning** Accessing the Lora gateway register array without the checks
+and safety provided by the functions in loragw_reg is not recommended.
### 2.4. loragw_aux ###
-This module contains a single host-dependant function wait_ms to pause for a defined amount of milliseconds.
+This module contains a single host-dependant function wait_ms to pause for a
+defined amount of milliseconds.
-The procedure to start and configure the Lora gateway hardware contained in the loragw_hal module requires to wait for several milliseconds at certain steps, typically to allow for supply voltages or clocks to stabilize after been switched on.
+The procedure to start and configure the Lora gateway hardware contained in the
+loragw_hal module requires to wait for several milliseconds at certain steps,
+typically to allow for supply voltages or clocks to stabilize after been
+switched on.
An accuracy of 1 ms or less is ideal.
-If your system doesn't allow that level of accuracy, make sure that the actual delay is *longer* that the time specified when the function is called (ie. wait_ms(X) *MUST NOT* before X milliseconds under any circumstance).
+If your system doesn't allow that level of accuracy, make sure that the actual
+delay is *longer* that the time specified when the function is called (ie.
+wait_ms(X) *MUST NOT* before X milliseconds under any circumstance).
-If the minimum delays are not guaranteed during the configuration and start procedure, the hardware might not work at nominal performance.
+If the minimum delays are not guaranteed during the configuration and start
+procedure, the hardware might not work at nominal performance.
Most likely, it will not work at all.
3. Software dependencies
------------------------
-The library is written following ANSI C conventions but using C99 explicit length data type for all data exchanges with hardware and for parameters.
+The library is written following ANSI C conventions but using C99 explicit
+length data type for all data exchanges with hardware and for parameters.
-The loragw_aux module contains POSIX dependant functions for millisecond accuracy pause.
+The loragw_aux module contains POSIX dependant functions for millisecond
+accuracy pause.
For embedded platforms, the function could be rewritten using hardware times.
-All modules use the fprintf(stderr,...) function to display debug diagnostic messages if the DEBUG flag is defined (eg. for GCC, add the -DDEBUG flag).
+All modules use the fprintf(stderr,...) function to display debug diagnostic
+messages if the DEBUG flag is defined (eg. for GCC, add the -DDEBUG flag).
4. Hardware dependencies
------------------------
-The loragw_reg and loragw_hal are written for a specific version on the Semtech hardware.
-The library will not work if there is a mismatch between the hardware version and the library version.
-You can use the test program test_loragw_reg to check if the hardware registers match their software declaration.
+The loragw_reg and loragw_hal are written for a specific version on the Semtech
+hardware.
+The library will not work if there is a mismatch between the hardware version
+and the library version.
+You can use the test program test_loragw_reg to check if the hardware registers
+match their software declaration.
-loragw_spi contains 4 SPI functions (read, write, burst read, burst write) that are platform-dependant.
-The functions must rewritten depending on the SPI bridge you use:
+loragw_spi contains 4 SPI functions (read, write, burst read, burst write) that
+are platform-dependant.
+The functions must be rewritten depending on the SPI bridge you use:
* SPI master matched to the Linux SPI device driver (provided)
* SPI over USB using FTDI components (not provided)
* native SPI using a microcontroller peripheral (not provided)
-You can use the test program test_loragw_spi to check with a logic analyser that the SPI communication is working
+You can use the test program test_loragw_spi to check with a logic analyser
+that the SPI communication is working
5. Usage
@@ -117,9 +149,12 @@ You can use the test program test_loragw_spi to check with a logic analyser that
To use the HAL in your application, you must follow some basic rules:
* configure the radios path and IF+modem path before starting the radio
-* the configuration is only transferred to hardware when you call the *start* function
-* you cannot receive packets until one (or +) radio is enabled AND one (or +) IF+modem part is enabled AND the gateway is started
-* you cannot send packets until one (or +) radio is enabled AND the gateway is started
+* the configuration is only transferred to hardware when you call the *start*
+function
+* you cannot receive packets until one (or +) radio is enabled AND one (or +)
+IF+modem part is enabled AND the gateway is started
+* you cannot send packets until one (or +) radio is enabled AND the gateway is
+started
* you must stop the gateway before changing the configuration
A typical application flow for using the HAL is the following:
@@ -133,16 +168,22 @@ loop {
}
<stop the gateway>
-To debug your application, it might help to compile the loragw_hal function with the DEBUG flag defined.
+To debug your application, it might help to compile the loragw_hal function
+with the DEBUG flag defined.
It then send a lot of details, including detailed error messages to *stderr*.
-**/!\ Warning** The lgw_send function is non-blocking and returns while the Lora gateway is still sending the packet, or even before the packet has started to be transmitted if the packet is triggered on a future event.
-While a packet is emitted, no packet can be received (limitation intrinsic to most radio frequency systems).
+**/!\ Warning** The lgw_send function is non-blocking and returns while the
+Lora gateway is still sending the packet, or even before the packet has started
+to be transmitted if the packet is triggered on a future event.
+While a packet is emitted, no packet can be received (limitation intrinsic to
+most radio frequency systems).
Your application *must* take into account the time it takes to send a packet.
-Trying to send a packet while the previous packet has not finished being send will result in the previous packet not being sent or being sent only partially (resulting in a CRC error in the receiver).
+Trying to send a packet while the previous packet has not finished being send
+will result in the previous packet not being sent or being sent only partially
+(resulting in a CRC error in the receiver).
6. License
diff --git a/loragw_hal/inc/loragw_aux.h b/loragw_hal/inc/loragw_aux.h
index a0cc7cb..09f543f 100644
--- a/loragw_hal/inc/loragw_aux.h
+++ b/loragw_hal/inc/loragw_aux.h
@@ -1,13 +1,13 @@
/*
- / _____) _ | |
-( (____ _____ ____ _| |_ _____ ____| |__
+ / _____) _ | |
+( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
©2013 Semtech-Cycleo
Description:
- Lora gateway Hardware Abstraction Layer
+ Lora gateway Hardware Abstraction Layer
*/
diff --git a/loragw_hal/inc/loragw_hal.h b/loragw_hal/inc/loragw_hal.h
index 39c8ca0..1057251 100644
--- a/loragw_hal/inc/loragw_hal.h
+++ b/loragw_hal/inc/loragw_hal.h
@@ -1,13 +1,13 @@
/*
- / _____) _ | |
-( (____ _____ ____ _| |_ _____ ____| |__
+ / _____) _ | |
+( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
©2013 Semtech-Cycleo
Description:
- Lora gateway Hardware Abstraction Layer
+ Lora gateway Hardware Abstraction Layer
*/
@@ -17,24 +17,24 @@ Description:
/* -------------------------------------------------------------------------- */
/* --- DEPENDANCIES --------------------------------------------------------- */
-#include <stdint.h> /* C99 types */
-#include <stdbool.h> /* bool type */
+#include <stdint.h> /* C99 types */
+#include <stdbool.h> /* bool type */
/* -------------------------------------------------------------------------- */
/* --- PUBLIC CONSTANTS ----------------------------------------------------- */
/* return status code */
-#define LGW_HAL_SUCCESS 0
-#define LGW_HAL_ERROR -1
+#define LGW_HAL_SUCCESS 0
+#define LGW_HAL_ERROR -1
/* hardware characteristics */
-#define LGW_RF_CHAIN_NB 2 /* number of RF chains */
-#define LGW_IF_CHAIN_NB 10 /* number of IF+modem RX chains */
-#define LGW_MULTI_NB 4 /* number of Lora 'multi SF' chains */
+#define LGW_RF_CHAIN_NB 2 /* number of RF chains */
+#define LGW_IF_CHAIN_NB 10 /* number of IF+modem RX chains */
+#define LGW_MULTI_NB 4 /* number of Lora 'multi SF' chains */
-#define LGW_PKT_FIFO_SIZE 8
-#define LGW_DATABUFF_SIZE 1024
-#define LGW_RF_BANDWIDTH 800000
+#define LGW_PKT_FIFO_SIZE 8
+#define LGW_DATABUFF_SIZE 1024
+#define LGW_RF_BANDWIDTH 800000
/*
SX1275 frequency setting :
@@ -42,79 +42,79 @@ F_register(24bit) = F_rf (Hz) / F_step(Hz)
= F_rf (Hz) * 2^19 / F_xtal(Hz)
= F_rf (Hz) * 256/15625
*/
-#define LGW_XTAL_FREQU 32000000
-#define LGW_SW1257_DENUM 15625 /* pll settings denominator when the numerator is 2^8 */
+#define LGW_XTAL_FREQU 32000000
+#define LGW_SX1257_DENOMINATOR 15625 /* pll settings denominator when the numerator is 2^8 */
/* to use those parameters, declare a local constant, and use 'rf_chain' as index */
-#define LGW_RF_RX_LOWFREQ {863000000, 863000000}
-#define LGW_RF_RX_UPFREQ {870000000, 870000000}
-#define LGW_RF_TX_LOWFREQ {863000000, 863000000}
-#define LGW_RF_TX_UPFREQ {870000000, 870000000}
+#define LGW_RF_RX_LOWFREQ {863000000, 863000000}
+#define LGW_RF_RX_UPFREQ {870000000, 870000000}
+#define LGW_RF_TX_LOWFREQ {863000000, 863000000}
+#define LGW_RF_TX_UPFREQ {870000000, 870000000}
/* type of if_chain + modem */
-#define IF_UNDEFINED 0
-#define IF_LORA_STD 0x10 /* if + standard single-SF Lora modem */
-#define IF_LORA_MULTI 0x11 /* if + Lora receiver with multi-SF capability */
-#define IF_FSK_STD 0x20 /* if + standard FSK modem */
+#define IF_UNDEFINED 0
+#define IF_LORA_STD 0x10 /* if + standard single-SF Lora modem */
+#define IF_LORA_MULTI 0x11 /* if + Lora receiver with multi-SF capability */
+#define IF_FSK_STD 0x20 /* if + standard FSK modem */
/* configuration of available IF chains and modems on the hardware */
/* to use, declare a local constant, and use 'if_chain' as index */
#define LGW_IFMODEM_CONFIG {\
- IF_LORA_MULTI, \
- IF_LORA_MULTI, \
- IF_LORA_MULTI, \
- IF_LORA_MULTI, \
- IF_UNDEFINED, \
- IF_UNDEFINED, \
- IF_UNDEFINED, \
- IF_UNDEFINED, \
- IF_LORA_STD, \
- IF_FSK_STD }
+ IF_LORA_MULTI, \
+ IF_LORA_MULTI, \
+ IF_LORA_MULTI, \
+ IF_LORA_MULTI, \
+ IF_UNDEFINED, \
+ IF_UNDEFINED, \
+ IF_UNDEFINED, \
+ IF_UNDEFINED, \
+ IF_LORA_STD, \
+ IF_FSK_STD }
/* values available for the 'modulation' parameters */
-#define MOD_UNDEFINED 0
-#define MOD_LORA 0x10
-#define MOD_FSK 0x20
-#define MOD_GFSK 0x21
+#define MOD_UNDEFINED 0
+#define MOD_LORA 0x10
+#define MOD_FSK 0x20
+#define MOD_GFSK 0x21
/* values available for the 'bandwidth' parameters */
-#define BW_UNDEFINED 0
-#define BW_500KHZ 0x04
-#define BW_250KHZ 0x08
-#define BW_125KHZ 0x0C
-// TODO: add all the supporter FSK bandwidth
+#define BW_UNDEFINED 0
+#define BW_500KHZ 0x04
+#define BW_250KHZ 0x08
+#define BW_125KHZ 0x0C
+// TODO: add all the supported FSK bandwidth
/* values available for the 'datarate' parameters */
-#define DR_UNDEFINED 0
-#define DR_LORA_SF7 0x1002
-#define DR_LORA_SF8 0x1004
-#define DR_LORA_SF9 0x1008
-#define DR_LORA_SF10 0x1010
-#define DR_LORA_SF11 0x1020
-#define DR_LORA_SF12 0x1040
-#define DR_LORA_MULTI 0x107E
-// TODO: add FSK datarates
+#define DR_UNDEFINED 0
+#define DR_LORA_SF7 0x1002
+#define DR_LORA_SF8 0x1004
+#define DR_LORA_SF9 0x1008
+#define DR_LORA_SF10 0x1010
+#define DR_LORA_SF11 0x1020
+#define DR_LORA_SF12 0x1040
+#define DR_LORA_MULTI 0x107E
+// TODO: add FSK data rates
/* values available for the 'coderate' parameters */
-#define CR_UNDEFINED 0
-#define CR_LORA_4_5 0x11
-#define CR_LORA_4_6 0x12
-#define CR_LORA_4_7 0x13
-#define CR_LORA_4_8 0x14
+#define CR_UNDEFINED 0
+#define CR_LORA_4_5 0x11
+#define CR_LORA_4_6 0x12
+#define CR_LORA_4_7 0x13
+#define CR_LORA_4_8 0x14
/* values available for the 'status' parameter */
-#define STAT_UNDEFINED 0x00
-#define STAT_NO_CRC 0x01
-#define STAT_CRC_BAD 0x11
-#define STAT_CRC_OK 0x10
+#define STAT_UNDEFINED 0x00
+#define STAT_NO_CRC 0x01
+#define STAT_CRC_BAD 0x11
+#define STAT_CRC_OK 0x10
/* values available for the 'tx_mode' parameter */
-#define IMMEDIATE 0
-#define TIMESTAMPED 1
-#define ON_GPS 2
-//#define ON_EVENT 3
-//#define GPS_DELAYED 4
-//#define EVENT_DELAYED 5
+#define IMMEDIATE 0
+#define TIMESTAMPED 1
+#define ON_GPS 2
+//#define ON_EVENT 3
+//#define GPS_DELAYED 4
+//#define EVENT_DELAYED 5
/* -------------------------------------------------------------------------- */
/* --- PUBLIC TYPES --------------------------------------------------------- */
@@ -124,8 +124,8 @@ F_register(24bit) = F_rf (Hz) / F_step(Hz)
@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 */
+ bool enable; /*!> enable or disable that RF chain */
+ uint32_t freq_hz; /*!> center frequency of the radio in Hz */
};
/**
@@ -133,11 +133,11 @@ struct lgw_conf_rxrf_s {
@brief Configuration structure for an IF chain
*/
struct lgw_conf_rxif_s {
- bool enable; /*!> enable or disable that IF chain */
- uint8_t rf_chain; /*!> to which RF chain is that IF chain associated */
- int32_t freq_hz; /*!> center frequ of the IF chain, relative to RF chain frequency */
- uint8_t bandwidth; /*!> RX bandwidth, 0 for default */
- uint16_t datarate; /*!> RX datarate, 0 for default */
+ bool enable; /*!> enable or disable that IF chain */
+ uint8_t rf_chain; /*!> to which RF chain is that IF chain associated */
+ int32_t freq_hz; /*!> center frequ of the IF chain, relative to RF chain frequency */
+ uint8_t bandwidth; /*!> RX bandwidth, 0 for default */
+ uint16_t datarate; /*!> RX datarate, 0 for default */
};
/**
@@ -145,20 +145,20 @@ struct lgw_conf_rxif_s {
@brief Structure containing the metadata of a packet that was received and a pointer to the payload
*/
struct lgw_pkt_rx_s {
- uint8_t if_chain; /*!> by which IF chain was packet received */
- uint8_t status; /*!> status of the received packet */
- uint8_t modulation; /*!> modulation used by the packet */
- uint8_t bandwidth; /*!> modulation bandwidth (LORA only) */
- uint16_t datarate; /*!> RX datarate of the packet */
- uint8_t coderate; /*!> error-correcting code of the packet */
- uint32_t count_us; /*!> internal gateway counter for timestamping, 1 microsecond resolution */
- float rssi; /*!> average packet RSSI in dB */
- float snr; /*!> average packet SNR, in dB (LORA only) */
- float snr_min; /*!> minimum packet SNR, in dB (LORA only) */
- float snr_max; /*!> maximum packet SNR, in dB (LORA only) */
- uint16_t crc; /*!> CRC that was received in the payload */
- uint16_t size; /*!> payload size in bytes */
- uint8_t *payload; /*!> pointer to the payload */
+ uint8_t if_chain; /*!> by which IF chain was packet received */
+ uint8_t status; /*!> status of the received packet */
+ uint8_t modulation; /*!> modulation used by the packet */
+ uint8_t bandwidth; /*!> modulation bandwidth (Lora only) */
+ uint16_t datarate; /*!> RX datarate of the packet */
+ uint8_t coderate; /*!> error-correcting code of the packet */
+ uint32_t count_us; /*!> internal gateway counter for timestamping, 1 microsecond resolution */
+ float rssi; /*!> average packet RSSI in dB */
+ float snr; /*!> average packet SNR, in dB (Lora only) */
+ float snr_min; /*!> minimum packet SNR, in dB (Lora only) */
+ float snr_max; /*!> maximum packet SNR, in dB (Lora only) */
+ uint16_t crc; /*!> CRC that was received in the payload */
+ uint16_t size; /*!> payload size in bytes */
+ uint8_t *payload; /*!> pointer to the payload */
};
/**
@@ -166,21 +166,22 @@ struct lgw_pkt_rx_s {
@brief Structure containing the configuration of a packet to send and a pointer to the payload
*/
struct lgw_pkt_tx_s {
- uint32_t freq_hz; /*!> center frequency of TX */
- uint8_t tx_mode; /*!> select on what event/time the TX is triggered */
- uint32_t count_us; /*!> timestamp or delay in microseconds for TX trigger */
- uint8_t rf_chain; /*!> through which RF chain will the packet be sent */
- int8_t rf_power; /*!> TX power, in dBm */
- uint8_t modulation; /*!> modulation to use for the packet */
- uint8_t bandwidth; /*!> modulation bandwidth (LORA only) */
- uint16_t f_dev; /*!> frequency deviation (FSK only) */
- uint16_t datarate; /*!> TX datarate */
- uint8_t coderate; /*!> error-correcting code of the packet */
- uint16_t preamble; /*!> set the preamble length, 0 for default */
- bool no_crc; /*!> if true, do not send a CRC in the packet */
- bool no_header; /*!> if true, enable implicit header mode */
- uint16_t size; /*!> payload size in bytes */
- uint8_t *payload; /*!> pointer to the payload */
+ uint32_t freq_hz; /*!> center frequency of TX */
+ uint8_t tx_mode; /*!> select on what event/time the TX is triggered */
+ uint32_t count_us; /*!> timestamp or delay in microseconds for TX trigger */
+ uint8_t rf_chain; /*!> through which RF chain will the packet be sent */
+ int8_t rf_power; /*!> TX power, in dBm */
+ uint8_t modulation; /*!> modulation to use for the packet */
+ uint8_t bandwidth; /*!> modulation bandwidth (Lora only) */
+ bool invert_pol; /*!> invert signal polarity, for orthogonal downlinks (Lora only) */
+ uint16_t f_dev; /*!> frequency deviation (FSK only) */
+ uint16_t datarate; /*!> TX datarate */
+ uint8_t coderate; /*!> error-correcting code of the packet */
+ uint16_t preamble; /*!> set the preamble length, 0 for default */
+ bool no_crc; /*!> if true, do not send a CRC in the packet */
+ bool no_header; /*!> if true, enable implicit header mode */
+ uint16_t size; /*!> payload size in bytes */
+ uint8_t *payload; /*!> pointer to the payload */
};
/* -------------------------------------------------------------------------- */
diff --git a/loragw_hal/inc/loragw_reg.h b/loragw_hal/inc/loragw_reg.h
index e0f9390..922d3df 100644
--- a/loragw_hal/inc/loragw_reg.h
+++ b/loragw_hal/inc/loragw_reg.h
@@ -1,16 +1,16 @@
/*
- / _____) _ | |
-( (____ _____ ____ _| |_ _____ ____| |__
+ / _____) _ | |
+( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
©2013 Semtech-Cycleo
Description:
- Functions used to handle a single Lora gateway.
- Registers are addressed by name.
- Multi-bytes registers are handled automatically.
- Read-modify-write is handled automatically.
+ Functions used to handle a single Lora gateway.
+ Registers are addressed by name.
+ Multi-bytes registers are handled automatically.
+ Read-modify-write is handled automatically.
*/
@@ -20,14 +20,14 @@ Description:
/* -------------------------------------------------------------------------- */
/* --- DEPENDANCIES --------------------------------------------------------- */
-#include <stdint.h> /* C99 types */
-#include <stdbool.h> /* bool type */
+#include <stdint.h> /* C99 types */
+#include <stdbool.h> /* bool type */
/* -------------------------------------------------------------------------- */
/* --- PUBLIC CONSTANTS ----------------------------------------------------- */
-#define LGW_REG_SUCCESS 0
-#define LGW_REG_ERROR -1
+#define LGW_REG_SUCCESS 0
+#define LGW_REG_ERROR -1
/*
auto generated register mapping for C code : 24-Jun-2013 20:29:09
diff --git a/loragw_hal/inc/loragw_spi.h b/loragw_hal/inc/loragw_spi.h
index 62cdeb4..3ad857f 100644
--- a/loragw_hal/inc/loragw_spi.h
+++ b/loragw_hal/inc/loragw_spi.h
@@ -1,17 +1,17 @@
/*
- / _____) _ | |
-( (____ _____ ____ _| |_ _____ ____| |__
+ / _____) _ | |
+( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
©2013 Semtech-Cycleo
Description:
- Host specific functions to address the LoRa™ gateway registers through a
- SPI interface.
- Single-byte read/write and burst read/write.
- Does not handle pagination.
- Could be used with multiple SPI ports in parallel (explicit file descriptor)
+ Host specific functions to address the LoRa™ gateway registers through a
+ SPI interface.
+ Single-byte read/write and burst read/write.
+ Does not handle pagination.
+ Could be used with multiple SPI ports in parallel (explicit file descriptor)
*/
@@ -21,14 +21,14 @@ Description:
/* -------------------------------------------------------------------------- */
/* --- DEPENDANCIES --------------------------------------------------------- */
-#include <stdint.h> /* C99 types*/
+#include <stdint.h> /* C99 types*/
/* -------------------------------------------------------------------------- */
/* --- PUBLIC CONSTANTS ----------------------------------------------------- */
-#define LGW_SPI_SUCCESS 0
-#define LGW_SPI_ERROR -1
-#define LGW_BURST_CHUNK 1024
+#define LGW_SPI_SUCCESS 0
+#define LGW_SPI_ERROR -1
+#define LGW_BURST_CHUNK 1024
/* -------------------------------------------------------------------------- */
/* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */
diff --git a/loragw_hal/src/agc_fw.var b/loragw_hal/src/agc_fw.var
index 350e56d..a0dde65 100644
--- a/loragw_hal/src/agc_fw.var
+++ b/loragw_hal/src/agc_fw.var
@@ -1,13 +1,13 @@
/*
- / _____) _ | |
-( (____ _____ ____ _| |_ _____ ____| |__
+ / _____) _ | |
+( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
©2013 Semtech-Cycleo
Description:
- AGC firmware
+ AGC firmware
*/
static uint8_t agc_firmware[MCU_AGC_FW_BYTE] = {
diff --git a/loragw_hal/src/arb_fw.var b/loragw_hal/src/arb_fw.var
index 2e41dcc..2cb66f5 100644
--- a/loragw_hal/src/arb_fw.var
+++ b/loragw_hal/src/arb_fw.var
@@ -1,13 +1,13 @@
/*
- / _____) _ | |
-( (____ _____ ____ _| |_ _____ ____| |__
+ / _____) _ | |
+( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
©2013 Semtech-Cycleo
Description:
- Arbiter firmware
+ Arbiter firmware
*/
static uint8_t arb_firmware[MCU_ARB_FW_BYTE] = {
diff --git a/loragw_hal/src/loragw_aux.c b/loragw_hal/src/loragw_aux.c
index 52df612..9adafe3 100644
--- a/loragw_hal/src/loragw_aux.c
+++ b/loragw_hal/src/loragw_aux.c
@@ -1,31 +1,31 @@
/*
- / _____) _ | |
-( (____ _____ ____ _| |_ _____ ____| |__
+ / _____) _ | |
+( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
©2013 Semtech-Cycleo
Description:
- Lora gateway auxiliary functions
+ Lora gateway auxiliary functions
*/
/* -------------------------------------------------------------------------- */
/* --- DEPENDANCIES --------------------------------------------------------- */
-#include <stdio.h> /* printf fprintf */
-#include <time.h> /* clock_nanosleep */
+#include <stdio.h> /* printf fprintf */
+#include <time.h> /* clock_nanosleep */
/* -------------------------------------------------------------------------- */
/* --- PRIVATE MACROS ------------------------------------------------------- */
#ifdef DEBUG
- #define DEBUG_MSG(str) fprintf(stderr, str)
- #define DEBUG_PRINTF(fmt, args...) fprintf(stderr,"%s:%d: "fmt, __FUNCTION__, __LINE__, args)
+ #define DEBUG_MSG(str) fprintf(stderr, str)
+ #define DEBUG_PRINTF(fmt, args...) fprintf(stderr,"%s:%d: "fmt, __FUNCTION__, __LINE__, args)
#else
- #define DEBUG_MSG(str)
- #define DEBUG_PRINTF(fmt, args...)
+ #define DEBUG_MSG(str)
+ #define DEBUG_PRINTF(fmt, args...)
#endif
/* -------------------------------------------------------------------------- */
@@ -33,19 +33,19 @@ Description:
/* This implementation is POSIX-pecific and require a fix to be compatible with C99 */
void wait_ms(unsigned long a) {
- struct timespec dly;
- struct timespec rem;
-
- dly.tv_sec = a / 1000;
- dly.tv_nsec = ((long)a % 1000) * 1000000;
-
- DEBUG_PRINTF("NOTE dly: %ld sec %ld ns\n", dly.tv_sec, dly.tv_nsec);
-
- if((dly.tv_sec > 0) || ((dly.tv_sec == 0) && (dly.tv_nsec > 100000))) {
- clock_nanosleep(CLOCK_MONOTONIC, 0, &dly, &rem);
- DEBUG_PRINTF("NOTE remain: %ld sec %ld ns\n", rem.tv_sec, rem.tv_nsec);
- }
- return;
+ struct timespec dly;
+ struct timespec rem;
+
+ dly.tv_sec = a / 1000;
+ dly.tv_nsec = ((long)a % 1000) * 1000000;
+
+ DEBUG_PRINTF("NOTE dly: %ld sec %ld ns\n", dly.tv_sec, dly.tv_nsec);
+
+ if((dly.tv_sec > 0) || ((dly.tv_sec == 0) && (dly.tv_nsec > 100000))) {
+ clock_nanosleep(CLOCK_MONOTONIC, 0, &dly, &rem);
+ DEBUG_PRINTF("NOTE remain: %ld sec %ld ns\n", rem.tv_sec, rem.tv_nsec);
+ }
+ return;
}
/* --- EOF ------------------------------------------------------------------ */
diff --git a/loragw_hal/src/loragw_hal.c b/loragw_hal/src/loragw_hal.c
index bdf563c..d597f5d 100644
--- a/loragw_hal/src/loragw_hal.c
+++ b/loragw_hal/src/loragw_hal.c
@@ -1,24 +1,25 @@
/*
- / _____) _ | |
-( (____ _____ ____ _| |_ _____ ____| |__
+ / _____) _ | |
+( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
©2013 Semtech-Cycleo
Description:
- Lora gateway Hardware Abstraction Layer
+ Lora gateway Hardware Abstraction Layer
*/
/* -------------------------------------------------------------------------- */
/* --- DEPENDANCIES --------------------------------------------------------- */
-#include <stdint.h> /* C99 types */
-#include <stdlib.h> /* malloc & free */
-#include <stdbool.h> /* bool type */
-#include <stdio.h> /* printf fprintf */
-#include <math.h> /* NaN */
+#include <stdint.h> /* C99 types */
+#include <stdlib.h> /* malloc & free */
+#include <stdbool.h> /* bool type */
+#include <stdio.h> /* printf fprintf */
+#include <math.h> /* NaN */
+#include <string.h> /* memcpy */
#include "loragw_reg.h"
#include "loragw_hal.h"
@@ -29,15 +30,15 @@ Description:
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#ifdef DEBUG
- #define DEBUG_MSG(str) fprintf(stderr, str)
- #define DEBUG_PRINTF(fmt, args...) fprintf(stderr,"%s:%d: "fmt, __FUNCTION__, __LINE__, args)
- #define DEBUG_ARRAY(a,b,c) for(a=0;a<b;++a) fprintf(stderr,"%x.",c[a]);fprintf(stderr,"end\n")
- #define CHECK_NULL(a) if(a==NULL){fprintf(stderr,"%s:%d: ERROR: NULL POINTER AS ARGUMENT\n", __FUNCTION__, __LINE__);return LGW_HAL_ERROR;}
+ #define DEBUG_MSG(str) fprintf(stderr, str)
+ #define DEBUG_PRINTF(fmt, args...) fprintf(stderr,"%s:%d: "fmt, __FUNCTION__, __LINE__, args)
+ #define DEBUG_ARRAY(a,b,c) for(a=0;a<b;++a) fprintf(stderr,"%x.",c[a]);fprintf(stderr,"end\n")
+ #define CHECK_NULL(a) if(a==NULL){fprintf(stderr,"%s:%d: ERROR: NULL POINTER AS ARGUMENT\n", __FUNCTION__, __LINE__);return LGW_HAL_ERROR;}
#else
- #define DEBUG_MSG(str)
- #def