mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-11-21 22:47:05 +00:00
Adds repeater, room_server, companion_radio_usb and kiss_modem environments for the NUCLEO-WL55JC1 (STM32WL55JC, integrated SubGHz radio). Notes on the board setup: - Uses the upstream nucleo_wl55jc board. PlatformIO's boards_remap maps it to the core's NUCLEO_WL55JC1 variant, so the LEDs, user buttons and the LPUART1 -> ST-LINK VCP serial mapping all come from the core rather than being redefined here. - The RF switch table is built from the core's LORAWAN_RFSWITCH_* macros (SP3T front end on PC3/PC4/PC5) so it tracks upstream if those are ever revised. Both RFO_LP and RFO_HP are registered, so RadioLib selects HP above 14 dBm and LP below it. - board_build.extra_flags pins the device to STM32WL55xx. The stock board manifest declares product_line STM32WL55xx but extra_flags -DSTM32WLE5xx; that only works because every #elif chain happens to test WL55xx first. - The Nucleo's LD1..LD3 are driven active HIGH, so the TX LED hooks are inverted relative to STM32Board's active-LOW default. - 32 KB reserved at the top of flash for LittleFS, as on the other STM32WL variants. Verified on hardware: all four environments build; repeater and room_server flash and run over ST-LINK; identity and prefs persist across reboot and across a firmware swap; and GPIOC reads back the documented RX levels at idle, confirming the front-end switch is driven correctly. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
66 lines
1.9 KiB
C++
66 lines
1.9 KiB
C++
#include <Arduino.h>
|
|
#include "target.h"
|
|
#include <helpers/ArduinoHelpers.h>
|
|
|
|
NucleoWL55JCBoard board;
|
|
|
|
RADIO_CLASS radio = new STM32WLx_Module();
|
|
|
|
WRAPPER_CLASS radio_driver(radio, board);
|
|
|
|
// The NUCLEO-WL55JC1 drives an SP3T front-end switch from FE_CTRL1..3 (PC4, PC5, PC3),
|
|
// routing the single SMA between RX, RFO_LP and RFO_HP. Pin order and levels are taken
|
|
// straight from the core's board definition (variant_NUCLEO_WL55JC1.h) so they stay in
|
|
// sync with upstream.
|
|
static const uint32_t rfswitch_pins[] = {LORAWAN_RFSWITCH_PINS, RADIOLIB_NC, RADIOLIB_NC};
|
|
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
|
{STM32WLx::MODE_IDLE, {LORAWAN_RFSWITCH_OFF_VALUES}},
|
|
{STM32WLx::MODE_RX, {LORAWAN_RFSWITCH_RX_VALUES}},
|
|
{STM32WLx::MODE_TX_LP, {LORAWAN_RFSWITCH_RFO_LP_VALUES}},
|
|
{STM32WLx::MODE_TX_HP, {LORAWAN_RFSWITCH_RFO_HP_VALUES}},
|
|
END_OF_MODE_TABLE,
|
|
};
|
|
|
|
VolatileRTCClock rtc_clock;
|
|
SensorManager sensors;
|
|
|
|
#ifndef LORA_CR
|
|
#define LORA_CR 5
|
|
#endif
|
|
|
|
#ifndef STM32WL_TCXO_VOLTAGE
|
|
// The board is fitted with a 32MHz TCXO powered from the radio's DIO3 at 1.7V
|
|
#define STM32WL_TCXO_VOLTAGE 1.7
|
|
#endif
|
|
|
|
#ifndef LORA_TX_POWER
|
|
#define LORA_TX_POWER 22
|
|
#endif
|
|
|
|
bool radio_init() {
|
|
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
|
|
|
|
// Both PA paths are registered above, so RadioLib picks RFO_HP whenever the
|
|
// requested power is above 14dBm, and RFO_LP below that.
|
|
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, STM32WL_TCXO_VOLTAGE, 0);
|
|
|
|
if (status != RADIOLIB_ERR_NONE) {
|
|
Serial.print("ERROR: radio init failed: ");
|
|
Serial.println(status);
|
|
return false; // fail
|
|
}
|
|
|
|
#ifdef RX_BOOSTED_GAIN
|
|
radio.setRxBoostedGainMode(RX_BOOSTED_GAIN);
|
|
#endif
|
|
|
|
radio.setCRC(1);
|
|
|
|
return true; // success
|
|
}
|
|
|
|
mesh::LocalIdentity radio_new_identity() {
|
|
RadioNoiseListener rng(radio);
|
|
return mesh::LocalIdentity(&rng); // create new random identity
|
|
}
|