Skip to content

activacion del modo debug #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions libloragw/inc/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef _LORAGW_CONFIGURATION_H
#define _LORAGW_CONFIGURATION_H
#define LIBLORAGW_VERSION "5.0.1"
#define DEBUG_AUX 1
#define DEBUG_SPI 1
#define DEBUG_REG 1
#define DEBUG_HAL 1
#define DEBUG_GPS 1
#define DEBUG_GPIO
#define DEBUG_LBT 1
#endif
Binary file added libloragw/libloragw.a
Binary file not shown.
12 changes: 6 additions & 6 deletions libloragw/library.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# Set the DEBUG_* to 1 to activate debug mode in individual modules.
# Warning: that makes the module *very verbose*, do not use for production

DEBUG_AUX= 0
DEBUG_SPI= 0
DEBUG_REG= 0
DEBUG_HAL= 0
DEBUG_LBT= 0
DEBUG_GPS= 0
DEBUG_AUX= 1
DEBUG_SPI= 1
DEBUG_REG= 1
DEBUG_HAL= 1
DEBUG_LBT= 1
DEBUG_GPS= 1
1 change: 1 addition & 0 deletions libloragw/src/loragw_spi.native.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ int lgw_spi_r(void *spi_target, uint8_t spi_mux_mode, uint8_t spi_mux_target, ui
return LGW_SPI_ERROR;
} else {
DEBUG_MSG("Note: SPI read success\n");
DEBUG_PRINTF("Note: SPI read data: %u \n",in_buf[command_size - 1]);
*data = in_buf[command_size - 1];
return LGW_SPI_SUCCESS;
}
Expand Down
Binary file added libloragw/test_loragw_cal
Binary file not shown.
Binary file added libloragw/test_loragw_gps
Binary file not shown.
Binary file added libloragw/test_loragw_hal
Binary file not shown.
Binary file added libloragw/test_loragw_reg
Binary file not shown.
Binary file added libloragw/test_loragw_spi
Binary file not shown.
12 changes: 12 additions & 0 deletions libloragw/tst/library.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# That file will be included in the Makefile files that have hardware dependencies

### Debug options ###
# Set the DEBUG_* to 1 to activate debug mode in individual modules.
# Warning: that makes the module *very verbose*, do not use for production

DEBUG_AUX= 1
DEBUG_SPI= 1
DEBUG_REG= 1
DEBUG_HAL= 1
DEBUG_LBT= 1
DEBUG_GPS= 1
105 changes: 105 additions & 0 deletions libloragw/tst/loragw_spi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
/ _____) _ | |
( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
(C)2013 Semtech-Cycleo

Description:
Host specific functions to address the LoRa concentrator 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)

License: Revised BSD License, see LICENSE.TXT file include in the project
Maintainer: Sylvain Miermont
*/


#ifndef _LORAGW_SPI_H
#define _LORAGW_SPI_H

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

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

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

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

#define LGW_SPI_SUCCESS 0
#define LGW_SPI_ERROR -1
#define LGW_BURST_CHUNK 1024

#define LGW_SPI_MUX_MODE0 0x0 /* No FPGA */
#define LGW_SPI_MUX_MODE1 0x1 /* FPGA, with spi mux header */

#define LGW_SPI_MUX_TARGET_SX1301 0x0
#define LGW_SPI_MUX_TARGET_FPGA 0x1
#define LGW_SPI_MUX_TARGET_EEPROM 0x2
#define LGW_SPI_MUX_TARGET_SX127X 0x3

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

/**
@brief LoRa concentrator SPI setup (configure I/O and peripherals)
@param spi_target_ptr pointer on a generic pointer to SPI target (implementation dependant)
@return status of register operation (LGW_SPI_SUCCESS/LGW_SPI_ERROR)
*/

int lgw_spi_open(void **spi_target_ptr);

/**
@brief LoRa concentrator SPI close
@param spi_target generic pointer to SPI target (implementation dependant)
@return status of register operation (LGW_SPI_SUCCESS/LGW_SPI_ERROR)
*/

