Integrate W12 RF switching and LR2021 receive PRs

Adapt upstream MeshCore #3579 at 7457cff43c22697119e06ad7d192a37de0990403:
retain GC1109 LF standby bias, with checked cold controls before band supply
changes and shutdown. Preserve exclusive LF/HF rails and TX error cleanup.
Reset before boot rail changes and before SPI-dependent hard recovery.

Retain our stronger implementation of #3512 at
d208bfef94ab83280de30ba4a0675ff73b3ecef3. Add regressions for suspect FIFO
contents, failed RX_DONE acknowledgement, and fresh preamble timing.
W12 TX power defaults from #3319 were already included via 65aa1138a.

Validation: 79 targeted native tests; canonical W12 Full repeater and Full
Companion builds, capability checks, app-size and RAM checks passed.
Physical W12 RF envelope, current and LoRa management confirmation remain.

Upstream PRs:
https://github.com/meshcore-dev/MeshCore/pull/3579
https://github.com/meshcore-dev/MeshCore/pull/3512
https://github.com/meshcore-dev/MeshCore/pull/3319
This commit is contained in:
mikecarper committed 2026-10-25 15:46:18 -07:00
1 parent 73c5f572eb
commit ad34fd3a0d
15 files changed
+514 -137

No files matched your search

+20 -4
View File
@@ -16,7 +16,7 @@
#define LR2021_USE_DCDC 0
#endif
// Board-specific FEM warm-up. Do not leave a PA enabled in ordinary standby.
// Optional board-specific FEM settling; the RF table defines standby bias.
#ifndef LR2021_TX_PREARM_MS
#define LR2021_TX_PREARM_MS 0
#endif
@@ -72,8 +72,9 @@ class CustomLR2021 : public LR2021 {
}
int16_t prepareTxRfSwitch() {
// stageMode(TX) does not enter standby. Stop RX before temporarily enabling
// the LF PA there; HF routing and boards without this opt-in are unchanged.
// stageMode(TX) does not enter standby. Stop RX before settling the LF PA.
// A warm standby table (W12 PR #3579) retains its original DIO masks;
// other tables temporarily add the TX bias only for this preparation.
int16_t status = standby();
if (status == RADIOLIB_ERR_NONE && !mesh::lr2021::isHighBand(freqMHz)) {
status = setTxStandbyMask(true);
@@ -124,7 +125,9 @@ class CustomLR2021 : public LR2021 {
#if LR2021_TX_PREARM_MS > 0
_tx_standby_armed = false;
#endif
return RADIOLIB_ERR_NONE;
// Some DIO implementations latch a new mask only on a mode transition.
// Reset restoration must physically select the restored standby outputs.
return LR2021::standby();
}
uint8_t rfSwitchRxMode() const {
@@ -264,6 +267,17 @@ class CustomLR2021 : public LR2021 {
return true; // success
}
int16_t replaceRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS],
const Module::RfSwitchMode_t table[]) {
// Used by W12 supply transitions. Keep the old rail powered until a
// checked cold standby has confirmed every control output is low.
int16_t status = LR2021::standby();
if (status != RADIOLIB_ERR_NONE) return status;
for (size_t i = 0; i < Module::RFSWITCH_MAX_PINS; ++i) _rf_switch_pins[i] = pins[i];
_rf_switch_table = table;
return restoreRfSwitchTable();
}
void setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS],
const Module::RfSwitchMode_t table[]) {
for (size_t i = 0; i < Module::RFSWITCH_MAX_PINS; i++) {
@@ -421,6 +435,8 @@ class CustomLR2021 : public LR2021 {
}
int16_t readData(uint8_t* data, size_t len) override {
// PR #3512 (d208bfef): reject continuous-RX FIFO races. The wrapper
// stops RX before this snapshot; reject errors/mismatches before copying.
uint16_t fifo_level = 0;
const int16_t status = getRxFifoLevel(&fifo_level);
if (status != RADIOLIB_ERR_NONE) return status;
+3 -1
View File
@@ -59,9 +59,11 @@ protected:
float morseReceiverBandwidthKHz() const override { return 4.8f; }
int16_t prepareMorseReceiver(float frequency_mhz) override {
if (!supportsRadioDeepInit()) return RADIOLIB_ERR_UNSUPPORTED;
if (!_board->prepareRadioFrequency(frequency_mhz)) return RADIOLIB_ERR_INVALID_FREQUENCY;
_morse_rx_fsk_mode = true;
// W12's rail preparation checks DIO routing over SPI. Recover a failed
// transceiver before asking it to quiesce controls for a band change.
if (!prepareRadioHardReset()) return RADIOLIB_ERR_CHIP_NOT_FOUND;
if (!_board->prepareRadioFrequency(frequency_mhz)) return RADIOLIB_ERR_INVALID_FREQUENCY;
const int16_t status = static_cast<CustomLR2021*>(_radio)->beginMorseReceive(frequency_mhz);
const bool finished = _board->finishRadioHardReset();
return status == RADIOLIB_ERR_NONE && !finished ? RADIOLIB_ERR_UNKNOWN : status;