Merge pull request #14730 from Ekidna/fix/sx126x-select-pins

Add config macros for device-variant, freq-support and xtal config
pull/14945/head
Martin Kojtal 2021-07-21 14:52:44 +02:00 committed by GitHub
commit e060c8c007
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 2 deletions

View File

@ -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;
@ -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();
@ -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();
@ -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)

View File

@ -306,11 +306,19 @@ private:
// 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;

View File

@ -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"
},