chore: replace make_static! macro usage with non-macro version
This commit is contained in:
@ -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)));
|
||||
|
@ -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)));
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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)));
|
||||
|
Reference in New Issue
Block a user