Skip to content

Commit 16177b3

Browse files
committed
Add rssi_cal field; make raw-feather adapt automatically to board in use
1 parent e115d14 commit 16177b3

File tree

5 files changed

+42
-8
lines changed

5 files changed

+42
-8
lines changed

examples/raw-feather/raw-feather.ino

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,33 @@ Revision history:
7474
#define TX_INTERVAL 2000 // milliseconds
7575
#define RX_RSSI_INTERVAL 100 // milliseconds
7676

77-
// Pin mapping for Adafruit Feather M0 LoRa
77+
// Pin mapping for Adafruit Feather M0 LoRa, etc.
78+
#if defined(ARDUINO_SAMD_FEATHER_M0)
7879
const lmic_pinmap lmic_pins = {
7980
.nss = 8,
8081
.rxtx = LMIC_UNUSED_PIN,
8182
.rst = 4,
8283
.dio = {3, 6, LMIC_UNUSED_PIN},
84+
.rxtx_rx_active = 0,
85+
.rssi_cal = 8, // LBT cal for the Adafruit Feather M0 LoRa, in dB
86+
.spi_freq = 8000000,
8387
};
84-
88+
#elif defined(ARDUINO_CATENA_4551)
89+
const lmic_pinmap lmic_pins = {
90+
.nss = 7,
91+
.rxtx = 29,
92+
.rst = 8,
93+
.dio = { 25, // DIO0 (IRQ) is D25
94+
26, // DIO1 is D26
95+
27, // DIO2 is D27
96+
},
97+
.rxtx_rx_active = 1,
98+
.rssi_cal = 10,
99+
.spi_freq = 8000000 // 8MHz
100+
};
101+
#else
102+
# error "Unknown target"
103+
#endif
85104

86105
// These callbacks are only used in over-the-air activation, so they are
87106
// left empty here (we cannot leave them out completely unless

src/hal/hal.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ void hal_pin_rst (u1_t val) {
6161
}
6262
}
6363

64+
s1_t hal_getRssiCal (void) {
65+
return plmic_pins->rssi_cal;
66+
}
67+
6468
#if !defined(LMIC_USE_INTERRUPTS)
6569
static void hal_interrupt_init() {
6670
pinMode(plmic_pins->dio[0], INPUT);

src/hal/hal.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@
1212

1313
static const int NUM_DIO = 3;
1414

15+
// be careful of alignment below.
1516
struct lmic_pinmap {
16-
u1_t nss;
17-
u1_t rxtx;
18-
u1_t rst;
19-
u1_t dio[NUM_DIO];
20-
u1_t rxtx_rx_active;
21-
u4_t spi_freq;
17+
u1_t nss; // byte 0: pin for select
18+
u1_t rxtx; // byte 1: pin for rx/tx control
19+
u1_t rst; // byte 2: pin for reset
20+
u1_t dio[NUM_DIO]; // bytes 3..5: pins for DIO0, DOI1, DIO2
21+
// true if we must set rxtx for rx_active, false for tx_active
22+
u1_t rxtx_rx_active; // byte 6: polarity of rxtx active
23+
s1_t rssi_cal; // byte 7: cal in dB -- added to RSSI
24+
// measured prior to decision.
25+
// Must include noise guardband!
26+
u4_t spi_freq; // bytes 8..11: SPI freq in Hz.
2227
};
2328

2429
// Use this for any unused pins.

src/lmic/hal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ u1_t hal_checkTimer (u4_t targettime);
105105
*/
106106
void hal_failed (const char *file, u2_t line);
107107

108+
/*
109+
* get the calibration value for radio_rssi
110+
*/
111+
s1_t hal_getRssiCal (void);
112+
108113
#ifdef __cplusplus
109114
} // extern "C"
110115
#endif

src/lmic/radio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,7 @@ void radio_monitor_rssi(ostime_t nTicks, oslmic_radio_rssi_t *pRssi) {
873873
} else {
874874
rssiAdjust = SX127X_RSSI_ADJUST_LF;
875875
}
876+
rssiAdjust += hal_getRssiCal();
876877

877878
// zero the results
878879
rssiMax = 255;

0 commit comments

Comments
 (0)