Remove Forever, switch to static_cell.

This commit is contained in:
Dario Nieuwenhuis
2022-08-22 15:51:44 +02:00
parent 1b95990258
commit 478f472784
45 changed files with 139 additions and 220 deletions

View File

@ -24,3 +24,4 @@ nb = "1.0.0"
rand_core = "0.6.3"
critical-section = "1.1"
embedded-storage = "0.3.0"
static_cell = "1.0"

View File

@ -13,16 +13,16 @@ use embassy_stm32::rng::Rng;
use embassy_stm32::time::mhz;
use embassy_stm32::{interrupt, Config};
use embassy_time::{Duration, Timer};
use embassy_util::Forever;
use embedded_io::asynch::Write;
use rand_core::RngCore;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
macro_rules! forever {
macro_rules! singleton {
($val:expr) => {{
type T = impl Sized;
static FOREVER: Forever<T> = Forever::new();
FOREVER.put_with(move || $val)
static STATIC_CELL: StaticCell<T> = StaticCell::new();
STATIC_CELL.init_with(move || $val)
}};
}
@ -52,7 +52,7 @@ async fn main(spawner: Spawner) -> ! {
let device = unsafe {
Ethernet::new(
forever!(State::new()),
singleton!(State::new()),
p.ETH,
eth_int,
p.PA1,
@ -78,10 +78,10 @@ async fn main(spawner: Spawner) -> ! {
//});
// Init network stack
let stack = &*forever!(Stack::new(
let stack = &*singleton!(Stack::new(
device,
config,
forever!(StackResources::<1, 2, 8>::new()),
singleton!(StackResources::<1, 2, 8>::new()),
seed
));