From b8b7880a482dfdb9ca1b5acde34dfcb8fb37dd3b Mon Sep 17 00:00:00 2001 From: mikecarper Date: Fri, 23 Oct 2026 01:39:08 -0700 Subject: [PATCH] Use 8 MHz buffered radio SPI on RAK3401 --- test/test_rak3401_buffered_radio_hal.py | 4 ++-- test/test_rak3401_onboard_radio.py | 2 +- variants/rak3401/target.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_rak3401_buffered_radio_hal.py b/test/test_rak3401_buffered_radio_hal.py index 8c54b4c11..66d54fb2b 100644 --- a/test/test_rak3401_buffered_radio_hal.py +++ b/test/test_rak3401_buffered_radio_hal.py @@ -60,7 +60,7 @@ struct Module { Module(ArduinoHal* adapter, unsigned cs, unsigned irq, unsigned rst, unsigned busy) : hal(adapter) { assert(cs==1 && irq==2 && rst==3 && busy==4); - assert(hal->spi == &SPI1 && hal->spiSettings.hz == 2000000); + assert(hal->spi == &SPI1 && hal->spiSettings.hz == 8000000); } }; struct Radio { @@ -97,7 +97,7 @@ int main() { class Rak3401BufferedRadioHalTests(unittest.TestCase): - def test_actual_target_uses_one_transfer_per_command_on_same_2mhz_spi1(self): + def test_actual_target_uses_one_transfer_per_command_on_same_spi1_at_8mhz(self): target = (ROOT / "variants/rak3401/target.cpp").read_text(encoding="ascii") construction = "\n".join(re.findall( r"^(?:static Nrf52BufferedRadioHal radioHal\([^;]+;|" diff --git a/test/test_rak3401_onboard_radio.py b/test/test_rak3401_onboard_radio.py index 17508ea94..9353da1bc 100644 --- a/test/test_rak3401_onboard_radio.py +++ b/test/test_rak3401_onboard_radio.py @@ -471,7 +471,7 @@ class Rak3401OnboardRadioTests(unittest.TestCase): self.assertIn("P_LORA_RESET, P_LORA_BUSY, SPI)", target) # External-radio construction and retry must retain their SPI1 owner. external_target = (VARIANT / "target.cpp").read_text() - self.assertIn("Nrf52BufferedRadioHal radioHal(SPI1, 2000000)", external_target) + self.assertIn("Nrf52BufferedRadioHal radioHal(SPI1, 8000000)", external_target) self.assertIn("new Module(&radioHal, P_LORA_NSS, P_LORA_DIO_1, " "P_LORA_RESET, P_LORA_BUSY)", external_target) external_init = extract_braced(external_target, "bool radio_init()") diff --git a/variants/rak3401/target.cpp b/variants/rak3401/target.cpp index 682d80685..c9453f587 100644 --- a/variants/rak3401/target.cpp +++ b/variants/rak3401/target.cpp @@ -126,9 +126,9 @@ RAK3401Board board; // controller instance for startup and watchdog recovery; resetting the radio // must not replace or tear down the SPI object used by its Module. // Batch each RadioLib command into one SPIM transfer rather than starting a -// transfer per byte. Retain the existing 2 MHz clock and RadioLib's BUSY, +// transfer per byte. Use the SPI1-supported 8 MHz clock and retain RadioLib's BUSY, // chip-select, command status, and IRQ handling. -static Nrf52BufferedRadioHal radioHal(SPI1, 2000000); +static Nrf52BufferedRadioHal radioHal(SPI1, 8000000); RADIO_CLASS radio = new Module(&radioHal, P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY); WRAPPER_CLASS radio_driver(radio, board);