Skip to content

Commit 42e11ac

Browse files
committed
Allow to use LowPower fix as a parameter
Allow to use TCXO Control Voltage and LowPower fix as a parameter leave current default value to avoid breaking changes astyle fix
1 parent 91b793c commit 42e11ac

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

connectivity/drivers/lora/TARGET_STM32WL/STM32WL_LoRaRadio.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ uint8_t crystal_select = MBED_CONF_STM32WL_LORA_DRIVER_CRYSTAL_SELECT;
5555

5656
uint8_t board_rf_switch_config = MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CONFIG;
5757

58+
radio_TCXO_ctrl_voltage_t tcxo_ctrl = MBED_CONF_STM32WL_LORA_DRIVER_TCXO_CTRL;
59+
5860

5961
static void SUBGHZ_Radio_IRQHandler(void);
6062

@@ -76,12 +78,6 @@ static uint8_t _active_modem;
7678
using namespace std::chrono;
7779
using namespace mbed;
7880

79-
80-
/**
81-
* @brief voltage of vdd tcxo.
82-
*/
83-
#define TCXO_CTRL_VOLTAGE TCXO_CTRL_1_7V
84-
8581
/*!
8682
* FSK bandwidth definition
8783
*/
@@ -466,7 +462,9 @@ void STM32WL_LoRaRadio::SUBGRF_SetTxParams(uint8_t paSelect, int8_t power, radio
466462
// if in mbed_app.json we have configured rf_switch_config in rfo_hp ONLY
467463
// so "stm32wl-lora-driver.rf_switch_config": "RBI_CONF_RFO_HP"
468464
// in this particular case it's not optimal settings for power<=20dBm
469-
if (board_rf_switch_config == RBI_CONF_RFO_HP) {
465+
// So if we set also rfo_hp_lpfix to 1 then optimize power
466+
// See https://github.com/ARMmbed/mbed-os/pull/15017#issuecomment-1173455762
467+
if (board_rf_switch_config == RBI_CONF_RFO_HP && MBED_CONF_STM32WL_LORA_DRIVER_RF_RFO_HP_LPFIX == 1) {
470468
// See Section 5.1.2 of the following Application Note
471469
// https://www.st.com/resource/en/application_note/an5457-rf-matching-network-design-guide-for-stm32wl-series-stmicroelectronics.pdf
472470
if (power > 20) {
@@ -633,7 +631,7 @@ void STM32WL_LoRaRadio::cold_start_wakeup()
633631
if (crystal_select == 1) {
634632
calibration_params_t calib_param;
635633

636-
SUBGRF_SetTcxoMode(TCXO_CTRL_VOLTAGE, MBED_CONF_STM32WL_LORA_DRIVER_RF_WAKEUP_TIME << 6); //100 ms
634+
SUBGRF_SetTcxoMode(tcxo_ctrl, MBED_CONF_STM32WL_LORA_DRIVER_RF_WAKEUP_TIME << 6); //100 ms
637635

638636
calib_param.value = 0x7F;
639637
write_opmode_command(RADIO_CALIBRATE, &calib_param.value, 1);

connectivity/drivers/lora/TARGET_STM32WL/STM32WL_radio_driver.h

+12-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,18 @@
1717
#define RFO_HP 2
1818

1919
/* STM32WL Nucleo antenna switch defines */
20-
#define RBI_CONF_RFO_LP_HP 0
21-
#define RBI_CONF_RFO_LP 1
22-
#define RBI_CONF_RFO_HP 2
20+
#define RBI_CONF_RFO_LP_HP 0
21+
#define RBI_CONF_RFO_LP 1
22+
#define RBI_CONF_RFO_HP 2
23+
// Some boards such as LoRa-E5 and RAK3172 have only RFO_HP path wired
24+
// thus, in EU868 mode, TX peak is 80mA (over consumption)
25+
// We made a fix that decrease consumption according datasheet but
26+
// since fix breaks HW machting network, transmit range may be lowered so
27+
// it's depending on what you want to achieve, hi range or low consumption
28+
// Setting RBI_CONF_RFO_HP_LPFIX decrease power according datasheet but can
29+
// reduce range (long ones) due to bad HW macthing network on the both modules
30+
// See https://github.com/ARMmbed/mbed-os/pull/15017#issuecomment-1173455762
31+
#define RBI_CONF_RFO_HP_LPFIX 3
2332

2433
typedef enum {
2534
RBI_SWITCH_OFF = 0,

connectivity/drivers/lora/TARGET_STM32WL/mbed_lib.json

+8
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,18 @@
2626
"help": "Default: Internal XO = 0, IS_TCXO_SUPPORTED = 1",
2727
"value": "IS_TCXO_SUPPORTED"
2828
},
29+
"tcxo_ctrl": {
30+
"help": "TCXO Control voltage. Default: TCXO control TCXO_CTRL_1_7V (RAK3172SIP use TCXO_CTRL_3_0V)",
31+
"value": "TCXO_CTRL_1_7V"
32+
},
2933
"rf_switch_config": {
3034
"help": "Default: RBI_CONF_RFO_LP_HP = 0, RBI_CONF_RFO_LP = 1, RBI_CONF_RFO_HP = 2",
3135
"value": "RBI_CONF_RFO_LP_HP"
3236
},
37+
"rf_rfo_hp_lpfix": {
38+
"help": "Fix high power consumption when only RFO_HP is used on some boards. No fix = 0, Fix = 1",
39+
"value": 1
40+
},
3341
"rf_wakeup_time": {
3442
"help": "Radio maximum wakeup time (in ms)",
3543
"value": 10

0 commit comments

Comments
 (0)