eculocate

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 13b0868488f8137ad1bd059b876c404a1c8fef7e
parent 9a958895231bf44ec5a0155bcbde3d9f450ad20a
Author: Daniel Barlow <dan@telent.net>
Date:   Sun,  1 Feb 2026 00:17:24 +0000

esp_radio Controller is shared between wifi, ble

in preparation for adding ble, move its creation into main and
pass the object into wifi

Diffstat:
Mecu-esp32/src/main.rs | 13+++++++++++++
Mecu-esp32/src/wifi.rs | 2+-
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/ecu-esp32/src/main.rs b/ecu-esp32/src/main.rs @@ -24,6 +24,7 @@ use embassy_executor::Spawner; use embassy_futures::join::join; use embassy_time::Timer; +use esp_radio::Controller; use log::{info}; @@ -40,6 +41,15 @@ esp_bootloader_esp_idf::esp_app_desc!(); const BUILD_ID: &str = env!("BUILD_ID"); +macro_rules! mk_static { + ($t:ty,$val:expr) => {{ + static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new(); + #[deny(unused_attributes)] + let x = STATIC_CELL.uninit().write(($val)); + x + }}; +} + // #[main] #[esp_rtos::main] async fn main(s : Spawner) { @@ -71,7 +81,10 @@ async fn main(s : Spawner) { let flasher = Flasher::new(peripherals.FLASH, peripherals.SHA); join( + let esp_radio_ctrl = // esp_radio::init().expect("esp_radio init failed"); + &*mk_static!(Controller<'static>, esp_radio::init().unwrap()); crate::wifi::start_wifi(&s, + esp_radio_ctrl, flasher, peripherals.WIFI, &mut ecu), diff --git a/ecu-esp32/src/wifi.rs b/ecu-esp32/src/wifi.rs @@ -132,12 +132,12 @@ impl SessionStore { pub async fn start_wifi(spawner: &Spawner, + esp_radio_ctrl: &'static Controller<'static>, flasher: crate::ota::Flasher<'_>, wifi_peripheral: esp_hal::peripherals::WIFI<'static>, ecu: &mut crate::ecu::Ecu<'_>) { - let esp_radio_ctrl = &*mk_static!(Controller<'static>, esp_radio::init().unwrap()); let (controller, interfaces) = esp_radio::wifi::new(esp_radio_ctrl, wifi_peripheral, Default::default()).unwrap();