Use make_static! from static-cell v1.1
This commit is contained in:
@ -21,18 +21,9 @@ use embassy_time::{Duration, Timer};
|
||||
use embedded_hal_async::spi::ExclusiveDevice;
|
||||
use embedded_io::asynch::Write;
|
||||
use rand::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
|
||||
}};
|
||||
}
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn ethernet_task(
|
||||
runner: Runner<
|
||||
@ -65,7 +56,7 @@ async fn main(spawner: Spawner) {
|
||||
let w5500_reset = Output::new(p.PIN_20, Level::High);
|
||||
|
||||
let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00];
|
||||
let state = singleton!(State::<8, 8>::new());
|
||||
let state = make_static!(State::<8, 8>::new());
|
||||
let (device, runner) =
|
||||
embassy_net_w5500::new(mac_addr, state, ExclusiveDevice::new(spi, cs), w5500_int, w5500_reset).await;
|
||||
unwrap!(spawner.spawn(ethernet_task(runner)));
|
||||
@ -74,10 +65,10 @@ async fn main(spawner: Spawner) {
|
||||
let seed = rng.next_u64();
|
||||
|
||||
// Init network stack
|
||||
let stack = &*singleton!(Stack::new(
|
||||
let stack = &*make_static!(Stack::new(
|
||||
device,
|
||||
embassy_net::Config::Dhcp(Default::default()),
|
||||
singleton!(StackResources::<2>::new()),
|
||||
make_static!(StackResources::<2>::new()),
|
||||
seed
|
||||
));
|
||||
|
||||
|
Reference in New Issue
Block a user