Skip to content

Commit e060c8c

Browse files
authored
Merge pull request #14730 from Ekidna/fix/sx126x-select-pins
Add config macros for device-variant, freq-support and xtal config
2 parents 655d889 + 89789f2 commit e060c8c

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

connectivity/drivers/lora/COMPONENT_SX126X/SX126X_LoRaRadio.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,11 @@ void SX126X_LoRaRadio::cold_start_wakeup()
431431
write_opmode_command(RADIO_SET_REGULATORMODE, &regulator_mode, 1);
432432
set_buffer_base_addr(0x00, 0x00);
433433

434+
#if MBED_CONF_SX126X_LORA_DRIVER_XTAL == -1
434435
if (_crystal_select.is_connected() && _crystal_select == 0) {
436+
#else
437+
if (MBED_CONF_SX126X_LORA_DRIVER_XTAL == 0) {
438+
#endif
435439
caliberation_params_t calib_param;
436440
set_dio3_as_tcxo_ctrl(TCXO_CTRL_1_7V, 320); //5 ms
437441
calib_param.value = 0x7F;
@@ -692,6 +696,7 @@ void SX126X_LoRaRadio::read_fifo(uint8_t *buffer, uint8_t size, uint8_t offset)
692696

693697
uint8_t SX126X_LoRaRadio::get_device_variant(void)
694698
{
699+
#if MBED_CONF_SX126X_LORA_DRIVER_DEVICE_VARIANT == -1
695700
uint16_t val = 0;
696701
val = _dev_select.read_u16();
697702

@@ -702,10 +707,14 @@ uint8_t SX126X_LoRaRadio::get_device_variant(void)
702707
} else {
703708
return SX1261;
704709
}
710+
#else
711+
return MBED_CONF_SX126X_LORA_DRIVER_DEVICE_VARIANT;
712+
#endif
705713
}
706714

707715
uint8_t SX126X_LoRaRadio::get_frequency_support(void)
708716
{
717+
#if MBED_CONF_SX126X_LORA_DRIVER_FREQ_SUPPORT == -1
709718
uint16_t val = 0;
710719
val = _freq_select.read_u16();
711720

@@ -724,6 +733,9 @@ uint8_t SX126X_LoRaRadio::get_frequency_support(void)
724733
} else {
725734
return (MATCHING_FREQ_868);
726735
}
736+
#else
737+
return MBED_CONF_SX126X_LORA_DRIVER_FREQ_SUPPORT;
738+
#endif
727739
}
728740

729741
uint8_t SX126X_LoRaRadio::get_fsk_bw_reg_val(uint32_t bandwidth)

connectivity/drivers/lora/COMPONENT_SX126X/SX126X_LoRaRadio.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,19 @@ class SX126X_LoRaRadio : public LoRaRadio {
306306
// module busy control
307307
mbed::DigitalIn _busy;
308308

309-
// module frequency selection
309+
// module frequency selection
310+
#if MBED_CONF_SX126X_LORA_DRIVER_FREQ_SUPPORT == -1
310311
mbed::AnalogIn _freq_select;
312+
#else
313+
mbed::DigitalIn _freq_select; // AnalogIn errors if NC
314+
#endif
311315

312-
// module device variant selection
316+
// module device variant selection
317+
#if MBED_CONF_SX126X_LORA_DRIVER_DEVICE_VARIANT == -1
313318
mbed::AnalogIn _dev_select;
319+
#else
320+
mbed::DigitalIn _dev_select; // AnalogIn errors if NC
321+
#endif
314322

315323
// module TCXO/XTAL control
316324
mbed::DigitalIn _crystal_select;

connectivity/drivers/lora/COMPONENT_SX126X/mbed_lib.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525
"help": "Default: STDBY_RC = 0, STDBY_XOSC = 1",
2626
"value": 0
2727
},
28+
"device-variant": {
29+
"help": "Default: -1 = use device-select, SX1261, SX1262, SX1268",
30+
"value": -1
31+
},
32+
"freq-support": {
33+
"help": "Default: -1 = use freq-select, MATCHING_FREQ_169, MATCHING_FREQ_280, MATCHING_FREQ_434, MATCHING_FREQ_490, MATCHING_FREQ_780, MATCHING_FREQ_868, MATCHING_FREQ_915",
34+
"value": -1
35+
},
36+
"xtal": {
37+
"help": "Default: -1 = use crystal-select, TXCO = 0, XTAL = 1",
38+
"value": -1
39+
},
2840
"spi-mosi": {
2941
"value": "NC"
3042
},

0 commit comments

Comments
 (0)