Merge pull request #2339 from embassy-rs/make-static-remove
Replace make_static! macro usage with non-macro version
This commit is contained in:
commit
530ead5fde
@ -411,10 +411,12 @@ impl<D: Driver> Stack<D> {
|
|||||||
/// ```ignore
|
/// ```ignore
|
||||||
/// let config = embassy_net::Config::dhcpv4(Default::default());
|
/// let config = embassy_net::Config::dhcpv4(Default::default());
|
||||||
///// Init network stack
|
///// 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,
|
/// device,
|
||||||
/// config,
|
/// config,
|
||||||
/// make_static!(embassy_net::StackResources::<2>::new()),
|
/// RESOURCES.init(embassy_net::StackResources::new()),
|
||||||
/// seed
|
/// seed
|
||||||
/// ));
|
/// ));
|
||||||
/// // Launch network task that runs `stack.run().await`
|
/// // Launch network task that runs `stack.run().await`
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
//! use embassy_executor::Spawner;
|
//! use embassy_executor::Spawner;
|
||||||
//! use embassy_stm32::low_power::Executor;
|
//! use embassy_stm32::low_power::Executor;
|
||||||
//! use embassy_stm32::rtc::{Rtc, RtcConfig};
|
//! use embassy_stm32::rtc::{Rtc, RtcConfig};
|
||||||
//! use static_cell::make_static;
|
//! use static_cell::StaticCell;
|
||||||
//!
|
//!
|
||||||
//! #[cortex_m_rt::entry]
|
//! #[cortex_m_rt::entry]
|
||||||
//! fn main() -> ! {
|
//! fn main() -> ! {
|
||||||
@ -41,7 +41,8 @@
|
|||||||
//!
|
//!
|
||||||
//! // give the RTC to the executor...
|
//! // give the RTC to the executor...
|
||||||
//! let mut rtc = Rtc::new(p.RTC, RtcConfig::default());
|
//! 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);
|
//! embassy_stm32::low_power::stop_with_rtc(rtc);
|
||||||
//!
|
//!
|
||||||
//! // your application here...
|
//! // your application here...
|
||||||
|
@ -14,7 +14,7 @@ use embassy_nrf::{bind_interrupts, peripherals, spim};
|
|||||||
use embassy_time::Delay;
|
use embassy_time::Delay;
|
||||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -70,11 +70,20 @@ async fn main(spawner: Spawner) {
|
|||||||
let seed = u64::from_le_bytes(seed);
|
let seed = u64::from_le_bytes(seed);
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
unwrap!(spawner.spawn(net_task(stack)));
|
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::class::cdc_ncm::{CdcNcmClass, State};
|
||||||
use embassy_usb::{Builder, Config, UsbDevice};
|
use embassy_usb::{Builder, Config, UsbDevice};
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -71,14 +71,19 @@ async fn main(spawner: Spawner) {
|
|||||||
config.device_protocol = 0x01;
|
config.device_protocol = 0x01;
|
||||||
|
|
||||||
// Create embassy-usb DeviceBuilder using the driver and config.
|
// 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(
|
let mut builder = Builder::new(
|
||||||
driver,
|
driver,
|
||||||
config,
|
config,
|
||||||
&mut make_static!([0; 256])[..],
|
&mut DEVICE_DESC.init([0; 256])[..],
|
||||||
&mut make_static!([0; 256])[..],
|
&mut CONFIG_DESC.init([0; 256])[..],
|
||||||
&mut make_static!([0; 256])[..],
|
&mut BOS_DESC.init([0; 256])[..],
|
||||||
&mut make_static!([0; 128])[..],
|
&mut MSOS_DESC.init([0; 128])[..],
|
||||||
&mut make_static!([0; 128])[..],
|
&mut CONTROL_BUF.init([0; 128])[..],
|
||||||
);
|
);
|
||||||
|
|
||||||
// Our MAC addr.
|
// Our MAC addr.
|
||||||
@ -87,14 +92,16 @@ async fn main(spawner: Spawner) {
|
|||||||
let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88];
|
let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88];
|
||||||
|
|
||||||
// Create classes on the builder.
|
// 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.
|
// Build the builder.
|
||||||
let usb = builder.build();
|
let usb = builder.build();
|
||||||
|
|
||||||
unwrap!(spawner.spawn(usb_task(usb)));
|
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)));
|
unwrap!(spawner.spawn(usb_ncm_task(runner)));
|
||||||
|
|
||||||
let config = embassy_net::Config::dhcpv4(Default::default());
|
let config = embassy_net::Config::dhcpv4(Default::default());
|
||||||
@ -111,12 +118,9 @@ async fn main(spawner: Spawner) {
|
|||||||
let seed = u64::from_le_bytes(seed);
|
let seed = u64::from_le_bytes(seed);
|
||||||
|
|
||||||
// Init network stack
|
// Init network stack
|
||||||
let stack = &*make_static!(Stack::new(
|
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
|
||||||
device,
|
static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new();
|
||||||
config,
|
let stack = &*STACK.init(Stack::new(device, config, RESOURCES.init(StackResources::new()), seed));
|
||||||
make_static!(StackResources::<2>::new()),
|
|
||||||
seed
|
|
||||||
));
|
|
||||||
|
|
||||||
unwrap!(spawner.spawn(net_task(stack)));
|
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::class::cdc_acm::{CdcAcmClass, State};
|
||||||
use embassy_usb::driver::EndpointError;
|
use embassy_usb::driver::EndpointError;
|
||||||
use embassy_usb::{Builder, Config, UsbDevice};
|
use embassy_usb::{Builder, Config, UsbDevice};
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -64,17 +64,23 @@ async fn main(spawner: Spawner) {
|
|||||||
config.device_protocol = 0x01;
|
config.device_protocol = 0x01;
|
||||||
config.composite_with_iads = true;
|
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.
|
// 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(
|
let mut builder = Builder::new(
|
||||||
driver,
|
driver,
|
||||||
config,
|
config,
|
||||||
&mut make_static!([0; 256])[..],
|
&mut DEVICE_DESC.init([0; 256])[..],
|
||||||
&mut make_static!([0; 256])[..],
|
&mut CONFIG_DESC.init([0; 256])[..],
|
||||||
&mut make_static!([0; 256])[..],
|
&mut BOS_DESC.init([0; 256])[..],
|
||||||
&mut make_static!([0; 128])[..],
|
&mut MSOS_DESC.init([0; 128])[..],
|
||||||
&mut make_static!([0; 128])[..],
|
&mut CONTROL_BUF.init([0; 128])[..],
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create classes on the builder.
|
// Create classes on the builder.
|
||||||
|
@ -13,7 +13,7 @@ use embassy_nrf::{bind_interrupts, peripherals};
|
|||||||
use embassy_time::Delay;
|
use embassy_time::Delay;
|
||||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||||
use embedded_io_async::Write;
|
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 _};
|
use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _};
|
||||||
|
|
||||||
const WIFI_NETWORK: &str = "EmbassyTest";
|
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 = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config);
|
||||||
let spi = ExclusiveDevice::new(spi, cs, Delay);
|
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(
|
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,
|
spi,
|
||||||
handshake,
|
handshake,
|
||||||
ready,
|
ready,
|
||||||
@ -89,11 +90,13 @@ async fn main(spawner: Spawner) {
|
|||||||
let seed = u64::from_le_bytes(seed);
|
let seed = u64::from_le_bytes(seed);
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
unwrap!(spawner.spawn(net_task(stack)));
|
unwrap!(spawner.spawn(net_task(stack)));
|
||||||
|
@ -20,7 +20,7 @@ use embassy_time::{Delay, Duration};
|
|||||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
@ -55,7 +55,8 @@ async fn main(spawner: Spawner) {
|
|||||||
let w5500_reset = Output::new(p.PIN_20, Level::High);
|
let w5500_reset = Output::new(p.PIN_20, Level::High);
|
||||||
|
|
||||||
let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00];
|
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(
|
let (device, runner) = embassy_net_wiznet::new(
|
||||||
mac_addr,
|
mac_addr,
|
||||||
state,
|
state,
|
||||||
@ -70,11 +71,13 @@ async fn main(spawner: Spawner) {
|
|||||||
let seed = rng.next_u64();
|
let seed = rng.next_u64();
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
embassy_net::Config::dhcpv4(Default::default()),
|
embassy_net::Config::dhcpv4(Default::default()),
|
||||||
make_static!(StackResources::<3>::new()),
|
RESOURCES.init(StackResources::<3>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -22,7 +22,7 @@ use embassy_time::{Delay, Duration, Timer};
|
|||||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
@ -58,7 +58,8 @@ async fn main(spawner: Spawner) {
|
|||||||
let w5500_reset = Output::new(p.PIN_20, Level::High);
|
let w5500_reset = Output::new(p.PIN_20, Level::High);
|
||||||
|
|
||||||
let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00];
|
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(
|
let (device, runner) = embassy_net_wiznet::new(
|
||||||
mac_addr,
|
mac_addr,
|
||||||
state,
|
state,
|
||||||
@ -73,11 +74,13 @@ async fn main(spawner: Spawner) {
|
|||||||
let seed = rng.next_u64();
|
let seed = rng.next_u64();
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
embassy_net::Config::dhcpv4(Default::default()),
|
embassy_net::Config::dhcpv4(Default::default()),
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -21,7 +21,7 @@ use embassy_time::{Delay, Duration};
|
|||||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
@ -57,7 +57,8 @@ async fn main(spawner: Spawner) {
|
|||||||
let w5500_reset = Output::new(p.PIN_20, Level::High);
|
let w5500_reset = Output::new(p.PIN_20, Level::High);
|
||||||
|
|
||||||
let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00];
|
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(
|
let (device, runner) = embassy_net_wiznet::new(
|
||||||
mac_addr,
|
mac_addr,
|
||||||
state,
|
state,
|
||||||
@ -72,11 +73,13 @@ async fn main(spawner: Spawner) {
|
|||||||
let seed = rng.next_u64();
|
let seed = rng.next_u64();
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
embassy_net::Config::dhcpv4(Default::default()),
|
embassy_net::Config::dhcpv4(Default::default()),
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -20,7 +20,7 @@ use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
|
|||||||
use embassy_time::Delay;
|
use embassy_time::Delay;
|
||||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
@ -55,7 +55,8 @@ async fn main(spawner: Spawner) {
|
|||||||
let w5500_reset = Output::new(p.PIN_20, Level::High);
|
let w5500_reset = Output::new(p.PIN_20, Level::High);
|
||||||
|
|
||||||
let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00];
|
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(
|
let (device, runner) = embassy_net_wiznet::new(
|
||||||
mac_addr,
|
mac_addr,
|
||||||
state,
|
state,
|
||||||
@ -70,11 +71,13 @@ async fn main(spawner: Spawner) {
|
|||||||
let seed = rng.next_u64();
|
let seed = rng.next_u64();
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
embassy_net::Config::dhcpv4(Default::default()),
|
embassy_net::Config::dhcpv4(Default::default()),
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -15,7 +15,7 @@ use embassy_rp::peripherals::UART0;
|
|||||||
use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config};
|
use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config};
|
||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
use embedded_io_async::{Read, Write};
|
use embedded_io_async::{Read, Write};
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -27,8 +27,10 @@ async fn main(spawner: Spawner) {
|
|||||||
let p = embassy_rp::init(Default::default());
|
let p = embassy_rp::init(Default::default());
|
||||||
let (tx_pin, rx_pin, uart) = (p.PIN_0, p.PIN_1, p.UART0);
|
let (tx_pin, rx_pin, uart) = (p.PIN_0, p.PIN_1, p.UART0);
|
||||||
|
|
||||||
let tx_buf = &mut make_static!([0u8; 16])[..];
|
static TX_BUF: StaticCell<[u8; 16]> = StaticCell::new();
|
||||||
let rx_buf = &mut make_static!([0u8; 16])[..];
|
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 uart = BufferedUart::new(uart, Irqs, tx_pin, rx_pin, tx_buf, rx_buf, Config::default());
|
||||||
let (rx, mut tx) = uart.split();
|
let (rx, mut tx) = uart.split();
|
||||||
|
|
||||||
|
@ -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::class::cdc_ncm::{CdcNcmClass, State};
|
||||||
use embassy_usb::{Builder, Config, UsbDevice};
|
use embassy_usb::{Builder, Config, UsbDevice};
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -65,14 +65,18 @@ async fn main(spawner: Spawner) {
|
|||||||
config.device_protocol = 0x01;
|
config.device_protocol = 0x01;
|
||||||
|
|
||||||
// Create embassy-usb DeviceBuilder using the driver and config.
|
// 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(
|
let mut builder = Builder::new(
|
||||||
driver,
|
driver,
|
||||||
config,
|
config,
|
||||||
&mut make_static!([0; 256])[..],
|
&mut DEVICE_DESC.init([0; 256])[..],
|
||||||
&mut make_static!([0; 256])[..],
|
&mut CONFIG_DESC.init([0; 256])[..],
|
||||||
&mut make_static!([0; 256])[..],
|
&mut BOS_DESC.init([0; 256])[..],
|
||||||
&mut [], // no msos descriptors
|
&mut [], // no msos descriptors
|
||||||
&mut make_static!([0; 128])[..],
|
&mut CONTROL_BUF.init([0; 128])[..],
|
||||||
);
|
);
|
||||||
|
|
||||||
// Our MAC addr.
|
// Our MAC addr.
|
||||||
@ -81,14 +85,16 @@ async fn main(spawner: Spawner) {
|
|||||||
let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88];
|
let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88];
|
||||||
|
|
||||||
// Create classes on the builder.
|
// 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.
|
// Build the builder.
|
||||||
let usb = builder.build();
|
let usb = builder.build();
|
||||||
|
|
||||||
unwrap!(spawner.spawn(usb_task(usb)));
|
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)));
|
unwrap!(spawner.spawn(usb_ncm_task(runner)));
|
||||||
|
|
||||||
let config = embassy_net::Config::dhcpv4(Default::default());
|
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
|
let seed = 1234; // guaranteed random, chosen by a fair dice roll
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
unwrap!(spawner.spawn(net_task(stack)));
|
unwrap!(spawner.spawn(net_task(stack)));
|
||||||
|
@ -19,7 +19,7 @@ use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
|||||||
use embassy_rp::pio::{InterruptHandler, Pio};
|
use embassy_rp::pio::{InterruptHandler, Pio};
|
||||||
use embassy_time::Duration;
|
use embassy_time::Duration;
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -59,7 +59,8 @@ async fn main(spawner: Spawner) {
|
|||||||
let mut pio = Pio::new(p.PIO0, Irqs);
|
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 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;
|
let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
|
||||||
unwrap!(spawner.spawn(wifi_task(runner)));
|
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.
|
let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random.
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
net_device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
unwrap!(spawner.spawn(net_task(stack)));
|
unwrap!(spawner.spawn(net_task(stack)));
|
||||||
|
@ -14,7 +14,7 @@ use embassy_rp::gpio::{Level, Output};
|
|||||||
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
||||||
use embassy_rp::pio::{InterruptHandler, Pio};
|
use embassy_rp::pio::{InterruptHandler, Pio};
|
||||||
use embassy_time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -46,7 +46,8 @@ async fn main(spawner: Spawner) {
|
|||||||
let mut pio = Pio::new(p.PIO0, Irqs);
|
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 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;
|
let (_net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
|
||||||
unwrap!(spawner.spawn(wifi_task(runner)));
|
unwrap!(spawner.spawn(wifi_task(runner)));
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ use embassy_rp::bind_interrupts;
|
|||||||
use embassy_rp::gpio::{Level, Output};
|
use embassy_rp::gpio::{Level, Output};
|
||||||
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
||||||
use embassy_rp::pio::{InterruptHandler, Pio};
|
use embassy_rp::pio::{InterruptHandler, Pio};
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -56,7 +56,8 @@ async fn main(spawner: Spawner) {
|
|||||||
let mut pio = Pio::new(p.PIO0, Irqs);
|
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 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;
|
let (_net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
|
||||||
unwrap!(spawner.spawn(wifi_task(runner)));
|
unwrap!(spawner.spawn(wifi_task(runner)));
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
|||||||
use embassy_rp::pio::{InterruptHandler, Pio};
|
use embassy_rp::pio::{InterruptHandler, Pio};
|
||||||
use embassy_time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -62,7 +62,8 @@ async fn main(spawner: Spawner) {
|
|||||||
let mut pio = Pio::new(p.PIO0, Irqs);
|
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 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;
|
let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
|
||||||
unwrap!(spawner.spawn(wifi_task(runner)));
|
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.
|
let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random.
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
net_device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
unwrap!(spawner.spawn(net_task(stack)));
|
unwrap!(spawner.spawn(net_task(stack)));
|
||||||
|
@ -12,7 +12,7 @@ use embedded_io_async::Write;
|
|||||||
use heapless::Vec;
|
use heapless::Vec;
|
||||||
use log::*;
|
use log::*;
|
||||||
use rand_core::{OsRng, RngCore};
|
use rand_core::{OsRng, RngCore};
|
||||||
use static_cell::{make_static, StaticCell};
|
use static_cell::StaticCell;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(version = "1.0")]
|
#[clap(version = "1.0")]
|
||||||
@ -54,11 +54,13 @@ async fn main_task(spawner: Spawner) {
|
|||||||
let seed = u64::from_le_bytes(seed);
|
let seed = u64::from_le_bytes(seed);
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<3>::new()),
|
RESOURCES.init(StackResources::<3>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -10,7 +10,7 @@ use embassy_net_tuntap::TunTapDevice;
|
|||||||
use heapless::Vec;
|
use heapless::Vec;
|
||||||
use log::*;
|
use log::*;
|
||||||
use rand_core::{OsRng, RngCore};
|
use rand_core::{OsRng, RngCore};
|
||||||
use static_cell::{make_static, StaticCell};
|
use static_cell::StaticCell;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(version = "1.0")]
|
#[clap(version = "1.0")]
|
||||||
@ -53,11 +53,13 @@ async fn main_task(spawner: Spawner) {
|
|||||||
let seed = u64::from_le_bytes(seed);
|
let seed = u64::from_le_bytes(seed);
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<3>::new()),
|
RESOURCES.init(StackResources::<3>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -25,7 +25,7 @@ use heapless::Vec;
|
|||||||
use log::*;
|
use log::*;
|
||||||
use nix::sys::termios;
|
use nix::sys::termios;
|
||||||
use rand_core::{OsRng, RngCore};
|
use rand_core::{OsRng, RngCore};
|
||||||
use static_cell::{make_static, StaticCell};
|
use static_cell::StaticCell;
|
||||||
|
|
||||||
use crate::serial_port::SerialPort;
|
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();
|
let port = SerialPort::new(opts.device.as_str(), baudrate).unwrap();
|
||||||
|
|
||||||
// Init network device
|
// 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);
|
let (device, runner) = embassy_net_ppp::new(state);
|
||||||
|
|
||||||
// Generate random seed
|
// Generate random seed
|
||||||
@ -97,11 +98,13 @@ async fn main_task(spawner: Spawner) {
|
|||||||
let seed = u64::from_le_bytes(seed);
|
let seed = u64::from_le_bytes(seed);
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
Config::default(), // don't configure IP yet
|
Config::default(), // don't configure IP yet
|
||||||
make_static!(StackResources::<3>::new()),
|
RESOURCES.init(StackResources::<3>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -8,7 +8,7 @@ use embassy_net_tuntap::TunTapDevice;
|
|||||||
use heapless::Vec;
|
use heapless::Vec;
|
||||||
use log::*;
|
use log::*;
|
||||||
use rand_core::{OsRng, RngCore};
|
use rand_core::{OsRng, RngCore};
|
||||||
use static_cell::{make_static, StaticCell};
|
use static_cell::StaticCell;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(version = "1.0")]
|
#[clap(version = "1.0")]
|
||||||
@ -50,11 +50,13 @@ async fn main_task(spawner: Spawner) {
|
|||||||
let seed = u64::from_le_bytes(seed);
|
let seed = u64::from_le_bytes(seed);
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<3>::new()),
|
RESOURCES.init(StackResources::<3>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -13,7 +13,7 @@ use embedded_io_async::Write as _;
|
|||||||
use heapless::Vec;
|
use heapless::Vec;
|
||||||
use log::*;
|
use log::*;
|
||||||
use rand_core::{OsRng, RngCore};
|
use rand_core::{OsRng, RngCore};
|
||||||
use static_cell::{make_static, StaticCell};
|
use static_cell::StaticCell;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(version = "1.0")]
|
#[clap(version = "1.0")]
|
||||||
@ -65,11 +65,13 @@ async fn main_task(spawner: Spawner) {
|
|||||||
let seed = u64::from_le_bytes(seed);
|
let seed = u64::from_le_bytes(seed);
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<3>::new()),
|
RESOURCES.init(StackResources::<3>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -14,7 +14,7 @@ use embassy_stm32::time::Hertz;
|
|||||||
use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
|
use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
|
||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -63,8 +63,9 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
|
|
||||||
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
|
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
|
||||||
|
|
||||||
|
static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new();
|
||||||
let device = Ethernet::new(
|
let device = Ethernet::new(
|
||||||
make_static!(PacketQueue::<16, 16>::new()),
|
PACKETS.init(PacketQueue::<16, 16>::new()),
|
||||||
p.ETH,
|
p.ETH,
|
||||||
Irqs,
|
Irqs,
|
||||||
p.PA1,
|
p.PA1,
|
||||||
@ -88,11 +89,13 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
//});
|
//});
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -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::class::cdc_ncm::{CdcNcmClass, State};
|
||||||
use embassy_usb::{Builder, UsbDevice};
|
use embassy_usb::{Builder, UsbDevice};
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
type UsbDriver = Driver<'static, embassy_stm32::peripherals::USB_OTG_FS>;
|
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);
|
let p = embassy_stm32::init(config);
|
||||||
|
|
||||||
// Create the driver, from the HAL.
|
// 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();
|
let mut config = embassy_stm32::usb_otg::Config::default();
|
||||||
config.vbus_detection = true;
|
config.vbus_detection = true;
|
||||||
let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, ep_out_buffer, config);
|
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;
|
config.device_protocol = 0x01;
|
||||||
|
|
||||||
// Create embassy-usb DeviceBuilder using the driver and config.
|
// 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(
|
let mut builder = Builder::new(
|
||||||
driver,
|
driver,
|
||||||
config,
|
config,
|
||||||
&mut make_static!([0; 256])[..],
|
&mut DEVICE_DESC.init([0; 256])[..],
|
||||||
&mut make_static!([0; 256])[..],
|
&mut CONFIG_DESC.init([0; 256])[..],
|
||||||
&mut make_static!([0; 256])[..],
|
&mut BOS_DESC.init([0; 256])[..],
|
||||||
&mut [], // no msos descriptors
|
&mut [], // no msos descriptors
|
||||||
&mut make_static!([0; 128])[..],
|
&mut CONTROL_BUF.init([0; 128])[..],
|
||||||
);
|
);
|
||||||
|
|
||||||
// Our MAC addr.
|
// Our MAC addr.
|
||||||
@ -104,14 +109,16 @@ async fn main(spawner: Spawner) {
|
|||||||
let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88];
|
let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88];
|
||||||
|
|
||||||
// Create classes on the builder.
|
// 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.
|
// Build the builder.
|
||||||
let usb = builder.build();
|
let usb = builder.build();
|
||||||
|
|
||||||
unwrap!(spawner.spawn(usb_task(usb)));
|
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)));
|
unwrap!(spawner.spawn(usb_ncm_task(runner)));
|
||||||
|
|
||||||
let config = embassy_net::Config::dhcpv4(Default::default());
|
let config = embassy_net::Config::dhcpv4(Default::default());
|
||||||
@ -128,11 +135,13 @@ async fn main(spawner: Spawner) {
|
|||||||
let seed = u64::from_le_bytes(seed);
|
let seed = u64::from_le_bytes(seed);
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
unwrap!(spawner.spawn(net_task(stack)));
|
unwrap!(spawner.spawn(net_task(stack)));
|
||||||
|
@ -12,6 +12,7 @@ use embassy_stm32::can::{
|
|||||||
};
|
};
|
||||||
use embassy_stm32::gpio::{Input, Pull};
|
use embassy_stm32::gpio::{Input, Pull};
|
||||||
use embassy_stm32::peripherals::CAN3;
|
use embassy_stm32::peripherals::CAN3;
|
||||||
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -43,7 +44,8 @@ async fn main(spawner: Spawner) {
|
|||||||
let rx_pin = Input::new(&mut p.PA15, Pull::Up);
|
let rx_pin = Input::new(&mut p.PA15, Pull::Up);
|
||||||
core::mem::forget(rx_pin);
|
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()
|
can.as_mut()
|
||||||
.modify_filters()
|
.modify_filters()
|
||||||
.enable_bank(0, Fifo::Fifo0, Mask32::accept_all());
|
.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, 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();
|
spawner.spawn(send_can_message(tx)).unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -15,7 +15,7 @@ use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
|
|||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use rand_core::RngCore;
|
use rand_core::RngCore;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -64,8 +64,9 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
|
|
||||||
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
|
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
|
||||||
|
|
||||||
|
static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new();
|
||||||
let device = Ethernet::new(
|
let device = Ethernet::new(
|
||||||
make_static!(PacketQueue::<16, 16>::new()),
|
PACKETS.init(PacketQueue::<16, 16>::new()),
|
||||||
p.ETH,
|
p.ETH,
|
||||||
Irqs,
|
Irqs,
|
||||||
p.PA1,
|
p.PA1,
|
||||||
@ -89,11 +90,13 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
//});
|
//});
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -18,7 +18,7 @@ use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
|
|||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use rand_core::RngCore;
|
use rand_core::RngCore;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -67,8 +67,9 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
|
|
||||||
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
|
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
|
||||||
|
|
||||||
|
static PACKETS: StaticCell<PacketQueue<4, 4>> = StaticCell::new();
|
||||||
let device = Ethernet::new(
|
let device = Ethernet::new(
|
||||||
make_static!(PacketQueue::<4, 4>::new()),
|
PACKETS.init(PacketQueue::<4, 4>::new()),
|
||||||
p.ETH,
|
p.ETH,
|
||||||
Irqs,
|
Irqs,
|
||||||
p.PA1,
|
p.PA1,
|
||||||
@ -92,11 +93,13 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
//});
|
//});
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -14,7 +14,7 @@ use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
|
|||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use rand_core::RngCore;
|
use rand_core::RngCore;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -64,8 +64,9 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
|
|
||||||
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
|
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
|
||||||
|
|
||||||
|
static PACKETS: StaticCell<PacketQueue<4, 4>> = StaticCell::new();
|
||||||
let device = Ethernet::new(
|
let device = Ethernet::new(
|
||||||
make_static!(PacketQueue::<16, 16>::new()),
|
PACKETS.init(PacketQueue::<4, 4>::new()),
|
||||||
p.ETH,
|
p.ETH,
|
||||||
Irqs,
|
Irqs,
|
||||||
p.PA1,
|
p.PA1,
|
||||||
@ -89,11 +90,13 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
//});
|
//});
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<3>::new()),
|
RESOURCES.init(StackResources::<3>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -15,7 +15,7 @@ use embassy_time::Timer;
|
|||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect};
|
use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect};
|
||||||
use rand_core::RngCore;
|
use rand_core::RngCore;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -65,8 +65,9 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
|
|
||||||
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
|
let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
|
||||||
|
|
||||||
|
static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new();
|
||||||
let device = Ethernet::new(
|
let device = Ethernet::new(
|
||||||
make_static!(PacketQueue::<16, 16>::new()),
|
PACKETS.init(PacketQueue::<16, 16>::new()),
|
||||||
p.ETH,
|
p.ETH,
|
||||||
Irqs,
|
Irqs,
|
||||||
p.PA1,
|
p.PA1,
|
||||||
@ -90,11 +91,13 @@ async fn main(spawner: Spawner) -> ! {
|
|||||||
//});
|
//});
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<3>::new()),
|
RESOURCES.init(StackResources::<3>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -36,7 +36,7 @@ use hal::rng::{self, Rng};
|
|||||||
use hal::{bind_interrupts, exti, pac, peripherals};
|
use hal::{bind_interrupts, exti, pac, peripherals};
|
||||||
use heapless::Vec;
|
use heapless::Vec;
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {embassy_stm32 as hal, panic_probe as _};
|
use {embassy_stm32 as hal, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
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(
|
let (device, runner) = embassy_net_adin1110::new(
|
||||||
MAC,
|
MAC,
|
||||||
@ -217,11 +218,13 @@ async fn main(spawner: Spawner) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
ip_cfg,
|
ip_cfg,
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -15,7 +15,7 @@ use embassy_usb::class::cdc_ncm::{CdcNcmClass, State};
|
|||||||
use embassy_usb::{Builder, UsbDevice};
|
use embassy_usb::{Builder, UsbDevice};
|
||||||
use embedded_io_async::Write;
|
use embedded_io_async::Write;
|
||||||
use rand_core::RngCore;
|
use rand_core::RngCore;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
type MyDriver = Driver<'static, embassy_stm32::peripherals::USB>;
|
type MyDriver = Driver<'static, embassy_stm32::peripherals::USB>;
|
||||||
@ -76,14 +76,18 @@ async fn main(spawner: Spawner) {
|
|||||||
config.device_protocol = 0x01;
|
config.device_protocol = 0x01;
|
||||||
|
|
||||||
// Create embassy-usb DeviceBuilder using the driver and config.
|
// 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(
|
let mut builder = Builder::new(
|
||||||
driver,
|
driver,
|
||||||
config,
|
config,
|
||||||
&mut make_static!([0; 256])[..],
|
&mut DEVICE_DESC.init([0; 256])[..],
|
||||||
&mut make_static!([0; 256])[..],
|
&mut CONFIG_DESC.init([0; 256])[..],
|
||||||
&mut make_static!([0; 256])[..],
|
&mut BOS_DESC.init([0; 256])[..],
|
||||||
&mut [], // no msos descriptors
|
&mut [], // no msos descriptors
|
||||||
&mut make_static!([0; 128])[..],
|
&mut CONTROL_BUF.init([0; 128])[..],
|
||||||
);
|
);
|
||||||
|
|
||||||
// Our MAC addr.
|
// Our MAC addr.
|
||||||
@ -92,14 +96,16 @@ async fn main(spawner: Spawner) {
|
|||||||
let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88];
|
let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88];
|
||||||
|
|
||||||
// Create classes on the builder.
|
// 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.
|
// Build the builder.
|
||||||
let usb = builder.build();
|
let usb = builder.build();
|
||||||
|
|
||||||
unwrap!(spawner.spawn(usb_task(usb)));
|
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)));
|
unwrap!(spawner.spawn(usb_ncm_task(runner)));
|
||||||
|
|
||||||
let config = embassy_net::Config::dhcpv4(Default::default());
|
let config = embassy_net::Config::dhcpv4(Default::default());
|
||||||
@ -114,11 +120,13 @@ async fn main(spawner: Spawner) {
|
|||||||
let seed = rng.next_u64();
|
let seed = rng.next_u64();
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
unwrap!(spawner.spawn(net_task(stack)));
|
unwrap!(spawner.spawn(net_task(stack)));
|
||||||
|
@ -12,7 +12,7 @@ use embassy_stm32_wpan::mac::typedefs::{MacChannel, PanId, PibId};
|
|||||||
use embassy_stm32_wpan::mac::{self, Runner};
|
use embassy_stm32_wpan::mac::{self, Runner};
|
||||||
use embassy_stm32_wpan::sub::mm;
|
use embassy_stm32_wpan::sub::mm;
|
||||||
use embassy_stm32_wpan::TlMbox;
|
use embassy_stm32_wpan::TlMbox;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs{
|
bind_interrupts!(struct Irqs{
|
||||||
@ -154,15 +154,21 @@ async fn main(spawner: Spawner) {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
defmt::info!("{:#x}", mbox.mac_subsystem.read().await.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 = [
|
let tx_queue = [
|
||||||
make_static!([0u8; 127]),
|
TX1.init([0u8; 127]),
|
||||||
make_static!([0u8; 127]),
|
TX2.init([0u8; 127]),
|
||||||
make_static!([0u8; 127]),
|
TX3.init([0u8; 127]),
|
||||||
make_static!([0u8; 127]),
|
TX4.init([0u8; 127]),
|
||||||
make_static!([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();
|
spawner.spawn(run_mac(runner)).unwrap();
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ use embassy_nrf::spim::{self, Spim};
|
|||||||
use embassy_nrf::{bind_interrupts, peripherals};
|
use embassy_nrf::{bind_interrupts, peripherals};
|
||||||
use embassy_time::Delay;
|
use embassy_time::Delay;
|
||||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -68,11 +68,13 @@ async fn main(spawner: Spawner) {
|
|||||||
let seed = u64::from_le_bytes(seed);
|
let seed = u64::from_le_bytes(seed);
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
unwrap!(spawner.spawn(net_task(stack)));
|
unwrap!(spawner.spawn(net_task(stack)));
|
||||||
|
@ -13,7 +13,7 @@ use embassy_nrf::spim::{self, Spim};
|
|||||||
use embassy_nrf::{bind_interrupts, peripherals};
|
use embassy_nrf::{bind_interrupts, peripherals};
|
||||||
use embassy_time::Delay;
|
use embassy_time::Delay;
|
||||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
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 _};
|
use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
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 = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config);
|
||||||
let spi = ExclusiveDevice::new(spi, cs, Delay);
|
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(
|
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,
|
spi,
|
||||||
handshake,
|
handshake,
|
||||||
ready,
|
ready,
|
||||||
@ -85,11 +86,13 @@ async fn main(spawner: Spawner) {
|
|||||||
let seed = u64::from_le_bytes(seed);
|
let seed = u64::from_le_bytes(seed);
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
Config::dhcpv4(Default::default()),
|
Config::dhcpv4(Default::default()),
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
unwrap!(spawner.spawn(net_task(stack)));
|
unwrap!(spawner.spawn(net_task(stack)));
|
||||||
|
@ -11,7 +11,7 @@ use embassy_rp::gpio::{Level, Output};
|
|||||||
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
||||||
use embassy_rp::pio::{InterruptHandler, Pio};
|
use embassy_rp::pio::{InterruptHandler, Pio};
|
||||||
use embassy_rp::{bind_interrupts, rom_data};
|
use embassy_rp::{bind_interrupts, rom_data};
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
bind_interrupts!(struct Irqs {
|
bind_interrupts!(struct Irqs {
|
||||||
@ -58,7 +58,8 @@ async fn main(spawner: Spawner) {
|
|||||||
let mut pio = Pio::new(p.PIO0, Irqs);
|
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 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;
|
let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
|
||||||
unwrap!(spawner.spawn(wifi_task(runner)));
|
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.
|
let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random.
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
net_device,
|
||||||
Config::dhcpv4(Default::default()),
|
Config::dhcpv4(Default::default()),
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
unwrap!(spawner.spawn(net_task(stack)));
|
unwrap!(spawner.spawn(net_task(stack)));
|
||||||
|
@ -16,7 +16,7 @@ use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
|
|||||||
use embassy_time::Delay;
|
use embassy_time::Delay;
|
||||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
@ -51,7 +51,8 @@ async fn main(spawner: Spawner) {
|
|||||||
let w5500_reset = Output::new(p.PIN_20, Level::High);
|
let w5500_reset = Output::new(p.PIN_20, Level::High);
|
||||||
|
|
||||||
let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00];
|
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(
|
let (device, runner) = embassy_net_wiznet::new(
|
||||||
mac_addr,
|
mac_addr,
|
||||||
state,
|
state,
|
||||||
@ -66,11 +67,13 @@ async fn main(spawner: Spawner) {
|
|||||||
let seed = rng.next_u64();
|
let seed = rng.next_u64();
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
embassy_net::Config::dhcpv4(Default::default()),
|
embassy_net::Config::dhcpv4(Default::default()),
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -14,7 +14,7 @@ use embassy_stm32::peripherals::ETH;
|
|||||||
use embassy_stm32::rng::Rng;
|
use embassy_stm32::rng::Rng;
|
||||||
use embassy_stm32::{bind_interrupts, eth, peripherals, rng};
|
use embassy_stm32::{bind_interrupts, eth, peripherals, rng};
|
||||||
use rand_core::RngCore;
|
use rand_core::RngCore;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
teleprobe_meta::timeout!(120);
|
teleprobe_meta::timeout!(120);
|
||||||
@ -71,8 +71,9 @@ async fn main(spawner: Spawner) {
|
|||||||
#[cfg(not(feature = "stm32f207zg"))]
|
#[cfg(not(feature = "stm32f207zg"))]
|
||||||
const PACKET_QUEUE_SIZE: usize = 4;
|
const PACKET_QUEUE_SIZE: usize = 4;
|
||||||
|
|
||||||
|
static PACKETS: StaticCell<PacketQueue<PACKET_QUEUE_SIZE, PACKET_QUEUE_SIZE>> = StaticCell::new();
|
||||||
let device = Ethernet::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,
|
p.ETH,
|
||||||
Irqs,
|
Irqs,
|
||||||
p.PA1,
|
p.PA1,
|
||||||
@ -99,11 +100,13 @@ async fn main(spawner: Spawner) {
|
|||||||
//});
|
//});
|
||||||
|
|
||||||
// Init network stack
|
// 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,
|
device,
|
||||||
config,
|
config,
|
||||||
make_static!(StackResources::<2>::new()),
|
RESOURCES.init(StackResources::<2>::new()),
|
||||||
seed
|
seed,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Launch network task
|
// Launch network task
|
||||||
|
@ -15,7 +15,7 @@ use embassy_stm32::rcc::LsConfig;
|
|||||||
use embassy_stm32::rtc::{Rtc, RtcConfig};
|
use embassy_stm32::rtc::{Rtc, RtcConfig};
|
||||||
use embassy_stm32::Config;
|
use embassy_stm32::Config;
|
||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
use static_cell::make_static;
|
use static_cell::StaticCell;
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
@ -64,7 +64,8 @@ async fn async_main(spawner: Spawner) {
|
|||||||
|
|
||||||
rtc.set_datetime(now.into()).expect("datetime not set");
|
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);
|
stop_with_rtc(rtc);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user