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

pull/14730/head
Evan Davey 2021-06-03 10:27:01 +10:00
parent 5fe4dafc34
commit e61a8caabe
3 changed files with 40 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;
@ -690,6 +694,7 @@ void SX126X_LoRaRadio::read_fifo(uint8_t *buffer, uint8_t size, uint8_t offset)
_chip_select = 1;
}
#if MBED_CONF_SX126X_LORA_DRIVER_DEVICE_VARIANT == -1
uint8_t SX126X_LoRaRadio::get_device_variant(void)
{
uint16_t val = 0;
@ -703,7 +708,14 @@ uint8_t SX126X_LoRaRadio::get_device_variant(void)
return SX1261;
}
}
#else
uint8_t SX126X_LoRaRadio::get_device_variant(void)
{
return MBED_CONF_SX126X_LORA_DRIVER_DEVICE_VARIANT;
}
#endif
#if MBED_CONF_SX126X_LORA_DRIVER_FREQ_SUPPORT == -1
uint8_t SX126X_LoRaRadio::get_frequency_support(void)
{
uint16_t val = 0;
@ -725,6 +737,12 @@ uint8_t SX126X_LoRaRadio::get_frequency_support(void)
return (MATCHING_FREQ_868);
}
}
#else
uint8_t SX126X_LoRaRadio::get_frequency_support(void)
{
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"
},