diff options
| author | Frostie314159 <[email protected]> | 2024-03-31 20:48:05 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-03-31 20:48:05 +0200 |
| commit | 67c9cc2c4b886e6962ecdd6eff8794b14c1accdc (patch) | |
| tree | f176ab269949d26f48e04c950cebc5489bae8c56 /examples/nrf52840/src | |
| parent | a2f9aa592ec61beb247065003016515f0d423c13 (diff) | |
| parent | 6634cc90bcd3eb25b64712688920f383584b2964 (diff) | |
Merge branch 'embassy-rs:main' into ticker_send_sync
Diffstat (limited to 'examples/nrf52840/src')
51 files changed, 58 insertions, 107 deletions
diff --git a/examples/nrf52840/src/bin/blinky.rs b/examples/nrf52840/src/bin/blinky.rs index d3d1a7122..58a3d2cd9 100644 --- a/examples/nrf52840/src/bin/blinky.rs +++ b/examples/nrf52840/src/bin/blinky.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use embassy_executor::Spawner; | 4 | use embassy_executor::Spawner; |
| 6 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 5 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
diff --git a/examples/nrf52840/src/bin/buffered_uart.rs b/examples/nrf52840/src/bin/buffered_uart.rs index d9c505786..6ac72bcaf 100644 --- a/examples/nrf52840/src/bin/buffered_uart.rs +++ b/examples/nrf52840/src/bin/buffered_uart.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/channel.rs b/examples/nrf52840/src/bin/channel.rs index d3c7b47d2..7fcea9dbd 100644 --- a/examples/nrf52840/src/bin/channel.rs +++ b/examples/nrf52840/src/bin/channel.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::unwrap; | 4 | use defmt::unwrap; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/channel_sender_receiver.rs b/examples/nrf52840/src/bin/channel_sender_receiver.rs index 79d2c4048..3095a04ec 100644 --- a/examples/nrf52840/src/bin/channel_sender_receiver.rs +++ b/examples/nrf52840/src/bin/channel_sender_receiver.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::unwrap; | 4 | use defmt::unwrap; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/ethernet_enc28j60.rs b/examples/nrf52840/src/bin/ethernet_enc28j60.rs index d1b796fab..279f32edc 100644 --- a/examples/nrf52840/src/bin/ethernet_enc28j60.rs +++ b/examples/nrf52840/src/bin/ethernet_enc28j60.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| @@ -14,7 +13,7 @@ use embassy_nrf::{bind_interrupts, peripherals, spim}; | |||
| 14 | use embassy_time::Delay; | 13 | use embassy_time::Delay; |
| 15 | use embedded_hal_bus::spi::ExclusiveDevice; | 14 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 16 | use embedded_io_async::Write; | 15 | use embedded_io_async::Write; |
| 17 | use static_cell::make_static; | 16 | use static_cell::StaticCell; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 17 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 18 | ||
| 20 | bind_interrupts!(struct Irqs { | 19 | bind_interrupts!(struct Irqs { |
| @@ -25,10 +24,7 @@ bind_interrupts!(struct Irqs { | |||
| 25 | #[embassy_executor::task] | 24 | #[embassy_executor::task] |
| 26 | async fn net_task( | 25 | async fn net_task( |
| 27 | stack: &'static Stack< | 26 | stack: &'static Stack< |
| 28 | Enc28j60< | 27 | Enc28j60<ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, Output<'static>>, |
| 29 | ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_15>, Delay>, | ||
| 30 | Output<'static, peripherals::P0_13>, | ||
| 31 | >, | ||
| 32 | >, | 28 | >, |
| 33 | ) -> ! { | 29 | ) -> ! { |
| 34 | stack.run().await | 30 | stack.run().await |
| @@ -70,11 +66,15 @@ async fn main(spawner: Spawner) { | |||
| 70 | let seed = u64::from_le_bytes(seed); | 66 | let seed = u64::from_le_bytes(seed); |
| 71 | 67 | ||
| 72 | // Init network stack | 68 | // Init network stack |
| 73 | let stack = &*make_static!(Stack::new( | 69 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); |
| 70 | static STACK: StaticCell< | ||
| 71 | Stack<Enc28j60<ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, Output<'static>>>, | ||
| 72 | > = StaticCell::new(); | ||
| 73 | let stack = STACK.init(Stack::new( | ||
| 74 | device, | 74 | device, |
| 75 | config, | 75 | config, |
| 76 | make_static!(StackResources::<2>::new()), | 76 | RESOURCES.init(StackResources::<2>::new()), |
| 77 | seed | 77 | seed, |
| 78 | )); | 78 | )); |
| 79 | 79 | ||
| 80 | unwrap!(spawner.spawn(net_task(stack))); | 80 | unwrap!(spawner.spawn(net_task(stack))); |
diff --git a/examples/nrf52840/src/bin/executor_fairness_test.rs b/examples/nrf52840/src/bin/executor_fairness_test.rs index f111b272e..df6e7af3f 100644 --- a/examples/nrf52840/src/bin/executor_fairness_test.rs +++ b/examples/nrf52840/src/bin/executor_fairness_test.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use core::future::poll_fn; | 4 | use core::future::poll_fn; |
| 6 | use core::task::Poll; | 5 | use core::task::Poll; |
diff --git a/examples/nrf52840/src/bin/gpiote_channel.rs b/examples/nrf52840/src/bin/gpiote_channel.rs index 5bfd02465..e254d613d 100644 --- a/examples/nrf52840/src/bin/gpiote_channel.rs +++ b/examples/nrf52840/src/bin/gpiote_channel.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::info; | 4 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/gpiote_port.rs b/examples/nrf52840/src/bin/gpiote_port.rs index 0155d539e..0dddb1a97 100644 --- a/examples/nrf52840/src/bin/gpiote_port.rs +++ b/examples/nrf52840/src/bin/gpiote_port.rs | |||
| @@ -1,14 +1,13 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::{info, unwrap}; | 4 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; | 6 | use embassy_nrf::gpio::{Input, Pull}; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 7 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 8 | ||
| 10 | #[embassy_executor::task(pool_size = 4)] | 9 | #[embassy_executor::task(pool_size = 4)] |
| 11 | async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) { | 10 | async fn button_task(n: usize, mut pin: Input<'static>) { |
| 12 | loop { | 11 | loop { |
| 13 | pin.wait_for_low().await; | 12 | pin.wait_for_low().await; |
| 14 | info!("Button {:?} pressed!", n); | 13 | info!("Button {:?} pressed!", n); |
| @@ -22,10 +21,10 @@ async fn main(spawner: Spawner) { | |||
| 22 | let p = embassy_nrf::init(Default::default()); | 21 | let p = embassy_nrf::init(Default::default()); |
| 23 | info!("Starting!"); | 22 | info!("Starting!"); |
| 24 | 23 | ||
| 25 | let btn1 = Input::new(p.P0_11.degrade(), Pull::Up); | 24 | let btn1 = Input::new(p.P0_11, Pull::Up); |
| 26 | let btn2 = Input::new(p.P0_12.degrade(), Pull::Up); | 25 | let btn2 = Input::new(p.P0_12, Pull::Up); |
| 27 | let btn3 = Input::new(p.P0_24.degrade(), Pull::Up); | 26 | let btn3 = Input::new(p.P0_24, Pull::Up); |
| 28 | let btn4 = Input::new(p.P0_25.degrade(), Pull::Up); | 27 | let btn4 = Input::new(p.P0_25, Pull::Up); |
| 29 | 28 | ||
| 30 | unwrap!(spawner.spawn(button_task(1, btn1))); | 29 | unwrap!(spawner.spawn(button_task(1, btn1))); |
| 31 | unwrap!(spawner.spawn(button_task(2, btn2))); | 30 | unwrap!(spawner.spawn(button_task(2, btn2))); |
diff --git a/examples/nrf52840/src/bin/i2s_effect.rs b/examples/nrf52840/src/bin/i2s_effect.rs index 391514d93..9eadeb4e4 100644 --- a/examples/nrf52840/src/bin/i2s_effect.rs +++ b/examples/nrf52840/src/bin/i2s_effect.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use core::f32::consts::PI; | 4 | use core::f32::consts::PI; |
| 6 | 5 | ||
diff --git a/examples/nrf52840/src/bin/i2s_monitor.rs b/examples/nrf52840/src/bin/i2s_monitor.rs index 4ed597c0d..799be351f 100644 --- a/examples/nrf52840/src/bin/i2s_monitor.rs +++ b/examples/nrf52840/src/bin/i2s_monitor.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::{debug, error, info}; | 4 | use defmt::{debug, error, info}; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/i2s_waveform.rs b/examples/nrf52840/src/bin/i2s_waveform.rs index f2c1166b1..137d82840 100644 --- a/examples/nrf52840/src/bin/i2s_waveform.rs +++ b/examples/nrf52840/src/bin/i2s_waveform.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use core::f32::consts::PI; | 4 | use core::f32::consts::PI; |
| 6 | 5 | ||
diff --git a/examples/nrf52840/src/bin/manually_create_executor.rs b/examples/nrf52840/src/bin/manually_create_executor.rs index 80364d34a..7ca39348e 100644 --- a/examples/nrf52840/src/bin/manually_create_executor.rs +++ b/examples/nrf52840/src/bin/manually_create_executor.rs | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | 3 | ||
| 4 | #![no_std] | 4 | #![no_std] |
| 5 | #![no_main] | 5 | #![no_main] |
| 6 | #![feature(type_alias_impl_trait)] | ||
| 7 | 6 | ||
| 8 | use cortex_m_rt::entry; | 7 | use cortex_m_rt::entry; |
| 9 | use defmt::{info, unwrap}; | 8 | use defmt::{info, unwrap}; |
diff --git a/examples/nrf52840/src/bin/multiprio.rs b/examples/nrf52840/src/bin/multiprio.rs index 352f62bf2..b634d8569 100644 --- a/examples/nrf52840/src/bin/multiprio.rs +++ b/examples/nrf52840/src/bin/multiprio.rs | |||
| @@ -55,7 +55,6 @@ | |||
| 55 | 55 | ||
| 56 | #![no_std] | 56 | #![no_std] |
| 57 | #![no_main] | 57 | #![no_main] |
| 58 | #![feature(type_alias_impl_trait)] | ||
| 59 | 58 | ||
| 60 | use cortex_m_rt::entry; | 59 | use cortex_m_rt::entry; |
| 61 | use defmt::{info, unwrap}; | 60 | use defmt::{info, unwrap}; |
diff --git a/examples/nrf52840/src/bin/mutex.rs b/examples/nrf52840/src/bin/mutex.rs index 11b47d991..5c22279b5 100644 --- a/examples/nrf52840/src/bin/mutex.rs +++ b/examples/nrf52840/src/bin/mutex.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::{info, unwrap}; | 4 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/nvmc.rs b/examples/nrf52840/src/bin/nvmc.rs index 624829863..a79385b98 100644 --- a/examples/nrf52840/src/bin/nvmc.rs +++ b/examples/nrf52840/src/bin/nvmc.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::{info, unwrap}; | 4 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/pdm.rs b/examples/nrf52840/src/bin/pdm.rs index bff323974..52dadc805 100644 --- a/examples/nrf52840/src/bin/pdm.rs +++ b/examples/nrf52840/src/bin/pdm.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::info; | 4 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/pdm_continuous.rs b/examples/nrf52840/src/bin/pdm_continuous.rs index 7d8531475..e948203a5 100644 --- a/examples/nrf52840/src/bin/pdm_continuous.rs +++ b/examples/nrf52840/src/bin/pdm_continuous.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use core::cmp::Ordering; | 4 | use core::cmp::Ordering; |
| 6 | 5 | ||
diff --git a/examples/nrf52840/src/bin/ppi.rs b/examples/nrf52840/src/bin/ppi.rs index d74ce4064..129ad06e7 100644 --- a/examples/nrf52840/src/bin/ppi.rs +++ b/examples/nrf52840/src/bin/ppi.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use core::future::pending; | 4 | use core::future::pending; |
| 6 | 5 | ||
diff --git a/examples/nrf52840/src/bin/pubsub.rs b/examples/nrf52840/src/bin/pubsub.rs index 17d902227..5ebea9220 100644 --- a/examples/nrf52840/src/bin/pubsub.rs +++ b/examples/nrf52840/src/bin/pubsub.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::unwrap; | 4 | use defmt::unwrap; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/pwm.rs b/examples/nrf52840/src/bin/pwm.rs index 9750935c8..a5bb1347a 100644 --- a/examples/nrf52840/src/bin/pwm.rs +++ b/examples/nrf52840/src/bin/pwm.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/pwm_double_sequence.rs b/examples/nrf52840/src/bin/pwm_double_sequence.rs index 1bfe6e15a..386c483b8 100644 --- a/examples/nrf52840/src/bin/pwm_double_sequence.rs +++ b/examples/nrf52840/src/bin/pwm_double_sequence.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/pwm_sequence.rs b/examples/nrf52840/src/bin/pwm_sequence.rs index f282cf910..87eda265f 100644 --- a/examples/nrf52840/src/bin/pwm_sequence.rs +++ b/examples/nrf52840/src/bin/pwm_sequence.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/pwm_sequence_ppi.rs b/examples/nrf52840/src/bin/pwm_sequence_ppi.rs index 6594fa348..60ea712b5 100644 --- a/examples/nrf52840/src/bin/pwm_sequence_ppi.rs +++ b/examples/nrf52840/src/bin/pwm_sequence_ppi.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use core::future::pending; | 4 | use core::future::pending; |
| 6 | 5 | ||
diff --git a/examples/nrf52840/src/bin/pwm_sequence_ws2812b.rs b/examples/nrf52840/src/bin/pwm_sequence_ws2812b.rs index 8596e6545..751cf4425 100644 --- a/examples/nrf52840/src/bin/pwm_sequence_ws2812b.rs +++ b/examples/nrf52840/src/bin/pwm_sequence_ws2812b.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/pwm_servo.rs b/examples/nrf52840/src/bin/pwm_servo.rs index 92ded1f88..d772d2f5d 100644 --- a/examples/nrf52840/src/bin/pwm_servo.rs +++ b/examples/nrf52840/src/bin/pwm_servo.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/qdec.rs b/examples/nrf52840/src/bin/qdec.rs index 59783d312..ea849be63 100644 --- a/examples/nrf52840/src/bin/qdec.rs +++ b/examples/nrf52840/src/bin/qdec.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::info; | 4 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/qspi.rs b/examples/nrf52840/src/bin/qspi.rs index 9e8a01f4e..4539dd0e3 100644 --- a/examples/nrf52840/src/bin/qspi.rs +++ b/examples/nrf52840/src/bin/qspi.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::{assert_eq, info, unwrap}; | 4 | use defmt::{assert_eq, info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/qspi_lowpower.rs b/examples/nrf52840/src/bin/qspi_lowpower.rs index 42b5454e0..516c9b481 100644 --- a/examples/nrf52840/src/bin/qspi_lowpower.rs +++ b/examples/nrf52840/src/bin/qspi_lowpower.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use core::mem; | 4 | use core::mem; |
| 6 | 5 | ||
diff --git a/examples/nrf52840/src/bin/rng.rs b/examples/nrf52840/src/bin/rng.rs index 855743f50..326054c9a 100644 --- a/examples/nrf52840/src/bin/rng.rs +++ b/examples/nrf52840/src/bin/rng.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use embassy_executor::Spawner; | 4 | use embassy_executor::Spawner; |
| 6 | use embassy_nrf::rng::Rng; | 5 | use embassy_nrf::rng::Rng; |
diff --git a/examples/nrf52840/src/bin/saadc.rs b/examples/nrf52840/src/bin/saadc.rs index d651834f5..653b7d606 100644 --- a/examples/nrf52840/src/bin/saadc.rs +++ b/examples/nrf52840/src/bin/saadc.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::info; | 4 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/saadc_continuous.rs b/examples/nrf52840/src/bin/saadc_continuous.rs index a5f8a4dd7..f76fa3570 100644 --- a/examples/nrf52840/src/bin/saadc_continuous.rs +++ b/examples/nrf52840/src/bin/saadc_continuous.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::info; | 4 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/self_spawn.rs b/examples/nrf52840/src/bin/self_spawn.rs index 8a58396a4..5bfefc2af 100644 --- a/examples/nrf52840/src/bin/self_spawn.rs +++ b/examples/nrf52840/src/bin/self_spawn.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::{info, unwrap}; | 4 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/self_spawn_current_executor.rs b/examples/nrf52840/src/bin/self_spawn_current_executor.rs index 65d50f8c3..ec9569a64 100644 --- a/examples/nrf52840/src/bin/self_spawn_current_executor.rs +++ b/examples/nrf52840/src/bin/self_spawn_current_executor.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::{info, unwrap}; | 4 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/spim.rs b/examples/nrf52840/src/bin/spim.rs index 9d1843a8f..131187660 100644 --- a/examples/nrf52840/src/bin/spim.rs +++ b/examples/nrf52840/src/bin/spim.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::{info, unwrap}; | 4 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/spis.rs b/examples/nrf52840/src/bin/spis.rs index 77b6e8b64..613cd37ab 100644 --- a/examples/nrf52840/src/bin/spis.rs +++ b/examples/nrf52840/src/bin/spis.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::info; | 4 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/temp.rs b/examples/nrf52840/src/bin/temp.rs index d94dea38d..1d28f8ecf 100644 --- a/examples/nrf52840/src/bin/temp.rs +++ b/examples/nrf52840/src/bin/temp.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::info; | 4 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/timer.rs b/examples/nrf52840/src/bin/timer.rs index 9b9bb3eb4..365695a20 100644 --- a/examples/nrf52840/src/bin/timer.rs +++ b/examples/nrf52840/src/bin/timer.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::{info, unwrap}; | 4 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/twim.rs b/examples/nrf52840/src/bin/twim.rs index 959e3a4be..a9a0765e8 100644 --- a/examples/nrf52840/src/bin/twim.rs +++ b/examples/nrf52840/src/bin/twim.rs | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #![no_std] | 5 | #![no_std] |
| 6 | #![no_main] | 6 | #![no_main] |
| 7 | #![feature(type_alias_impl_trait)] | ||
| 8 | 7 | ||
| 9 | use defmt::*; | 8 | use defmt::*; |
| 10 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/twim_lowpower.rs b/examples/nrf52840/src/bin/twim_lowpower.rs index bf9f966ef..c743614b8 100644 --- a/examples/nrf52840/src/bin/twim_lowpower.rs +++ b/examples/nrf52840/src/bin/twim_lowpower.rs | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #![no_std] | 7 | #![no_std] |
| 8 | #![no_main] | 8 | #![no_main] |
| 9 | #![feature(type_alias_impl_trait)] | ||
| 10 | 9 | ||
| 11 | use core::mem; | 10 | use core::mem; |
| 12 | 11 | ||
diff --git a/examples/nrf52840/src/bin/twis.rs b/examples/nrf52840/src/bin/twis.rs index aa42b679e..88bd4cceb 100644 --- a/examples/nrf52840/src/bin/twis.rs +++ b/examples/nrf52840/src/bin/twis.rs | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | 2 | ||
| 3 | #![no_std] | 3 | #![no_std] |
| 4 | #![no_main] | 4 | #![no_main] |
| 5 | #![feature(type_alias_impl_trait)] | ||
| 6 | 5 | ||
| 7 | use defmt::*; | 6 | use defmt::*; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/uart.rs b/examples/nrf52840/src/bin/uart.rs index 50d5cab8c..accaccea1 100644 --- a/examples/nrf52840/src/bin/uart.rs +++ b/examples/nrf52840/src/bin/uart.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/uart_idle.rs b/examples/nrf52840/src/bin/uart_idle.rs index e1f42fa6c..fa93bcf21 100644 --- a/examples/nrf52840/src/bin/uart_idle.rs +++ b/examples/nrf52840/src/bin/uart_idle.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/uart_split.rs b/examples/nrf52840/src/bin/uart_split.rs index b748bfcd8..c7510a9a8 100644 --- a/examples/nrf52840/src/bin/uart_split.rs +++ b/examples/nrf52840/src/bin/uart_split.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/usb_ethernet.rs b/examples/nrf52840/src/bin/usb_ethernet.rs index b7806f418..a7e5c2668 100644 --- a/examples/nrf52840/src/bin/usb_ethernet.rs +++ b/examples/nrf52840/src/bin/usb_ethernet.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use core::mem; | 4 | use core::mem; |
| 6 | 5 | ||
| @@ -16,7 +15,7 @@ use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState | |||
| 16 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | 15 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; |
| 17 | use embassy_usb::{Builder, Config, UsbDevice}; | 16 | use embassy_usb::{Builder, Config, UsbDevice}; |
| 18 | use embedded_io_async::Write; | 17 | use embedded_io_async::Write; |
| 19 | use static_cell::make_static; | 18 | use static_cell::StaticCell; |
| 20 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 20 | ||
| 22 | bind_interrupts!(struct Irqs { | 21 | bind_interrupts!(struct Irqs { |
| @@ -71,14 +70,17 @@ async fn main(spawner: Spawner) { | |||
| 71 | config.device_protocol = 0x01; | 70 | config.device_protocol = 0x01; |
| 72 | 71 | ||
| 73 | // Create embassy-usb DeviceBuilder using the driver and config. | 72 | // Create embassy-usb DeviceBuilder using the driver and config. |
| 73 | static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 74 | static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 75 | static MSOS_DESC: StaticCell<[u8; 128]> = StaticCell::new(); | ||
| 76 | static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new(); | ||
| 74 | let mut builder = Builder::new( | 77 | let mut builder = Builder::new( |
| 75 | driver, | 78 | driver, |
| 76 | config, | 79 | config, |
| 77 | &mut make_static!([0; 256])[..], | 80 | &mut CONFIG_DESC.init([0; 256])[..], |
| 78 | &mut make_static!([0; 256])[..], | 81 | &mut BOS_DESC.init([0; 256])[..], |
| 79 | &mut make_static!([0; 256])[..], | 82 | &mut MSOS_DESC.init([0; 128])[..], |
| 80 | &mut make_static!([0; 128])[..], | 83 | &mut CONTROL_BUF.init([0; 128])[..], |
| 81 | &mut make_static!([0; 128])[..], | ||
| 82 | ); | 84 | ); |
| 83 | 85 | ||
| 84 | // Our MAC addr. | 86 | // Our MAC addr. |
| @@ -87,14 +89,16 @@ async fn main(spawner: Spawner) { | |||
| 87 | let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88]; | 89 | let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88]; |
| 88 | 90 | ||
| 89 | // Create classes on the builder. | 91 | // Create classes on the builder. |
| 90 | let class = CdcNcmClass::new(&mut builder, make_static!(State::new()), host_mac_addr, 64); | 92 | static STATE: StaticCell<State> = StaticCell::new(); |
| 93 | let class = CdcNcmClass::new(&mut builder, STATE.init(State::new()), host_mac_addr, 64); | ||
| 91 | 94 | ||
| 92 | // Build the builder. | 95 | // Build the builder. |
| 93 | let usb = builder.build(); | 96 | let usb = builder.build(); |
| 94 | 97 | ||
| 95 | unwrap!(spawner.spawn(usb_task(usb))); | 98 | unwrap!(spawner.spawn(usb_task(usb))); |
| 96 | 99 | ||
| 97 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); | 100 | static NET_STATE: StaticCell<NetState<MTU, 4, 4>> = StaticCell::new(); |
| 101 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(NET_STATE.init(NetState::new()), our_mac_addr); | ||
| 98 | unwrap!(spawner.spawn(usb_ncm_task(runner))); | 102 | unwrap!(spawner.spawn(usb_ncm_task(runner))); |
| 99 | 103 | ||
| 100 | let config = embassy_net::Config::dhcpv4(Default::default()); | 104 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| @@ -111,12 +115,9 @@ async fn main(spawner: Spawner) { | |||
| 111 | let seed = u64::from_le_bytes(seed); | 115 | let seed = u64::from_le_bytes(seed); |
| 112 | 116 | ||
| 113 | // Init network stack | 117 | // Init network stack |
| 114 | let stack = &*make_static!(Stack::new( | 118 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); |
| 115 | device, | 119 | static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new(); |
| 116 | config, | 120 | let stack = &*STACK.init(Stack::new(device, config, RESOURCES.init(StackResources::new()), seed)); |
| 117 | make_static!(StackResources::<2>::new()), | ||
| 118 | seed | ||
| 119 | )); | ||
| 120 | 121 | ||
| 121 | unwrap!(spawner.spawn(net_task(stack))); | 122 | unwrap!(spawner.spawn(net_task(stack))); |
| 122 | 123 | ||
diff --git a/examples/nrf52840/src/bin/usb_hid_keyboard.rs b/examples/nrf52840/src/bin/usb_hid_keyboard.rs index 7ccd2946a..52f081487 100644 --- a/examples/nrf52840/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf52840/src/bin/usb_hid_keyboard.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use core::mem; | 4 | use core::mem; |
| 6 | use core::sync::atomic::{AtomicBool, Ordering}; | 5 | use core::sync::atomic::{AtomicBool, Ordering}; |
| @@ -9,7 +8,7 @@ use defmt::*; | |||
| 9 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 10 | use embassy_futures::join::join; | 9 | use embassy_futures::join::join; |
| 11 | use embassy_futures::select::{select, Either}; | 10 | use embassy_futures::select::{select, Either}; |
| 12 | use embassy_nrf::gpio::{Input, Pin, Pull}; | 11 | use embassy_nrf::gpio::{Input, Pull}; |
| 13 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; | 12 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; |
| 14 | use embassy_nrf::usb::Driver; | 13 | use embassy_nrf::usb::Driver; |
| 15 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; | 14 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; |
| @@ -51,7 +50,6 @@ async fn main(_spawner: Spawner) { | |||
| 51 | 50 | ||
| 52 | // Create embassy-usb DeviceBuilder using the driver and config. | 51 | // Create embassy-usb DeviceBuilder using the driver and config. |
| 53 | // It needs some buffers for building the descriptors. | 52 | // It needs some buffers for building the descriptors. |
| 54 | let mut device_descriptor = [0; 256]; | ||
| 55 | let mut config_descriptor = [0; 256]; | 53 | let mut config_descriptor = [0; 256]; |
| 56 | let mut bos_descriptor = [0; 256]; | 54 | let mut bos_descriptor = [0; 256]; |
| 57 | let mut msos_descriptor = [0; 256]; | 55 | let mut msos_descriptor = [0; 256]; |
| @@ -64,7 +62,6 @@ async fn main(_spawner: Spawner) { | |||
| 64 | let mut builder = Builder::new( | 62 | let mut builder = Builder::new( |
| 65 | driver, | 63 | driver, |
| 66 | config, | 64 | config, |
| 67 | &mut device_descriptor, | ||
| 68 | &mut config_descriptor, | 65 | &mut config_descriptor, |
| 69 | &mut bos_descriptor, | 66 | &mut bos_descriptor, |
| 70 | &mut msos_descriptor, | 67 | &mut msos_descriptor, |
| @@ -98,7 +95,7 @@ async fn main(_spawner: Spawner) { | |||
| 98 | } | 95 | } |
| 99 | }; | 96 | }; |
| 100 | 97 | ||
| 101 | let mut button = Input::new(p.P0_11.degrade(), Pull::Up); | 98 | let mut button = Input::new(p.P0_11, Pull::Up); |
| 102 | 99 | ||
| 103 | let (reader, mut writer) = hid.split(); | 100 | let (reader, mut writer) = hid.split(); |
| 104 | 101 | ||
diff --git a/examples/nrf52840/src/bin/usb_hid_mouse.rs b/examples/nrf52840/src/bin/usb_hid_mouse.rs index 96fcf8a66..5d2837793 100644 --- a/examples/nrf52840/src/bin/usb_hid_mouse.rs +++ b/examples/nrf52840/src/bin/usb_hid_mouse.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use core::mem; | 4 | use core::mem; |
| 6 | 5 | ||
| @@ -44,7 +43,6 @@ async fn main(_spawner: Spawner) { | |||
| 44 | 43 | ||
| 45 | // Create embassy-usb DeviceBuilder using the driver and config. | 44 | // Create embassy-usb DeviceBuilder using the driver and config. |
| 46 | // It needs some buffers for building the descriptors. | 45 | // It needs some buffers for building the descriptors. |
| 47 | let mut device_descriptor = [0; 256]; | ||
| 48 | let mut config_descriptor = [0; 256]; | 46 | let mut config_descriptor = [0; 256]; |
| 49 | let mut bos_descriptor = [0; 256]; | 47 | let mut bos_descriptor = [0; 256]; |
| 50 | let mut msos_descriptor = [0; 256]; | 48 | let mut msos_descriptor = [0; 256]; |
| @@ -56,7 +54,6 @@ async fn main(_spawner: Spawner) { | |||
| 56 | let mut builder = Builder::new( | 54 | let mut builder = Builder::new( |
| 57 | driver, | 55 | driver, |
| 58 | config, | 56 | config, |
| 59 | &mut device_descriptor, | ||
| 60 | &mut config_descriptor, | 57 | &mut config_descriptor, |
| 61 | &mut bos_descriptor, | 58 | &mut bos_descriptor, |
| 62 | &mut msos_descriptor, | 59 | &mut msos_descriptor, |
diff --git a/examples/nrf52840/src/bin/usb_serial.rs b/examples/nrf52840/src/bin/usb_serial.rs index dc95cde84..02048e692 100644 --- a/examples/nrf52840/src/bin/usb_serial.rs +++ b/examples/nrf52840/src/bin/usb_serial.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use core::mem; | 4 | use core::mem; |
| 6 | 5 | ||
| @@ -49,7 +48,6 @@ async fn main(_spawner: Spawner) { | |||
| 49 | 48 | ||
| 50 | // Create embassy-usb DeviceBuilder using the driver and config. | 49 | // Create embassy-usb DeviceBuilder using the driver and config. |
| 51 | // It needs some buffers for building the descriptors. | 50 | // It needs some buffers for building the descriptors. |
| 52 | let mut device_descriptor = [0; 256]; | ||
| 53 | let mut config_descriptor = [0; 256]; | 51 | let mut config_descriptor = [0; 256]; |
| 54 | let mut bos_descriptor = [0; 256]; | 52 | let mut bos_descriptor = [0; 256]; |
| 55 | let mut msos_descriptor = [0; 256]; | 53 | let mut msos_descriptor = [0; 256]; |
| @@ -60,7 +58,6 @@ async fn main(_spawner: Spawner) { | |||
| 60 | let mut builder = Builder::new( | 58 | let mut builder = Builder::new( |
| 61 | driver, | 59 | driver, |
| 62 | config, | 60 | config, |
| 63 | &mut device_descriptor, | ||
| 64 | &mut config_descriptor, | 61 | &mut config_descriptor, |
| 65 | &mut bos_descriptor, | 62 | &mut bos_descriptor, |
| 66 | &mut msos_descriptor, | 63 | &mut msos_descriptor, |
diff --git a/examples/nrf52840/src/bin/usb_serial_multitask.rs b/examples/nrf52840/src/bin/usb_serial_multitask.rs index cd4392903..895cca8b9 100644 --- a/examples/nrf52840/src/bin/usb_serial_multitask.rs +++ b/examples/nrf52840/src/bin/usb_serial_multitask.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use core::mem; | 4 | use core::mem; |
| 6 | 5 | ||
| @@ -12,7 +11,7 @@ use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; | |||
| 12 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 13 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 14 | use embassy_usb::{Builder, Config, UsbDevice}; | 13 | use embassy_usb::{Builder, Config, UsbDevice}; |
| 15 | use static_cell::make_static; | 14 | use static_cell::StaticCell; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 16 | ||
| 18 | bind_interrupts!(struct Irqs { | 17 | bind_interrupts!(struct Irqs { |
| @@ -64,17 +63,21 @@ async fn main(spawner: Spawner) { | |||
| 64 | config.device_protocol = 0x01; | 63 | config.device_protocol = 0x01; |
| 65 | config.composite_with_iads = true; | 64 | config.composite_with_iads = true; |
| 66 | 65 | ||
| 67 | let state = make_static!(State::new()); | 66 | static STATE: StaticCell<State> = StaticCell::new(); |
| 67 | let state = STATE.init(State::new()); | ||
| 68 | 68 | ||
| 69 | // Create embassy-usb DeviceBuilder using the driver and config. | 69 | // Create embassy-usb DeviceBuilder using the driver and config. |
| 70 | static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 71 | static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 72 | static MSOS_DESC: StaticCell<[u8; 128]> = StaticCell::new(); | ||
| 73 | static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new(); | ||
| 70 | let mut builder = Builder::new( | 74 | let mut builder = Builder::new( |
| 71 | driver, | 75 | driver, |
| 72 | config, | 76 | config, |
| 73 | &mut make_static!([0; 256])[..], | 77 | &mut CONFIG_DESC.init([0; 256])[..], |
| 74 | &mut make_static!([0; 256])[..], | 78 | &mut BOS_DESC.init([0; 256])[..], |
| 75 | &mut make_static!([0; 256])[..], | 79 | &mut MSOS_DESC.init([0; 128])[..], |
| 76 | &mut make_static!([0; 128])[..], | 80 | &mut CONTROL_BUF.init([0; 128])[..], |
| 77 | &mut make_static!([0; 128])[..], | ||
| 78 | ); | 81 | ); |
| 79 | 82 | ||
| 80 | // Create classes on the builder. | 83 | // Create classes on the builder. |
diff --git a/examples/nrf52840/src/bin/usb_serial_winusb.rs b/examples/nrf52840/src/bin/usb_serial_winusb.rs index 1d39d3841..c6675a3d3 100644 --- a/examples/nrf52840/src/bin/usb_serial_winusb.rs +++ b/examples/nrf52840/src/bin/usb_serial_winusb.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use core::mem; | 4 | use core::mem; |
| 6 | 5 | ||
| @@ -54,7 +53,6 @@ async fn main(_spawner: Spawner) { | |||
| 54 | 53 | ||
| 55 | // Create embassy-usb DeviceBuilder using the driver and config. | 54 | // Create embassy-usb DeviceBuilder using the driver and config. |
| 56 | // It needs some buffers for building the descriptors. | 55 | // It needs some buffers for building the descriptors. |
| 57 | let mut device_descriptor = [0; 256]; | ||
| 58 | let mut config_descriptor = [0; 256]; | 56 | let mut config_descriptor = [0; 256]; |
| 59 | let mut bos_descriptor = [0; 256]; | 57 | let mut bos_descriptor = [0; 256]; |
| 60 | let mut msos_descriptor = [0; 256]; | 58 | let mut msos_descriptor = [0; 256]; |
| @@ -65,7 +63,6 @@ async fn main(_spawner: Spawner) { | |||
| 65 | let mut builder = Builder::new( | 63 | let mut builder = Builder::new( |
| 66 | driver, | 64 | driver, |
| 67 | config, | 65 | config, |
| 68 | &mut device_descriptor, | ||
| 69 | &mut config_descriptor, | 66 | &mut config_descriptor, |
| 70 | &mut bos_descriptor, | 67 | &mut bos_descriptor, |
| 71 | &mut msos_descriptor, | 68 | &mut msos_descriptor, |
diff --git a/examples/nrf52840/src/bin/wdt.rs b/examples/nrf52840/src/bin/wdt.rs index 058746518..ede88cc26 100644 --- a/examples/nrf52840/src/bin/wdt.rs +++ b/examples/nrf52840/src/bin/wdt.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840/src/bin/wifi_esp_hosted.rs b/examples/nrf52840/src/bin/wifi_esp_hosted.rs index a60822fd9..00bd50081 100644 --- a/examples/nrf52840/src/bin/wifi_esp_hosted.rs +++ b/examples/nrf52840/src/bin/wifi_esp_hosted.rs | |||
| @@ -1,19 +1,18 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | 3 | ||
| 5 | use defmt::{info, unwrap, warn}; | 4 | use defmt::{info, unwrap, warn}; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 7 | use embassy_net::tcp::TcpSocket; | 6 | use embassy_net::tcp::TcpSocket; |
| 8 | use embassy_net::{Stack, StackResources}; | 7 | use embassy_net::{Stack, StackResources}; |
| 9 | use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull}; | 8 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; |
| 10 | use embassy_nrf::rng::Rng; | 9 | use embassy_nrf::rng::Rng; |
| 11 | use embassy_nrf::spim::{self, Spim}; | 10 | use embassy_nrf::spim::{self, Spim}; |
| 12 | use embassy_nrf::{bind_interrupts, peripherals}; | 11 | use embassy_nrf::{bind_interrupts, peripherals}; |
| 13 | use embassy_time::Delay; | 12 | use embassy_time::Delay; |
| 14 | use embedded_hal_bus::spi::ExclusiveDevice; | 13 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 15 | use embedded_io_async::Write; | 14 | use embedded_io_async::Write; |
| 16 | use static_cell::make_static; | 15 | use static_cell::StaticCell; |
| 17 | use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _}; | 16 | use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _}; |
| 18 | 17 | ||
| 19 | const WIFI_NETWORK: &str = "EmbassyTest"; | 18 | const WIFI_NETWORK: &str = "EmbassyTest"; |
| @@ -28,9 +27,9 @@ bind_interrupts!(struct Irqs { | |||
| 28 | async fn wifi_task( | 27 | async fn wifi_task( |
| 29 | runner: hosted::Runner< | 28 | runner: hosted::Runner< |
| 30 | 'static, | 29 | 'static, |
| 31 | ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_31>, Delay>, | 30 | ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, |
| 32 | Input<'static, AnyPin>, | 31 | Input<'static>, |
| 33 | Output<'static, peripherals::P1_05>, | 32 | Output<'static>, |
| 34 | >, | 33 | >, |
| 35 | ) -> ! { | 34 | ) -> ! { |
| 36 | runner.run().await | 35 | runner.run().await |
| @@ -51,8 +50,8 @@ async fn main(spawner: Spawner) { | |||
| 51 | let sck = p.P0_29; | 50 | let sck = p.P0_29; |
| 52 | let mosi = p.P0_30; | 51 | let mosi = p.P0_30; |
| 53 | let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive); | 52 | let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive); |
| 54 | let handshake = Input::new(p.P1_01.degrade(), Pull::Up); | 53 | let handshake = Input::new(p.P1_01, Pull::Up); |
| 55 | let ready = Input::new(p.P1_04.degrade(), Pull::None); | 54 | let ready = Input::new(p.P1_04, Pull::None); |
| 56 | let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard); | 55 | let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard); |
| 57 | 56 | ||
| 58 | let mut config = spim::Config::default(); | 57 | let mut config = spim::Config::default(); |
| @@ -61,8 +60,9 @@ async fn main(spawner: Spawner) { | |||
| 61 | let spi = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config); | 60 | let spi = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config); |
| 62 | let spi = ExclusiveDevice::new(spi, cs, Delay); | 61 | let spi = ExclusiveDevice::new(spi, cs, Delay); |
| 63 | 62 | ||
| 63 | static ESP_STATE: StaticCell<embassy_net_esp_hosted::State> = StaticCell::new(); | ||
| 64 | let (device, mut control, runner) = embassy_net_esp_hosted::new( | 64 | let (device, mut control, runner) = embassy_net_esp_hosted::new( |
| 65 | make_static!(embassy_net_esp_hosted::State::new()), | 65 | ESP_STATE.init(embassy_net_esp_hosted::State::new()), |
| 66 | spi, | 66 | spi, |
| 67 | handshake, | 67 | handshake, |
| 68 | ready, | 68 | ready, |
| @@ -89,11 +89,13 @@ async fn main(spawner: Spawner) { | |||
| 89 | let seed = u64::from_le_bytes(seed); | 89 | let seed = u64::from_le_bytes(seed); |
| 90 | 90 | ||
| 91 | // Init network stack | 91 | // Init network stack |
| 92 | let stack = &*make_static!(Stack::new( | 92 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); |
| 93 | static STACK: StaticCell<Stack<hosted::NetDriver<'static>>> = StaticCell::new(); | ||
| 94 | let stack = &*STACK.init(Stack::new( | ||
| 93 | device, | 95 | device, |
| 94 | config, | 96 | config, |
| 95 | make_static!(StackResources::<2>::new()), | 97 | RESOURCES.init(StackResources::<2>::new()), |
| 96 | seed | 98 | seed, |
| 97 | )); | 99 | )); |
| 98 | 100 | ||
| 99 | unwrap!(spawner.spawn(net_task(stack))); | 101 | unwrap!(spawner.spawn(net_task(stack))); |
