Skip to content

Commit f98d1d1

Browse files
author
Gonzalo Casas
committed
Added IMST+RPi platform
1 parent 05f3612 commit f98d1d1

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

libloragw/inc/imst_rpi.h

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* imst_rpi.h
3+
*
4+
* Created on: Dec 30, 2015
5+
* Author: gonzalocasas
6+
*/
7+
8+
#ifndef _IMST_RPI_H_
9+
#define _IMST_RPI_H_
10+
11+
/* Human readable platform definition */
12+
#define DISPLAY_PLATFORM "IMST + Rpi"
13+
14+
/* parameters for native spi */
15+
#define SPI_SPEED 8000000
16+
#define SPI_DEV_PATH "/dev/spidev0.0"
17+
#define SPI_CS_CHANGE 0
18+
19+
/* parameters for a FT2232H */
20+
#define VID 0x0403
21+
#define PID 0x6014
22+
23+
#endif /* _IMST_RPI_H_ */

libloragw/inc/kerlink.h

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/* parameters for native spi */
1515
#define SPI_SPEED 8000000
1616
#define SPI_DEV_PATH "/dev/spidev32766.0"
17+
#define SPI_CS_CHANGE 1
1718

1819
/* parameters for a FT2232H */
1920
#define VID 0x0403

libloragw/inc/lorank.h

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/* parameters for native spi */
1515
#define SPI_SPEED 8000000
1616
#define SPI_DEV_PATH "/dev/spidev1.0"
17+
#define SPI_CS_CHANGE 1
1718

1819
/* parameters for a FT2232H */
1920
#define VID 0x0403

libloragw/library.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ CFG_SPI= native
1717
# Accepted values:
1818
# kerlink This is the default from Semtech and works for the Kerlink
1919
# lorank This is for the Lorank, and probably for any gateway based on the IMST concentrator.
20+
# imst_rpi This is for the IMST concentrators with a Raspberry Pi host.
2021

2122
PLATFORM= kerlink
2223

libloragw/src/loragw_spi.native.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ int lgw_spi_w(void *spi_target, uint8_t address, uint8_t data) {
182182
k.tx_buf = (unsigned long) out_buf;
183183
k.len = ARRAY_SIZE(out_buf);
184184
k.speed_hz = SPI_SPEED;
185-
k.cs_change = 1;
185+
k.cs_change = SPI_CS_CHANGE;
186186
k.bits_per_word = 8;
187187
a = ioctl(spi_device, SPI_IOC_MESSAGE(1), &k);
188188

@@ -224,7 +224,7 @@ int lgw_spi_r(void *spi_target, uint8_t address, uint8_t *data) {
224224
k.tx_buf = (unsigned long) out_buf;
225225
k.rx_buf = (unsigned long) in_buf;
226226
k.len = ARRAY_SIZE(out_buf);
227-
k.cs_change = 1;
227+
k.cs_change = SPI_CS_CHANGE;
228228
a = ioctl(spi_device, SPI_IOC_MESSAGE(1), &k);
229229

230230
/* determine return code */
@@ -271,7 +271,7 @@ int lgw_spi_wb(void *spi_target, uint8_t address, uint8_t *data, uint16_t size)
271271
k[0].tx_buf = (unsigned long) &command;
272272
k[0].len = 1;
273273
k[0].cs_change = 0;
274-
k[1].cs_change = 1;
274+
k[1].cs_change = SPI_CS_CHANGE;
275275
for (i=0; size_to_do > 0; ++i) {
276276
chunk_size = (size_to_do < LGW_BURST_CHUNK) ? size_to_do : LGW_BURST_CHUNK;
277277
offset = i * LGW_BURST_CHUNK;
@@ -325,7 +325,7 @@ int lgw_spi_rb(void *spi_target, uint8_t address, uint8_t *data, uint16_t size)
325325
k[0].tx_buf = (unsigned long) &command;
326326
k[0].len = 1;
327327
k[0].cs_change = 0;
328-
k[1].cs_change = 1;
328+
k[1].cs_change = SPI_CS_CHANGE;
329329
for (i=0; size_to_do > 0; ++i) {
330330
chunk_size = (size_to_do < LGW_BURST_CHUNK) ? size_to_do : LGW_BURST_CHUNK;
331331
offset = i * LGW_BURST_CHUNK;

0 commit comments

Comments
 (0)