aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32f4/src
diff options
context:
space:
mode:
authoreZio Pan <[email protected]>2023-12-22 00:19:00 +0800
committerGitHub <[email protected]>2023-12-22 00:19:00 +0800
commitd7e517e2d32c590e62e3e3339e191d19ce764c12 (patch)
tree3862995264a953b224557353bd37c38e83f92f95 /examples/stm32f4/src
parent05b8818de01866fa988a8f65a395690f02176b34 (diff)
parent87c03037e320ce30c0cd34fe97e0365e1b11aa9a (diff)
Merge branch 'main' into stm32f4-example-ws2812-spi
Diffstat (limited to 'examples/stm32f4/src')
-rw-r--r--examples/stm32f4/src/bin/adc.rs1
-rw-r--r--examples/stm32f4/src/bin/blinky.rs1
-rw-r--r--examples/stm32f4/src/bin/button.rs1
-rw-r--r--examples/stm32f4/src/bin/button_exti.rs1
-rw-r--r--examples/stm32f4/src/bin/can.rs1
-rw-r--r--examples/stm32f4/src/bin/dac.rs1
-rw-r--r--examples/stm32f4/src/bin/eth.rs14
-rw-r--r--examples/stm32f4/src/bin/flash.rs7
-rw-r--r--examples/stm32f4/src/bin/flash_async.rs7
-rw-r--r--examples/stm32f4/src/bin/hello.rs1
-rw-r--r--examples/stm32f4/src/bin/i2c.rs1
-rw-r--r--examples/stm32f4/src/bin/i2c_async.rs1
-rw-r--r--examples/stm32f4/src/bin/i2c_comparison.rs1
-rw-r--r--examples/stm32f4/src/bin/i2s_dma.rs1
-rw-r--r--examples/stm32f4/src/bin/mco.rs1
-rw-r--r--examples/stm32f4/src/bin/multiprio.rs1
-rw-r--r--examples/stm32f4/src/bin/pwm.rs1
-rw-r--r--examples/stm32f4/src/bin/pwm_complementary.rs1
-rw-r--r--examples/stm32f4/src/bin/rtc.rs1
-rw-r--r--examples/stm32f4/src/bin/sdmmc.rs1
-rw-r--r--examples/stm32f4/src/bin/spi.rs1
-rw-r--r--examples/stm32f4/src/bin/spi_dma.rs1
-rw-r--r--examples/stm32f4/src/bin/usart.rs1
-rw-r--r--examples/stm32f4/src/bin/usart_buffered.rs1
-rw-r--r--examples/stm32f4/src/bin/usart_dma.rs1
-rw-r--r--examples/stm32f4/src/bin/usb_ethernet.rs32
-rw-r--r--examples/stm32f4/src/bin/usb_raw.rs1
-rw-r--r--examples/stm32f4/src/bin/usb_serial.rs1
-rw-r--r--examples/stm32f4/src/bin/wdt.rs1
-rw-r--r--examples/stm32f4/src/bin/ws2812_pwm_dma.rs3
30 files changed, 35 insertions, 53 deletions
diff --git a/examples/stm32f4/src/bin/adc.rs b/examples/stm32f4/src/bin/adc.rs
index f19328727..699c29c05 100644
--- a/examples/stm32f4/src/bin/adc.rs
+++ b/examples/stm32f4/src/bin/adc.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
5use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs; 4use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs;
6use defmt::*; 5use defmt::*;
diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs
index 4bfc5a50d..31cce8225 100644
--- a/examples/stm32f4/src/bin/blinky.rs
+++ b/examples/stm32f4/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
5use defmt::*; 4use defmt::*;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/button.rs b/examples/stm32f4/src/bin/button.rs
index aa1eed46f..ad30a56a2 100644
--- a/examples/stm32f4/src/bin/button.rs
+++ b/examples/stm32f4/src/bin/button.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
5use cortex_m_rt::entry; 4use cortex_m_rt::entry;
6use defmt::*; 5use defmt::*;
diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs
index dfe587d41..67751187d 100644
--- a/examples/stm32f4/src/bin/button_exti.rs
+++ b/examples/stm32f4/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
5use defmt::*; 4use defmt::*;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/can.rs b/examples/stm32f4/src/bin/can.rs
index 20ce4edce..d074b4265 100644
--- a/examples/stm32f4/src/bin/can.rs
+++ b/examples/stm32f4/src/bin/can.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
5use defmt::*; 4use defmt::*;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/dac.rs b/examples/stm32f4/src/bin/dac.rs
index 8f14d6078..9c7754c4f 100644
--- a/examples/stm32f4/src/bin/dac.rs
+++ b/examples/stm32f4/src/bin/dac.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
5use defmt::*; 4use defmt::*;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/eth.rs b/examples/stm32f4/src/bin/eth.rs
index 088d83c06..7f5c8fdb1 100644
--- a/examples/stm32f4/src/bin/eth.rs
+++ b/examples/stm32f4/src/bin/eth.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
5use defmt::*; 4use defmt::*;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
@@ -14,7 +13,7 @@ use embassy_stm32::time::Hertz;
14use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; 13use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
15use embassy_time::Timer; 14use embassy_time::Timer;
16use embedded_io_async::Write; 15use embedded_io_async::Write;
17use static_cell::make_static; 16use static_cell::StaticCell;
18use {defmt_rtt as _, panic_probe as _}; 17use {defmt_rtt as _, panic_probe as _};
19 18
20bind_interrupts!(struct Irqs { 19bind_interrupts!(struct Irqs {
@@ -63,8 +62,9 @@ async fn main(spawner: Spawner) -> ! {
63 62
64 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; 63 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
65 64
65 static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new();
66 let device = Ethernet::new( 66 let device = Ethernet::new(
67 make_static!(PacketQueue::<16, 16>::new()), 67 PACKETS.init(PacketQueue::<16, 16>::new()),
68 p.ETH, 68 p.ETH,
69 Irqs, 69 Irqs,
70 p.PA1, 70 p.PA1,
@@ -88,11 +88,13 @@ async fn main(spawner: Spawner) -> ! {
88 //}); 88 //});
89 89
90 // Init network stack 90 // Init network stack
91 let stack = &*make_static!(Stack::new( 91 static STACK: StaticCell<Stack<Device>> = StaticCell::new();
92 static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
93 let stack = &*STACK.init(Stack::new(
92 device, 94 device,
93 config, 95 config,
94 make_static!(StackResources::<2>::new()), 96 RESOURCES.init(StackResources::<2>::new()),
95 seed 97 seed,
96 )); 98 ));
97 99
98 // Launch network task 100 // Launch network task
diff --git a/examples/stm32f4/src/bin/flash.rs b/examples/stm32f4/src/bin/flash.rs
index 93c54e943..1e8cabab4 100644
--- a/examples/stm32f4/src/bin/flash.rs
+++ b/examples/stm32f4/src/bin/flash.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
5use defmt::{info, unwrap}; 4use defmt::{info, unwrap};
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
@@ -31,7 +30,7 @@ fn test_flash(f: &mut Flash<'_, Blocking>, offset: u32, size: u32) {
31 30
32 info!("Reading..."); 31 info!("Reading...");
33 let mut buf = [0u8; 32]; 32 let mut buf = [0u8; 32];
34 unwrap!(f.read(offset, &mut buf)); 33 unwrap!(f.blocking_read(offset, &mut buf));
35 info!("Read: {=[u8]:x}", buf); 34 info!("Read: {=[u8]:x}", buf);
36 35
37 info!("Erasing..."); 36 info!("Erasing...");
@@ -39,7 +38,7 @@ fn test_flash(f: &mut Flash<'_, Blocking>, offset: u32, size: u32) {
39 38
40 info!("Reading..."); 39 info!("Reading...");
41 let mut buf = [0u8; 32]; 40 let mut buf = [0u8; 32];
42 unwrap!(f.read(offset, &mut buf)); 41 unwrap!(f.blocking_read(offset, &mut buf));
43 info!("Read after erase: {=[u8]:x}", buf); 42 info!("Read after erase: {=[u8]:x}", buf);
44 43
45 info!("Writing..."); 44 info!("Writing...");
@@ -53,7 +52,7 @@ fn test_flash(f: &mut Flash<'_, Blocking>, offset: u32, size: u32) {
53 52
54 info!("Reading..."); 53 info!("Reading...");
55 let mut buf = [0u8; 32]; 54 let mut buf = [0u8; 32];
56 unwrap!(f.read(offset, &mut buf)); 55 unwrap!(f.blocking_read(offset, &mut buf));
57 info!("Read: {=[u8]:x}", buf); 56 info!("Read: {=[u8]:x}", buf);
58 assert_eq!( 57 assert_eq!(
59 &buf[..], 58 &buf[..],
diff --git a/examples/stm32f4/src/bin/flash_async.rs b/examples/stm32f4/src/bin/flash_async.rs
index f0a65a725..493a536f3 100644
--- a/examples/stm32f4/src/bin/flash_async.rs
+++ b/examples/stm32f4/src/bin/flash_async.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
5use defmt::{info, unwrap}; 4use defmt::{info, unwrap};
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
@@ -48,7 +47,7 @@ async fn test_flash<'a>(f: &mut Flash<'a>, offset: u32, size: u32) {
48 47
49 info!("Reading..."); 48 info!("Reading...");
50 let mut buf = [0u8; 32]; 49 let mut buf = [0u8; 32];
51 unwrap!(f.read(offset, &mut buf)); 50 unwrap!(f.blocking_read(offset, &mut buf));
52 info!("Read: {=[u8]:x}", buf); 51 info!("Read: {=[u8]:x}", buf);
53 52
54 info!("Erasing..."); 53 info!("Erasing...");
@@ -56,7 +55,7 @@ async fn test_flash<'a>(f: &mut Flash<'a>, offset: u32, size: u32) {
56 55
57 info!("Reading..."); 56 info!("Reading...");
58 let mut buf = [0u8; 32]; 57 let mut buf = [0u8; 32];
59 unwrap!(f.read(offset, &mut buf)); 58 unwrap!(f.blocking_read(offset, &mut buf));
60 info!("Read after erase: {=[u8]:x}", buf); 59 info!("Read after erase: {=[u8]:x}", buf);
61 60
62 info!("Writing..."); 61 info!("Writing...");
@@ -73,7 +72,7 @@ async fn test_flash<'a>(f: &mut Flash<'a>, offset: u32, size: u32) {
73 72
74 info!("Reading..."); 73 info!("Reading...");
75 let mut buf = [0u8; 32]; 74 let mut buf = [0u8; 32];
76 unwrap!(f.read(offset, &mut buf)); 75 unwrap!(f.blocking_read(offset, &mut buf));
77 info!("Read: {=[u8]:x}", buf); 76 info!("Read: {=[u8]:x}", buf);
78 assert_eq!( 77 assert_eq!(
79 &buf[..], 78 &buf[..],
diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs
index a2a287110..3c295612c 100644
--- a/examples/stm32f4/src/bin/hello.rs
+++ b/examples/stm32f4/src/bin/hello.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
5use defmt::info; 4use defmt::info;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/i2c.rs b/examples/stm32f4/src/bin/i2c.rs
index 4f4adde28..4b5da774d 100644
--- a/examples/stm32f4/src/bin/i2c.rs
+++ b/examples/stm32f4/src/bin/i2c.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
5use defmt::*; 4use defmt::*;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/i2c_async.rs b/examples/stm32f4/src/bin/i2c_async.rs
index 9f59e4d41..90d11d4b4 100644
--- a/examples/stm32f4/src/bin/i2c_async.rs
+++ b/examples/stm32f4/src/bin/i2c_async.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// Example originally designed for stm32f411ceu6 reading an A1454 hall effect sensor on I2C1 4// Example originally designed for stm32f411ceu6 reading an A1454 hall effect sensor on I2C1
6// DMA peripherals changed to compile for stm32f429zi, for the CI. 5// DMA peripherals changed to compile for stm32f429zi, for the CI.
diff --git a/examples/stm32f4/src/bin/i2c_comparison.rs b/examples/stm32f4/src/bin/i2c_comparison.rs
index 6d23c0ed8..30cfbdf57 100644
--- a/examples/stm32f4/src/bin/i2c_comparison.rs
+++ b/examples/stm32f4/src/bin/i2c_comparison.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// Example originally designed for stm32f411ceu6 with three A1454 hall effect sensors, connected to I2C1, 2 and 3 4// Example originally designed for stm32f411ceu6 with three A1454 hall effect sensors, connected to I2C1, 2 and 3
6// on the pins referenced in the peripheral definitions. 5// on the pins referenced in the peripheral definitions.
diff --git a/examples/stm32f4/src/bin/i2s_dma.rs b/examples/stm32f4/src/bin/i2s_dma.rs
index e8d7b5f77..97a04b2aa 100644
--- a/examples/stm32f4/src/bin/i2s_dma.rs
+++ b/examples/stm32f4/src/bin/i2s_dma.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
5use core::fmt::Write; 4use core::fmt::Write;
6 5
diff --git a/examples/stm32f4/src/bin/mco.rs b/examples/stm32f4/src/bin/mco.rs
index 3315e7652..eb7bb6261 100644
--- a/examples/stm32f4/src/bin/mco.rs
+++ b/examples/stm32f4/src/bin/mco.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
5use defmt::*; 4use defmt::*;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/multiprio.rs b/examples/stm32f4/src/bin/multiprio.rs
index 74f3bb1c5..328447210 100644
--- a/examples/stm32f4/src/bin/multiprio.rs
+++ b/examples/stm32f4/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
60use cortex_m_rt::entry; 59use cortex_m_rt::entry;
61use defmt::*; 60use defmt::*;
diff --git a/examples/stm32f4/src/bin/pwm.rs b/examples/stm32f4/src/bin/pwm.rs
index 8e41d0e78..8844a9f0e 100644
--- a/examples/stm32f4/src/bin/pwm.rs
+++ b/examples/stm32f4/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
5use defmt::*; 4use defmt::*;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/pwm_complementary.rs b/examples/stm32f4/src/bin/pwm_complementary.rs
index d925f26d9..161f43c48 100644
--- a/examples/stm32f4/src/bin/pwm_complementary.rs
+++ b/examples/stm32f4/src/bin/pwm_complementary.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
5use defmt::*; 4use defmt::*;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/rtc.rs b/examples/stm32f4/src/bin/rtc.rs
index 44b4303c0..abab07b6b 100644
--- a/examples/stm32f4/src/bin/rtc.rs
+++ b/examples/stm32f4/src/bin/rtc.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
5use chrono::{NaiveDate, NaiveDateTime}; 4use chrono::{NaiveDate, NaiveDateTime};
6use defmt::*; 5use defmt::*;
diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs
index 91747b2d5..66e4e527c 100644
--- a/examples/stm32f4/src/bin/sdmmc.rs
+++ b/examples/stm32f4/src/bin/sdmmc.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
5use defmt::*; 4use defmt::*;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/spi.rs b/examples/stm32f4/src/bin/spi.rs
index 0919e9874..dc9141c62 100644
--- a/examples/stm32f4/src/bin/spi.rs
+++ b/examples/stm32f4/src/bin/spi.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
5use cortex_m_rt::entry; 4use cortex_m_rt::entry;
6use defmt::*; 5use defmt::*;
diff --git a/examples/stm32f4/src/bin/spi_dma.rs b/examples/stm32f4/src/bin/spi_dma.rs
index f291f7dba..7249c831a 100644
--- a/examples/stm32f4/src/bin/spi_dma.rs
+++ b/examples/stm32f4/src/bin/spi_dma.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
5use core::fmt::Write; 4use core::fmt::Write;
6use core::str::from_utf8; 5use core::str::from_utf8;
diff --git a/examples/stm32f4/src/bin/usart.rs b/examples/stm32f4/src/bin/usart.rs
index 45e94715f..40d9d70f1 100644
--- a/examples/stm32f4/src/bin/usart.rs
+++ b/examples/stm32f4/src/bin/usart.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
5use cortex_m_rt::entry; 4use cortex_m_rt::entry;
6use defmt::*; 5use defmt::*;
diff --git a/examples/stm32f4/src/bin/usart_buffered.rs b/examples/stm32f4/src/bin/usart_buffered.rs
index 71abc2893..c99807f11 100644
--- a/examples/stm32f4/src/bin/usart_buffered.rs
+++ b/examples/stm32f4/src/bin/usart_buffered.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
5use defmt::*; 4use defmt::*;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/usart_dma.rs b/examples/stm32f4/src/bin/usart_dma.rs
index dca25a78c..dd6de599c 100644
--- a/examples/stm32f4/src/bin/usart_dma.rs
+++ b/examples/stm32f4/src/bin/usart_dma.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
5use core::fmt::Write; 4use core::fmt::Write;
6 5
diff --git a/examples/stm32f4/src/bin/usb_ethernet.rs b/examples/stm32f4/src/bin/usb_ethernet.rs
index 6bf5b1cba..a196259a8 100644
--- a/examples/stm32f4/src/bin/usb_ethernet.rs
+++ b/examples/stm32f4/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
5use defmt::*; 4use defmt::*;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
@@ -14,7 +13,7 @@ use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState
14use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; 13use embassy_usb::class::cdc_ncm::{CdcNcmClass, State};
15use embassy_usb::{Builder, UsbDevice}; 14use embassy_usb::{Builder, UsbDevice};
16use embedded_io_async::Write; 15use embedded_io_async::Write;
17use static_cell::make_static; 16use static_cell::StaticCell;
18use {defmt_rtt as _, panic_probe as _}; 17use {defmt_rtt as _, panic_probe as _};
19 18
20type UsbDriver = Driver<'static, embassy_stm32::peripherals::USB_OTG_FS>; 19type UsbDriver = Driver<'static, embassy_stm32::peripherals::USB_OTG_FS>;
@@ -68,7 +67,8 @@ async fn main(spawner: Spawner) {
68 let p = embassy_stm32::init(config); 67 let p = embassy_stm32::init(config);
69 68
70 // Create the driver, from the HAL. 69 // Create the driver, from the HAL.
71 let ep_out_buffer = &mut make_static!([0; 256])[..]; 70 static OUTPUT_BUFFER: StaticCell<[u8; 256]> = StaticCell::new();
71 let ep_out_buffer = &mut OUTPUT_BUFFER.init([0; 256])[..];
72 let mut config = embassy_stm32::usb_otg::Config::default(); 72 let mut config = embassy_stm32::usb_otg::Config::default();
73 config.vbus_detection = true; 73 config.vbus_detection = true;
74 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, ep_out_buffer, config); 74 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, ep_out_buffer, config);
@@ -88,14 +88,18 @@ async fn main(spawner: Spawner) {
88 config.device_protocol = 0x01; 88 config.device_protocol = 0x01;
89 89
90 // Create embassy-usb DeviceBuilder using the driver and config. 90 // Create embassy-usb DeviceBuilder using the driver and config.
91 static DEVICE_DESC: StaticCell<[u8; 256]> = StaticCell::new();
92 static CONFIG_DESC: StaticCell<[u8; 256]> = StaticCell::new();
93 static BOS_DESC: StaticCell<[u8; 256]> = StaticCell::new();
94 static CONTROL_BUF: StaticCell<[u8; 128]> = StaticCell::new();
91 let mut builder = Builder::new( 95 let mut builder = Builder::new(
92 driver, 96 driver,
93 config, 97 config,
94 &mut make_static!([0; 256])[..], 98 &mut DEVICE_DESC.init([0; 256])[..],
95 &mut make_static!([0; 256])[..], 99 &mut CONFIG_DESC.init([0; 256])[..],
96 &mut make_static!([0; 256])[..], 100 &mut BOS_DESC.init([0; 256])[..],
97 &mut [], // no msos descriptors 101 &mut [], // no msos descriptors
98 &mut make_static!([0; 128])[..], 102 &mut CONTROL_BUF.init([0; 128])[..],
99 ); 103 );
100 104
101 // Our MAC addr. 105 // Our MAC addr.
@@ -104,14 +108,16 @@ async fn main(spawner: Spawner) {
104 let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88]; 108 let host_mac_addr = [0x88, 0x88, 0x88, 0x88, 0x88, 0x88];
105 109
106 // Create classes on the builder. 110 // Create classes on the builder.
107 let class = CdcNcmClass::new(&mut builder, make_static!(State::new()), host_mac_addr, 64); 111 static STATE: StaticCell<State> = StaticCell::new();
112 let class = CdcNcmClass::new(&mut builder, STATE.init(State::new()), host_mac_addr, 64);
108 113
109 // Build the builder. 114 // Build the builder.
110 let usb = builder.build(); 115 let usb = builder.build();
111 116
112 unwrap!(spawner.spawn(usb_task(usb))); 117 unwrap!(spawner.spawn(usb_task(usb)));
113 118
114 let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(make_static!(NetState::new()), our_mac_addr); 119 static NET_STATE: StaticCell<NetState<MTU, 4, 4>> = StaticCell::new();
120 let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(NET_STATE.init(NetState::new()), our_mac_addr);
115 unwrap!(spawner.spawn(usb_ncm_task(runner))); 121 unwrap!(spawner.spawn(usb_ncm_task(runner)));
116 122
117 let config = embassy_net::Config::dhcpv4(Default::default()); 123 let config = embassy_net::Config::dhcpv4(Default::default());
@@ -128,11 +134,13 @@ async fn main(spawner: Spawner) {
128 let seed = u64::from_le_bytes(seed); 134 let seed = u64::from_le_bytes(seed);
129 135
130 // Init network stack 136 // Init network stack
131 let stack = &*make_static!(Stack::new( 137 static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new();
138 static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
139 let stack = &*STACK.init(Stack::new(
132 device, 140 device,
133 config, 141 config,
134 make_static!(StackResources::<2>::new()), 142 RESOURCES.init(StackResources::<2>::new()),
135 seed 143 seed,
136 )); 144 ));
137 145
138 unwrap!(spawner.spawn(net_task(stack))); 146 unwrap!(spawner.spawn(net_task(stack)));
diff --git a/examples/stm32f4/src/bin/usb_raw.rs b/examples/stm32f4/src/bin/usb_raw.rs
index 719b22bb9..afff55187 100644
--- a/examples/stm32f4/src/bin/usb_raw.rs
+++ b/examples/stm32f4/src/bin/usb_raw.rs
@@ -48,7 +48,6 @@
48 48
49#![no_std] 49#![no_std]
50#![no_main] 50#![no_main]
51#![feature(type_alias_impl_trait)]
52 51
53use defmt::*; 52use defmt::*;
54use embassy_executor::Spawner; 53use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/usb_serial.rs b/examples/stm32f4/src/bin/usb_serial.rs
index e2ccc9142..58d994a61 100644
--- a/examples/stm32f4/src/bin/usb_serial.rs
+++ b/examples/stm32f4/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
5use defmt::{panic, *}; 4use defmt::{panic, *};
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/wdt.rs b/examples/stm32f4/src/bin/wdt.rs
index 0443b61c5..ea27ebce0 100644
--- a/examples/stm32f4/src/bin/wdt.rs
+++ b/examples/stm32f4/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
5use defmt::*; 4use defmt::*;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
diff --git a/examples/stm32f4/src/bin/ws2812_pwm_dma.rs b/examples/stm32f4/src/bin/ws2812_pwm_dma.rs
index dccd639ac..dc397eff1 100644
--- a/examples/stm32f4/src/bin/ws2812_pwm_dma.rs
+++ b/examples/stm32f4/src/bin/ws2812_pwm_dma.rs
@@ -17,7 +17,6 @@
17 17
18#![no_std] 18#![no_std]
19#![no_main] 19#![no_main]
20#![feature(type_alias_impl_trait)]
21 20
22use embassy_executor::Spawner; 21use embassy_executor::Spawner;
23use embassy_stm32::gpio::OutputType; 22use embassy_stm32::gpio::OutputType;
@@ -118,7 +117,7 @@ async fn main(_spawner: Spawner) {
118 &mut dp.DMA1_CH2, 117 &mut dp.DMA1_CH2,
119 5, 118 5,
120 color, 119 color,
121 pac::TIM3.ccr(pwm_channel.raw()).as_ptr() as *mut _, 120 pac::TIM3.ccr(pwm_channel.index()).as_ptr() as *mut _,
122 dma_transfer_option, 121 dma_transfer_option,
123 ) 122 )
124 .await; 123 .await;