Skip to content

Commit 530d4be

Browse files
authored
Merge pull request #14734 from jeromecoutant/PR_RFSWITCH
STM32WL LORA: HW specific out of STM32WL_LoRaRadio class
2 parents 86b85a3 + 777b273 commit 530d4be

File tree

3 files changed

+70
-63
lines changed

3 files changed

+70
-63
lines changed

connectivity/drivers/lora/TARGET_STM32WL/STM32WL_LoRaRadio.cpp

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,10 @@ static DigitalOut _rf_dbg_tx(MBED_CONF_STM32WL_LORA_DRIVER_DEBUG_TX, 0);
123123
#endif
124124

125125

126-
STM32WL_LoRaRadio::STM32WL_LoRaRadio(PinName rf_switch_ctrl1,
127-
PinName rf_switch_ctrl2,
128-
PinName rf_switch_ctrl3
129-
)
130-
:
131-
_rf_switch_ctrl1(rf_switch_ctrl1, 0),
132-
_rf_switch_ctrl2(rf_switch_ctrl2, 0),
133-
_rf_switch_ctrl3(rf_switch_ctrl3, 0)
134-
126+
STM32WL_LoRaRadio::STM32WL_LoRaRadio()
135127
{
128+
set_antenna_switch(RBI_SWITCH_OFF);
129+
136130
_radio_events = NULL;
137131
_image_calibrated = false;
138132
_force_image_calibration = false;
@@ -481,49 +475,6 @@ void STM32WL_LoRaRadio::Radio_SMPS_Set(uint8_t level)
481475
}
482476
}
483477

