diff options
| author | Ulf Lilleengen <[email protected]> | 2023-12-21 10:02:11 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-12-21 10:02:11 +0000 |
| commit | 530ead5fdeba97dd7d84798463436d1c75bbe96e (patch) | |
| tree | 40c027b0f69efe9a9edb9913c0c1122a9b608318 /tests | |
| parent | 8442e72589f47182f8ca1c979c668afc800e5d1e (diff) | |
| parent | 0acf7b09c3bc9176d00479d601356d8df2537a9b (diff) | |
Merge pull request #2339 from embassy-rs/make-static-remove
Replace make_static! macro usage with non-macro version
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/nrf/src/bin/ethernet_enc28j60_perf.rs | 10 | ||||
| -rw-r--r-- | tests/nrf/src/bin/wifi_esp_hosted_perf.rs | 13 | ||||
| -rw-r--r-- | tests/rp/src/bin/cyw43-perf.rs | 13 | ||||
| -rw-r--r-- | tests/rp/src/bin/ethernet_w5100s_perf.rs | 13 | ||||
| -rw-r--r-- | tests/stm32/src/bin/eth.rs | 13 | ||||
| -rw-r--r-- | tests/stm32/src/bin/stop.rs | 5 |
6 files changed, 41 insertions, 26 deletions
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 | ||
