Remove Forever, switch to static_cell.
This commit is contained in:
@ -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"
|
||||
|
@ -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
|
||||
));
|
||||
|
||||
|
Reference in New Issue
Block a user