484-
/**
485-
* Sets up radio switch position according to the
486-
* radio mode
487-
*/
488-
void STM32WL_LoRaRadio::set_antenna_switch(RBI_Switch_TypeDef state)
489-
{
490-
// here we got to do ifdef for changing controls
491-
// as some pins might be NC
492-
switch (state) {
493-
case RBI_SWITCH_OFF: {
494-
/* Turn off switch */
495-
_rf_switch_ctrl3 = 0;
496-
_rf_switch_ctrl1 = 0;
497-
_rf_switch_ctrl2 = 0;
498-
break;
499-
}
500-
case RBI_SWITCH_RX: {
501-
/*Turns On in Rx Mode the RF Switch */
502-
_rf_switch_ctrl3 = 1;
503-
_rf_switch_ctrl1 = 1;
504-
_rf_switch_ctrl2 = 0;
505-
break;
506-
}
507-
case RBI_SWITCH_RFO_LP: {
508-
/*Turns On in Tx Low Power the RF Switch */
509-
_rf_switch_ctrl3 = 1;
510-
_rf_switch_ctrl1 = 1;
511-
_rf_switch_ctrl2 = 1;
512-
break;
513-
}
514-
case RBI_SWITCH_RFO_HP: {
515-
/*Turns On in Tx High Power the RF Switch */
516-
_rf_switch_ctrl3 = 1;
517-
_rf_switch_ctrl1 = 0;
518-
_rf_switch_ctrl2 = 1;
519-
break;
520-
}
521-
default:
522-
break;
523-
}
524-
}
525-
/* End STM32WL specific HW defs */
526-
527478
void STM32WL_LoRaRadio::calibrate_image(uint32_t freq)
528479
{
529480
uint8_t cal_freq[2];

connectivity/drivers/lora/TARGET_STM32WL/STM32WL_LoRaRadio.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,14 @@ SPDX-License-Identifier: BSD-3-Clause
5151
#define MAX_DATA_BUFFER_SIZE_STM32WL 255
5252
#endif
5353

54-
54+
extern void set_antenna_switch(RBI_Switch_TypeDef state);
5555

5656
class STM32WL_LoRaRadio : public LoRaRadio {
5757

5858
public:
59-
STM32WL_LoRaRadio(PinName rf_switch_ctrl1 = MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL1,
60-
PinName rf_switch_ctrl2 = MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL2,
61-
PinName rf_switch_ctrl3 = MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL3);
59+
STM32WL_LoRaRadio();
6260

63-
virtual ~STM32WL_LoRaRadio();
61+
~STM32WL_LoRaRadio();
6462

6563
/**
6664
* Registers radio events with the Mbed LoRaWAN stack and
@@ -315,11 +313,6 @@ class STM32WL_LoRaRadio : public LoRaRadio {
315313

316314
private:
317315

318-
// Radio specific controls (TX/RX duplexer switch control)
319-
mbed::DigitalOut _rf_switch_ctrl1;
320-
mbed::DigitalOut _rf_switch_ctrl2;
321-
mbed::DigitalOut _rf_switch_ctrl3;
322-
323316
// Access protection
324317
PlatformMutex mutex;
325318

@@ -369,7 +362,6 @@ class STM32WL_LoRaRadio : public LoRaRadio {
369362
uint8_t SUBGRF_SetRfTxPower(int8_t power);
370363
void SUBGRF_SetTxParams(uint8_t paSelect, int8_t power, radio_ramp_time_t rampTime);
371364
void Radio_SMPS_Set(uint8_t level);
372-
void set_antenna_switch(RBI_Switch_TypeDef state);
373365
uint32_t RadioGetWakeupTime(void);
374366

375367

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* mbed Microcontroller Library
2+
* SPDX-License-Identifier: BSD-3-Clause
3+
******************************************************************************
4+
*
5+
* Copyright (c) 2021 STMicroelectronics.
6+
* All rights reserved.
7+
*
8+
* This software component is licensed by ST under BSD 3-Clause license,
9+
* the "License"; You may not use this file except in compliance with the
10+
* License. You may obtain a copy of the License at:
11+
* opensource.org/licenses/BSD-3-Clause
12+
*
13+
******************************************************************************
14+
*/
15+
16+
#include "STM32WL_radio_driver.h"
17+
#include "drivers/DigitalOut.h"
18+
19+
20+
/* Sets up radio switch position according to the radio mode */
21+
/* This configuration is for NUCLEO_WL55JC */
22+
/* But provided as __weak so it has to be overwritten to match each specicific HW board */
23+
MBED_WEAK void set_antenna_switch(RBI_Switch_TypeDef state)
24+
{
25+
26+
// Radio specific controls (TX/RX duplexer switch control)
27+
mbed::DigitalOut _rf_switch_ctrl1(MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL1);
28+
mbed::DigitalOut _rf_switch_ctrl2(MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL2);
29+
mbed::DigitalOut _rf_switch_ctrl3(MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL3);
30+
31+
switch (state) {
32+
case RBI_SWITCH_OFF: {
33+
/* Turn off switch */
34+
_rf_switch_ctrl3 = 0;
35+
_rf_switch_ctrl1 = 0;
36+
_rf_switch_ctrl2 = 0;
37+
break;
38+
}
39+
case RBI_SWITCH_RX: {
40+
/*Turns On in Rx Mode the RF Switch */
41+
_rf_switch_ctrl3 = 1;
42+
_rf_switch_ctrl1 = 1;
43+
_rf_switch_ctrl2 = 0;
44+
break;
45+
}
46+
case RBI_SWITCH_RFO_LP: {
47+
/*Turns On in Tx Low Power the RF Switch */
48+
_rf_switch_ctrl3 = 1;
49+
_rf_switch_ctrl1 = 1;
50+
_rf_switch_ctrl2 = 1;
51+
break;
52+
}
53+
case RBI_SWITCH_RFO_HP: {
54+
/*Turns On in Tx High Power the RF Switch */
55+
_rf_switch_ctrl3 = 1;
56+
_rf_switch_ctrl1 = 0;
57+
_rf_switch_ctrl2 = 1;
58+
break;
59+
}
60+
default:
61+
break;
62+
}
63+
}
64+

0 commit comments

Comments
 (0)