Skip to content

Commit

Permalink
Merge pull request #14730 from Ekidna/fix/sx126x-select-pins
Browse files Browse the repository at this point in the history
Add config macros for device-variant, freq-support and xtal config
  • Loading branch information
0xc0170 authored Jul 21, 2021
2 parents 655d889 + 89789f2 commit e060c8c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
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;
#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

0 comments on commit e060c8c

Please sign in to comment.