chore: replace make_static! macro usage with non-macro version

This commit is contained in:
Ulf Lilleengen 2023-12-21 08:50:54 +01:00
parent d832d45c0b
commit 0acf7b09c3
37 changed files with 313 additions and 188 deletions

View file

@ -411,10 +411,12 @@ impl<D: Driver> Stack<D> {
/// ```ignore
/// let config = embassy_net::Config::dhcpv4(Default::default());
///// Init network stack
/// let stack = &*make_static!(embassy_net::Stack::new(
/// static RESOURCES: StaticCell<embassy_net::StackResources<2> = StaticCell::new();
/// static STACK: StaticCell<embassy_net::Stack> = StaticCell::new();
/// let stack = &*STACK.init(embassy_net::Stack::new(
/// device,
/// config,
/// make_static!(embassy_net::StackResources::<2>::new()),
/// RESOURCES.init(embassy_net::StackResources::new()),
/// seed
/// ));
/// // Launch network task that runs `stack.run().await`

View file

@ -24,7 +24,7 @@
//! use embassy_executor::Spawner;
//! use embassy_stm32::low_power::Executor;
//! use embassy_stm32::rtc::{Rtc, RtcConfig};
//! use static_cell::make_static;
//! use static_cell::StaticCell;
//!
//! #[cortex_m_rt::entry]
//! fn main() -> ! {
@ -41,7 +41,8 @@
//!
//! // give the RTC to the executor...
//! let mut rtc = Rtc::new(p.RTC, RtcConfig::default());
//! let rtc = make_static!(rtc);
//! static RTC: StaticCell<Rtc> = StaticCell::new();
//! let rtc = RTC.init(rtc);
//! embassy_stm32::low_power::stop_with_rtc(rtc);
//!
//! // your application here...

View file

@ -14,7 +14,7 @@ use embassy_nrf::{bind_interrupts, peripherals, spim};
use embassy_time::Delay;
use embedded_hal_bus::spi::ExclusiveDevice;
use embedded_io_async::Write;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -70,11 +70,20 @@ async fn main(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);
// Init network stack
let stack = &*make_static!(Stack::new(
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
static STACK: StaticCell<
Stack<
Enc28j60<
ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_15>, Delay>,
Output<'static, peripherals::P0_13>,
>,
>,
> = StaticCell::new();
let stack = STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
unwrap!(spawner.spawn(net_task(stack)));

View file

@ -16,7 +16,7 @@ use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState
use embassy_usb::class::cdc_ncm::{CdcNcmClass, State};
use embassy_usb::{Builder, Config, UsbDevice};
use embedded_io_async::Write;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -71,14 +71,19 @@ async fn main(spawner: Spawner) {
config.device_protocol = 0x01;
// Create embassy-usb DeviceBuilder using the driver and config.
static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static MSOS_DESC: StaticCell<[u8; 128]> = StaticCell::new();
static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new();
let mut builder = Builder::new(
driver,
config,
&mut make_static!([0; 256])[..],
&mut make_static!([0; 256])[..],
&mut make_static!([0; 256])[..],
&mut make_static!([0; 128])[..],
&mut make_static!([0; 128])[..],
&mut DEVICE_DESC.init([0; 256])[..],
&mut CONFIG_DESC.init([0; 256])[..],
&mut BOS_DESC.init([0; 256])[..],
&mut MSOS_DESC.init([0; 128])[..],
&mut CONTROL_BUF.init([0; 128])[..],
);
// Our MAC addr.
@ -87,14 +92,16 @@ async fn main(spawner: Spawner) {
let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88];
// Create classes on the builder.
let class = CdcNcmClass::new(&mut builder, make_static!(State::new()), host_mac_addr, 64);
static STATE: StaticCell<State> = StaticCell::new();
let class = CdcNcmClass::new(&mut builder, STATE.init(State::new()), host_mac_addr, 64);
// Build the builder.
let usb = builder.build();
unwrap!(spawner.spawn(usb_task(usb)));
let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr);
static NET_STATE: StaticCell<NetState<MTU, 4, 4>> = StaticCell::new();
let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(NET_STATE.init(NetState::new()), our_mac_addr);
unwrap!(spawner.spawn(usb_ncm_task(runner)));
let config = embassy_net::Config::dhcpv4(Default::default());
@ -111,12 +118,9 @@ async fn main(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);
// Init network stack
let stack = &*make_static!(Stack::new(
device,
config,
make_static!(StackResources::<2>::new()),
seed
));
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(device, config, RESOURCES.init(StackResources::new()), seed));
unwrap!(spawner.spawn(net_task(stack)));

View file

@ -12,7 +12,7 @@ use embassy_nrf::{bind_interrupts, pac, peripherals, usb};
use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
use embassy_usb::driver::EndpointError;
use embassy_usb::{Builder, Config, UsbDevice};
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -64,17 +64,23 @@ async fn main(spawner: Spawner) {
config.device_protocol = 0x01;
config.composite_with_iads = true;
let state = make_static!(State::new());
static STATE: StaticCell<State> = StaticCell::new();
let state = STATE.init(State::new());
// Create embassy-usb DeviceBuilder using the driver and config.
static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static MSOS_DESC: StaticCell<[u8; 128]> = StaticCell::new();
static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new();
let mut builder = Builder::new(
driver,
config,
&mut make_static!([0; 256])[..],
&mut make_static!([0; 256])[..],
&mut make_static!([0; 256])[..],
&mut make_static!([0; 128])[..],
&mut make_static!([0; 128])[..],
&mut DEVICE_DESC.init([0; 256])[..],
&mut CONFIG_DESC.init([0; 256])[..],
&mut BOS_DESC.init([0; 256])[..],
&mut MSOS_DESC.init([0; 128])[..],
&mut CONTROL_BUF.init([0; 128])[..],
);
// Create classes on the builder.

View file

@ -13,7 +13,7 @@ use embassy_nrf::{bind_interrupts, peripherals};
use embassy_time::Delay;
use embedded_hal_bus::spi::ExclusiveDevice;
use embedded_io_async::Write;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _};
const WIFI_NETWORK: &str = "EmbassyTest";
@ -61,8 +61,9 @@ async fn main(spawner: Spawner) {
let spi = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config);
let spi = ExclusiveDevice::new(spi, cs, Delay);
static ESP_STATE: StaticCell<embassy_net_esp_hosted::State> = StaticCell::new();
let (device, mut control, runner) = embassy_net_esp_hosted::new(
make_static!(embassy_net_esp_hosted::State::new()),
ESP_STATE.init(embassy_net_esp_hosted::State::new()),
spi,
handshake,
ready,
@ -89,11 +90,13 @@ async fn main(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);
// Init network stack
let stack = &*make_static!(Stack::new(
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
static STACK: StaticCell<Stack<hosted::NetDriver<'static>>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
unwrap!(spawner.spawn(net_task(stack)));

View file

@ -20,7 +20,7 @@ use embassy_time::{Delay, Duration};
use embedded_hal_bus::spi::ExclusiveDevice;
use embedded_io_async::Write;
use rand::RngCore;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -55,7 +55,8 @@ 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 = make_static!(State::<8, 8>::new());
static STATE: StaticCell<State<8, 8>> = StaticCell::new();
let state = STATE.init(State::<8, 8>::new());
let (device, runner) = embassy_net_wiznet::new(
mac_addr,
state,
@ -70,11 +71,13 @@ async fn main(spawner: Spawner) {
let seed = rng.next_u64();
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device<'static>>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
embassy_net::Config::dhcpv4(Default::default()),
make_static!(StackResources::<3>::new()),
seed
RESOURCES.init(StackResources::<3>::new()),
seed,
));
// Launch network task

View file

@ -22,7 +22,7 @@ use embassy_time::{Delay, Duration, Timer};
use embedded_hal_bus::spi::ExclusiveDevice;
use embedded_io_async::Write;
use rand::RngCore;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -58,7 +58,8 @@ 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 = make_static!(State::<8, 8>::new());
static STATE: StaticCell<State<8, 8>> = StaticCell::new();
let state = STATE.init(State::<8, 8>::new());
let (device, runner) = embassy_net_wiznet::new(
mac_addr,
state,
@ -73,11 +74,13 @@ async fn main(spawner: Spawner) {
let seed = rng.next_u64();
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device<'static>>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
embassy_net::Config::dhcpv4(Default::default()),
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
// Launch network task

View file

@ -21,7 +21,7 @@ use embassy_time::{Delay, Duration};
use embedded_hal_bus::spi::ExclusiveDevice;
use embedded_io_async::Write;
use rand::RngCore;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -57,7 +57,8 @@ 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 = make_static!(State::<8, 8>::new());
static STATE: StaticCell<State<8, 8>> = StaticCell::new();
let state = STATE.init(State::<8, 8>::new());
let (device, runner) = embassy_net_wiznet::new(
mac_addr,
state,
@ -72,11 +73,13 @@ async fn main(spawner: Spawner) {
let seed = rng.next_u64();
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device<'static>>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
embassy_net::Config::dhcpv4(Default::default()),
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
// Launch network task

View file

@ -20,7 +20,7 @@ use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
use embassy_time::Delay;
use embedded_hal_bus::spi::ExclusiveDevice;
use rand::RngCore;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -55,7 +55,8 @@ 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 = make_static!(State::<8, 8>::new());
static STATE: StaticCell<State<8, 8>> = StaticCell::new();
let state = STATE.init(State::<8, 8>::new());
let (device, runner) = embassy_net_wiznet::new(
mac_addr,
state,
@ -70,11 +71,13 @@ async fn main(spawner: Spawner) {
let seed = rng.next_u64();
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device<'static>>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
embassy_net::Config::dhcpv4(Default::default()),
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
// Launch network task

View file

@ -15,7 +15,7 @@ use embassy_rp::peripherals::UART0;
use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config};
use embassy_time::Timer;
use embedded_io_async::{Read, Write};
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -27,8 +27,10 @@ async fn main(spawner: Spawner) {
let p = embassy_rp::init(Default::default());
let (tx_pin, rx_pin, uart) = (p.PIN_0, p.PIN_1, p.UART0);
let tx_buf = &mut make_static!([0u8; 16])[..];
let rx_buf = &mut make_static!([0u8; 16])[..];
static TX_BUF: StaticCell<[u8; 16]> = StaticCell::new();
let tx_buf = &mut TX_BUF.init([0; 16])[..];
static RX_BUF: StaticCell<[u8; 16]> = StaticCell::new();
let rx_buf = &mut RX_BUF.init([0; 16])[..];
let uart = BufferedUart::new(uart, Irqs, tx_pin, rx_pin, tx_buf, rx_buf, Config::default());
let (rx, mut tx) = uart.split();

View file

@ -17,7 +17,7 @@ use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState
use embassy_usb::class::cdc_ncm::{CdcNcmClass, State};
use embassy_usb::{Builder, Config, UsbDevice};
use embedded_io_async::Write;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -65,14 +65,18 @@ async fn main(spawner: Spawner) {
config.device_protocol = 0x01;
// Create embassy-usb DeviceBuilder using the driver and config.
static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new();
let mut builder = Builder::new(
driver,
config,
&mut make_static!([0; 256])[..],
&mut make_static!([0; 256])[..],
&mut make_static!([0; 256])[..],
&mut DEVICE_DESC.init([0; 256])[..],
&mut CONFIG_DESC.init([0; 256])[..],
&mut BOS_DESC.init([0; 256])[..],
&mut [], // no msos descriptors
&mut make_static!([0; 128])[..],
&mut CONTROL_BUF.init([0; 128])[..],
);
// Our MAC addr.
@ -81,14 +85,16 @@ async fn main(spawner: Spawner) {
let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88];
// Create classes on the builder.
let class = CdcNcmClass::new(&mut builder, make_static!(State::new()), host_mac_addr, 64);
static STATE: StaticCell<State> = StaticCell::new();
let class = CdcNcmClass::new(&mut builder, STATE.init(State::new()), host_mac_addr, 64);
// Build the builder.
let usb = builder.build();
unwrap!(spawner.spawn(usb_task(usb)));
let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr);
static NET_STATE: StaticCell<NetState<MTU, 4, 4>> = StaticCell::new();
let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(NET_STATE.init(NetState::new()), our_mac_addr);
unwrap!(spawner.spawn(usb_ncm_task(runner)));
let config = embassy_net::Config::dhcpv4(Default::default());
@ -102,11 +108,13 @@ async fn main(spawner: Spawner) {
let seed = 1234; // guaranteed random, chosen by a fair dice roll
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
unwrap!(spawner.spawn(net_task(stack)));

View file

@ -19,7 +19,7 @@ use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
use embassy_rp::pio::{InterruptHandler, Pio};
use embassy_time::Duration;
use embedded_io_async::Write;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -59,7 +59,8 @@ async fn main(spawner: Spawner) {
let mut pio = Pio::new(p.PIO0, Irqs);
let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0);
let state = make_static!(cyw43::State::new());
static STATE: StaticCell<cyw43::State> = StaticCell::new();
let state = STATE.init(cyw43::State::new());
let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
unwrap!(spawner.spawn(wifi_task(runner)));
@ -79,11 +80,13 @@ async fn main(spawner: Spawner) {
let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random.
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<cyw43::NetDriver<'static>>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
net_device,
config,
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
unwrap!(spawner.spawn(net_task(stack)));

View file

@ -14,7 +14,7 @@ use embassy_rp::gpio::{Level, Output};
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
use embassy_rp::pio::{InterruptHandler, Pio};
use embassy_time::{Duration, Timer};
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -46,7 +46,8 @@ async fn main(spawner: Spawner) {
let mut pio = Pio::new(p.PIO0, Irqs);
let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0);
let state = make_static!(cyw43::State::new());
static STATE: StaticCell<cyw43::State> = StaticCell::new();
let state = STATE.init(cyw43::State::new());
let (_net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
unwrap!(spawner.spawn(wifi_task(runner)));

View file

@ -16,7 +16,7 @@ use embassy_rp::bind_interrupts;
use embassy_rp::gpio::{Level, Output};
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
use embassy_rp::pio::{InterruptHandler, Pio};
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -56,7 +56,8 @@ async fn main(spawner: Spawner) {
let mut pio = Pio::new(p.PIO0, Irqs);
let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0);
let state = make_static!(cyw43::State::new());
static STATE: StaticCell<cyw43::State> = StaticCell::new();
let state = STATE.init(cyw43::State::new());
let (_net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
unwrap!(spawner.spawn(wifi_task(runner)));

View file

@ -19,7 +19,7 @@ use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
use embassy_rp::pio::{InterruptHandler, Pio};
use embassy_time::{Duration, Timer};
use embedded_io_async::Write;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -62,7 +62,8 @@ async fn main(spawner: Spawner) {
let mut pio = Pio::new(p.PIO0, Irqs);
let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0);
let state = make_static!(cyw43::State::new());
static STATE: StaticCell<cyw43::State> = StaticCell::new();
let state = STATE.init(cyw43::State::new());
let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
unwrap!(spawner.spawn(wifi_task(runner)));
@ -82,11 +83,13 @@ async fn main(spawner: Spawner) {
let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random.
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<cyw43::NetDriver<'static>>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
net_device,
config,
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
unwrap!(spawner.spawn(net_task(stack)));

View file

@ -12,7 +12,7 @@ use embedded_io_async::Write;
use heapless::Vec;
use log::*;
use rand_core::{OsRng, RngCore};
use static_cell::{make_static, StaticCell};
use static_cell::StaticCell;
#[derive(Parser)]
#[clap(version = "1.0")]
@ -54,11 +54,13 @@ async fn main_task(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<TunTapDevice>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<3>::new()),
seed
RESOURCES.init(StackResources::<3>::new()),
seed,
));
// Launch network task

View file

@ -10,7 +10,7 @@ use embassy_net_tuntap::TunTapDevice;
use heapless::Vec;
use log::*;
use rand_core::{OsRng, RngCore};
use static_cell::{make_static, StaticCell};
use static_cell::StaticCell;
#[derive(Parser)]
#[clap(version = "1.0")]
@ -53,11 +53,13 @@ async fn main_task(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);
// Init network stack
let stack: &Stack<_> = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<TunTapDevice>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new();
let stack: &Stack<_> = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<3>::new()),
seed
RESOURCES.init(StackResources::<3>::new()),
seed,
));
// Launch network task

View file

@ -25,7 +25,7 @@ use heapless::Vec;
use log::*;
use nix::sys::termios;
use rand_core::{OsRng, RngCore};
use static_cell::{make_static, StaticCell};
use static_cell::StaticCell;
use crate::serial_port::SerialPort;
@ -88,7 +88,8 @@ async fn main_task(spawner: Spawner) {
let port = SerialPort::new(opts.device.as_str(), baudrate).unwrap();
// Init network device
let state = make_static!(embassy_net_ppp::State::<4, 4>::new());
static STATE: StaticCell<embassy_net_ppp::State<4, 4>> = StaticCell::new();
let state = STATE.init(embassy_net_ppp::State::<4, 4>::new());
let (device, runner) = embassy_net_ppp::new(state);
// Generate random seed
@ -97,11 +98,13 @@ async fn main_task(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<embassy_net_ppp::Device<'static>>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
Config::default(), // don't configure IP yet
make_static!(StackResources::<3>::new()),
seed
RESOURCES.init(StackResources::<3>::new()),
seed,
));
// Launch network task

View file

@ -8,7 +8,7 @@ use embassy_net_tuntap::TunTapDevice;
use heapless::Vec;
use log::*;
use rand_core::{OsRng, RngCore};
use static_cell::{make_static, StaticCell};
use static_cell::StaticCell;
#[derive(Parser)]
#[clap(version = "1.0")]
@ -50,11 +50,13 @@ async fn main_task(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<TunTapDevice>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<3>::new()),
seed
RESOURCES.init(StackResources::<3>::new()),
seed,
));
// Launch network task

View file

@ -13,7 +13,7 @@ use embedded_io_async::Write as _;
use heapless::Vec;
use log::*;
use rand_core::{OsRng, RngCore};
use static_cell::{make_static, StaticCell};
use static_cell::StaticCell;
#[derive(Parser)]
#[clap(version = "1.0")]
@ -65,11 +65,13 @@ async fn main_task(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<TunTapDevice>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<3>::new()),
seed
RESOURCES.init(StackResources::<3>::new()),
seed,
));
// Launch network task

View file

@ -14,7 +14,7 @@ use embassy_stm32::time::Hertz;
use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
use embassy_time::Timer;
use embedded_io_async::Write;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -63,8 +63,9 @@ async fn main(spawner: Spawner) -> ! {
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new();
let device = Ethernet::new(
make_static!(PacketQueue::<16, 16>::new()),
PACKETS.init(PacketQueue::<16, 16>::new()),
p.ETH,
Irqs,
p.PA1,
@ -88,11 +89,13 @@ async fn main(spawner: Spawner) -> ! {
//});
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
// Launch network task

View file

@ -14,7 +14,7 @@ use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState
use embassy_usb::class::cdc_ncm::{CdcNcmClass, State};
use embassy_usb::{Builder, UsbDevice};
use embedded_io_async::Write;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
type UsbDriver = Driver<'static, embassy_stm32::peripherals::USB_OTG_FS>;
@ -68,7 +68,8 @@ async fn main(spawner: Spawner) {
let p = embassy_stm32::init(config);
// Create the driver, from the HAL.
let ep_out_buffer = &mut make_static!([0; 256])[..];
static OUTPUT_BUFFER: StaticCell<[u8; 256]> = StaticCell::new();
let ep_out_buffer = &mut OUTPUT_BUFFER.init([0; 256])[..];
let mut config = embassy_stm32::usb_otg::Config::default();
config.vbus_detection = true;
let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, ep_out_buffer, config);
@ -88,14 +89,18 @@ async fn main(spawner: Spawner) {
config.device_protocol = 0x01;
// Create embassy-usb DeviceBuilder using the driver and config.
static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new();
let mut builder = Builder::new(
driver,
config,
&mut make_static!([0; 256])[..],
&mut make_static!([0; 256])[..],
&mut make_static!([0; 256])[..],
&mut DEVICE_DESC.init([0; 256])[..],
&mut CONFIG_DESC.init([0; 256])[..],
&mut BOS_DESC.init([0; 256])[..],
&mut [], // no msos descriptors
&mut make_static!([0; 128])[..],
&mut CONTROL_BUF.init([0; 128])[..],
);
// Our MAC addr.
@ -104,14 +109,16 @@ async fn main(spawner: Spawner) {
let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88];
// Create classes on the builder.
let class = CdcNcmClass::new(&mut builder, make_static!(State::new()), host_mac_addr, 64);
static STATE: StaticCell<State> = StaticCell::new();
let class = CdcNcmClass::new(&mut builder, STATE.init(State::new()), host_mac_addr, 64);
// Build the builder.
let usb = builder.build();
unwrap!(spawner.spawn(usb_task(usb)));
let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr);
static NET_STATE: StaticCell<NetState<MTU, 4, 4>> = StaticCell::new();
let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(NET_STATE.init(NetState::new()), our_mac_addr);
unwrap!(spawner.spawn(usb_ncm_task(runner)));
let config = embassy_net::Config::dhcpv4(Default::default());
@ -128,11 +135,13 @@ async fn main(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
unwrap!(spawner.spawn(net_task(stack)));

View file

@ -12,6 +12,7 @@ use embassy_stm32::can::{
};
use embassy_stm32::gpio::{Input, Pull};
use embassy_stm32::peripherals::CAN3;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -43,7 +44,8 @@ async fn main(spawner: Spawner) {
let rx_pin = Input::new(&mut p.PA15, Pull::Up);
core::mem::forget(rx_pin);
let can: &'static mut Can<'static, CAN3> = static_cell::make_static!(Can::new(p.CAN3, p.PA8, p.PA15, Irqs));
static CAN: StaticCell<Can<'static, CAN3>> = StaticCell::new();
let can = CAN.init(Can::new(p.CAN3, p.PA8, p.PA15, Irqs));
can.as_mut()
.modify_filters()
.enable_bank(0, Fifo::Fifo0, Mask32::accept_all());
@ -56,7 +58,8 @@ async fn main(spawner: Spawner) {
let (tx, mut rx) = can.split();
let tx: &'static mut CanTx<'static, 'static, CAN3> = static_cell::make_static!(tx);
static CAN_TX: StaticCell<CanTx<'static, 'static, CAN3>> = StaticCell::new();
let tx = CAN_TX.init(tx);
spawner.spawn(send_can_message(tx)).unwrap();
loop {

View file

@ -15,7 +15,7 @@ use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
use embassy_time::Timer;
use embedded_io_async::Write;
use rand_core::RngCore;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -64,8 +64,9 @@ async fn main(spawner: Spawner) -> ! {
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new();
let device = Ethernet::new(
make_static!(PacketQueue::<16, 16>::new()),
PACKETS.init(PacketQueue::<16, 16>::new()),
p.ETH,
Irqs,
p.PA1,
@ -89,11 +90,13 @@ async fn main(spawner: Spawner) -> ! {
//});
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
// Launch network task

View file

@ -18,7 +18,7 @@ use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
use embassy_time::Timer;
use embedded_io_async::Write;
use rand_core::RngCore;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -67,8 +67,9 @@ async fn main(spawner: Spawner) -> ! {
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
static PACKETS: StaticCell<PacketQueue<4, 4>> = StaticCell::new();
let device = Ethernet::new(
make_static!(PacketQueue::<4, 4>::new()),
PACKETS.init(PacketQueue::<4, 4>::new()),
p.ETH,
Irqs,
p.PA1,
@ -92,11 +93,13 @@ async fn main(spawner: Spawner) -> ! {
//});
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
// Launch network task

View file

@ -14,7 +14,7 @@ use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
use embassy_time::Timer;
use embedded_io_async::Write;
use rand_core::RngCore;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -64,8 +64,9 @@ async fn main(spawner: Spawner) -> ! {
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
static PACKETS: StaticCell<PacketQueue<4, 4>> = StaticCell::new();
let device = Ethernet::new(
make_static!(PacketQueue::<16, 16>::new()),
PACKETS.init(PacketQueue::<4, 4>::new()),
p.ETH,
Irqs,
p.PA1,
@ -89,11 +90,13 @@ async fn main(spawner: Spawner) -> ! {
//});
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<3>::new()),
seed
RESOURCES.init(StackResources::<3>::new()),
seed,
));
// Launch network task

View file

@ -15,7 +15,7 @@ use embassy_time::Timer;
use embedded_io_async::Write;
use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect};
use rand_core::RngCore;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -65,8 +65,9 @@ async fn main(spawner: Spawner) -> ! {
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new();
let device = Ethernet::new(
make_static!(PacketQueue::<16, 16>::new()),
PACKETS.init(PacketQueue::<16, 16>::new()),
p.ETH,
Irqs,
p.PA1,
@ -90,11 +91,13 @@ async fn main(spawner: Spawner) -> ! {
//});
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<3>::new()),
seed
RESOURCES.init(StackResources::<3>::new()),
seed,
));
// Launch network task

View file

@ -36,7 +36,7 @@ use hal::rng::{self, Rng};
use hal::{bind_interrupts, exti, pac, peripherals};
use heapless::Vec;
use rand::RngCore;
use static_cell::make_static;
use static_cell::StaticCell;
use {embassy_stm32 as hal, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -180,7 +180,8 @@ async fn main(spawner: Spawner) {
}
};
let state = make_static!(embassy_net_adin1110::State::<8, 8>::new());
static STATE: StaticCell<embassy_net_adin1110::State<8, 8>> = StaticCell::new();
let state = STATE.init(embassy_net_adin1110::State::<8, 8>::new());
let (device, runner) = embassy_net_adin1110::new(
MAC,
@ -217,11 +218,13 @@ async fn main(spawner: Spawner) {
};
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device<'static>>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
ip_cfg,
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
// Launch network task

View file

@ -15,7 +15,7 @@ use embassy_usb::class::cdc_ncm::{CdcNcmClass, State};
use embassy_usb::{Builder, UsbDevice};
use embedded_io_async::Write;
use rand_core::RngCore;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
type MyDriver = Driver<'static, embassy_stm32::peripherals::USB>;
@ -76,14 +76,18 @@ async fn main(spawner: Spawner) {
config.device_protocol = 0x01;
// Create embassy-usb DeviceBuilder using the driver and config.
static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new();
let mut builder = Builder::new(
driver,
config,
&mut make_static!([0; 256])[..],
&mut make_static!([0; 256])[..],
&mut make_static!([0; 256])[..],
&mut DEVICE_DESC.init([0; 256])[..],
&mut CONFIG_DESC.init([0; 256])[..],
&mut BOS_DESC.init([0; 256])[..],
&mut [], // no msos descriptors
&mut make_static!([0; 128])[..],
&mut CONTROL_BUF.init([0; 128])[..],
);
// Our MAC addr.
@ -92,14 +96,16 @@ async fn main(spawner: Spawner) {
let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88];
// Create classes on the builder.
let class = CdcNcmClass::new(&mut builder, make_static!(State::new()), host_mac_addr, 64);
static STATE: StaticCell<State> = StaticCell::new();
let class = CdcNcmClass::new(&mut builder, STATE.init(State::new()), host_mac_addr, 64);
// Build the builder.
let usb = builder.build();
unwrap!(spawner.spawn(usb_task(usb)));
let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr);
static NET_STATE: StaticCell<NetState<MTU, 4, 4>> = StaticCell::new();
let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(NET_STATE.init(NetState::new()), our_mac_addr);
unwrap!(spawner.spawn(usb_ncm_task(runner)));
let config = embassy_net::Config::dhcpv4(Default::default());
@ -114,11 +120,13 @@ async fn main(spawner: Spawner) {
let seed = rng.next_u64();
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
unwrap!(spawner.spawn(net_task(stack)));

View file

@ -12,7 +12,7 @@ use embassy_stm32_wpan::mac::typedefs::{MacChannel, PanId, PibId};
use embassy_stm32_wpan::mac::{self, Runner};
use embassy_stm32_wpan::sub::mm;
use embassy_stm32_wpan::TlMbox;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs{
@ -154,15 +154,21 @@ async fn main(spawner: Spawner) {
.unwrap();
defmt::info!("{:#x}", mbox.mac_subsystem.read().await.unwrap());
static TX1: StaticCell<[u8; 127]> = StaticCell::new();
static TX2: StaticCell<[u8; 127]> = StaticCell::new();
static TX3: StaticCell<[u8; 127]> = StaticCell::new();
static TX4: StaticCell<[u8; 127]> = StaticCell::new();
static TX5: StaticCell<[u8; 127]> = StaticCell::new();
let tx_queue = [
make_static!([0u8; 127]),
make_static!([0u8; 127]),
make_static!([0u8; 127]),
make_static!([0u8; 127]),
make_static!([0u8; 127]),
TX1.init([0u8; 127]),
TX2.init([0u8; 127]),
TX3.init([0u8; 127]),
TX4.init([0u8; 127]),
TX5.init([0u8; 127]),
];
let runner = make_static!(Runner::new(mbox.mac_subsystem, tx_queue));
static RUNNER: StaticCell<Runner> = StaticCell::new();
let runner = RUNNER.init(Runner::new(mbox.mac_subsystem, tx_queue));
spawner.spawn(run_mac(runner)).unwrap();

View file

@ -14,7 +14,7 @@ use embassy_nrf::spim::{self, Spim};
use embassy_nrf::{bind_interrupts, peripherals};
use embassy_time::Delay;
use embedded_hal_bus::spi::ExclusiveDevice;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -68,11 +68,13 @@ async fn main(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<MyDriver>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
unwrap!(spawner.spawn(net_task(stack)));

View file

@ -13,7 +13,7 @@ use embassy_nrf::spim::{self, Spim};
use embassy_nrf::{bind_interrupts, peripherals};
use embassy_time::Delay;
use embedded_hal_bus::spi::ExclusiveDevice;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -64,8 +64,9 @@ async fn main(spawner: Spawner) {
let spi = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config);
let spi = ExclusiveDevice::new(spi, cs, Delay);
static STATE: StaticCell<embassy_net_esp_hosted::State> = StaticCell::new();
let (device, mut control, runner) = embassy_net_esp_hosted::new(
make_static!(embassy_net_esp_hosted::State::new()),
STATE.init(embassy_net_esp_hosted::State::new()),
spi,
handshake,
ready,
@ -85,11 +86,13 @@ async fn main(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<MyDriver>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
Config::dhcpv4(Default::default()),
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
unwrap!(spawner.spawn(net_task(stack)));

View file

@ -11,7 +11,7 @@ use embassy_rp::gpio::{Level, Output};
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
use embassy_rp::pio::{InterruptHandler, Pio};
use embassy_rp::{bind_interrupts, rom_data};
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs {
@ -58,7 +58,8 @@ async fn main(spawner: Spawner) {
let mut pio = Pio::new(p.PIO0, Irqs);
let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0);
let state = make_static!(cyw43::State::new());
static STATE: StaticCell<cyw43::State> = StaticCell::new();
let state = STATE.init(cyw43::State::new());
let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
unwrap!(spawner.spawn(wifi_task(runner)));
@ -71,11 +72,13 @@ async fn main(spawner: Spawner) {
let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random.
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<cyw43::NetDriver<'static>>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
net_device,
Config::dhcpv4(Default::default()),
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
unwrap!(spawner.spawn(net_task(stack)));

View file

@ -16,7 +16,7 @@ use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
use embassy_time::Delay;
use embedded_hal_bus::spi::ExclusiveDevice;
use rand::RngCore;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -51,7 +51,8 @@ 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 = make_static!(State::<8, 8>::new());
static STATE: StaticCell<State<8, 8>> = StaticCell::new();
let state = STATE.init(State::<8, 8>::new());
let (device, runner) = embassy_net_wiznet::new(
mac_addr,
state,
@ -66,11 +67,13 @@ async fn main(spawner: Spawner) {
let seed = rng.next_u64();
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device<'static>>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
embassy_net::Config::dhcpv4(Default::default()),
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
// Launch network task

View file

@ -14,7 +14,7 @@ use embassy_stm32::peripherals::ETH;
use embassy_stm32::rng::Rng;
use embassy_stm32::{bind_interrupts, eth, peripherals, rng};
use rand_core::RngCore;
use static_cell::make_static;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
teleprobe_meta::timeout!(120);
@ -71,8 +71,9 @@ async fn main(spawner: Spawner) {
#[cfg(not(feature = "stm32f207zg"))]
const PACKET_QUEUE_SIZE: usize = 4;
static PACKETS: StaticCell<PacketQueue<PACKET_QUEUE_SIZE, PACKET_QUEUE_SIZE>> = StaticCell::new();
let device = Ethernet::new(
make_static!(PacketQueue::<PACKET_QUEUE_SIZE, PACKET_QUEUE_SIZE>::new()),
PACKETS.init(PacketQueue::<PACKET_QUEUE_SIZE, PACKET_QUEUE_SIZE>::new()),
p.ETH,
Irqs,
p.PA1,
@ -99,11 +100,13 @@ async fn main(spawner: Spawner) {
//});
// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<Device>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<2>::new()),
seed
RESOURCES.init(StackResources::<2>::new()),
seed,
));
// Launch network task

View file

@ -15,7 +15,7 @@ use embassy_stm32::rcc::LsConfig;
use embassy_stm32::rtc::{Rtc, RtcConfig};
use embassy_stm32::Config;
use embassy_time::Timer;
use static_cell::make_static;
use static_cell::StaticCell;
#[entry]
fn main() -> ! {
@ -64,7 +64,8 @@ async fn async_main(spawner: Spawner) {
rtc.set_datetime(now.into()).expect("datetime not set");
let rtc = make_static!(rtc);
static RTC: StaticCell<Rtc> = StaticCell::new();
let rtc = RTC.init(rtc);
stop_with_rtc(rtc);