From 6d0747727e8a14fcafe337b7125c8c8c89ac5d66 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 20 Aug 2021 01:47:25 +0200 Subject: [PATCH] added optimal settings for RFO_HP only fixed wrong help values name added detailled comments fix style-check fix style-check --- .../lora/TARGET_STM32WL/STM32WL_LoRaRadio.cpp | 20 ++++++++++++++++++- .../drivers/lora/TARGET_STM32WL/mbed_lib.json | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/connectivity/drivers/lora/TARGET_STM32WL/STM32WL_LoRaRadio.cpp b/connectivity/drivers/lora/TARGET_STM32WL/STM32WL_LoRaRadio.cpp index a6ad4c77e09..6a0327e380a 100644 --- a/connectivity/drivers/lora/TARGET_STM32WL/STM32WL_LoRaRadio.cpp +++ b/connectivity/drivers/lora/TARGET_STM32WL/STM32WL_LoRaRadio.cpp @@ -452,7 +452,25 @@ void STM32WL_LoRaRadio::SUBGRF_SetTxParams(uint8_t paSelect, int8_t power, radio // RegTxClampConfig = @address 0x08D8 write_to_register(REG_TX_CLAMP, read_register(REG_TX_CLAMP) | (0x0F << 1)); - set_pa_config(0x04, 0x07, 0x00, 0x01); + // if in mbed_app.json we have configured rf_switch_config in rfo_hp ONLY + // so "stm32wl-lora-driver.rf_switch_config": "RBI_CONF_RFO_HP" + // in this particular case it's not optimal settings for power<=20dBm + if (board_rf_switch_config == RBI_CONF_RFO_HP) { + // See Section 5.1.2 of the following Application Note + // https://www.st.com/resource/en/application_note/an5457-rf-matching-network-design-guide-for-stm32wl-series-stmicroelectronics.pdf + if (power > 20) { + set_pa_config(0x04, 0x07, 0x00, 0x01); + } else if (power > 17) { + set_pa_config(0x03, 0x05, 0x00, 0x01); + } else if (power > 14) { + set_pa_config(0x02, 0x03, 0x00, 0x01); + } else { + set_pa_config(0x02, 0x02, 0x00, 0x01); + } + } else { + set_pa_config(0x04, 0x07, 0x00, 0x01); + } + if (power > 22) { power = 22; } else if (power < -9) { diff --git a/connectivity/drivers/lora/TARGET_STM32WL/mbed_lib.json b/connectivity/drivers/lora/TARGET_STM32WL/mbed_lib.json index 31545441760..3d3def03830 100644 --- a/connectivity/drivers/lora/TARGET_STM32WL/mbed_lib.json +++ b/connectivity/drivers/lora/TARGET_STM32WL/mbed_lib.json @@ -26,7 +26,7 @@ "value": "IS_TCXO_SUPPORTED" }, "rf_switch_config": { - "help": "Default: CONF_RFO_LP_HP = 0, CONF_RFO_LP = 1, CONF_RFO_HP = 2", + "help": "Default: RBI_CONF_RFO_LP_HP = 0, RBI_CONF_RFO_LP = 1, RBI_CONF_RFO_HP = 2", "value": "RBI_CONF_RFO_LP_HP" }, "rf_wakeup_time": {