summaryrefslogtreecommitdiff
path: root/loragw_hal/test/test_loragw_spi.c
diff options
context:
space:
mode:
authorSylvain Miermont <smiermont@semtech.com>2013-08-08 15:49:31 +0200
committerSylvain Miermont <smiermont@semtech.com>2013-10-23 11:03:07 +0200
commitddac0aa483dd5f7bca31b0c042949eca370a8fdc (patch)
tree339b16655dbb9b6cca0e972454a8591256330900 /loragw_hal/test/test_loragw_spi.c
parente588fccf2b13065c25c95c70be191614cd23b005 (diff)
downloadlora_gateway-ddac0aa483dd5f7bca31b0c042949eca370a8fdc.tar.gz
lora_gateway-ddac0aa483dd5f7bca31b0c042949eca370a8fdc.tar.bz2
lora_gateway-ddac0aa483dd5f7bca31b0c042949eca370a8fdc.zip
Beta 3v1.b3
- modified 'native' SPI module to align with the way resource pointers are managed in 'ftdi' variant (void pointers) - better check of channel frequency + bandwidth vs. authorized band - improved Makefile
Diffstat (limited to 'loragw_hal/test/test_loragw_spi.c')
-rw-r--r--loragw_hal/test/test_loragw_spi.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/loragw_hal/test/test_loragw_spi.c b/loragw_hal/test/test_loragw_spi.c
index c5ab45b..0eae55d 100644
--- a/loragw_hal/test/test_loragw_spi.c
+++ b/loragw_hal/test/test_loragw_spi.c
@@ -29,6 +29,7 @@ Description:
/* --- PRIVATE CONSTANTS ---------------------------------------------------- */
#define BURST_TEST_SIZE 2500 /* >> LGW_BURST_CHUNK */
+#define TIMING_REPEAT 1 /* repeat transactions multiple times for timing characterisation */
/* -------------------------------------------------------------------------- */
/* --- MAIN FUNCTION -------------------------------------------------------- */
@@ -36,8 +37,8 @@ Description:
int main(int argc, char **argv)
{
int i;
- int spi_device;
- uint8_t data;
+ void *spi_target = NULL;
+ uint8_t data = 0;
uint8_t dataout[BURST_TEST_SIZE];
uint8_t datain[BURST_TEST_SIZE];
@@ -47,20 +48,31 @@ int main(int argc, char **argv)
}
printf("Beginning of test for loragw_spi.c\n");
- lgw_spi_open(&spi_device);
+ lgw_spi_open(&spi_target);
/* normal R/W test */
- lgw_spi_w(spi_device, 0xAA, 0x96);
- lgw_spi_r(spi_device, 0x55, &data);
+ for (i = 0; i < TIMING_REPEAT; ++i)
+ lgw_spi_w(spi_target, 0xAA, 0x96);
+ for (i = 0; i < TIMING_REPEAT; ++i)
+ lgw_spi_r(spi_target, 0x55, &data);
- /* burst R/W test */
- lgw_spi_wb(spi_device, 0x55, dataout, ARRAY_SIZE(dataout));
- lgw_spi_rb(spi_device, 0x55, datain, ARRAY_SIZE(datain));
+ /* burst R/W test, small bursts << LGW_BURST_CHUNK */
+ for (i = 0; i < TIMING_REPEAT; ++i)
+ lgw_spi_wb(spi_target, 0x55, dataout, 16);
+ for (i = 0; i < TIMING_REPEAT; ++i)
+ lgw_spi_rb(spi_target, 0x55, datain, 16);
- /* display results */
- printf("data received: %d\n",data);
+ /* burst R/W test, large bursts >> LGW_BURST_CHUNK */
+ for (i = 0; i < TIMING_REPEAT; ++i)
+ lgw_spi_wb(spi_target, 0x5A, dataout, ARRAY_SIZE(dataout));
+ for (i = 0; i < TIMING_REPEAT; ++i)
+ lgw_spi_rb(spi_target, 0x5A, datain, ARRAY_SIZE(datain));
- lgw_spi_close(spi_device);
+ /* last read (blocking), just to be sure no to quit before the FTDI buffer is flushed */
+ lgw_spi_r(spi_target, 0x55, &data);
+ printf("data received (simple read): %d\n",data);
+
+ lgw_spi_close(spi_target);
printf("End of test for loragw_spi.c\n");
return 0;