Skip to content

STM32WL preparation for new chip rak3172sip #15312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions connectivity/drivers/lora/TARGET_STM32WL/STM32WL_LoRaRadio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ uint8_t crystal_select = MBED_CONF_STM32WL_LORA_DRIVER_CRYSTAL_SELECT;

uint8_t board_rf_switch_config = MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CONFIG;

radio_TCXO_ctrl_voltage_t tcxo_ctrl = MBED_CONF_STM32WL_LORA_DRIVER_TCXO_CTRL;


static void SUBGHZ_Radio_IRQHandler(void);

Expand All @@ -76,12 +78,6 @@ static uint8_t _active_modem;
using namespace std::chrono;
using namespace mbed;


/**
* @brief voltage of vdd tcxo.
*/
#define TCXO_CTRL_VOLTAGE TCXO_CTRL_1_7V

/*!
* FSK bandwidth definition
*/
Expand Down Expand Up @@ -466,7 +462,9 @@ void STM32WL_LoRaRadio::SUBGRF_SetTxParams(uint8_t paSelect, int8_t power, radio
// 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) {
// So if we set also rfo_hp_lpfix to 1 then optimize power
// See https://github.com/ARMmbed/mbed-os/pull/15017#issuecomment-1173455762
if (board_rf_switch_config == RBI_CONF_RFO_HP && MBED_CONF_STM32WL_LORA_DRIVER_RF_RFO_HP_LPFIX == 1) {
// 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) {
Expand Down Expand Up @@ -633,7 +631,7 @@ void STM32WL_LoRaRadio::cold_start_wakeup()
if (crystal_select == 1) {
calibration_params_t calib_param;

SUBGRF_SetTcxoMode(TCXO_CTRL_VOLTAGE, MBED_CONF_STM32WL_LORA_DRIVER_RF_WAKEUP_TIME << 6); //100 ms
SUBGRF_SetTcxoMode(tcxo_ctrl, MBED_CONF_STM32WL_LORA_DRIVER_RF_WAKEUP_TIME << 6); //100 ms

calib_param.value = 0x7F;
write_opmode_command(RADIO_CALIBRATE, &calib_param.value, 1);
Expand Down
15 changes: 12 additions & 3 deletions connectivity/drivers/lora/TARGET_STM32WL/STM32WL_radio_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,18 @@
#define RFO_HP 2

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

typedef enum {
RBI_SWITCH_OFF = 0,
Expand Down
8 changes: 8 additions & 0 deletions connectivity/drivers/lora/TARGET_STM32WL/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@
"help": "Default: Internal XO = 0, IS_TCXO_SUPPORTED = 1",
"value": "IS_TCXO_SUPPORTED"
},
"tcxo_ctrl": {
"help": "TCXO Control voltage. Default: TCXO control TCXO_CTRL_1_7V (RAK3172SIP use TCXO_CTRL_3_0V)",
"value": "TCXO_CTRL_1_7V"
},
"rf_switch_config": {
"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_rfo_hp_lpfix": {
"help": "Fix high power consumption when only RFO_HP is used on some boards. No fix = 0, Fix = 1",
"value": 1
},
"rf_wakeup_time": {
"help": "Radio maximum wakeup time (in ms)",
"value": 10
Expand Down