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