diff options
| author | Ulf Lilleengen <[email protected]> | 2023-12-21 08:50:54 +0100 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2023-12-21 10:29:57 +0100 |
| commit | 0acf7b09c3bc9176d00479d601356d8df2537a9b (patch) | |
| tree | 7a04543c661b38b6aba8893c9150ef8090199ee5 | |
| parent | d832d45c0ba5f2624a5f5c1e549e2d7fe8bd0e01 (diff) | |
chore: replace make_static! macro usage with non-macro version
37 files changed, 313 insertions, 188 deletions
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs index bf1468642..d970d0332 100644 --- a/embassy-net/src/lib.rs +++ b/embassy-net/src/lib.rs | |||
| @@ -411,10 +411,12 @@ impl<D: Driver> Stack<D> { | |||
| 411 | /// ```ignore | 411 | /// ```ignore |
| 412 | /// let config = embassy_net::Config::dhcpv4(Default::default()); | 412 | /// let config = embassy_net::Config::dhcpv4(Default::default()); |
| 413 | ///// Init network stack | 413 | ///// Init network stack |
| 414 | /// let stack = &*make_static!(embassy_net::Stack::new( | 414 | /// static RESOURCES: StaticCell<embassy_net::StackResources<2> = StaticCell::new(); |
| 415 | /// static STACK: StaticCell<embassy_net::Stack> = StaticCell::new(); | ||
| 416 | /// let stack = &*STACK.init(embassy_net::Stack::new( | ||
| 415 | /// device, | 417 | /// device, |
| 416 | /// config, | 418 | /// config, |
| 417 | /// make_static!(embassy_net::StackResources::<2>::new()), | 419 | /// RESOURCES.init(embassy_net::StackResources::new()), |
| 418 | /// seed | 420 | /// seed |
| 419 | /// )); | 421 | /// )); |
| 420 | /// // Launch network task that runs `stack.run().await` | 422 | /// // Launch network task that runs `stack.run().await` |
diff --git a/embassy-stm32/src/low_power.rs b/embassy-stm32/src/low_power.rs index a41c40eba..4fab8dae4 100644 --- a/embassy-stm32/src/low_power.rs +++ b/embassy-stm32/src/low_power.rs | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | //! use embassy_executor::Spawner; | 24 | //! use embassy_executor::Spawner; |
| 25 | //! use embassy_stm32::low_power::Executor; | 25 | //! use embassy_stm32::low_power::Executor; |
| 26 | //! use embassy_stm32::rtc::{Rtc, RtcConfig}; | 26 | //! use embassy_stm32::rtc::{Rtc, RtcConfig}; |
| 27 | //! use static_cell::make_static; | 27 | //! use static_cell::StaticCell; |
| 28 | //! | 28 | //! |
| 29 | //! #[cortex_m_rt::entry] | 29 | //! #[cortex_m_rt::entry] |
| 30 | //! fn main() -> ! { | 30 | //! fn main() -> ! { |
| @@ -41,7 +41,8 @@ | |||
| 41 | //! | 41 | //! |
| 42 | //! // give the RTC to the executor... | 42 | //! // give the RTC to the executor... |
| 43 | //! let mut rtc = Rtc::new(p.RTC, RtcConfig::default()); | 43 | //! let mut rtc = Rtc::new(p.RTC, RtcConfig::default()); |
| 44 | //! let rtc = make_static!(rtc); | 44 | //! static RTC: StaticCell<Rtc> = StaticCell::new(); |
| 45 | //! let rtc = RTC.init(rtc); | ||
| 45 | //! embassy_stm32::low_power::stop_with_rtc(rtc); | 46 | //! embassy_stm32::low_power::stop_with_rtc(rtc); |
| 46 | //! | 47 | //! |
| 47 | //! // your application here... | 48 | //! // your application here... |
diff --git a/examples/nrf52840/src/bin/ethernet_enc28j60.rs b/examples/nrf52840/src/bin/ethernet_enc28j60.rs index d1b796fab..840a16556 100644 --- a/examples/nrf52840/src/bin/ethernet_enc28j60.rs +++ b/examples/nrf52840/src/bin/ethernet_enc28j60.rs | |||
| @@ -14,7 +14,7 @@ use embassy_nrf::{bind_interrupts, peripherals, spim}; | |||
| 14 | use embassy_time::Delay; | 14 | use embassy_time::Delay; |
| 15 | use embedded_hal_bus::spi::ExclusiveDevice; | 15 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 16 | use embedded_io_async::Write; | 16 | use embedded_io_async::Write; |
| 17 | use static_cell::make_static; | 17 | use static_cell::StaticCell; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | bind_interrupts!(struct Irqs { | 20 | bind_interrupts!(struct Irqs { |
| @@ -70,11 +70,20 @@ async fn main(spawner: Spawner) { | |||
| 70 | let seed = u64::from_le_bytes(seed); | 70 | let seed = u64::from_le_bytes(seed); |
| 71 | 71 | ||
| 72 | // Init network stack | 72 | // Init network stack |
| 73 | let stack = &*make_static!(Stack::new( | 73 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); |
| 74 | static STACK: StaticCell< | ||
| 75 | Stack< | ||
| 76 | Enc28j60< | ||
| 77 | ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_15>, Delay>, | ||
| 78 | Output<'static, peripherals::P0_13>, | ||
| 79 | >, | ||
| 80 | >, | ||
| 81 | > = StaticCell::new(); | ||
| 82 | let stack = STACK.init(Stack::new( | ||
| 74 | device, | 83 | device, |
| 75 | config, | 84 | config, |
| 76 | make_static!(StackResources::<2>::new()), | 85 | RESOURCES.init(StackResources::<2>::new()), |
| 77 | seed | 86 | seed, |
| 78 | )); | 87 | )); |
| 79 | 88 | ||
| 80 | unwrap!(spawner.spawn(net_task(stack))); | 89 | unwrap!(spawner.spawn(net_task(stack))); |
diff --git a/examples/nrf52840/src/bin/usb_ethernet.rs b/examples/nrf52840/src/bin/usb_ethernet.rs index b7806f418..de661c019 100644 --- a/examples/nrf52840/src/bin/usb_ethernet.rs +++ b/examples/nrf52840/src/bin/usb_ethernet.rs | |||
| @@ -16,7 +16,7 @@ use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState | |||
| 16 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | 16 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; |
| 17 | use embassy_usb::{Builder, Config, UsbDevice}; | 17 | use embassy_usb::{Builder, Config, UsbDevice}; |
| 18 | use embedded_io_async::Write; | 18 | use embedded_io_async::Write; |
| 19 | use static_cell::make_static; | 19 | use static_cell::StaticCell; |
| 20 | use {defmt_rtt as _, panic_probe as _}; | 20 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 21 | ||
| 22 | bind_interrupts!(struct Irqs { | 22 | bind_interrupts!(struct Irqs { |
| @@ -71,14 +71,19 @@ async fn main(spawner: Spawner) { | |||
| 71 | config.device_protocol = 0x01; | 71 | config.device_protocol = 0x01; |
| 72 | 72 | ||
| 73 | // Create embassy-usb DeviceBuilder using the driver and config. | 73 | // Create embassy-usb DeviceBuilder using the driver and config. |
| 74 | static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 75 | static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 76 | static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 77 | static MSOS_DESC: StaticCell<[u8; 128]> = StaticCell::new(); | ||
| 78 | static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new(); | ||
| 74 | let mut builder = Builder::new( | 79 | let mut builder = Builder::new( |
| 75 | driver, | 80 | driver, |
| 76 | config, | 81 | config, |
| 77 | &mut make_static!([0; 256])[..], | 82 | &mut DEVICE_DESC.init([0; 256])[..], |
| 78 | &mut make_static!([0; 256])[..], | 83 | &mut CONFIG_DESC.init([0; 256])[..], |
| 79 | &mut make_static!([0; 256])[..], | 84 | &mut BOS_DESC.init([0; 256])[..], |
| 80 | &mut make_static!([0; 128])[..], | 85 | &mut MSOS_DESC.init([0; 128])[..], |
| 81 | &mut make_static!([0; 128])[..], | 86 | &mut CONTROL_BUF.init([0; 128])[..], |
| 82 | ); | 87 | ); |
| 83 | 88 | ||
| 84 | // Our MAC addr. | 89 | // Our MAC addr. |
| @@ -87,14 +92,16 @@ async fn main(spawner: Spawner) { | |||
| 87 | let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88]; | 92 | let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88]; |
| 88 | 93 | ||
| 89 | // Create classes on the builder. | 94 | // Create classes on the builder. |
| 90 | let class = CdcNcmClass::new(&mut builder, make_static!(State::new()), host_mac_addr, 64); | 95 | static STATE: StaticCell<State> = StaticCell::new(); |
| 96 | let class = CdcNcmClass::new(&mut builder, STATE.init(State::new()), host_mac_addr, 64); | ||
| 91 | 97 | ||
| 92 | // Build the builder. | 98 | // Build the builder. |
| 93 | let usb = builder.build(); | 99 | let usb = builder.build(); |
| 94 | 100 | ||
| 95 | unwrap!(spawner.spawn(usb_task(usb))); | 101 | unwrap!(spawner.spawn(usb_task(usb))); |
| 96 | 102 | ||
| 97 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); | 103 | static NET_STATE: StaticCell<NetState<MTU, 4, 4>> = StaticCell::new(); |
| 104 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(NET_STATE.init(NetState::new()), our_mac_addr); | ||
| 98 | unwrap!(spawner.spawn(usb_ncm_task(runner))); | 105 | unwrap!(spawner.spawn(usb_ncm_task(runner))); |
| 99 | 106 | ||
| 100 | let config = embassy_net::Config::dhcpv4(Default::default()); | 107 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| @@ -111,12 +118,9 @@ async fn main(spawner: Spawner) { | |||
| 111 | let seed = u64::from_le_bytes(seed); | 118 | let seed = u64::from_le_bytes(seed); |
| 112 | 119 | ||
| 113 | // Init network stack | 120 | // Init network stack |
| 114 | let stack = &*make_static!(Stack::new( | 121 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); |
| 115 | device, | 122 | static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new(); |
| 116 | config, | 123 | let stack = &*STACK.init(Stack::new(device, config, RESOURCES.init(StackResources::new()), seed)); |
| 117 | make_static!(StackResources::<2>::new()), | ||
| 118 | seed | ||
| 119 | )); | ||
| 120 | 124 | ||
| 121 | unwrap!(spawner.spawn(net_task(stack))); | 125 | unwrap!(spawner.spawn(net_task(stack))); |
| 122 | 126 | ||
diff --git a/examples/nrf52840/src/bin/usb_serial_multitask.rs b/examples/nrf52840/src/bin/usb_serial_multitask.rs index cd4392903..7a7bf962b 100644 --- a/examples/nrf52840/src/bin/usb_serial_multitask.rs +++ b/examples/nrf52840/src/bin/usb_serial_multitask.rs | |||
| @@ -12,7 +12,7 @@ use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; | |||
| 12 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 12 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 13 | use embassy_usb::driver::EndpointError; | 13 | use embassy_usb::driver::EndpointError; |
| 14 | use embassy_usb::{Builder, Config, UsbDevice}; | 14 | use embassy_usb::{Builder, Config, UsbDevice}; |
| 15 | use static_cell::make_static; | 15 | use static_cell::StaticCell; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
| 18 | bind_interrupts!(struct Irqs { | 18 | bind_interrupts!(struct Irqs { |
| @@ -64,17 +64,23 @@ async fn main(spawner: Spawner) { | |||
| 64 | config.device_protocol = 0x01; | 64 | config.device_protocol = 0x01; |
| 65 | config.composite_with_iads = true; | 65 | config.composite_with_iads = true; |
| 66 | 66 | ||
| 67 | let state = make_static!(State::new()); | 67 | static STATE: StaticCell<State> = StaticCell::new(); |
| 68 | let state = STATE.init(State::new()); | ||
| 68 | 69 | ||
| 69 | // Create embassy-usb DeviceBuilder using the driver and config. | 70 | // Create embassy-usb DeviceBuilder using the driver and config. |
| 71 | static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 72 | static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 73 | static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 74 | static MSOS_DESC: StaticCell<[u8; 128]> = StaticCell::new(); | ||
| 75 | static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new(); | ||
| 70 | let mut builder = Builder::new( | 76 | let mut builder = Builder::new( |
| 71 | driver, | 77 | driver, |
| 72 | config, | 78 | config, |
| 73 | &mut make_static!([0; 256])[..], | 79 | &mut DEVICE_DESC.init([0; 256])[..], |
| 74 | &mut make_static!([0; 256])[..], | 80 | &mut CONFIG_DESC.init([0; 256])[..], |
| 75 | &mut make_static!([0; 256])[..], | 81 | &mut BOS_DESC.init([0; 256])[..], |
| 76 | &mut make_static!([0; 128])[..], | 82 | &mut MSOS_DESC.init([0; 128])[..], |
| 77 | &mut make_static!([0; 128])[..], | 83 | &mut CONTROL_BUF.init([0; 128])[..], |
| 78 | ); | 84 | ); |
| 79 | 85 | ||
| 80 | // Create classes on the builder. | 86 | // Create classes on the builder. |
diff --git a/examples/nrf52840/src/bin/wifi_esp_hosted.rs b/examples/nrf52840/src/bin/wifi_esp_hosted.rs index a60822fd9..b56c9bd8d 100644 --- a/examples/nrf52840/src/bin/wifi_esp_hosted.rs +++ b/examples/nrf52840/src/bin/wifi_esp_hosted.rs | |||
| @@ -13,7 +13,7 @@ use embassy_nrf::{bind_interrupts, peripherals}; | |||
| 13 | use embassy_time::Delay; | 13 | use embassy_time::Delay; |
| 14 | use embedded_hal_bus::spi::ExclusiveDevice; | 14 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 15 | use embedded_io_async::Write; | 15 | use embedded_io_async::Write; |
| 16 | use static_cell::make_static; | 16 | use static_cell::StaticCell; |
| 17 | use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _}; | 17 | use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _}; |
| 18 | 18 | ||
| 19 | const WIFI_NETWORK: &str = "EmbassyTest"; | 19 | const WIFI_NETWORK: &str = "EmbassyTest"; |
| @@ -61,8 +61,9 @@ async fn main(spawner: Spawner) { | |||
| 61 | let spi = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config); | 61 | let spi = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config); |
| 62 | let spi = ExclusiveDevice::new(spi, cs, Delay); | 62 | let spi = ExclusiveDevice::new(spi, cs, Delay); |
| 63 | 63 | ||
| 64 | static ESP_STATE: StaticCell<embassy_net_esp_hosted::State> = StaticCell::new(); | ||
| 64 | let (device, mut control, runner) = embassy_net_esp_hosted::new( | 65 | let (device, mut control, runner) = embassy_net_esp_hosted::new( |
| 65 | make_static!(embassy_net_esp_hosted::State::new()), | 66 | ESP_STATE.init(embassy_net_esp_hosted::State::new()), |
| 66 | spi, | 67 | spi, |
| 67 | handshake, | 68 | handshake, |
| 68 | ready, | 69 | ready, |
| @@ -89,11 +90,13 @@ async fn main(spawner: Spawner) { | |||
| 89 | let seed = u64::from_le_bytes(seed); | 90 | let seed = u64::from_le_bytes(seed); |
| 90 | 91 | ||
| 91 | // Init network stack | 92 | // Init network stack |
| 92 | let stack = &*make_static!(Stack::new( | 93 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); |
| 94 | static STACK: StaticCell<Stack<hosted::NetDriver<'static>>> = StaticCell::new(); | ||
| 95 | let stack = &*STACK.init(Stack::new( | ||
| 93 | device, | 96 | device, |
| 94 | config, | 97 | config, |
| 95 | make_static!(StackResources::<2>::new()), | 98 | RESOURCES.init(StackResources::<2>::new()), |
| 96 | seed | 99 | seed, |
| 97 | )); | 100 | )); |
| 98 | 101 | ||
| 99 | unwrap!(spawner.spawn(net_task(stack))); | 102 | unwrap!(spawner.spawn(net_task(stack))); |
diff --git a/examples/rp/src/bin/ethernet_w5500_multisocket.rs b/examples/rp/src/bin/ethernet_w5500_multisocket.rs index c0fde62ab..b9dba0f1d 100644 --- a/examples/rp/src/bin/ethernet_w5500_multisocket.rs +++ b/examples/rp/src/bin/ethernet_w5500_multisocket.rs | |||
| @@ -20,7 +20,7 @@ use embassy_time::{Delay, Duration}; | |||
| 20 | use embedded_hal_bus::spi::ExclusiveDevice; | 20 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 21 | use embedded_io_async::Write; | 21 | use embedded_io_async::Write; |
| 22 | use rand::RngCore; | 22 | use rand::RngCore; |
| 23 | use static_cell::make_static; | 23 | use static_cell::StaticCell; |
| 24 | use {defmt_rtt as _, panic_probe as _}; | 24 | use {defmt_rtt as _, panic_probe as _}; |
| 25 | 25 | ||
| 26 | #[embassy_executor::task] | 26 | #[embassy_executor::task] |
| @@ -55,7 +55,8 @@ async fn main(spawner: Spawner) { | |||
| 55 | let w5500_reset = Output::new(p.PIN_20, Level::High); | 55 | let w5500_reset = Output::new(p.PIN_20, Level::High); |
| 56 | 56 | ||
| 57 | let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; | 57 | let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; |
| 58 | let state = make_static!(State::<8, 8>::new()); | 58 | static STATE: StaticCell<State<8, 8>> = StaticCell::new(); |
| 59 | let state = STATE.init(State::<8, 8>::new()); | ||
| 59 | let (device, runner) = embassy_net_wiznet::new( | 60 | let (device, runner) = embassy_net_wiznet::new( |
| 60 | mac_addr, | 61 | mac_addr, |
| 61 | state, | 62 | state, |
| @@ -70,11 +71,13 @@ async fn main(spawner: Spawner) { | |||
| 70 | let seed = rng.next_u64(); | 71 | let seed = rng.next_u64(); |
| 71 | 72 | ||
| 72 | // Init network stack | 73 | // Init network stack |
| 73 | let stack = &*make_static!(Stack::new( | 74 | static STACK: StaticCell<Stack<Device<'static>>> = StaticCell::new(); |
| 75 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); | ||
| 76 | let stack = &*STACK.init(Stack::new( | ||
| 74 | device, | 77 | device, |
| 75 | embassy_net::Config::dhcpv4(Default::default()), | 78 | embassy_net::Config::dhcpv4(Default::default()), |
| 76 | make_static!(StackResources::<3>::new()), | 79 | RESOURCES.init(StackResources::<3>::new()), |
| 77 | seed | 80 | seed, |
| 78 | )); | 81 | )); |
| 79 | 82 | ||
| 80 | // Launch network task | 83 | // Launch network task |
diff --git a/examples/rp/src/bin/ethernet_w5500_tcp_client.rs b/examples/rp/src/bin/ethernet_w5500_tcp_client.rs index b19362fc1..36073f20b 100644 --- a/examples/rp/src/bin/ethernet_w5500_tcp_client.rs +++ b/examples/rp/src/bin/ethernet_w5500_tcp_client.rs | |||
| @@ -22,7 +22,7 @@ use embassy_time::{Delay, Duration, Timer}; | |||
| 22 | use embedded_hal_bus::spi::ExclusiveDevice; | 22 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 23 | use embedded_io_async::Write; | 23 | use embedded_io_async::Write; |
| 24 | use rand::RngCore; | 24 | use rand::RngCore; |
| 25 | use static_cell::make_static; | 25 | use static_cell::StaticCell; |
| 26 | use {defmt_rtt as _, panic_probe as _}; | 26 | use {defmt_rtt as _, panic_probe as _}; |
| 27 | 27 | ||
| 28 | #[embassy_executor::task] | 28 | #[embassy_executor::task] |
| @@ -58,7 +58,8 @@ async fn main(spawner: Spawner) { | |||
| 58 | let w5500_reset = Output::new(p.PIN_20, Level::High); | 58 | let w5500_reset = Output::new(p.PIN_20, Level::High); |
| 59 | 59 | ||
| 60 | let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; | 60 | let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; |
| 61 | let state = make_static!(State::<8, 8>::new()); | 61 | static STATE: StaticCell<State<8, 8>> = StaticCell::new(); |
| 62 | let state = STATE.init(State::<8, 8>::new()); | ||
| 62 | let (device, runner) = embassy_net_wiznet::new( | 63 | let (device, runner) = embassy_net_wiznet::new( |
| 63 | mac_addr, | 64 | mac_addr, |
| 64 | state, | 65 | state, |
| @@ -73,11 +74,13 @@ async fn main(spawner: Spawner) { | |||
| 73 | let seed = rng.next_u64(); | 74 | let seed = rng.next_u64(); |
| 74 | 75 | ||
| 75 | // Init network stack | 76 | // Init network stack |
| 76 | let stack = &*make_static!(Stack::new( | 77 | static STACK: StaticCell<Stack<Device<'static>>> = StaticCell::new(); |
| 78 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 79 | let stack = &*STACK.init(Stack::new( | ||
| 77 | device, | 80 | device, |
| 78 | embassy_net::Config::dhcpv4(Default::default()), | 81 | embassy_net::Config::dhcpv4(Default::default()), |
| 79 | make_static!(StackResources::<2>::new()), | 82 | RESOURCES.init(StackResources::<2>::new()), |
| 80 | seed | 83 | seed, |
| 81 | )); | 84 | )); |
| 82 | 85 | ||
| 83 | // Launch network task | 86 | // Launch network task |
diff --git a/examples/rp/src/bin/ethernet_w5500_tcp_server.rs b/examples/rp/src/bin/ethernet_w5500_tcp_server.rs index c62caed7a..d523a8772 100644 --- a/examples/rp/src/bin/ethernet_w5500_tcp_server.rs +++ b/examples/rp/src/bin/ethernet_w5500_tcp_server.rs | |||
| @@ -21,7 +21,7 @@ use embassy_time::{Delay, Duration}; | |||
| 21 | use embedded_hal_bus::spi::ExclusiveDevice; | 21 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 22 | use embedded_io_async::Write; | 22 | use embedded_io_async::Write; |
| 23 | use rand::RngCore; | 23 | use rand::RngCore; |
| 24 | use static_cell::make_static; | 24 | use static_cell::StaticCell; |
| 25 | use {defmt_rtt as _, panic_probe as _}; | 25 | use {defmt_rtt as _, panic_probe as _}; |
| 26 | 26 | ||
| 27 | #[embassy_executor::task] | 27 | #[embassy_executor::task] |
| @@ -57,7 +57,8 @@ async fn main(spawner: Spawner) { | |||
| 57 | let w5500_reset = Output::new(p.PIN_20, Level::High); | 57 | let w5500_reset = Output::new(p.PIN_20, Level::High); |
| 58 | 58 | ||
| 59 | let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; | 59 | let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; |
| 60 | let state = make_static!(State::<8, 8>::new()); | 60 | static STATE: StaticCell<State<8, 8>> = StaticCell::new(); |
| 61 | let state = STATE.init(State::<8, 8>::new()); | ||
| 61 | let (device, runner) = embassy_net_wiznet::new( | 62 | let (device, runner) = embassy_net_wiznet::new( |
| 62 | mac_addr, | 63 | mac_addr, |
| 63 | state, | 64 | state, |
| @@ -72,11 +73,13 @@ async fn main(spawner: Spawner) { | |||
| 72 | let seed = rng.next_u64(); | 73 | let seed = rng.next_u64(); |
| 73 | 74 | ||
| 74 | // Init network stack | 75 | // Init network stack |
| 75 | let stack = &*make_static!(Stack::new( | 76 | static STACK: StaticCell<Stack<Device<'static>>> = StaticCell::new(); |
| 77 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 78 | let stack = &*STACK.init(Stack::new( | ||
| 76 | device, | 79 | device, |
| 77 | embassy_net::Config::dhcpv4(Default::default()), | 80 | embassy_net::Config::dhcpv4(Default::default()), |
| 78 | make_static!(StackResources::<2>::new()), | 81 | RESOURCES.init(StackResources::<2>::new()), |
| 79 | seed | 82 | seed, |
| 80 | )); | 83 | )); |
| 81 | 84 | ||
| 82 | // Launch network task | 85 | // Launch network task |
diff --git a/examples/rp/src/bin/ethernet_w5500_udp.rs b/examples/rp/src/bin/ethernet_w5500_udp.rs index 76dabce1c..0cc47cb56 100644 --- a/examples/rp/src/bin/ethernet_w5500_udp.rs +++ b/examples/rp/src/bin/ethernet_w5500_udp.rs | |||
| @@ -20,7 +20,7 @@ use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | |||
| 20 | use embassy_time::Delay; | 20 | use embassy_time::Delay; |
| 21 | use embedded_hal_bus::spi::ExclusiveDevice; | 21 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 22 | use rand::RngCore; | 22 | use rand::RngCore; |
| 23 | use static_cell::make_static; | 23 | use static_cell::StaticCell; |
| 24 | use {defmt_rtt as _, panic_probe as _}; | 24 | use {defmt_rtt as _, panic_probe as _}; |
| 25 | 25 | ||
| 26 | #[embassy_executor::task] | 26 | #[embassy_executor::task] |
| @@ -55,7 +55,8 @@ async fn main(spawner: Spawner) { | |||
| 55 | let w5500_reset = Output::new(p.PIN_20, Level::High); | 55 | let w5500_reset = Output::new(p.PIN_20, Level::High); |
| 56 | 56 | ||
| 57 | let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; | 57 | let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; |
| 58 | let state = make_static!(State::<8, 8>::new()); | 58 | static STATE: StaticCell<State<8, 8>> = StaticCell::new(); |
| 59 | let state = STATE.init(State::<8, 8>::new()); | ||
| 59 | let (device, runner) = embassy_net_wiznet::new( | 60 | let (device, runner) = embassy_net_wiznet::new( |
| 60 | mac_addr, | 61 | mac_addr, |
| 61 | state, | 62 | state, |
| @@ -70,11 +71,13 @@ async fn main(spawner: Spawner) { | |||
| 70 | let seed = rng.next_u64(); | 71 | let seed = rng.next_u64(); |
| 71 | 72 | ||
| 72 | // Init network stack | 73 | // Init network stack |
| 73 | let stack = &*make_static!(Stack::new( | 74 | static STACK: StaticCell<Stack<Device<'static>>> = StaticCell::new(); |
| 75 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 76 | let stack = &*STACK.init(Stack::new( | ||
| 74 | device, | 77 | device, |
| 75 | embassy_net::Config::dhcpv4(Default::default()), | 78 | embassy_net::Config::dhcpv4(Default::default()), |
| 76 | make_static!(StackResources::<2>::new()), | 79 | RESOURCES.init(StackResources::<2>::new()), |
| 77 | seed | 80 | seed, |
| 78 | )); | 81 | )); |
| 79 | 82 | ||
| 80 | // Launch network task | 83 | // Launch network task |
diff --git a/examples/rp/src/bin/uart_buffered_split.rs b/examples/rp/src/bin/uart_buffered_split.rs index 14e8810a4..dc57d89c7 100644 --- a/examples/rp/src/bin/uart_buffered_split.rs +++ b/examples/rp/src/bin/uart_buffered_split.rs | |||
| @@ -15,7 +15,7 @@ use embassy_rp::peripherals::UART0; | |||
| 15 | use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config}; | 15 | use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config}; |
| 16 | use embassy_time::Timer; | 16 | use embassy_time::Timer; |
| 17 | use embedded_io_async::{Read, Write}; | 17 | use embedded_io_async::{Read, Write}; |
| 18 | use static_cell::make_static; | 18 | use static_cell::StaticCell; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 20 | ||
| 21 | bind_interrupts!(struct Irqs { | 21 | bind_interrupts!(struct Irqs { |
| @@ -27,8 +27,10 @@ async fn main(spawner: Spawner) { | |||
| 27 | let p = embassy_rp::init(Default::default()); | 27 | let p = embassy_rp::init(Default::default()); |
| 28 | let (tx_pin, rx_pin, uart) = (p.PIN_0, p.PIN_1, p.UART0); | 28 | let (tx_pin, rx_pin, uart) = (p.PIN_0, p.PIN_1, p.UART0); |
| 29 | 29 | ||
| 30 | let tx_buf = &mut make_static!([0u8; 16])[..]; | 30 | static TX_BUF: StaticCell<[u8; 16]> = StaticCell::new(); |
| 31 | let rx_buf = &mut make_static!([0u8; 16])[..]; | 31 | let tx_buf = &mut TX_BUF.init([0; 16])[..]; |
| 32 | static RX_BUF: StaticCell<[u8; 16]> = StaticCell::new(); | ||
| 33 | let rx_buf = &mut RX_BUF.init([0; 16])[..]; | ||
| 32 | let uart = BufferedUart::new(uart, Irqs, tx_pin, rx_pin, tx_buf, rx_buf, Config::default()); | 34 | let uart = BufferedUart::new(uart, Irqs, tx_pin, rx_pin, tx_buf, rx_buf, Config::default()); |
| 33 | let (rx, mut tx) = uart.split(); | 35 | let (rx, mut tx) = uart.split(); |
| 34 | 36 | ||
diff --git a/examples/rp/src/bin/usb_ethernet.rs b/examples/rp/src/bin/usb_ethernet.rs index cc63029fb..674b83f5d 100644 --- a/examples/rp/src/bin/usb_ethernet.rs +++ b/examples/rp/src/bin/usb_ethernet.rs | |||
| @@ -17,7 +17,7 @@ use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState | |||
| 17 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | 17 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; |
| 18 | use embassy_usb::{Builder, Config, UsbDevice}; | 18 | use embassy_usb::{Builder, Config, UsbDevice}; |
| 19 | use embedded_io_async::Write; | 19 | use embedded_io_async::Write; |
| 20 | use static_cell::make_static; | 20 | use static_cell::StaticCell; |
| 21 | use {defmt_rtt as _, panic_probe as _}; | 21 | use {defmt_rtt as _, panic_probe as _}; |
| 22 | 22 | ||
| 23 | bind_interrupts!(struct Irqs { | 23 | bind_interrupts!(struct Irqs { |
| @@ -65,14 +65,18 @@ async fn main(spawner: Spawner) { | |||
| 65 | config.device_protocol = 0x01; | 65 | config.device_protocol = 0x01; |
| 66 | 66 | ||
| 67 | // Create embassy-usb DeviceBuilder using the driver and config. | 67 | // Create embassy-usb DeviceBuilder using the driver and config. |
| 68 | static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 69 | static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 70 | static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 71 | static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new(); | ||
| 68 | let mut builder = Builder::new( | 72 | let mut builder = Builder::new( |
| 69 | driver, | 73 | driver, |
| 70 | config, | 74 | config, |
| 71 | &mut make_static!([0; 256])[..], | 75 | &mut DEVICE_DESC.init([0; 256])[..], |
| 72 | &mut make_static!([0; 256])[..], | 76 | &mut CONFIG_DESC.init([0; 256])[..], |
| 73 | &mut make_static!([0; 256])[..], | 77 | &mut BOS_DESC.init([0; 256])[..], |
| 74 | &mut [], // no msos descriptors | 78 | &mut [], // no msos descriptors |
| 75 | &mut make_static!([0; 128])[..], | 79 | &mut CONTROL_BUF.init([0; 128])[..], |
| 76 | ); | 80 | ); |
| 77 | 81 | ||
| 78 | // Our MAC addr. | 82 | // Our MAC addr. |
| @@ -81,14 +85,16 @@ async fn main(spawner: Spawner) { | |||
| 81 | let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88]; | 85 | let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88]; |
| 82 | 86 | ||
| 83 | // Create classes on the builder. | 87 | // Create classes on the builder. |
| 84 | let class = CdcNcmClass::new(&mut builder, make_static!(State::new()), host_mac_addr, 64); | 88 | static STATE: StaticCell<State> = StaticCell::new(); |
| 89 | let class = CdcNcmClass::new(&mut builder, STATE.init(State::new()), host_mac_addr, 64); | ||
| 85 | 90 | ||
| 86 | // Build the builder. | 91 | // Build the builder. |
| 87 | let usb = builder.build(); | 92 | let usb = builder.build(); |
| 88 | 93 | ||
| 89 | unwrap!(spawner.spawn(usb_task(usb))); | 94 | unwrap!(spawner.spawn(usb_task(usb))); |
| 90 | 95 | ||
| 91 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); | 96 | static NET_STATE: StaticCell<NetState<MTU, 4, 4>> = StaticCell::new(); |
| 97 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(NET_STATE.init(NetState::new()), our_mac_addr); | ||
| 92 | unwrap!(spawner.spawn(usb_ncm_task(runner))); | 98 | unwrap!(spawner.spawn(usb_ncm_task(runner))); |
| 93 | 99 | ||
| 94 | let config = embassy_net::Config::dhcpv4(Default::default()); | 100 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| @@ -102,11 +108,13 @@ async fn main(spawner: Spawner) { | |||
| 102 | let seed = 1234; // guaranteed random, chosen by a fair dice roll | 108 | let seed = 1234; // guaranteed random, chosen by a fair dice roll |
| 103 | 109 | ||
| 104 | // Init network stack | 110 | // Init network stack |
| 105 | let stack = &*make_static!(Stack::new( | 111 | static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new(); |
| 112 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 113 | let stack = &*STACK.init(Stack::new( | ||
| 106 | device, | 114 | device, |
| 107 | config, | 115 | config, |
| 108 | make_static!(StackResources::<2>::new()), | 116 | RESOURCES.init(StackResources::<2>::new()), |
| 109 | seed | 117 | seed, |
| 110 | )); | 118 | )); |
| 111 | 119 | ||
| 112 | unwrap!(spawner.spawn(net_task(stack))); | 120 | unwrap!(spawner.spawn(net_task(stack))); |
diff --git a/examples/rp/src/bin/wifi_ap_tcp_server.rs b/examples/rp/src/bin/wifi_ap_tcp_server.rs index ad1fa6462..20b8aad15 100644 --- a/examples/rp/src/bin/wifi_ap_tcp_server.rs +++ b/examples/rp/src/bin/wifi_ap_tcp_server.rs | |||
| @@ -19,7 +19,7 @@ use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | |||
| 19 | use embassy_rp::pio::{InterruptHandler, Pio}; | 19 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 20 | use embassy_time::Duration; | 20 | use embassy_time::Duration; |
| 21 | use embedded_io_async::Write; | 21 | use embedded_io_async::Write; |
| 22 | use static_cell::make_static; | 22 | use static_cell::StaticCell; |
| 23 | use {defmt_rtt as _, panic_probe as _}; | 23 | use {defmt_rtt as _, panic_probe as _}; |
| 24 | 24 | ||
| 25 | bind_interrupts!(struct Irqs { | 25 | bind_interrupts!(struct Irqs { |
| @@ -59,7 +59,8 @@ async fn main(spawner: Spawner) { | |||
| 59 | let mut pio = Pio::new(p.PIO0, Irqs); | 59 | let mut pio = Pio::new(p.PIO0, Irqs); |
| 60 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); | 60 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); |
| 61 | 61 | ||
| 62 | let state = make_static!(cyw43::State::new()); | 62 | static STATE: StaticCell<cyw43::State> = StaticCell::new(); |
| 63 | let state = STATE.init(cyw43::State::new()); | ||
| 63 | let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; | 64 | let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; |
| 64 | unwrap!(spawner.spawn(wifi_task(runner))); | 65 | unwrap!(spawner.spawn(wifi_task(runner))); |
| 65 | 66 | ||
| @@ -79,11 +80,13 @@ async fn main(spawner: Spawner) { | |||
| 79 | let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random. | 80 | let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random. |
| 80 | 81 | ||
| 81 | // Init network stack | 82 | // Init network stack |
| 82 | let stack = &*make_static!(Stack::new( | 83 | static STACK: StaticCell<Stack<cyw43::NetDriver<'static>>> = StaticCell::new(); |
| 84 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 85 | let stack = &*STACK.init(Stack::new( | ||
| 83 | net_device, | 86 | net_device, |
| 84 | config, | 87 | config, |
| 85 | make_static!(StackResources::<2>::new()), | 88 | RESOURCES.init(StackResources::<2>::new()), |
| 86 | seed | 89 | seed, |
| 87 | )); | 90 | )); |
| 88 | 91 | ||
| 89 | unwrap!(spawner.spawn(net_task(stack))); | 92 | unwrap!(spawner.spawn(net_task(stack))); |
diff --git a/examples/rp/src/bin/wifi_blinky.rs b/examples/rp/src/bin/wifi_blinky.rs index 14ace74e9..b89447b7d 100644 --- a/examples/rp/src/bin/wifi_blinky.rs +++ b/examples/rp/src/bin/wifi_blinky.rs | |||
| @@ -14,7 +14,7 @@ use embassy_rp::gpio::{Level, Output}; | |||
| 14 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | 14 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; |
| 15 | use embassy_rp::pio::{InterruptHandler, Pio}; | 15 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 16 | use embassy_time::{Duration, Timer}; | 16 | use embassy_time::{Duration, Timer}; |
| 17 | use static_cell::make_static; | 17 | use static_cell::StaticCell; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | bind_interrupts!(struct Irqs { | 20 | bind_interrupts!(struct Irqs { |
| @@ -46,7 +46,8 @@ async fn main(spawner: Spawner) { | |||
| 46 | let mut pio = Pio::new(p.PIO0, Irqs); | 46 | let mut pio = Pio::new(p.PIO0, Irqs); |
| 47 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); | 47 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); |
| 48 | 48 | ||
| 49 | let state = make_static!(cyw43::State::new()); | 49 | static STATE: StaticCell<cyw43::State> = StaticCell::new(); |
| 50 | let state = STATE.init(cyw43::State::new()); | ||
| 50 | let (_net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; | 51 | let (_net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; |
| 51 | unwrap!(spawner.spawn(wifi_task(runner))); | 52 | unwrap!(spawner.spawn(wifi_task(runner))); |
| 52 | 53 | ||
diff --git a/examples/rp/src/bin/wifi_scan.rs b/examples/rp/src/bin/wifi_scan.rs index 7adf52b88..0f7ad27dd 100644 --- a/examples/rp/src/bin/wifi_scan.rs +++ b/examples/rp/src/bin/wifi_scan.rs | |||
| @@ -16,7 +16,7 @@ use embassy_rp::bind_interrupts; | |||
| 16 | use embassy_rp::gpio::{Level, Output}; | 16 | use embassy_rp::gpio::{Level, Output}; |
| 17 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | 17 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; |
| 18 | use embassy_rp::pio::{InterruptHandler, Pio}; | 18 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 19 | use static_cell::make_static; | 19 | use static_cell::StaticCell; |
| 20 | use {defmt_rtt as _, panic_probe as _}; | 20 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 21 | ||
| 22 | bind_interrupts!(struct Irqs { | 22 | bind_interrupts!(struct Irqs { |
| @@ -56,7 +56,8 @@ async fn main(spawner: Spawner) { | |||
| 56 | let mut pio = Pio::new(p.PIO0, Irqs); | 56 | let mut pio = Pio::new(p.PIO0, Irqs); |
| 57 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); | 57 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); |
| 58 | 58 | ||
| 59 | let state = make_static!(cyw43::State::new()); | 59 | static STATE: StaticCell<cyw43::State> = StaticCell::new(); |
| 60 | let state = STATE.init(cyw43::State::new()); | ||
| 60 | let (_net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; | 61 | let (_net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; |
| 61 | unwrap!(spawner.spawn(wifi_task(runner))); | 62 | unwrap!(spawner.spawn(wifi_task(runner))); |
| 62 | 63 | ||
diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs index ec6b4ee74..f6cc48d8f 100644 --- a/examples/rp/src/bin/wifi_tcp_server.rs +++ b/examples/rp/src/bin/wifi_tcp_server.rs | |||
| @@ -19,7 +19,7 @@ use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | |||
| 19 | use embassy_rp::pio::{InterruptHandler, Pio}; | 19 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 20 | use embassy_time::{Duration, Timer}; | 20 | use embassy_time::{Duration, Timer}; |
| 21 | use embedded_io_async::Write; | 21 | use embedded_io_async::Write; |
| 22 | use static_cell::make_static; | 22 | use static_cell::StaticCell; |
| 23 | use {defmt_rtt as _, panic_probe as _}; | 23 | use {defmt_rtt as _, panic_probe as _}; |
| 24 | 24 | ||
| 25 | bind_interrupts!(struct Irqs { | 25 | bind_interrupts!(struct Irqs { |
| @@ -62,7 +62,8 @@ async fn main(spawner: Spawner) { | |||
| 62 | let mut pio = Pio::new(p.PIO0, Irqs); | 62 | let mut pio = Pio::new(p.PIO0, Irqs); |
| 63 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); | 63 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); |
| 64 | 64 | ||
| 65 | let state = make_static!(cyw43::State::new()); | 65 | static STATE: StaticCell<cyw43::State> = StaticCell::new(); |
| 66 | let state = STATE.init(cyw43::State::new()); | ||
| 66 | let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; | 67 | let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; |
| 67 | unwrap!(spawner.spawn(wifi_task(runner))); | 68 | unwrap!(spawner.spawn(wifi_task(runner))); |
| 68 | 69 | ||
| @@ -82,11 +83,13 @@ async fn main(spawner: Spawner) { | |||
| 82 | let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random. | 83 | let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random. |
| 83 | 84 | ||
| 84 | // Init network stack | 85 | // Init network stack |
| 85 | let stack = &*make_static!(Stack::new( | 86 | static STACK: StaticCell<Stack<cyw43::NetDriver<'static>>> = StaticCell::new(); |
| 87 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 88 | let stack = &*STACK.init(Stack::new( | ||
| 86 | net_device, | 89 | net_device, |
| 87 | config, | 90 | config, |
| 88 | make_static!(StackResources::<2>::new()), | 91 | RESOURCES.init(StackResources::<2>::new()), |
| 89 | seed | 92 | seed, |
| 90 | )); | 93 | )); |
| 91 | 94 | ||
| 92 | unwrap!(spawner.spawn(net_task(stack))); | 95 | unwrap!(spawner.spawn(net_task(stack))); |
diff --git a/examples/std/src/bin/net.rs b/examples/std/src/bin/net.rs index 8d8345057..c62a38d07 100644 --- a/examples/std/src/bin/net.rs +++ b/examples/std/src/bin/net.rs | |||
| @@ -12,7 +12,7 @@ use embedded_io_async::Write; | |||
| 12 | use heapless::Vec; | 12 | use heapless::Vec; |
| 13 | use log::*; | 13 | use log::*; |
| 14 | use rand_core::{OsRng, RngCore}; | 14 | use rand_core::{OsRng, RngCore}; |
| 15 | use static_cell::{make_static, StaticCell}; | 15 | use static_cell::StaticCell; |
| 16 | 16 | ||
| 17 | #[derive(Parser)] | 17 | #[derive(Parser)] |
| 18 | #[clap(version = "1.0")] | 18 | #[clap(version = "1.0")] |
| @@ -54,11 +54,13 @@ async fn main_task(spawner: Spawner) { | |||
| 54 | let seed = u64::from_le_bytes(seed); | 54 | let seed = u64::from_le_bytes(seed); |
| 55 | 55 | ||
| 56 | // Init network stack | 56 | // Init network stack |
| 57 | let stack = &*make_static!(Stack::new( | 57 | static STACK: StaticCell<Stack<TunTapDevice>> = StaticCell::new(); |
| 58 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); | ||
| 59 | let stack = &*STACK.init(Stack::new( | ||
| 58 | device, | 60 | device, |
| 59 | config, | 61 | config, |
| 60 | make_static!(StackResources::<3>::new()), | 62 | RESOURCES.init(StackResources::<3>::new()), |
| 61 | seed | 63 | seed, |
| 62 | )); | 64 | )); |
| 63 | 65 | ||
| 64 | // Launch network task | 66 | // Launch network task |
diff --git a/examples/std/src/bin/net_dns.rs b/examples/std/src/bin/net_dns.rs index 6c19874d5..e1e015bc8 100644 --- a/examples/std/src/bin/net_dns.rs +++ b/examples/std/src/bin/net_dns.rs | |||
| @@ -10,7 +10,7 @@ use embassy_net_tuntap::TunTapDevice; | |||
| 10 | use heapless::Vec; | 10 | use heapless::Vec; |
| 11 | use log::*; | 11 | use log::*; |
| 12 | use rand_core::{OsRng, RngCore}; | 12 | use rand_core::{OsRng, RngCore}; |
| 13 | use static_cell::{make_static, StaticCell}; | 13 | use static_cell::StaticCell; |
| 14 | 14 | ||
| 15 | #[derive(Parser)] | 15 | #[derive(Parser)] |
| 16 | #[clap(version = "1.0")] | 16 | #[clap(version = "1.0")] |
| @@ -53,11 +53,13 @@ async fn main_task(spawner: Spawner) { | |||
| 53 | let seed = u64::from_le_bytes(seed); | 53 | let seed = u64::from_le_bytes(seed); |
| 54 | 54 | ||
| 55 | // Init network stack | 55 | // Init network stack |
| 56 | let stack: &Stack<_> = &*make_static!(Stack::new( | 56 | static STACK: StaticCell<Stack<TunTapDevice>> = StaticCell::new(); |
| 57 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); | ||
| 58 | let stack: &Stack<_> = &*STACK.init(Stack::new( | ||
| 57 | device, | 59 | device, |
| 58 | config, | 60 | config, |
| 59 | make_static!(StackResources::<3>::new()), | 61 | RESOURCES.init(StackResources::<3>::new()), |
| 60 | seed | 62 | seed, |
| 61 | )); | 63 | )); |
| 62 | 64 | ||
| 63 | // Launch network task | 65 | // Launch network task |
diff --git a/examples/std/src/bin/net_ppp.rs b/examples/std/src/bin/net_ppp.rs index cee04e558..8c80c4beb 100644 --- a/examples/std/src/bin/net_ppp.rs +++ b/examples/std/src/bin/net_ppp.rs | |||
| @@ -25,7 +25,7 @@ use heapless::Vec; | |||
| 25 | use log::*; | 25 | use log::*; |
| 26 | use nix::sys::termios; | 26 | use nix::sys::termios; |
| 27 | use rand_core::{OsRng, RngCore}; | 27 | use rand_core::{OsRng, RngCore}; |
| 28 | use static_cell::{make_static, StaticCell}; | 28 | use static_cell::StaticCell; |
| 29 | 29 | ||
| 30 | use crate::serial_port::SerialPort; | 30 | use crate::serial_port::SerialPort; |
| 31 | 31 | ||
| @@ -88,7 +88,8 @@ async fn main_task(spawner: Spawner) { | |||
| 88 | let port = SerialPort::new(opts.device.as_str(), baudrate).unwrap(); | 88 | let port = SerialPort::new(opts.device.as_str(), baudrate).unwrap(); |
| 89 | 89 | ||
| 90 | // Init network device | 90 | // Init network device |
| 91 | let state = make_static!(embassy_net_ppp::State::<4, 4>::new()); | 91 | static STATE: StaticCell<embassy_net_ppp::State<4, 4>> = StaticCell::new(); |
| 92 | let state = STATE.init(embassy_net_ppp::State::<4, 4>::new()); | ||
| 92 | let (device, runner) = embassy_net_ppp::new(state); | 93 | let (device, runner) = embassy_net_ppp::new(state); |
| 93 | 94 | ||
| 94 | // Generate random seed | 95 | // Generate random seed |
| @@ -97,11 +98,13 @@ async fn main_task(spawner: Spawner) { | |||
| 97 | let seed = u64::from_le_bytes(seed); | 98 | let seed = u64::from_le_bytes(seed); |
| 98 | 99 | ||
| 99 | // Init network stack | 100 | // Init network stack |
| 100 | let stack = &*make_static!(Stack::new( | 101 | static STACK: StaticCell<Stack<embassy_net_ppp::Device<'static>>> = StaticCell::new(); |
| 102 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); | ||
| 103 | let stack = &*STACK.init(Stack::new( | ||
| 101 | device, | 104 | device, |
| 102 | Config::default(), // don't configure IP yet | 105 | Config::default(), // don't configure IP yet |
| 103 | make_static!(StackResources::<3>::new()), | 106 | RESOURCES.init(StackResources::<3>::new()), |
| 104 | seed | 107 | seed, |
| 105 | )); | 108 | )); |
| 106 | 109 | ||
| 107 | // Launch network task | 110 | // Launch network task |
diff --git a/examples/std/src/bin/net_udp.rs b/examples/std/src/bin/net_udp.rs index 98dcc9925..ac99ec626 100644 --- a/examples/std/src/bin/net_udp.rs +++ b/examples/std/src/bin/net_udp.rs | |||
| @@ -8,7 +8,7 @@ use embassy_net_tuntap::TunTapDevice; | |||
| 8 | use heapless::Vec; | 8 | use heapless::Vec; |
| 9 | use log::*; | 9 | use log::*; |
| 10 | use rand_core::{OsRng, RngCore}; | 10 | use rand_core::{OsRng, RngCore}; |
| 11 | use static_cell::{make_static, StaticCell}; | 11 | use static_cell::StaticCell; |
| 12 | 12 | ||
| 13 | #[derive(Parser)] | 13 | #[derive(Parser)] |
| 14 | #[clap(version = "1.0")] | 14 | #[clap(version = "1.0")] |
| @@ -50,11 +50,13 @@ async fn main_task(spawner: Spawner) { | |||
| 50 | let seed = u64::from_le_bytes(seed); | 50 | let seed = u64::from_le_bytes(seed); |
| 51 | 51 | ||
| 52 | // Init network stack | 52 | // Init network stack |
| 53 | let stack = &*make_static!(Stack::new( | 53 | static STACK: StaticCell<Stack<TunTapDevice>> = StaticCell::new(); |
| 54 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); | ||
| 55 | let stack = &*STACK.init(Stack::new( | ||
| 54 | device, | 56 | device, |
| 55 | config, | 57 | config, |
| 56 | make_static!(StackResources::<3>::new()), | 58 | RESOURCES.init(StackResources::<3>::new()), |
| 57 | seed | 59 | seed, |
| 58 | )); | 60 | )); |
| 59 | 61 | ||
| 60 | // Launch network task | 62 | // Launch network task |
diff --git a/examples/std/src/bin/tcp_accept.rs b/examples/std/src/bin/tcp_accept.rs index 79fa375cd..54ef0156b 100644 --- a/examples/std/src/bin/tcp_accept.rs +++ b/examples/std/src/bin/tcp_accept.rs | |||
| @@ -13,7 +13,7 @@ use embedded_io_async::Write as _; | |||
| 13 | use heapless::Vec; | 13 | use heapless::Vec; |
| 14 | use log::*; | 14 | use log::*; |
| 15 | use rand_core::{OsRng, RngCore}; | 15 | use rand_core::{OsRng, RngCore}; |
| 16 | use static_cell::{make_static, StaticCell}; | 16 | use static_cell::StaticCell; |
| 17 | 17 | ||
| 18 | #[derive(Parser)] | 18 | #[derive(Parser)] |
| 19 | #[clap(version = "1.0")] | 19 | #[clap(version = "1.0")] |
| @@ -65,11 +65,13 @@ async fn main_task(spawner: Spawner) { | |||
| 65 | let seed = u64::from_le_bytes(seed); | 65 | let seed = u64::from_le_bytes(seed); |
| 66 | 66 | ||
| 67 | // Init network stack | 67 | // Init network stack |
| 68 | let stack = &*make_static!(Stack::new( | 68 | static STACK: StaticCell<Stack<TunTapDevice>> = StaticCell::new(); |
| 69 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); | ||
| 70 | let stack = &*STACK.init(Stack::new( | ||
| 69 | device, | 71 | device, |
| 70 | config, | 72 | config, |
| 71 | make_static!(StackResources::<3>::new()), | 73 | RESOURCES.init(StackResources::<3>::new()), |
| 72 | seed | 74 | seed, |
| 73 | )); | 75 | )); |
| 74 | 76 | ||
| 75 | // Launch network task | 77 | // Launch network task |
diff --git a/examples/stm32f4/src/bin/eth.rs b/examples/stm32f4/src/bin/eth.rs index 088d83c06..17a14aac4 100644 --- a/examples/stm32f4/src/bin/eth.rs +++ b/examples/stm32f4/src/bin/eth.rs | |||
| @@ -14,7 +14,7 @@ use embassy_stm32::time::Hertz; | |||
| 14 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 14 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| 15 | use embassy_time::Timer; | 15 | use embassy_time::Timer; |
| 16 | use embedded_io_async::Write; | 16 | use embedded_io_async::Write; |
| 17 | use static_cell::make_static; | 17 | use static_cell::StaticCell; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | bind_interrupts!(struct Irqs { | 20 | bind_interrupts!(struct Irqs { |
| @@ -63,8 +63,9 @@ async fn main(spawner: Spawner) -> ! { | |||
| 63 | 63 | ||
| 64 | let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; | 64 | let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; |
| 65 | 65 | ||
| 66 | static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new(); | ||
| 66 | let device = Ethernet::new( | 67 | let device = Ethernet::new( |
| 67 | make_static!(PacketQueue::<16, 16>::new()), | 68 | PACKETS.init(PacketQueue::<16, 16>::new()), |
| 68 | p.ETH, | 69 | p.ETH, |
| 69 | Irqs, | 70 | Irqs, |
| 70 | p.PA1, | 71 | p.PA1, |
| @@ -88,11 +89,13 @@ async fn main(spawner: Spawner) -> ! { | |||
| 88 | //}); | 89 | //}); |
| 89 | 90 | ||
| 90 | // Init network stack | 91 | // Init network stack |
| 91 | let stack = &*make_static!(Stack::new( | 92 | static STACK: StaticCell<Stack<Device>> = StaticCell::new(); |
| 93 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 94 | let stack = &*STACK.init(Stack::new( | ||
| 92 | device, | 95 | device, |
| 93 | config, | 96 | config, |
| 94 | make_static!(StackResources::<2>::new()), | 97 | RESOURCES.init(StackResources::<2>::new()), |
| 95 | seed | 98 | seed, |
| 96 | )); | 99 | )); |
| 97 | 100 | ||
| 98 | // Launch network task | 101 | // Launch network task |
diff --git a/examples/stm32f4/src/bin/usb_ethernet.rs b/examples/stm32f4/src/bin/usb_ethernet.rs index 6bf5b1cba..57ee35e97 100644 --- a/examples/stm32f4/src/bin/usb_ethernet.rs +++ b/examples/stm32f4/src/bin/usb_ethernet.rs | |||
| @@ -14,7 +14,7 @@ use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState | |||
| 14 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | 14 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; |
| 15 | use embassy_usb::{Builder, UsbDevice}; | 15 | use embassy_usb::{Builder, UsbDevice}; |
| 16 | use embedded_io_async::Write; | 16 | use embedded_io_async::Write; |
| 17 | use static_cell::make_static; | 17 | use static_cell::StaticCell; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | type UsbDriver = Driver<'static, embassy_stm32::peripherals::USB_OTG_FS>; | 20 | type UsbDriver = Driver<'static, embassy_stm32::peripherals::USB_OTG_FS>; |
| @@ -68,7 +68,8 @@ async fn main(spawner: Spawner) { | |||
| 68 | let p = embassy_stm32::init(config); | 68 | let p = embassy_stm32::init(config); |
| 69 | 69 | ||
| 70 | // Create the driver, from the HAL. | 70 | // Create the driver, from the HAL. |
| 71 | let ep_out_buffer = &mut make_static!([0; 256])[..]; | 71 | static OUTPUT_BUFFER: StaticCell<[u8; 256]> = StaticCell::new(); |
| 72 | let ep_out_buffer = &mut OUTPUT_BUFFER.init([0; 256])[..]; | ||
| 72 | let mut config = embassy_stm32::usb_otg::Config::default(); | 73 | let mut config = embassy_stm32::usb_otg::Config::default(); |
| 73 | config.vbus_detection = true; | 74 | config.vbus_detection = true; |
| 74 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, ep_out_buffer, config); | 75 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, ep_out_buffer, config); |
| @@ -88,14 +89,18 @@ async fn main(spawner: Spawner) { | |||
| 88 | config.device_protocol = 0x01; | 89 | config.device_protocol = 0x01; |
| 89 | 90 | ||
| 90 | // Create embassy-usb DeviceBuilder using the driver and config. | 91 | // Create embassy-usb DeviceBuilder using the driver and config. |
| 92 | static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 93 | static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 94 | static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 95 | static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new(); | ||
| 91 | let mut builder = Builder::new( | 96 | let mut builder = Builder::new( |
| 92 | driver, | 97 | driver, |
| 93 | config, | 98 | config, |
| 94 | &mut make_static!([0; 256])[..], | 99 | &mut DEVICE_DESC.init([0; 256])[..], |
| 95 | &mut make_static!([0; 256])[..], | 100 | &mut CONFIG_DESC.init([0; 256])[..], |
| 96 | &mut make_static!([0; 256])[..], | 101 | &mut BOS_DESC.init([0; 256])[..], |
| 97 | &mut [], // no msos descriptors | 102 | &mut [], // no msos descriptors |
| 98 | &mut make_static!([0; 128])[..], | 103 | &mut CONTROL_BUF.init([0; 128])[..], |
| 99 | ); | 104 | ); |
| 100 | 105 | ||
| 101 | // Our MAC addr. | 106 | // Our MAC addr. |
| @@ -104,14 +109,16 @@ async fn main(spawner: Spawner) { | |||
| 104 | let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88]; | 109 | let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88]; |
| 105 | 110 | ||
| 106 | // Create classes on the builder. | 111 | // Create classes on the builder. |
| 107 | let class = CdcNcmClass::new(&mut builder, make_static!(State::new()), host_mac_addr, 64); | 112 | static STATE: StaticCell<State> = StaticCell::new(); |
| 113 | let class = CdcNcmClass::new(&mut builder, STATE.init(State::new()), host_mac_addr, 64); | ||
| 108 | 114 | ||
| 109 | // Build the builder. | 115 | // Build the builder. |
| 110 | let usb = builder.build(); | 116 | let usb = builder.build(); |
| 111 | 117 | ||
| 112 | unwrap!(spawner.spawn(usb_task(usb))); | 118 | unwrap!(spawner.spawn(usb_task(usb))); |
| 113 | 119 | ||
| 114 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); | 120 | static NET_STATE: StaticCell<NetState<MTU, 4, 4>> = StaticCell::new(); |
| 121 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(NET_STATE.init(NetState::new()), our_mac_addr); | ||
| 115 | unwrap!(spawner.spawn(usb_ncm_task(runner))); | 122 | unwrap!(spawner.spawn(usb_ncm_task(runner))); |
| 116 | 123 | ||
| 117 | let config = embassy_net::Config::dhcpv4(Default::default()); | 124 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| @@ -128,11 +135,13 @@ async fn main(spawner: Spawner) { | |||
| 128 | let seed = u64::from_le_bytes(seed); | 135 | let seed = u64::from_le_bytes(seed); |
| 129 | 136 | ||
| 130 | // Init network stack | 137 | // Init network stack |
| 131 | let stack = &*make_static!(Stack::new( | 138 | static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new(); |
| 139 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 140 | let stack = &*STACK.init(Stack::new( | ||
| 132 | device, | 141 | device, |
| 133 | config, | 142 | config, |
| 134 | make_static!(StackResources::<2>::new()), | 143 | RESOURCES.init(StackResources::<2>::new()), |
| 135 | seed | 144 | seed, |
| 136 | )); | 145 | )); |
| 137 | 146 | ||
| 138 | unwrap!(spawner.spawn(net_task(stack))); | 147 | unwrap!(spawner.spawn(net_task(stack))); |
diff --git a/examples/stm32f7/src/bin/can.rs b/examples/stm32f7/src/bin/can.rs index 78b21ceaa..06cd1ac7e 100644 --- a/examples/stm32f7/src/bin/can.rs +++ b/examples/stm32f7/src/bin/can.rs | |||
| @@ -12,6 +12,7 @@ use embassy_stm32::can::{ | |||
| 12 | }; | 12 | }; |
| 13 | use embassy_stm32::gpio::{Input, Pull}; | 13 | use embassy_stm32::gpio::{Input, Pull}; |
| 14 | use embassy_stm32::peripherals::CAN3; | 14 | use embassy_stm32::peripherals::CAN3; |
| 15 | use static_cell::StaticCell; | ||
| 15 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 17 | ||
| 17 | bind_interrupts!(struct Irqs { | 18 | bind_interrupts!(struct Irqs { |
| @@ -43,7 +44,8 @@ async fn main(spawner: Spawner) { | |||
| 43 | let rx_pin = Input::new(&mut p.PA15, Pull::Up); | 44 | let rx_pin = Input::new(&mut p.PA15, Pull::Up); |
| 44 | core::mem::forget(rx_pin); | 45 | core::mem::forget(rx_pin); |
| 45 | 46 | ||
| 46 | let can: &'static mut Can<'static, CAN3> = static_cell::make_static!(Can::new(p.CAN3, p.PA8, p.PA15, Irqs)); | 47 | static CAN: StaticCell<Can<'static, CAN3>> = StaticCell::new(); |
| 48 | let can = CAN.init(Can::new(p.CAN3, p.PA8, p.PA15, Irqs)); | ||
| 47 | can.as_mut() | 49 | can.as_mut() |
| 48 | .modify_filters() | 50 | .modify_filters() |
| 49 | .enable_bank(0, Fifo::Fifo0, Mask32::accept_all()); | 51 | .enable_bank(0, Fifo::Fifo0, Mask32::accept_all()); |
| @@ -56,7 +58,8 @@ async fn main(spawner: Spawner) { | |||
| 56 | 58 | ||
| 57 | let (tx, mut rx) = can.split(); | 59 | let (tx, mut rx) = can.split(); |
| 58 | 60 | ||
| 59 | let tx: &'static mut CanTx<'static, 'static, CAN3> = static_cell::make_static!(tx); | 61 | static CAN_TX: StaticCell<CanTx<'static, 'static, CAN3>> = StaticCell::new(); |
| 62 | let tx = CAN_TX.init(tx); | ||
| 60 | spawner.spawn(send_can_message(tx)).unwrap(); | 63 | spawner.spawn(send_can_message(tx)).unwrap(); |
| 61 | 64 | ||
| 62 | loop { | 65 | loop { |
diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index dd0069447..86c709852 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs | |||
| @@ -15,7 +15,7 @@ use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | |||
| 15 | use embassy_time::Timer; | 15 | use embassy_time::Timer; |
| 16 | use embedded_io_async::Write; | 16 | use embedded_io_async::Write; |
| 17 | use rand_core::RngCore; | 17 | use rand_core::RngCore; |
| 18 | use static_cell::make_static; | 18 | use static_cell::StaticCell; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 20 | ||
| 21 | bind_interrupts!(struct Irqs { | 21 | bind_interrupts!(struct Irqs { |
| @@ -64,8 +64,9 @@ async fn main(spawner: Spawner) -> ! { | |||
| 64 | 64 | ||
| 65 | let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; | 65 | let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; |
| 66 | 66 | ||
| 67 | static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new(); | ||
| 67 | let device = Ethernet::new( | 68 | let device = Ethernet::new( |
| 68 | make_static!(PacketQueue::<16, 16>::new()), | 69 | PACKETS.init(PacketQueue::<16, 16>::new()), |
| 69 | p.ETH, | 70 | p.ETH, |
| 70 | Irqs, | 71 | Irqs, |
| 71 | p.PA1, | 72 | p.PA1, |
| @@ -89,11 +90,13 @@ async fn main(spawner: Spawner) -> ! { | |||
| 89 | //}); | 90 | //}); |
| 90 | 91 | ||
| 91 | // Init network stack | 92 | // Init network stack |
| 92 | let stack = &*make_static!(Stack::new( | 93 | static STACK: StaticCell<Stack<Device>> = StaticCell::new(); |
| 94 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 95 | let stack = &*STACK.init(Stack::new( | ||
| 93 | device, | 96 | device, |
| 94 | config, | 97 | config, |
| 95 | make_static!(StackResources::<2>::new()), | 98 | RESOURCES.init(StackResources::<2>::new()), |
| 96 | seed | 99 | seed, |
| 97 | )); | 100 | )); |
| 98 | 101 | ||
| 99 | // Launch network task | 102 | // Launch network task |
diff --git a/examples/stm32h5/src/bin/eth.rs b/examples/stm32h5/src/bin/eth.rs index b2758cba0..8789e4e0b 100644 --- a/examples/stm32h5/src/bin/eth.rs +++ b/examples/stm32h5/src/bin/eth.rs | |||
| @@ -18,7 +18,7 @@ use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | |||
| 18 | use embassy_time::Timer; | 18 | use embassy_time::Timer; |
| 19 | use embedded_io_async::Write; | 19 | use embedded_io_async::Write; |
| 20 | use rand_core::RngCore; | 20 | use rand_core::RngCore; |
| 21 | use static_cell::make_static; | 21 | use static_cell::StaticCell; |
| 22 | use {defmt_rtt as _, panic_probe as _}; | 22 | use {defmt_rtt as _, panic_probe as _}; |
| 23 | 23 | ||
| 24 | bind_interrupts!(struct Irqs { | 24 | bind_interrupts!(struct Irqs { |
| @@ -67,8 +67,9 @@ async fn main(spawner: Spawner) -> ! { | |||
| 67 | 67 | ||
| 68 | let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; | 68 | let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; |
| 69 | 69 | ||
| 70 | static PACKETS: StaticCell<PacketQueue<4, 4>> = StaticCell::new(); | ||
| 70 | let device = Ethernet::new( | 71 | let device = Ethernet::new( |
| 71 | make_static!(PacketQueue::<4, 4>::new()), | 72 | PACKETS.init(PacketQueue::<4, 4>::new()), |
| 72 | p.ETH, | 73 | p.ETH, |
| 73 | Irqs, | 74 | Irqs, |
| 74 | p.PA1, | 75 | p.PA1, |
| @@ -92,11 +93,13 @@ async fn main(spawner: Spawner) -> ! { | |||
| 92 | //}); | 93 | //}); |
| 93 | 94 | ||
| 94 | // Init network stack | 95 | // Init network stack |
| 95 | let stack = &*make_static!(Stack::new( | 96 | static STACK: StaticCell<Stack<Device>> = StaticCell::new(); |
| 97 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 98 | let stack = &*STACK.init(Stack::new( | ||
| 96 | device, | 99 | device, |
| 97 | config, | 100 | config, |
| 98 | make_static!(StackResources::<2>::new()), | 101 | RESOURCES.init(StackResources::<2>::new()), |
| 99 | seed | 102 | seed, |
| 100 | )); | 103 | )); |
| 101 | 104 | ||
| 102 | // Launch network task | 105 | // Launch network task |
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index dbddfc22f..a64b3253a 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -14,7 +14,7 @@ use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | |||
| 14 | use embassy_time::Timer; | 14 | use embassy_time::Timer; |
| 15 | use embedded_io_async::Write; | 15 | use embedded_io_async::Write; |
| 16 | use rand_core::RngCore; | 16 | use rand_core::RngCore; |
| 17 | use static_cell::make_static; | 17 | use static_cell::StaticCell; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | bind_interrupts!(struct Irqs { | 20 | bind_interrupts!(struct Irqs { |
| @@ -64,8 +64,9 @@ async fn main(spawner: Spawner) -> ! { | |||
| 64 | 64 | ||
| 65 | let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; | 65 | let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; |
| 66 | 66 | ||
| 67 | static PACKETS: StaticCell<PacketQueue<4, 4>> = StaticCell::new(); | ||
| 67 | let device = Ethernet::new( | 68 | let device = Ethernet::new( |
| 68 | make_static!(PacketQueue::<16, 16>::new()), | 69 | PACKETS.init(PacketQueue::<4, 4>::new()), |
| 69 | p.ETH, | 70 | p.ETH, |
| 70 | Irqs, | 71 | Irqs, |
| 71 | p.PA1, | 72 | p.PA1, |
| @@ -89,11 +90,13 @@ async fn main(spawner: Spawner) -> ! { | |||
| 89 | //}); | 90 | //}); |
| 90 | 91 | ||
| 91 | // Init network stack | 92 | // Init network stack |
| 92 | let stack = &*make_static!(Stack::new( | 93 | static STACK: StaticCell<Stack<Device>> = StaticCell::new(); |
| 94 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); | ||
| 95 | let stack = &*STACK.init(Stack::new( | ||
| 93 | device, | 96 | device, |
| 94 | config, | 97 | config, |
| 95 | make_static!(StackResources::<3>::new()), | 98 | RESOURCES.init(StackResources::<3>::new()), |
| 96 | seed | 99 | seed, |
| 97 | )); | 100 | )); |
| 98 | 101 | ||
| 99 | // Launch network task | 102 | // Launch network task |
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index 17e1d9fb7..8e84d9964 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs | |||
| @@ -15,7 +15,7 @@ use embassy_time::Timer; | |||
| 15 | use embedded_io_async::Write; | 15 | use embedded_io_async::Write; |
| 16 | use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; | 16 | use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; |
| 17 | use rand_core::RngCore; | 17 | use rand_core::RngCore; |
| 18 | use static_cell::make_static; | 18 | use static_cell::StaticCell; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 20 | ||
| 21 | bind_interrupts!(struct Irqs { | 21 | bind_interrupts!(struct Irqs { |
| @@ -65,8 +65,9 @@ async fn main(spawner: Spawner) -> ! { | |||
| 65 | 65 | ||
| 66 | let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; | 66 | let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; |
| 67 | 67 | ||
| 68 | static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new(); | ||
| 68 | let device = Ethernet::new( | 69 | let device = Ethernet::new( |
| 69 | make_static!(PacketQueue::<16, 16>::new()), | 70 | PACKETS.init(PacketQueue::<16, 16>::new()), |
| 70 | p.ETH, | 71 | p.ETH, |
| 71 | Irqs, | 72 | Irqs, |
| 72 | p.PA1, | 73 | p.PA1, |
| @@ -90,11 +91,13 @@ async fn main(spawner: Spawner) -> ! { | |||
| 90 | //}); | 91 | //}); |
| 91 | 92 | ||
| 92 | // Init network stack | 93 | // Init network stack |
| 93 | let stack = &*make_static!(Stack::new( | 94 | static STACK: StaticCell<Stack<Device>> = StaticCell::new(); |
| 95 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); | ||
| 96 | let stack = &*STACK.init(Stack::new( | ||
| 94 | device, | 97 | device, |
| 95 | config, | 98 | config, |
| 96 | make_static!(StackResources::<3>::new()), | 99 | RESOURCES.init(StackResources::<3>::new()), |
| 97 | seed | 100 | seed, |
| 98 | )); | 101 | )); |
| 99 | 102 | ||
| 100 | // Launch network task | 103 | // Launch network task |
diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs index 8ec810c7f..eb04fe5e6 100644 --- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs +++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs | |||
| @@ -36,7 +36,7 @@ use hal::rng::{self, Rng}; | |||
| 36 | use hal::{bind_interrupts, exti, pac, peripherals}; | 36 | use hal::{bind_interrupts, exti, pac, peripherals}; |
| 37 | use heapless::Vec; | 37 | use heapless::Vec; |
| 38 | use rand::RngCore; | 38 | use rand::RngCore; |
| 39 | use static_cell::make_static; | 39 | use static_cell::StaticCell; |
| 40 | use {embassy_stm32 as hal, panic_probe as _}; | 40 | use {embassy_stm32 as hal, panic_probe as _}; |
| 41 | 41 | ||
| 42 | bind_interrupts!(struct Irqs { | 42 | bind_interrupts!(struct Irqs { |
| @@ -180,7 +180,8 @@ async fn main(spawner: Spawner) { | |||
| 180 | } | 180 | } |
| 181 | }; | 181 | }; |
| 182 | 182 | ||
| 183 | let state = make_static!(embassy_net_adin1110::State::<8, 8>::new()); | 183 | static STATE: StaticCell<embassy_net_adin1110::State<8, 8>> = StaticCell::new(); |
| 184 | let state = STATE.init(embassy_net_adin1110::State::<8, 8>::new()); | ||
| 184 | 185 | ||
| 185 | let (device, runner) = embassy_net_adin1110::new( | 186 | let (device, runner) = embassy_net_adin1110::new( |
| 186 | MAC, | 187 | MAC, |
| @@ -217,11 +218,13 @@ async fn main(spawner: Spawner) { | |||
| 217 | }; | 218 | }; |
| 218 | 219 | ||
| 219 | // Init network stack | 220 | // Init network stack |
| 220 | let stack = &*make_static!(Stack::new( | 221 | static STACK: StaticCell<Stack<Device<'static>>> = StaticCell::new(); |
| 222 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 223 | let stack = &*STACK.init(Stack::new( | ||
| 221 | device, | 224 | device, |
| 222 | ip_cfg, | 225 | ip_cfg, |
| 223 | make_static!(StackResources::<2>::new()), | 226 | RESOURCES.init(StackResources::<2>::new()), |
| 224 | seed | 227 | seed, |
| 225 | )); | 228 | )); |
| 226 | 229 | ||
| 227 | // Launch network task | 230 | // Launch network task |
diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 0b0a0e2db..214235bd5 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs | |||
| @@ -15,7 +15,7 @@ use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | |||
| 15 | use embassy_usb::{Builder, UsbDevice}; | 15 | use embassy_usb::{Builder, UsbDevice}; |
| 16 | use embedded_io_async::Write; | 16 | use embedded_io_async::Write; |
| 17 | use rand_core::RngCore; | 17 | use rand_core::RngCore; |
| 18 | use static_cell::make_static; | 18 | use static_cell::StaticCell; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 20 | ||
| 21 | type MyDriver = Driver<'static, embassy_stm32::peripherals::USB>; | 21 | type MyDriver = Driver<'static, embassy_stm32::peripherals::USB>; |
| @@ -76,14 +76,18 @@ async fn main(spawner: Spawner) { | |||
| 76 | config.device_protocol = 0x01; | 76 | config.device_protocol = 0x01; |
| 77 | 77 | ||
| 78 | // Create embassy-usb DeviceBuilder using the driver and config. | 78 | // Create embassy-usb DeviceBuilder using the driver and config. |
| 79 | static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 80 | static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 81 | static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 82 | static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new(); | ||
| 79 | let mut builder = Builder::new( | 83 | let mut builder = Builder::new( |
| 80 | driver, | 84 | driver, |
| 81 | config, | 85 | config, |
| 82 | &mut make_static!([0; 256])[..], | 86 | &mut DEVICE_DESC.init([0; 256])[..], |
| 83 | &mut make_static!([0; 256])[..], | 87 | &mut CONFIG_DESC.init([0; 256])[..], |
| 84 | &mut make_static!([0; 256])[..], | 88 | &mut BOS_DESC.init([0; 256])[..], |
| 85 | &mut [], // no msos descriptors | 89 | &mut [], // no msos descriptors |
| 86 | &mut make_static!([0; 128])[..], | 90 | &mut CONTROL_BUF.init([0; 128])[..], |
| 87 | ); | 91 | ); |
| 88 | 92 | ||
| 89 | // Our MAC addr. | 93 | // Our MAC addr. |
| @@ -92,14 +96,16 @@ async fn main(spawner: Spawner) { | |||
| 92 | let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88]; | 96 | let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88]; |
| 93 | 97 | ||
| 94 | // Create classes on the builder. | 98 | // Create classes on the builder. |
| 95 | let class = CdcNcmClass::new(&mut builder, make_static!(State::new()), host_mac_addr, 64); | 99 | static STATE: StaticCell<State> = StaticCell::new(); |
| 100 | let class = CdcNcmClass::new(&mut builder, STATE.init(State::new()), host_mac_addr, 64); | ||
| 96 | 101 | ||
| 97 | // Build the builder. | 102 | // Build the builder. |
| 98 | let usb = builder.build(); | 103 | let usb = builder.build(); |
| 99 | 104 | ||
| 100 | unwrap!(spawner.spawn(usb_task(usb))); | 105 | unwrap!(spawner.spawn(usb_task(usb))); |
| 101 | 106 | ||
| 102 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); | 107 | static NET_STATE: StaticCell<NetState<MTU, 4, 4>> = StaticCell::new(); |
| 108 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(NET_STATE.init(NetState::new()), our_mac_addr); | ||
| 103 | unwrap!(spawner.spawn(usb_ncm_task(runner))); | 109 | unwrap!(spawner.spawn(usb_ncm_task(runner))); |
| 104 | 110 | ||
| 105 | let config = embassy_net::Config::dhcpv4(Default::default()); | 111 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| @@ -114,11 +120,13 @@ async fn main(spawner: Spawner) { | |||
| 114 | let seed = rng.next_u64(); | 120 | let seed = rng.next_u64(); |
| 115 | 121 | ||
| 116 | // Init network stack | 122 | // Init network stack |
| 117 | let stack = &*make_static!(Stack::new( | 123 | static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new(); |
| 124 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 125 | let stack = &*STACK.init(Stack::new( | ||
| 118 | device, | 126 | device, |
| 119 | config, | 127 | config, |
| 120 | make_static!(StackResources::<2>::new()), | 128 | RESOURCES.init(StackResources::<2>::new()), |
| 121 | seed | 129 | seed, |
| 122 | )); | 130 | )); |
| 123 | 131 | ||
| 124 | unwrap!(spawner.spawn(net_task(stack))); | 132 | unwrap!(spawner.spawn(net_task(stack))); |
diff --git a/examples/stm32wb/src/bin/mac_ffd_net.rs b/examples/stm32wb/src/bin/mac_ffd_net.rs index f8c76b5a4..454530c03 100644 --- a/examples/stm32wb/src/bin/mac_ffd_net.rs +++ b/examples/stm32wb/src/bin/mac_ffd_net.rs | |||
| @@ -12,7 +12,7 @@ use embassy_stm32_wpan::mac::typedefs::{MacChannel, PanId, PibId}; | |||
| 12 | use embassy_stm32_wpan::mac::{self, Runner}; | 12 | use embassy_stm32_wpan::mac::{self, Runner}; |
| 13 | use embassy_stm32_wpan::sub::mm; | 13 | use embassy_stm32_wpan::sub::mm; |
| 14 | use embassy_stm32_wpan::TlMbox; | 14 | use embassy_stm32_wpan::TlMbox; |
| 15 | use static_cell::make_static; | 15 | use static_cell::StaticCell; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
| 18 | bind_interrupts!(struct Irqs{ | 18 | bind_interrupts!(struct Irqs{ |
| @@ -154,15 +154,21 @@ async fn main(spawner: Spawner) { | |||
| 154 | .unwrap(); | 154 | .unwrap(); |
| 155 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); | 155 | defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap()); |
| 156 | 156 | ||
| 157 | static TX1: StaticCell<[u8; 127]> = StaticCell::new(); | ||
| 158 | static TX2: StaticCell<[u8; 127]> = StaticCell::new(); | ||
| 159 | static TX3: StaticCell<[u8; 127]> = StaticCell::new(); | ||
| 160 | static TX4: StaticCell<[u8; 127]> = StaticCell::new(); | ||
| 161 | static TX5: StaticCell<[u8; 127]> = StaticCell::new(); | ||
| 157 | let tx_queue = [ | 162 | let tx_queue = [ |
| 158 | make_static!([0u8; 127]), | 163 | TX1.init([0u8; 127]), |
| 159 | make_static!([0u8; 127]), | 164 | TX2.init([0u8; 127]), |
| 160 | make_static!([0u8; 127]), | 165 | TX3.init([0u8; 127]), |
| 161 | make_static!([0u8; 127]), | 166 | TX4.init([0u8; 127]), |
| 162 | make_static!([0u8; 127]), | 167 | TX5.init([0u8; 127]), |
| 163 | ]; | 168 | ]; |
| 164 | 169 | ||
| 165 | let runner = make_static!(Runner::new(mbox.mac_subsystem, tx_queue)); | 170 | static RUNNER: StaticCell<Runner> = StaticCell::new(); |
| 171 | let runner = RUNNER.init(Runner::new(mbox.mac_subsystem, tx_queue)); | ||
| 166 | 172 | ||
| 167 | spawner.spawn(run_mac(runner)).unwrap(); | 173 | spawner.spawn(run_mac(runner)).unwrap(); |
| 168 | 174 | ||
diff --git a/tests/nrf/src/bin/ethernet_enc28j60_perf.rs b/tests/nrf/src/bin/ethernet_enc28j60_perf.rs index 60d30a2ff..c26c0d066 100644 --- a/tests/nrf/src/bin/ethernet_enc28j60_perf.rs +++ b/tests/nrf/src/bin/ethernet_enc28j60_perf.rs | |||
| @@ -14,7 +14,7 @@ use embassy_nrf::spim::{self, Spim}; | |||
| 14 | use embassy_nrf::{bind_interrupts, peripherals}; | 14 | use embassy_nrf::{bind_interrupts, peripherals}; |
| 15 | use embassy_time::Delay; | 15 | use embassy_time::Delay; |
| 16 | use embedded_hal_bus::spi::ExclusiveDevice; | 16 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 17 | use static_cell::make_static; | 17 | use static_cell::StaticCell; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | bind_interrupts!(struct Irqs { | 20 | bind_interrupts!(struct Irqs { |
| @@ -68,11 +68,13 @@ async fn main(spawner: Spawner) { | |||
| 68 | let seed = u64::from_le_bytes(seed); | 68 | let seed = u64::from_le_bytes(seed); |
| 69 | 69 | ||
| 70 | // Init network stack | 70 | // Init network stack |
| 71 | let stack = &*make_static!(Stack::new( | 71 | static STACK: StaticCell<Stack<MyDriver>> = StaticCell::new(); |
| 72 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 73 | let stack = &*STACK.init(Stack::new( | ||
| 72 | device, | 74 | device, |
| 73 | config, | 75 | config, |
| 74 | make_static!(StackResources::<2>::new()), | 76 | RESOURCES.init(StackResources::<2>::new()), |
| 75 | seed | 77 | seed, |
| 76 | )); | 78 | )); |
| 77 | 79 | ||
| 78 | unwrap!(spawner.spawn(net_task(stack))); | 80 | unwrap!(spawner.spawn(net_task(stack))); |
diff --git a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs index 9eee39ccf..5b43b75d7 100644 --- a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs +++ b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs | |||
| @@ -13,7 +13,7 @@ use embassy_nrf::spim::{self, Spim}; | |||
| 13 | use embassy_nrf::{bind_interrupts, peripherals}; | 13 | use embassy_nrf::{bind_interrupts, peripherals}; |
| 14 | use embassy_time::Delay; | 14 | use embassy_time::Delay; |
| 15 | use embedded_hal_bus::spi::ExclusiveDevice; | 15 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 16 | use static_cell::make_static; | 16 | use static_cell::StaticCell; |
| 17 | use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _}; | 17 | use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _}; |
| 18 | 18 | ||
| 19 | bind_interrupts!(struct Irqs { | 19 | bind_interrupts!(struct Irqs { |
| @@ -64,8 +64,9 @@ async fn main(spawner: Spawner) { | |||
| 64 | let spi = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config); | 64 | let spi = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config); |
| 65 | let spi = ExclusiveDevice::new(spi, cs, Delay); | 65 | let spi = ExclusiveDevice::new(spi, cs, Delay); |
| 66 | 66 | ||
| 67 | static STATE: StaticCell<embassy_net_esp_hosted::State> = StaticCell::new(); | ||
| 67 | let (device, mut control, runner) = embassy_net_esp_hosted::new( | 68 | let (device, mut control, runner) = embassy_net_esp_hosted::new( |
| 68 | make_static!(embassy_net_esp_hosted::State::new()), | 69 | STATE.init(embassy_net_esp_hosted::State::new()), |
| 69 | spi, | 70 | spi, |
| 70 | handshake, | 71 | handshake, |
| 71 | ready, | 72 | ready, |
| @@ -85,11 +86,13 @@ async fn main(spawner: Spawner) { | |||
| 85 | let seed = u64::from_le_bytes(seed); | 86 | let seed = u64::from_le_bytes(seed); |
| 86 | 87 | ||
| 87 | // Init network stack | 88 | // Init network stack |
| 88 | let stack = &*make_static!(Stack::new( | 89 | static STACK: StaticCell<Stack<MyDriver>> = StaticCell::new(); |
| 90 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 91 | let stack = &*STACK.init(Stack::new( | ||
| 89 | device, | 92 | device, |
| 90 | Config::dhcpv4(Default::default()), | 93 | Config::dhcpv4(Default::default()), |
| 91 | make_static!(StackResources::<2>::new()), | 94 | RESOURCES.init(StackResources::<2>::new()), |
| 92 | seed | 95 | seed, |
| 93 | )); | 96 | )); |
| 94 | 97 | ||
| 95 | unwrap!(spawner.spawn(net_task(stack))); | 98 | unwrap!(spawner.spawn(net_task(stack))); |
diff --git a/tests/rp/src/bin/cyw43-perf.rs b/tests/rp/src/bin/cyw43-perf.rs index de29c06dd..d70ef8ef3 100644 --- a/tests/rp/src/bin/cyw43-perf.rs +++ b/tests/rp/src/bin/cyw43-perf.rs | |||
| @@ -11,7 +11,7 @@ use embassy_rp::gpio::{Level, Output}; | |||
| 11 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | 11 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; |
| 12 | use embassy_rp::pio::{InterruptHandler, Pio}; | 12 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 13 | use embassy_rp::{bind_interrupts, rom_data}; | 13 | use embassy_rp::{bind_interrupts, rom_data}; |
| 14 | use static_cell::make_static; | 14 | use static_cell::StaticCell; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| 17 | bind_interrupts!(struct Irqs { | 17 | bind_interrupts!(struct Irqs { |
| @@ -58,7 +58,8 @@ async fn main(spawner: Spawner) { | |||
| 58 | let mut pio = Pio::new(p.PIO0, Irqs); | 58 | let mut pio = Pio::new(p.PIO0, Irqs); |
| 59 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); | 59 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); |
| 60 | 60 | ||
| 61 | let state = make_static!(cyw43::State::new()); | 61 | static STATE: StaticCell<cyw43::State> = StaticCell::new(); |
| 62 | let state = STATE.init(cyw43::State::new()); | ||
| 62 | let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; | 63 | let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; |
| 63 | unwrap!(spawner.spawn(wifi_task(runner))); | 64 | unwrap!(spawner.spawn(wifi_task(runner))); |
| 64 | 65 | ||
| @@ -71,11 +72,13 @@ async fn main(spawner: Spawner) { | |||
| 71 | let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random. | 72 | let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random. |
| 72 | 73 | ||
| 73 | // Init network stack | 74 | // Init network stack |
| 74 | let stack = &*make_static!(Stack::new( | 75 | static STACK: StaticCell<Stack<cyw43::NetDriver<'static>>> = StaticCell::new(); |
| 76 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 77 | let stack = &*STACK.init(Stack::new( | ||
| 75 | net_device, | 78 | net_device, |
| 76 | Config::dhcpv4(Default::default()), | 79 | Config::dhcpv4(Default::default()), |
| 77 | make_static!(StackResources::<2>::new()), | 80 | RESOURCES.init(StackResources::<2>::new()), |
| 78 | seed | 81 | seed, |
| 79 | )); | 82 | )); |
| 80 | 83 | ||
| 81 | unwrap!(spawner.spawn(net_task(stack))); | 84 | unwrap!(spawner.spawn(net_task(stack))); |
diff --git a/tests/rp/src/bin/ethernet_w5100s_perf.rs b/tests/rp/src/bin/ethernet_w5100s_perf.rs index a4d253b3c..5588b6427 100644 --- a/tests/rp/src/bin/ethernet_w5100s_perf.rs +++ b/tests/rp/src/bin/ethernet_w5100s_perf.rs | |||
| @@ -16,7 +16,7 @@ use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | |||
| 16 | use embassy_time::Delay; | 16 | use embassy_time::Delay; |
| 17 | use embedded_hal_bus::spi::ExclusiveDevice; | 17 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 18 | use rand::RngCore; | 18 | use rand::RngCore; |
| 19 | use static_cell::make_static; | 19 | use static_cell::StaticCell; |
| 20 | use {defmt_rtt as _, panic_probe as _}; | 20 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 21 | ||
| 22 | #[embassy_executor::task] | 22 | #[embassy_executor::task] |
| @@ -51,7 +51,8 @@ async fn main(spawner: Spawner) { | |||
| 51 | let w5500_reset = Output::new(p.PIN_20, Level::High); | 51 | let w5500_reset = Output::new(p.PIN_20, Level::High); |
| 52 | 52 | ||
| 53 | let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; | 53 | let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; |
| 54 | let state = make_static!(State::<8, 8>::new()); | 54 | static STATE: StaticCell<State<8, 8>> = StaticCell::new(); |
| 55 | let state = STATE.init(State::<8, 8>::new()); | ||
| 55 | let (device, runner) = embassy_net_wiznet::new( | 56 | let (device, runner) = embassy_net_wiznet::new( |
| 56 | mac_addr, | 57 | mac_addr, |
| 57 | state, | 58 | state, |
| @@ -66,11 +67,13 @@ async fn main(spawner: Spawner) { | |||
| 66 | let seed = rng.next_u64(); | 67 | let seed = rng.next_u64(); |
| 67 | 68 | ||
| 68 | // Init network stack | 69 | // Init network stack |
| 69 | let stack = &*make_static!(Stack::new( | 70 | static STACK: StaticCell<Stack<Device<'static>>> = StaticCell::new(); |
| 71 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 72 | let stack = &*STACK.init(Stack::new( | ||
| 70 | device, | 73 | device, |
| 71 | embassy_net::Config::dhcpv4(Default::default()), | 74 | embassy_net::Config::dhcpv4(Default::default()), |
| 72 | make_static!(StackResources::<2>::new()), | 75 | RESOURCES.init(StackResources::<2>::new()), |
| 73 | seed | 76 | seed, |
| 74 | )); | 77 | )); |
| 75 | 78 | ||
| 76 | // Launch network task | 79 | // Launch network task |
diff --git a/tests/stm32/src/bin/eth.rs b/tests/stm32/src/bin/eth.rs index 754354944..c01f33a97 100644 --- a/tests/stm32/src/bin/eth.rs +++ b/tests/stm32/src/bin/eth.rs | |||
| @@ -14,7 +14,7 @@ use embassy_stm32::peripherals::ETH; | |||
| 14 | use embassy_stm32::rng::Rng; | 14 | use embassy_stm32::rng::Rng; |
| 15 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng}; | 15 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng}; |
| 16 | use rand_core::RngCore; | 16 | use rand_core::RngCore; |
| 17 | use static_cell::make_static; | 17 | use static_cell::StaticCell; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | teleprobe_meta::timeout!(120); | 20 | teleprobe_meta::timeout!(120); |
| @@ -71,8 +71,9 @@ async fn main(spawner: Spawner) { | |||
| 71 | #[cfg(not(feature = "stm32f207zg"))] | 71 | #[cfg(not(feature = "stm32f207zg"))] |
| 72 | const PACKET_QUEUE_SIZE: usize = 4; | 72 | const PACKET_QUEUE_SIZE: usize = 4; |
| 73 | 73 | ||
| 74 | static PACKETS: StaticCell<PacketQueue<PACKET_QUEUE_SIZE, PACKET_QUEUE_SIZE>> = StaticCell::new(); | ||
| 74 | let device = Ethernet::new( | 75 | let device = Ethernet::new( |
| 75 | make_static!(PacketQueue::<PACKET_QUEUE_SIZE, PACKET_QUEUE_SIZE>::new()), | 76 | PACKETS.init(PacketQueue::<PACKET_QUEUE_SIZE, PACKET_QUEUE_SIZE>::new()), |
| 76 | p.ETH, | 77 | p.ETH, |
| 77 | Irqs, | 78 | Irqs, |
| 78 | p.PA1, | 79 | p.PA1, |
| @@ -99,11 +100,13 @@ async fn main(spawner: Spawner) { | |||
| 99 | //}); | 100 | //}); |
| 100 | 101 | ||
| 101 | // Init network stack | 102 | // Init network stack |
| 102 | let stack = &*make_static!(Stack::new( | 103 | static STACK: StaticCell<Stack<Device>> = StaticCell::new(); |
| 104 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 105 | let stack = &*STACK.init(Stack::new( | ||
| 103 | device, | 106 | device, |
| 104 | config, | 107 | config, |
| 105 | make_static!(StackResources::<2>::new()), | 108 | RESOURCES.init(StackResources::<2>::new()), |
| 106 | seed | 109 | seed, |
| 107 | )); | 110 | )); |
| 108 | 111 | ||
| 109 | // Launch network task | 112 | // Launch network task |
diff --git a/tests/stm32/src/bin/stop.rs b/tests/stm32/src/bin/stop.rs index b9810673a..f8e3c43d7 100644 --- a/tests/stm32/src/bin/stop.rs +++ b/tests/stm32/src/bin/stop.rs | |||
| @@ -15,7 +15,7 @@ use embassy_stm32::rcc::LsConfig; | |||
| 15 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 15 | use embassy_stm32::rtc::{Rtc, RtcConfig}; |
| 16 | use embassy_stm32::Config; | 16 | use embassy_stm32::Config; |
| 17 | use embassy_time::Timer; | 17 | use embassy_time::Timer; |
| 18 | use static_cell::make_static; | 18 | use static_cell::StaticCell; |
| 19 | 19 | ||
| 20 | #[entry] | 20 | #[entry] |
| 21 | fn main() -> ! { | 21 | fn main() -> ! { |
| @@ -64,7 +64,8 @@ async fn async_main(spawner: Spawner) { | |||
| 64 | 64 | ||
| 65 | rtc.set_datetime(now.into()).expect("datetime not set"); | 65 | rtc.set_datetime(now.into()).expect("datetime not set"); |
| 66 | 66 | ||
| 67 | let rtc = make_static!(rtc); | 67 | static RTC: StaticCell<Rtc> = StaticCell::new(); |
| 68 | let rtc = RTC.init(rtc); | ||
| 68 | 69 | ||
| 69 | stop_with_rtc(rtc); | 70 | stop_with_rtc(rtc); |
| 70 | 71 | ||
