2023-06-01 07:14:55 -05:00
|
|
|
#include "STM32WLE5JCInterface.h"
|
|
|
|
|
#include "configuration.h"
|
|
|
|
|
#include "error.h"
|
|
|
|
|
|
|
|
|
|
#ifndef STM32WLx_MAX_POWER
|
|
|
|
|
#define STM32WLx_MAX_POWER 22
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef ARCH_STM32WL
|
|
|
|
|
|
|
|
|
|
STM32WLE5JCInterface::STM32WLE5JCInterface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq,
|
|
|
|
|
RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy)
|
|
|
|
|
: SX126xInterface(hal, cs, irq, rst, busy)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool STM32WLE5JCInterface::init()
|
|
|
|
|
{
|
|
|
|
|
RadioLibInterface::init();
|
|
|
|
|
|
2025-03-21 16:12:27 +01:00
|
|
|
// https://github.com/Seeed-Studio/LoRaWan-E5-Node/blob/main/Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver/radio_driver.c
|
|
|
|
|
#if (!defined(_VARIANT_RAK3172_))
|
2025-02-15 16:06:10 +01:00
|
|
|
setTCXOVoltage(1.7);
|
2025-03-21 16:12:27 +01:00
|
|
|
#endif
|
2025-02-15 16:06:10 +01:00
|
|
|
|
2023-06-01 07:14:55 -05:00
|
|
|
lora.setRfSwitchTable(rfswitch_pins, rfswitch_table);
|
|
|
|
|
|
2025-05-25 18:26:31 +07:00
|
|
|
limitPower();
|
|
|
|
|
|
2023-06-01 07:14:55 -05:00
|
|
|
if (power > STM32WLx_MAX_POWER) // This chip has lower power limits than some
|
|
|
|
|
power = STM32WLx_MAX_POWER;
|
|
|
|
|
|
|
|
|
|
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage);
|
|
|
|
|
|
2024-10-14 06:11:43 +02:00
|
|
|
LOG_INFO("STM32WLx init result %d", res);
|
2023-06-01 07:14:55 -05:00
|
|
|
|
2024-10-14 06:11:43 +02:00
|
|
|
LOG_INFO("Frequency set to %f", getFreq());
|
|
|
|
|
LOG_INFO("Bandwidth set to %f", bw);
|
|
|
|
|
LOG_INFO("Power output set to %d", power);
|
2023-06-01 07:14:55 -05:00
|
|
|
|
|
|
|
|
if (res == RADIOLIB_ERR_NONE)
|
|
|
|
|
startReceive(); // start receiving
|
|
|
|
|
|
|
|
|
|
return res == RADIOLIB_ERR_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-21 16:12:27 +01:00
|
|
|
#endif // ARCH_STM32WL
|