mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #14734 from jeromecoutant/PR_RFSWITCH
STM32WL LORA: HW specific out of STM32WL_LoRaRadio classpull/14768/head
commit
530d4beea5
|
@ -123,16 +123,10 @@ static DigitalOut _rf_dbg_tx(MBED_CONF_STM32WL_LORA_DRIVER_DEBUG_TX, 0);
|
|||
#endif
|
||||
|
||||
|
||||
STM32WL_LoRaRadio::STM32WL_LoRaRadio(PinName rf_switch_ctrl1,
|
||||
PinName rf_switch_ctrl2,
|
||||
PinName rf_switch_ctrl3
|
||||
)
|
||||
:
|
||||
_rf_switch_ctrl1(rf_switch_ctrl1, 0),
|
||||
_rf_switch_ctrl2(rf_switch_ctrl2, 0),
|
||||
_rf_switch_ctrl3(rf_switch_ctrl3, 0)
|
||||
|
||||
STM32WL_LoRaRadio::STM32WL_LoRaRadio()
|
||||
{
|
||||
set_antenna_switch(RBI_SWITCH_OFF);
|
||||
|
||||
_radio_events = NULL;
|
||||
_image_calibrated = false;
|
||||
_force_image_calibration = false;
|
||||
|
@ -481,49 +475,6 @@ void STM32WL_LoRaRadio::Radio_SMPS_Set(uint8_t level)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up radio switch position according to the
|
||||
* radio mode
|
||||
*/
|
||||
void STM32WL_LoRaRadio::set_antenna_switch(RBI_Switch_TypeDef state)
|
||||
{
|
||||
// here we got to do ifdef for changing controls
|
||||
// as some pins might be NC
|
||||
switch (state) {
|
||||
case RBI_SWITCH_OFF: {
|
||||
/* Turn off switch */
|
||||
_rf_switch_ctrl3 = 0;
|
||||
_rf_switch_ctrl1 = 0;
|
||||
_rf_switch_ctrl2 = 0;
|
||||
break;
|
||||
}
|
||||
case RBI_SWITCH_RX: {
|
||||
/*Turns On in Rx Mode the RF Switch */
|
||||
_rf_switch_ctrl3 = 1;
|
||||
_rf_switch_ctrl1 = 1;
|
||||
_rf_switch_ctrl2 = 0;
|
||||
break;
|
||||
}
|
||||
case RBI_SWITCH_RFO_LP: {
|
||||
/*Turns On in Tx Low Power the RF Switch */
|
||||
_rf_switch_ctrl3 = 1;
|
||||
_rf_switch_ctrl1 = 1;
|
||||
_rf_switch_ctrl2 = 1;
|
||||
break;
|
||||
}
|
||||
case RBI_SWITCH_RFO_HP: {
|
||||
/*Turns On in Tx High Power the RF Switch */
|
||||
_rf_switch_ctrl3 = 1;
|
||||
_rf_switch_ctrl1 = 0;
|
||||
_rf_switch_ctrl2 = 1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* End STM32WL specific HW defs */
|
||||
|
||||
void STM32WL_LoRaRadio::calibrate_image(uint32_t freq)
|
||||
{
|
||||
uint8_t cal_freq[2];
|
||||
|
|
|
@ -51,16 +51,14 @@ SPDX-License-Identifier: BSD-3-Clause
|
|||
#define MAX_DATA_BUFFER_SIZE_STM32WL 255
|
||||
#endif
|
||||
|
||||
|
||||
extern void set_antenna_switch(RBI_Switch_TypeDef state);
|
||||
|
||||
class STM32WL_LoRaRadio : public LoRaRadio {
|
||||
|
||||
public:
|
||||
STM32WL_LoRaRadio(PinName rf_switch_ctrl1 = MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL1,
|
||||
PinName rf_switch_ctrl2 = MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL2,
|
||||
PinName rf_switch_ctrl3 = MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL3);
|
||||
STM32WL_LoRaRadio();
|
||||
|
||||
virtual ~STM32WL_LoRaRadio();
|
||||
~STM32WL_LoRaRadio();
|
||||
|
||||
/**
|
||||
* Registers radio events with the Mbed LoRaWAN stack and
|
||||
|
@ -315,11 +313,6 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
// Radio specific controls (TX/RX duplexer switch control)
|
||||
mbed::DigitalOut _rf_switch_ctrl1;
|
||||
mbed::DigitalOut _rf_switch_ctrl2;
|
||||
mbed::DigitalOut _rf_switch_ctrl3;
|
||||
|
||||
// Access protection
|
||||
PlatformMutex mutex;
|
||||
|
||||
|
@ -369,7 +362,6 @@ private:
|
|||
uint8_t SUBGRF_SetRfTxPower(int8_t power);
|
||||
void SUBGRF_SetTxParams(uint8_t paSelect, int8_t power, radio_ramp_time_t rampTime);
|
||||
void Radio_SMPS_Set(uint8_t level);
|
||||
void set_antenna_switch(RBI_Switch_TypeDef state);
|
||||
uint32_t RadioGetWakeupTime(void);
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/* mbed Microcontroller Library
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "STM32WL_radio_driver.h"
|
||||
#include "drivers/DigitalOut.h"
|
||||
|
||||
|
||||
/* Sets up radio switch position according to the radio mode */
|
||||
/* This configuration is for NUCLEO_WL55JC */
|
||||
/* But provided as __weak so it has to be overwritten to match each specicific HW board */
|
||||
MBED_WEAK void set_antenna_switch(RBI_Switch_TypeDef state)
|
||||
{
|
||||
|
||||
// Radio specific controls (TX/RX duplexer switch control)
|
||||
mbed::DigitalOut _rf_switch_ctrl1(MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL1);
|
||||
mbed::DigitalOut _rf_switch_ctrl2(MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL2);
|
||||
mbed::DigitalOut _rf_switch_ctrl3(MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL3);
|
||||
|
||||
switch (state) {
|
||||
case RBI_SWITCH_OFF: {
|
||||
/* Turn off switch */
|
||||
_rf_switch_ctrl3 = 0;
|
||||
_rf_switch_ctrl1 = 0;
|
||||
_rf_switch_ctrl2 = 0;
|
||||
break;
|
||||
}
|
||||
case RBI_SWITCH_RX: {
|
||||
/*Turns On in Rx Mode the RF Switch */
|
||||
_rf_switch_ctrl3 = 1;
|
||||
_rf_switch_ctrl1 = 1;
|
||||
_rf_switch_ctrl2 = 0;
|
||||
break;
|
||||
}
|
||||
case RBI_SWITCH_RFO_LP: {
|
||||
/*Turns On in Tx Low Power the RF Switch */
|
||||
_rf_switch_ctrl3 = 1;
|
||||
_rf_switch_ctrl1 = 1;
|
||||
_rf_switch_ctrl2 = 1;
|
||||
break;
|
||||
}
|
||||
case RBI_SWITCH_RFO_HP: {
|
||||
/*Turns On in Tx High Power the RF Switch */
|
||||
_rf_switch_ctrl3 = 1;
|
||||
_rf_switch_ctrl1 = 0;
|
||||
_rf_switch_ctrl2 = 1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue