diff options
| author | sodo <[email protected]> | 2024-01-02 01:37:00 +0900 |
|---|---|---|
| committer | sodo <[email protected]> | 2024-01-02 13:34:22 +0900 |
| commit | 6ee153a3e2eec284c0d9d87f31801265c0604f74 (patch) | |
| tree | 8b801cbd15f9ad5052d5942c731e75736dc9d7eb /examples/stm32l5/src/bin | |
| parent | b7cd7952c890f585ff876c622482534e5d58d4a4 (diff) | |
| parent | 0be9b0599aaf2e425d76ec7852ff4b3535defddf (diff) | |
Merge remote-tracking branch 'origin'
Diffstat (limited to 'examples/stm32l5/src/bin')
| -rw-r--r-- | examples/stm32l5/src/bin/button_exti.rs | 1 | ||||
| -rw-r--r-- | examples/stm32l5/src/bin/rng.rs | 1 | ||||
| -rw-r--r-- | examples/stm32l5/src/bin/usb_ethernet.rs | 29 | ||||
| -rw-r--r-- | examples/stm32l5/src/bin/usb_hid_mouse.rs | 1 | ||||
| -rw-r--r-- | examples/stm32l5/src/bin/usb_serial.rs | 1 |
5 files changed, 18 insertions, 15 deletions
diff --git a/examples/stm32l5/src/bin/button_exti.rs b/examples/stm32l5/src/bin/button_exti.rs index e80ad2b3a..91d0ccc2e 100644 --- a/examples/stm32l5/src/bin/button_exti.rs +++ b/examples/stm32l5/src/bin/button_exti.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/stm32l5/src/bin/rng.rs b/examples/stm32l5/src/bin/rng.rs index 279f4f65d..50da6c946 100644 --- a/examples/stm32l5/src/bin/rng.rs +++ b/examples/stm32l5/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 defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 0b0a0e2db..88060b6b0 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/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 defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| @@ -15,7 +14,7 @@ use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | |||
| 15 | use embassy_usb::{Builder, UsbDevice}; | 14 | use embassy_usb::{Builder, UsbDevice}; |
| 16 | use embedded_io_async::Write; | 15 | use embedded_io_async::Write; |
| 17 | use rand_core::RngCore; | 16 | use rand_core::RngCore; |
| 18 | use static_cell::make_static; | 17 | use static_cell::StaticCell; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 19 | ||
| 21 | type MyDriver = Driver<'static, embassy_stm32::peripherals::USB>; | 20 | type MyDriver = Driver<'static, embassy_stm32::peripherals::USB>; |
| @@ -76,14 +75,18 @@ async fn main(spawner: Spawner) { | |||
| 76 | config.device_protocol = 0x01; | 75 | config.device_protocol = 0x01; |
| 77 | 76 | ||
| 78 | // Create embassy-usb DeviceBuilder using the driver and config. | 77 | // Create embassy-usb DeviceBuilder using the driver and config. |
| 78 | static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 79 | static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 80 | static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new(); | ||
| 81 | static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new(); | ||
| 79 | let mut builder = Builder::new( | 82 | let mut builder = Builder::new( |
| 80 | driver, | 83 | driver, |
| 81 | config, | 84 | config, |
| 82 | &mut make_static!([0; 256])[..], | 85 | &mut DEVICE_DESC.init([0; 256])[..], |
| 83 | &mut make_static!([0; 256])[..], | 86 | &mut CONFIG_DESC.init([0; 256])[..], |
| 84 | &mut make_static!([0; 256])[..], | 87 | &mut BOS_DESC.init([0; 256])[..], |
| 85 | &mut [], // no msos descriptors | 88 | &mut [], // no msos descriptors |
| 86 | &mut make_static!([0; 128])[..], | 89 | &mut CONTROL_BUF.init([0; 128])[..], |
| 87 | ); | 90 | ); |
| 88 | 91 | ||
| 89 | // Our MAC addr. | 92 | // Our MAC addr. |
| @@ -92,14 +95,16 @@ async fn main(spawner: Spawner) { | |||
| 92 | let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88]; | 95 | let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88]; |
| 93 | 96 | ||
| 94 | // Create classes on the builder. | 97 | // Create classes on the builder. |
| 95 | let class = CdcNcmClass::new(&mut builder, make_static!(State::new()), host_mac_addr, 64); | 98 | static STATE: StaticCell<State> = StaticCell::new(); |
| 99 | let class = CdcNcmClass::new(&mut builder, STATE.init(State::new()), host_mac_addr, 64); | ||
| 96 | 100 | ||
| 97 | // Build the builder. | 101 | // Build the builder. |
| 98 | let usb = builder.build(); | 102 | let usb = builder.build(); |
| 99 | 103 | ||
| 100 | unwrap!(spawner.spawn(usb_task(usb))); | 104 | unwrap!(spawner.spawn(usb_task(usb))); |
| 101 | 105 | ||
| 102 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); | 106 | static NET_STATE: StaticCell<NetState<MTU, 4, 4>> = StaticCell::new(); |
| 107 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(NET_STATE.init(NetState::new()), our_mac_addr); | ||
| 103 | unwrap!(spawner.spawn(usb_ncm_task(runner))); | 108 | unwrap!(spawner.spawn(usb_ncm_task(runner))); |
| 104 | 109 | ||
| 105 | let config = embassy_net::Config::dhcpv4(Default::default()); | 110 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| @@ -114,11 +119,13 @@ async fn main(spawner: Spawner) { | |||
| 114 | let seed = rng.next_u64(); | 119 | let seed = rng.next_u64(); |
| 115 | 120 | ||
| 116 | // Init network stack | 121 | // Init network stack |
| 117 | let stack = &*make_static!(Stack::new( | 122 | static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new(); |
| 123 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | ||
| 124 | let stack = &*STACK.init(Stack::new( | ||
| 118 | device, | 125 | device, |
| 119 | config, | 126 | config, |
| 120 | make_static!(StackResources::<2>::new()), | 127 | RESOURCES.init(StackResources::<2>::new()), |
| 121 | seed | 128 | seed, |
| 122 | )); | 129 | )); |
| 123 | 130 | ||
| 124 | unwrap!(spawner.spawn(net_task(stack))); | 131 | unwrap!(spawner.spawn(net_task(stack))); |
diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs index 3614a8e0a..7c8a8ebfb 100644 --- a/examples/stm32l5/src/bin/usb_hid_mouse.rs +++ b/examples/stm32l5/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 defmt::*; | 4 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
diff --git a/examples/stm32l5/src/bin/usb_serial.rs b/examples/stm32l5/src/bin/usb_serial.rs index f2b894b68..75053ce4b 100644 --- a/examples/stm32l5/src/bin/usb_serial.rs +++ b/examples/stm32l5/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 defmt::{panic, *}; | 4 | use defmt::{panic, *}; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
