Skip to content

Commit e61a8ca

Browse files
committed
Add config macros for device-variant, freq-support and xtal config
1 parent 5fe4daf commit e61a8ca

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

connectivity/drivers/lora/COMPONENT_SX126X/SX126X_LoRaRadio.cpp

Lines changed: 18 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;
@@ -690,6 +694,7 @@ void SX126X_LoRaRadio::read_fifo(uint8_t *buffer, uint8_t size, uint8_t offset)
690694
_chip_select = 1;
691695
}
692696

697+
#if MBED_CONF_SX126X_LORA_DRIVER_DEVICE_VARIANT == -1
693698
uint8_t SX126X_LoRaRadio::get_device_variant(void)
694699
{
695700
uint16_t val = 0;
@@ -703,7 +708,14 @@ uint8_t SX126X_LoRaRadio::get_device_variant(void)
703708
return SX1261;
704709
}
705710
}
711+
#else
712+
uint8_t SX126X_LoRaRadio::get_device_variant(void)
713+
{
714+
return MBED_CONF_SX126X_LORA_DRIVER_DEVICE_VARIANT;
715+
}
716+
#endif
706717

718+
#if MBED_CONF_SX126X_LORA_DRIVER_FREQ_SUPPORT == -1
707719
uint8_t SX126X_LoRaRadio::get_frequency_support(void)
708720
{
709721
uint16_t val = 0;
@@ -725,6 +737,12 @@ uint8_t SX126X_LoRaRadio::get_frequency_support(void)
725737
return (MATCHING_FREQ_868);
726738
}
727739
}
740+
#else
741+
uint8_t SX126X_LoRaRadio::get_frequency_support(void)
742+
{
743+
return MBED_CONF_SX126X_LORA_DRIVER_FREQ_SUPPORT;
744+
}
745+
#endif
728746

729747
uint8_t SX126X_LoRaRadio::get_fsk_bw_reg_val(uint32_t bandwidth)
730748
{

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)