Use make_static! from static-cell v1.1

This commit is contained in:
Dario Nieuwenhuis
2023-06-01 01:32:11 +02:00
parent d7d66bd74f
commit 1d8321b821
38 changed files with 168 additions and 300 deletions

View File

@ -30,7 +30,7 @@ critical-section = "1.1"
micromath = "2.0.0"
stm32-fmc = "0.2.4"
embedded-storage = "0.3.0"
static_cell = "1.0"
static_cell = { version = "1.1", features = ["nightly"]}
# cargo build/run
[profile.dev]

View File

@ -16,18 +16,8 @@ use embassy_stm32::{bind_interrupts, eth, Config};
use embassy_time::{Duration, Timer};
use embedded_io::asynch::Write;
use rand_core::RngCore;
use static_cell::StaticCell;
use static_cell::make_static;
use {defmt_rtt as _, panic_probe as _};
macro_rules! singleton {
($val:expr) => {{
type T = impl Sized;
static STATIC_CELL: StaticCell<T> = StaticCell::new();
let (x,) = STATIC_CELL.init(($val,));
x
}};
}
bind_interrupts!(struct Irqs {
ETH => eth::InterruptHandler;
});
@ -74,7 +64,7 @@ async fn main(spawner: Spawner) -> ! {
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
let device = Ethernet::new(
singleton!(PacketQueue::<4, 4>::new()),
make_static!(PacketQueue::<4, 4>::new()),
p.ETH,
Irqs,
p.PA1,
@ -99,7 +89,12 @@ async fn main(spawner: Spawner) -> ! {
//});
// Init network stack
let stack = &*singleton!(Stack::new(device, config, singleton!(StackResources::<2>::new()), seed));
let stack = &*make_static!(Stack::new(
device,
config,
make_static!(StackResources::<2>::new()),
seed
));
// Launch network task
unwrap!(spawner.spawn(net_task(&stack)));