Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config macros for device-variant, freq-support and xtal config #14730

Merged
merged 2 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions connectivity/drivers/lora/COMPONENT_SX126X/SX126X_LoRaRadio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,11 @@ void SX126X_LoRaRadio::cold_start_wakeup()
write_opmode_command(RADIO_SET_REGULATORMODE, &regulator_mode, 1);
set_buffer_base_addr(0x00, 0x00);

#if MBED_CONF_SX126X_LORA_DRIVER_XTAL == -1
if (_crystal_select.is_connected() && _crystal_select == 0) {
#else
if (MBED_CONF_SX126X_LORA_DRIVER_XTAL == 0) {
#endif
caliberation_params_t calib_param;
set_dio3_as_tcxo_ctrl(TCXO_CTRL_1_7V, 320); //5 ms
calib_param.value = 0x7F;
Expand Down Expand Up @@ -692,6 +696,7 @@ void SX126X_LoRaRadio::read_fifo(uint8_t *buffer, uint8_t size, uint8_t offset)

uint8_t SX126X_LoRaRadio::get_device_variant(void)
{
#if MBED_CONF_SX126X_LORA_DRIVER_DEVICE_VARIANT == -1
uint16_t val = 0;
val = _dev_select.read_u16();

Expand All @@ -702,10 +707,14 @@ uint8_t SX126X_LoRaRadio::get_device_variant(void)
} else {
return SX1261;
}
#else
return MBED_CONF_SX126X_LORA_DRIVER_DEVICE_VARIANT;
evandavey marked this conversation as resolved.
Show resolved Hide resolved
#endif
}

uint8_t SX126X_LoRaRadio::get_frequency_support(void)
{
#if MBED_CONF_SX126X_LORA_DRIVER_FREQ_SUPPORT == -1
uint16_t val = 0;
val = _freq_select.read_u16();

Expand All @@ -724,6 +733,9 @@ uint8_t SX126X_LoRaRadio::get_frequency_support(void)
} else {
return (MATCHING_FREQ_868);
}
#else
return MBED_CONF_SX126X_LORA_DRIVER_FREQ_SUPPORT;
#endif
}

uint8_t SX126X_LoRaRadio::get_fsk_bw_reg_val(uint32_t bandwidth)
Expand Down
12 changes: 10 additions & 2 deletions connectivity/drivers/lora/COMPONENT_SX126X/SX126X_LoRaRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,19 @@ class SX126X_LoRaRadio : public LoRaRadio {
// module busy control
mbed::DigitalIn _busy;

// module frequency selection
// module frequency selection
#if MBED_CONF_SX126X_LORA_DRIVER_FREQ_SUPPORT == -1
mbed::AnalogIn _freq_select;
#else
mbed::DigitalIn _freq_select; // AnalogIn errors if NC
#endif

// module device variant selection
// module device variant selection
#if MBED_CONF_SX126X_LORA_DRIVER_DEVICE_VARIANT == -1
mbed::AnalogIn _dev_select;
#else
mbed::DigitalIn _dev_select; // AnalogIn errors if NC
#endif

// module TCXO/XTAL control
mbed::DigitalIn _crystal_select;
Expand Down
12 changes: 12 additions & 0 deletions connectivity/drivers/lora/COMPONENT_SX126X/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@
"help": "Default: STDBY_RC = 0, STDBY_XOSC = 1",
"value": 0
},
"device-variant": {
"help": "Default: -1 = use device-select, SX1261, SX1262, SX1268",
"value": -1
},
"freq-support": {
"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",
"value": -1
},
"xtal": {
"help": "Default: -1 = use crystal-select, TXCO = 0, XTAL = 1",
"value": -1
},
"spi-mosi": {
"value": "NC"
},
Expand Down