int lgw_spi_close(void *spi_target);

/**
@brief LoRa concentrator SPI single-byte write
@param spi_target generic pointer to SPI target (implementation dependant)
@param address 7-bit register address
@param data data byte to write
@return status of register operation (LGW_SPI_SUCCESS/LGW_SPI_ERROR)
*/
int lgw_spi_w(void *spi_target, uint8_t spi_mux_mode, uint8_t spi_mux_target, uint8_t address, uint8_t data);

/**
@brief LoRa concentrator SPI single-byte read
@param spi_target generic pointer to SPI target (implementation dependant)
@param address 7-bit register address
@param data data byte to write
@return status of register operation (LGW_SPI_SUCCESS/LGW_SPI_ERROR)
*/
int lgw_spi_r(void *spi_target, uint8_t spi_mux_mode, uint8_t spi_mux_target, uint8_t address, uint8_t *data);

/**
@brief LoRa concentrator SPI burst (multiple-byte) write
@param spi_target generic pointer to SPI target (implementation dependant)
@param address 7-bit register address
@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_SPI_SUCCESS/LGW_SPI_ERROR)
*/
int lgw_spi_wb(void *spi_target, uint8_t spi_mux_mode, uint8_t spi_mux_target, uint8_t address, uint8_t *data, uint16_t size);

/**
@brief LoRa concentrator SPI burst (multiple-byte) read
@param spi_target generic pointer to SPI target (implementation dependant)
@param address 7-bit register address
@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_SPI_SUCCESS/LGW_SPI_ERROR)
*/
int lgw_spi_rb(void *spi_target, uint8_t spi_mux_mode, uint8_t spi_mux_target, uint8_t address, uint8_t *data, uint16_t size);

#endif

/* --- EOF ------------------------------------------------------------------ */
7 changes: 4 additions & 3 deletions libloragw/tst/test_loragw_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Maintainer: Sylvain Miermont
/* --- PRIVATE CONSTANTS ---------------------------------------------------- */

#define BURST_TEST_SIZE 2500 /* >> LGW_BURST_CHUNK */
#define TIMING_REPEAT 1 /* repeat transactions multiple times for timing characterisation */
#define TIMING_REPEAT 100 /* repeat transactions multiple times for timing characterisation */

/* -------------------------------------------------------------------------- */
/* --- MAIN FUNCTION -------------------------------------------------------- */
Expand Down Expand Up @@ -61,16 +61,17 @@ int main()
lgw_spi_r(spi_target, spi_mux_mode, LGW_SPI_MUX_TARGET_SX1301, 0x55, &data);

/* burst R/W test, small bursts << LGW_BURST_CHUNK */
for (i = 0; i < TIMING_REPEAT; ++i)
/* for (i = 0; i < TIMING_REPEAT; ++i)
lgw_spi_wb(spi_target, spi_mux_mode, LGW_SPI_MUX_TARGET_SX1301, 0x55, dataout, 16);
for (i = 0; i < TIMING_REPEAT; ++i)
lgw_spi_rb(spi_target, spi_mux_mode, LGW_SPI_MUX_TARGET_SX1301, 0x55, datain, 16);

/* burst R/W test, large bursts >> LGW_BURST_CHUNK */
for (i = 0; i < TIMING_REPEAT; ++i)
/*for (i = 0; i < TIMING_REPEAT; ++i)
lgw_spi_wb(spi_target, spi_mux_mode, LGW_SPI_MUX_TARGET_SX1301, 0x5A, dataout, ARRAY_SIZE(dataout));
for (i = 0; i < TIMING_REPEAT; ++i)
lgw_spi_rb(spi_target, spi_mux_mode, LGW_SPI_MUX_TARGET_SX1301, 0x5A, datain, ARRAY_SIZE(datain));
*/

/* last read (blocking), just to be sure no to quit before the FTDI buffer is flushed */
lgw_spi_r(spi_target, spi_mux_mode, LGW_SPI_MUX_TARGET_SX1301, 0x55, &data);
Expand Down