diff options
| author | xoviat <[email protected]> | 2025-10-30 07:09:02 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-10-30 07:09:02 -0500 |
| commit | f4965c395b11f71891e0396e0b51b788437f4460 (patch) | |
| tree | 0bbc8c7c3f8f64d639d7105810859a2a7adb7908 /examples/stm32f4 | |
| parent | 3c8d078525c69867710bbd291dc135b3a5011702 (diff) | |
| parent | bc8ba64cf8248452fd030939a1c4e291cafc0911 (diff) | |
Merge branch 'main' into feature/stm32-i2c-v1-slave-mode
Diffstat (limited to 'examples/stm32f4')
| -rw-r--r-- | examples/stm32f4/Cargo.toml | 24 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/adc_dma.rs | 4 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/eth.rs | 4 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/eth_compliance_test.rs | 2 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/eth_w5500.rs | 6 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/flash_async.rs | 4 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/input_capture.rs | 4 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/mco.rs | 18 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/multiprio.rs | 10 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/pwm_complementary.rs | 2 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/pwm_input.rs | 4 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/rtc.rs | 2 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/sdmmc.rs | 4 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/usb_ethernet.rs | 10 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/usb_hid_keyboard.rs | 2 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/usb_hid_mouse.rs | 4 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/usb_raw.rs | 2 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/usb_serial.rs | 4 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/usb_uac_speaker.rs | 14 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/ws2812_pwm.rs | 2 |
20 files changed, 72 insertions, 54 deletions
diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index 3139bdf71..d06b7505c 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml | |||
| @@ -1,19 +1,20 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32f4-examples" | 3 | name = "embassy-stm32f4-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | publish = false | ||
| 6 | 7 | ||
| 7 | [dependencies] | 8 | [dependencies] |
| 8 | # Change stm32f429zi to your chip name, if necessary. | 9 | # Change stm32f429zi to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.3.0", path = "../../embassy-stm32", features = ["defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-tim4", "exti", "chrono"] } | 10 | embassy-stm32 = { version = "0.4.0", path = "../../embassy-stm32", features = ["defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-tim4", "exti", "chrono"] } |
| 10 | embassy-sync = { version = "0.7.1", path = "../../embassy-sync", features = ["defmt"] } | 11 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } | 12 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } |
| 12 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 13 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 13 | embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt" ] } | 14 | embassy-usb = { version = "0.5.1", path = "../../embassy-usb", features = ["defmt" ] } |
| 14 | embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } | 15 | embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } |
| 15 | embassy-net-wiznet = { version = "0.2.0", path = "../../embassy-net-wiznet", features = ["defmt"] } | 16 | embassy-net-wiznet = { version = "0.2.1", path = "../../embassy-net-wiznet", features = ["defmt"] } |
| 16 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 17 | embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } |
| 17 | 18 | ||
| 18 | defmt = "1.0.1" | 19 | defmt = "1.0.1" |
| 19 | defmt-rtt = "1.0.0" | 20 | defmt-rtt = "1.0.0" |
| @@ -37,3 +38,8 @@ chrono = { version = "^0.4", default-features = false} | |||
| 37 | 38 | ||
| 38 | [profile.release] | 39 | [profile.release] |
| 39 | debug = 2 | 40 | debug = 2 |
| 41 | |||
| 42 | [package.metadata.embassy] | ||
| 43 | build = [ | ||
| 44 | { target = "thumbv7em-none-eabi", artifact-dir = "out/examples/stm32f4" } | ||
| 45 | ] | ||
diff --git a/examples/stm32f4/src/bin/adc_dma.rs b/examples/stm32f4/src/bin/adc_dma.rs index 43a761e6d..c24f01753 100644 --- a/examples/stm32f4/src/bin/adc_dma.rs +++ b/examples/stm32f4/src/bin/adc_dma.rs | |||
| @@ -3,15 +3,15 @@ | |||
| 3 | use cortex_m::singleton; | 3 | use cortex_m::singleton; |
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::adc::{Adc, RingBufferedAdc, SampleTime, Sequence}; | ||
| 7 | use embassy_stm32::Peripherals; | 6 | use embassy_stm32::Peripherals; |
| 7 | use embassy_stm32::adc::{Adc, RingBufferedAdc, SampleTime, Sequence}; | ||
| 8 | use embassy_time::Instant; | 8 | use embassy_time::Instant; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 12 | async fn main(spawner: Spawner) { | 12 | async fn main(spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | 13 | let p = embassy_stm32::init(Default::default()); |
| 14 | spawner.must_spawn(adc_task(p)); | 14 | spawner.spawn(adc_task(p).unwrap()); |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | #[embassy_executor::task] | 17 | #[embassy_executor::task] |
diff --git a/examples/stm32f4/src/bin/eth.rs b/examples/stm32f4/src/bin/eth.rs index 634d8e2c6..2d72b6b0b 100644 --- a/examples/stm32f4/src/bin/eth.rs +++ b/examples/stm32f4/src/bin/eth.rs | |||
| @@ -9,7 +9,7 @@ use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; | |||
| 9 | use embassy_stm32::peripherals::ETH; | 9 | use embassy_stm32::peripherals::ETH; |
| 10 | use embassy_stm32::rng::Rng; | 10 | use embassy_stm32::rng::Rng; |
| 11 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 12 | use embassy_stm32::{Config, bind_interrupts, eth, peripherals, rng}; |
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | use embedded_io_async::Write; | 14 | use embedded_io_async::Write; |
| 15 | use static_cell::StaticCell; | 15 | use static_cell::StaticCell; |
| @@ -91,7 +91,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 91 | let (stack, runner) = embassy_net::new(device, config, RESOURCES.init(StackResources::new()), seed); | 91 | let (stack, runner) = embassy_net::new(device, config, RESOURCES.init(StackResources::new()), seed); |
| 92 | 92 | ||
| 93 | // Launch network task | 93 | // Launch network task |
| 94 | unwrap!(spawner.spawn(net_task(runner))); | 94 | spawner.spawn(unwrap!(net_task(runner))); |
| 95 | 95 | ||
| 96 | // Ensure DHCP configuration is up before trying connect | 96 | // Ensure DHCP configuration is up before trying connect |
| 97 | stack.wait_config_up().await; | 97 | stack.wait_config_up().await; |
diff --git a/examples/stm32f4/src/bin/eth_compliance_test.rs b/examples/stm32f4/src/bin/eth_compliance_test.rs index 52f9d57f6..734a14c2c 100644 --- a/examples/stm32f4/src/bin/eth_compliance_test.rs +++ b/examples/stm32f4/src/bin/eth_compliance_test.rs | |||
| @@ -5,7 +5,7 @@ use defmt::*; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue, StationManagement}; | 6 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue, StationManagement}; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, eth, peripherals, rng}; |
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use static_cell::StaticCell; | 10 | use static_cell::StaticCell; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/stm32f4/src/bin/eth_w5500.rs b/examples/stm32f4/src/bin/eth_w5500.rs index 6e6bef08c..cccf20949 100644 --- a/examples/stm32f4/src/bin/eth_w5500.rs +++ b/examples/stm32f4/src/bin/eth_w5500.rs | |||
| @@ -13,7 +13,7 @@ use embassy_stm32::mode::Async; | |||
| 13 | use embassy_stm32::rng::Rng; | 13 | use embassy_stm32::rng::Rng; |
| 14 | use embassy_stm32::spi::Spi; | 14 | use embassy_stm32::spi::Spi; |
| 15 | use embassy_stm32::time::Hertz; | 15 | use embassy_stm32::time::Hertz; |
| 16 | use embassy_stm32::{bind_interrupts, peripherals, rng, spi, Config}; | 16 | use embassy_stm32::{Config, bind_interrupts, peripherals, rng, spi}; |
| 17 | use embassy_time::{Delay, Timer}; | 17 | use embassy_time::{Delay, Timer}; |
| 18 | use embedded_hal_bus::spi::ExclusiveDevice; | 18 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 19 | use embedded_io_async::Write; | 19 | use embedded_io_async::Write; |
| @@ -83,7 +83,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 83 | let (device, runner) = embassy_net_wiznet::new(mac_addr, state, spi, w5500_int, w5500_reset) | 83 | let (device, runner) = embassy_net_wiznet::new(mac_addr, state, spi, w5500_int, w5500_reset) |
| 84 | .await | 84 | .await |
| 85 | .unwrap(); | 85 | .unwrap(); |
| 86 | unwrap!(spawner.spawn(ethernet_task(runner))); | 86 | spawner.spawn(unwrap!(ethernet_task(runner))); |
| 87 | 87 | ||
| 88 | let config = embassy_net::Config::dhcpv4(Default::default()); | 88 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| 89 | //let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { | 89 | //let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { |
| @@ -96,7 +96,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 96 | let (stack, runner) = embassy_net::new(device, config, RESOURCES.init(StackResources::new()), seed); | 96 | let (stack, runner) = embassy_net::new(device, config, RESOURCES.init(StackResources::new()), seed); |
| 97 | 97 | ||
| 98 | // Launch network task | 98 | // Launch network task |
| 99 | unwrap!(spawner.spawn(net_task(runner))); | 99 | spawner.spawn(unwrap!(net_task(runner))); |
| 100 | 100 | ||
| 101 | // Ensure DHCP configuration is up before trying connect | 101 | // Ensure DHCP configuration is up before trying connect |
| 102 | stack.wait_config_up().await; | 102 | stack.wait_config_up().await; |
diff --git a/examples/stm32f4/src/bin/flash_async.rs b/examples/stm32f4/src/bin/flash_async.rs index 755713542..14f029747 100644 --- a/examples/stm32f4/src/bin/flash_async.rs +++ b/examples/stm32f4/src/bin/flash_async.rs | |||
| @@ -5,7 +5,7 @@ use defmt::{info, unwrap}; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::flash::{Flash, InterruptHandler}; | 6 | use embassy_stm32::flash::{Flash, InterruptHandler}; |
| 7 | use embassy_stm32::gpio::{AnyPin, Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{AnyPin, Level, Output, Speed}; |
| 8 | use embassy_stm32::{bind_interrupts, Peri}; | 8 | use embassy_stm32::{Peri, bind_interrupts}; |
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| @@ -21,7 +21,7 @@ async fn main(spawner: Spawner) { | |||
| 21 | let mut f = Flash::new(p.FLASH, Irqs); | 21 | let mut f = Flash::new(p.FLASH, Irqs); |
| 22 | 22 | ||
| 23 | // Led should blink uninterrupted during ~2sec erase operation | 23 | // Led should blink uninterrupted during ~2sec erase operation |
| 24 | spawner.spawn(blinky(p.PB7.into())).unwrap(); | 24 | spawner.spawn(blinky(p.PB7.into()).unwrap()); |
| 25 | 25 | ||
| 26 | // Test on bank 2 in order not to stall CPU. | 26 | // Test on bank 2 in order not to stall CPU. |
| 27 | test_flash(&mut f, 1024 * 1024, 128 * 1024).await; | 27 | test_flash(&mut f, 1024 * 1024, 128 * 1024).await; |
diff --git a/examples/stm32f4/src/bin/input_capture.rs b/examples/stm32f4/src/bin/input_capture.rs index e15b4d26e..3ff96584d 100644 --- a/examples/stm32f4/src/bin/input_capture.rs +++ b/examples/stm32f4/src/bin/input_capture.rs | |||
| @@ -7,7 +7,7 @@ use embassy_stm32::gpio::{Level, Output, Pull, Speed}; | |||
| 7 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::input_capture::{CapturePin, InputCapture}; | 8 | use embassy_stm32::timer::input_capture::{CapturePin, InputCapture}; |
| 9 | use embassy_stm32::timer::{self, Channel}; | 9 | use embassy_stm32::timer::{self, Channel}; |
| 10 | use embassy_stm32::{bind_interrupts, peripherals, Peri}; | 10 | use embassy_stm32::{Peri, bind_interrupts, peripherals}; |
| 11 | use embassy_time::Timer; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| @@ -37,7 +37,7 @@ async fn main(spawner: Spawner) { | |||
| 37 | let p = embassy_stm32::init(Default::default()); | 37 | let p = embassy_stm32::init(Default::default()); |
| 38 | info!("Hello World!"); | 38 | info!("Hello World!"); |
| 39 | 39 | ||
| 40 | unwrap!(spawner.spawn(blinky(p.PB2))); | 40 | spawner.spawn(unwrap!(blinky(p.PB2))); |
| 41 | 41 | ||
| 42 | let ch3 = CapturePin::new(p.PB10, Pull::None); | 42 | let ch3 = CapturePin::new(p.PB10, Pull::None); |
| 43 | let mut ic = InputCapture::new(p.TIM2, None, None, Some(ch3), None, Irqs, khz(1000), Default::default()); | 43 | let mut ic = InputCapture::new(p.TIM2, None, None, Some(ch3), None, Irqs, khz(1000), Default::default()); |
diff --git a/examples/stm32f4/src/bin/mco.rs b/examples/stm32f4/src/bin/mco.rs index eb7bb6261..a2e229770 100644 --- a/examples/stm32f4/src/bin/mco.rs +++ b/examples/stm32f4/src/bin/mco.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::gpio::{Level, Output, Speed}; | 6 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 7 | use embassy_stm32::rcc::{Mco, Mco1Source, Mco2Source, McoPrescaler}; | 7 | use embassy_stm32::rcc::{Mco, Mco1Source, Mco2Source, McoConfig, McoPrescaler}; |
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| @@ -13,8 +13,20 @@ async fn main(_spawner: Spawner) { | |||
| 13 | let p = embassy_stm32::init(Default::default()); | 13 | let p = embassy_stm32::init(Default::default()); |
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let _mco1 = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, McoPrescaler::DIV1); | 16 | let config_mco1 = { |
| 17 | let _mco2 = Mco::new(p.MCO2, p.PC9, Mco2Source::PLL, McoPrescaler::DIV4); | 17 | let mut config = McoConfig::default(); |
| 18 | config.prescaler = McoPrescaler::DIV1; | ||
| 19 | config | ||
| 20 | }; | ||
| 21 | |||
| 22 | let config_mco2 = { | ||
| 23 | let mut config = McoConfig::default(); | ||
| 24 | config.prescaler = McoPrescaler::DIV4; | ||
| 25 | config | ||
| 26 | }; | ||
| 27 | |||
| 28 | let _mco1 = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, config_mco1); | ||
| 29 | let _mco2 = Mco::new(p.MCO2, p.PC9, Mco2Source::PLL, config_mco2); | ||
| 18 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); | 30 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); |
| 19 | 31 | ||
| 20 | loop { | 32 | loop { |
diff --git a/examples/stm32f4/src/bin/multiprio.rs b/examples/stm32f4/src/bin/multiprio.rs index b4620888f..8375e0e8e 100644 --- a/examples/stm32f4/src/bin/multiprio.rs +++ b/examples/stm32f4/src/bin/multiprio.rs | |||
| @@ -113,12 +113,12 @@ static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new(); | |||
| 113 | 113 | ||
| 114 | #[interrupt] | 114 | #[interrupt] |
| 115 | unsafe fn UART4() { | 115 | unsafe fn UART4() { |
| 116 | EXECUTOR_HIGH.on_interrupt() | 116 | unsafe { EXECUTOR_HIGH.on_interrupt() } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | #[interrupt] | 119 | #[interrupt] |
| 120 | unsafe fn UART5() { | 120 | unsafe fn UART5() { |
| 121 | EXECUTOR_MED.on_interrupt() | 121 | unsafe { EXECUTOR_MED.on_interrupt() } |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | #[entry] | 124 | #[entry] |
| @@ -135,16 +135,16 @@ fn main() -> ! { | |||
| 135 | // High-priority executor: UART4, priority level 6 | 135 | // High-priority executor: UART4, priority level 6 |
| 136 | interrupt::UART4.set_priority(Priority::P6); | 136 | interrupt::UART4.set_priority(Priority::P6); |
| 137 | let spawner = EXECUTOR_HIGH.start(interrupt::UART4); | 137 | let spawner = EXECUTOR_HIGH.start(interrupt::UART4); |
| 138 | unwrap!(spawner.spawn(run_high())); | 138 | spawner.spawn(unwrap!(run_high())); |
| 139 | 139 | ||
| 140 | // Medium-priority executor: UART5, priority level 7 | 140 | // Medium-priority executor: UART5, priority level 7 |
| 141 | interrupt::UART5.set_priority(Priority::P7); | 141 | interrupt::UART5.set_priority(Priority::P7); |
| 142 | let spawner = EXECUTOR_MED.start(interrupt::UART5); | 142 | let spawner = EXECUTOR_MED.start(interrupt::UART5); |
| 143 | unwrap!(spawner.spawn(run_med())); | 143 | spawner.spawn(unwrap!(run_med())); |
| 144 | 144 | ||
| 145 | // Low priority executor: runs in thread mode, using WFE/SEV | 145 | // Low priority executor: runs in thread mode, using WFE/SEV |
| 146 | let executor = EXECUTOR_LOW.init(Executor::new()); | 146 | let executor = EXECUTOR_LOW.init(Executor::new()); |
| 147 | executor.run(|spawner| { | 147 | executor.run(|spawner| { |
| 148 | unwrap!(spawner.spawn(run_low())); | 148 | spawner.spawn(unwrap!(run_low())); |
| 149 | }); | 149 | }); |
| 150 | } | 150 | } |
diff --git a/examples/stm32f4/src/bin/pwm_complementary.rs b/examples/stm32f4/src/bin/pwm_complementary.rs index c981f1a76..50008a37b 100644 --- a/examples/stm32f4/src/bin/pwm_complementary.rs +++ b/examples/stm32f4/src/bin/pwm_complementary.rs | |||
| @@ -5,9 +5,9 @@ use defmt::*; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::gpio::OutputType; | 6 | use embassy_stm32::gpio::OutputType; |
| 7 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::Channel; | ||
| 8 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; | 9 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; |
| 9 | use embassy_stm32::timer::simple_pwm::PwmPin; | 10 | use embassy_stm32::timer::simple_pwm::PwmPin; |
| 10 | use embassy_stm32::timer::Channel; | ||
| 11 | use embassy_time::Timer; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
diff --git a/examples/stm32f4/src/bin/pwm_input.rs b/examples/stm32f4/src/bin/pwm_input.rs index 74167cbf2..d8ea56a34 100644 --- a/examples/stm32f4/src/bin/pwm_input.rs +++ b/examples/stm32f4/src/bin/pwm_input.rs | |||
| @@ -6,7 +6,7 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; | 6 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 7 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::pwm_input::PwmInput; | 8 | use embassy_stm32::timer::pwm_input::PwmInput; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, timer, Peri}; | 9 | use embassy_stm32::{Peri, bind_interrupts, peripherals, timer}; |
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| @@ -36,7 +36,7 @@ async fn main(spawner: Spawner) { | |||
| 36 | let p = embassy_stm32::init(Default::default()); | 36 | let p = embassy_stm32::init(Default::default()); |
| 37 | info!("Hello World!"); | 37 | info!("Hello World!"); |
| 38 | 38 | ||
| 39 | unwrap!(spawner.spawn(blinky(p.PB2))); | 39 | spawner.spawn(unwrap!(blinky(p.PB2))); |
| 40 | 40 | ||
| 41 | let mut pwm_input = PwmInput::new_ch1(p.TIM3, p.PA6, Pull::None, khz(10)); | 41 | let mut pwm_input = PwmInput::new_ch1(p.TIM3, p.PA6, Pull::None, khz(10)); |
| 42 | pwm_input.enable(); | 42 | pwm_input.enable(); |
diff --git a/examples/stm32f4/src/bin/rtc.rs b/examples/stm32f4/src/bin/rtc.rs index 82d8a37ba..feb27f6d9 100644 --- a/examples/stm32f4/src/bin/rtc.rs +++ b/examples/stm32f4/src/bin/rtc.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use chrono::{NaiveDate, NaiveDateTime}; | 4 | use chrono::{NaiveDate, NaiveDateTime}; |
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | ||
| 8 | use embassy_stm32::Config; | 7 | use embassy_stm32::Config; |
| 8 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | ||
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs index e97b63925..fe0f887bf 100644 --- a/examples/stm32f4/src/bin/sdmmc.rs +++ b/examples/stm32f4/src/bin/sdmmc.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::sdmmc::{DataBlock, Sdmmc}; | 6 | use embassy_stm32::sdmmc::{DataBlock, Sdmmc}; |
| 7 | use embassy_stm32::time::{mhz, Hertz}; | 7 | use embassy_stm32::time::{Hertz, mhz}; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, sdmmc, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, peripherals, sdmmc}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | /// This is a safeguard to not overwrite any data on the SD card. | 11 | /// This is a safeguard to not overwrite any data on the SD card. |
diff --git a/examples/stm32f4/src/bin/usb_ethernet.rs b/examples/stm32f4/src/bin/usb_ethernet.rs index 322cb90c7..a5e625edd 100644 --- a/examples/stm32f4/src/bin/usb_ethernet.rs +++ b/examples/stm32f4/src/bin/usb_ethernet.rs | |||
| @@ -3,12 +3,12 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_net::tcp::TcpSocket; | ||
| 7 | use embassy_net::StackResources; | 6 | use embassy_net::StackResources; |
| 7 | use embassy_net::tcp::TcpSocket; | ||
| 8 | use embassy_stm32::rng::{self, Rng}; | 8 | use embassy_stm32::rng::{self, Rng}; |
| 9 | use embassy_stm32::time::Hertz; | 9 | use embassy_stm32::time::Hertz; |
| 10 | use embassy_stm32::usb::Driver; | 10 | use embassy_stm32::usb::Driver; |
| 11 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 11 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 12 | use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState}; | 12 | use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState}; |
| 13 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | 13 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; |
| 14 | use embassy_usb::{Builder, UsbDevice}; | 14 | use embassy_usb::{Builder, UsbDevice}; |
| @@ -118,11 +118,11 @@ async fn main(spawner: Spawner) { | |||
| 118 | // Build the builder. | 118 | // Build the builder. |
| 119 | let usb = builder.build(); | 119 | let usb = builder.build(); |
| 120 | 120 | ||
| 121 | unwrap!(spawner.spawn(usb_task(usb))); | 121 | spawner.spawn(unwrap!(usb_task(usb))); |
| 122 | 122 | ||
| 123 | static NET_STATE: StaticCell<NetState<MTU, 4, 4>> = StaticCell::new(); | 123 | static NET_STATE: StaticCell<NetState<MTU, 4, 4>> = StaticCell::new(); |
| 124 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(NET_STATE.init(NetState::new()), our_mac_addr); | 124 | let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(NET_STATE.init(NetState::new()), our_mac_addr); |
| 125 | unwrap!(spawner.spawn(usb_ncm_task(runner))); | 125 | spawner.spawn(unwrap!(usb_ncm_task(runner))); |
| 126 | 126 | ||
| 127 | let config = embassy_net::Config::dhcpv4(Default::default()); | 127 | let config = embassy_net::Config::dhcpv4(Default::default()); |
| 128 | //let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { | 128 | //let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { |
| @@ -141,7 +141,7 @@ async fn main(spawner: Spawner) { | |||
| 141 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); | 141 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); |
| 142 | let (stack, runner) = embassy_net::new(device, config, RESOURCES.init(StackResources::new()), seed); | 142 | let (stack, runner) = embassy_net::new(device, config, RESOURCES.init(StackResources::new()), seed); |
| 143 | 143 | ||
| 144 | unwrap!(spawner.spawn(net_task(runner))); | 144 | spawner.spawn(unwrap!(net_task(runner))); |
| 145 | 145 | ||
| 146 | // And now we can use it! | 146 | // And now we can use it! |
| 147 | 147 | ||
diff --git a/examples/stm32f4/src/bin/usb_hid_keyboard.rs b/examples/stm32f4/src/bin/usb_hid_keyboard.rs index d6b4a9bc9..a3afb887c 100644 --- a/examples/stm32f4/src/bin/usb_hid_keyboard.rs +++ b/examples/stm32f4/src/bin/usb_hid_keyboard.rs | |||
| @@ -10,7 +10,7 @@ use embassy_stm32::exti::ExtiInput; | |||
| 10 | use embassy_stm32::gpio::Pull; | 10 | use embassy_stm32::gpio::Pull; |
| 11 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::usb::Driver; | 12 | use embassy_stm32::usb::Driver; |
| 13 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 13 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 14 | use embassy_usb::class::hid::{HidReaderWriter, ReportId, RequestHandler, State}; | 14 | use embassy_usb::class::hid::{HidReaderWriter, ReportId, RequestHandler, State}; |
| 15 | use embassy_usb::control::OutResponse; | 15 | use embassy_usb::control::OutResponse; |
| 16 | use embassy_usb::{Builder, Handler}; | 16 | use embassy_usb::{Builder, Handler}; |
diff --git a/examples/stm32f4/src/bin/usb_hid_mouse.rs b/examples/stm32f4/src/bin/usb_hid_mouse.rs index badb65e98..162a035f2 100644 --- a/examples/stm32f4/src/bin/usb_hid_mouse.rs +++ b/examples/stm32f4/src/bin/usb_hid_mouse.rs | |||
| @@ -6,11 +6,11 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::usb::Driver; | 8 | use embassy_stm32::usb::Driver; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use embassy_usb::Builder; | ||
| 11 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; | 12 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; |
| 12 | use embassy_usb::control::OutResponse; | 13 | use embassy_usb::control::OutResponse; |
| 13 | use embassy_usb::Builder; | ||
| 14 | use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; | 14 | use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
diff --git a/examples/stm32f4/src/bin/usb_raw.rs b/examples/stm32f4/src/bin/usb_raw.rs index bbbcc082b..511f0b281 100644 --- a/examples/stm32f4/src/bin/usb_raw.rs +++ b/examples/stm32f4/src/bin/usb_raw.rs | |||
| @@ -53,7 +53,7 @@ use defmt::*; | |||
| 53 | use embassy_executor::Spawner; | 53 | use embassy_executor::Spawner; |
| 54 | use embassy_stm32::time::Hertz; | 54 | use embassy_stm32::time::Hertz; |
| 55 | use embassy_stm32::usb::Driver; | 55 | use embassy_stm32::usb::Driver; |
| 56 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 56 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 57 | use embassy_usb::control::{InResponse, OutResponse, Recipient, Request, RequestType}; | 57 | use embassy_usb::control::{InResponse, OutResponse, Recipient, Request, RequestType}; |
| 58 | use embassy_usb::msos::{self, windows_version}; | 58 | use embassy_usb::msos::{self, windows_version}; |
| 59 | use embassy_usb::types::InterfaceNumber; | 59 | use embassy_usb::types::InterfaceNumber; |
diff --git a/examples/stm32f4/src/bin/usb_serial.rs b/examples/stm32f4/src/bin/usb_serial.rs index e62b2d8d6..2e81e0a59 100644 --- a/examples/stm32f4/src/bin/usb_serial.rs +++ b/examples/stm32f4/src/bin/usb_serial.rs | |||
| @@ -6,10 +6,10 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::usb::{Driver, Instance}; | 8 | use embassy_stm32::usb::{Driver, Instance}; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 10 | use embassy_usb::Builder; | ||
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 12 | use embassy_usb::Builder; | ||
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32f4/src/bin/usb_uac_speaker.rs b/examples/stm32f4/src/bin/usb_uac_speaker.rs index 654bec498..b92f4531e 100644 --- a/examples/stm32f4/src/bin/usb_uac_speaker.rs +++ b/examples/stm32f4/src/bin/usb_uac_speaker.rs | |||
| @@ -6,9 +6,9 @@ use core::cell::{Cell, RefCell}; | |||
| 6 | use defmt::{panic, *}; | 6 | use defmt::{panic, *}; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::time::Hertz; | 8 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::{bind_interrupts, interrupt, peripherals, timer, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, interrupt, peripherals, timer, usb}; |
| 10 | use embassy_sync::blocking_mutex::raw::{CriticalSectionRawMutex, NoopRawMutex}; | ||
| 11 | use embassy_sync::blocking_mutex::Mutex; | 10 | use embassy_sync::blocking_mutex::Mutex; |
| 11 | use embassy_sync::blocking_mutex::raw::{CriticalSectionRawMutex, NoopRawMutex}; | ||
| 12 | use embassy_sync::signal::Signal; | 12 | use embassy_sync::signal::Signal; |
| 13 | use embassy_sync::zerocopy_channel; | 13 | use embassy_sync::zerocopy_channel; |
| 14 | use embassy_usb::class::uac1; | 14 | use embassy_usb::class::uac1; |
| @@ -375,9 +375,9 @@ async fn main(spawner: Spawner) { | |||
| 375 | } | 375 | } |
| 376 | 376 | ||
| 377 | // Launch USB audio tasks. | 377 | // Launch USB audio tasks. |
| 378 | unwrap!(spawner.spawn(usb_control_task(control_monitor))); | 378 | spawner.spawn(unwrap!(usb_control_task(control_monitor))); |
| 379 | unwrap!(spawner.spawn(usb_streaming_task(stream, sender))); | 379 | spawner.spawn(unwrap!(usb_streaming_task(stream, sender))); |
| 380 | unwrap!(spawner.spawn(usb_feedback_task(feedback))); | 380 | spawner.spawn(unwrap!(usb_feedback_task(feedback))); |
| 381 | unwrap!(spawner.spawn(usb_task(usb_device))); | 381 | spawner.spawn(unwrap!(usb_task(usb_device))); |
| 382 | unwrap!(spawner.spawn(audio_receiver_task(receiver))); | 382 | spawner.spawn(unwrap!(audio_receiver_task(receiver))); |
| 383 | } | 383 | } |
diff --git a/examples/stm32f4/src/bin/ws2812_pwm.rs b/examples/stm32f4/src/bin/ws2812_pwm.rs index 5153e1cfd..ccfd0661e 100644 --- a/examples/stm32f4/src/bin/ws2812_pwm.rs +++ b/examples/stm32f4/src/bin/ws2812_pwm.rs | |||
| @@ -15,9 +15,9 @@ | |||
| 15 | use embassy_executor::Spawner; | 15 | use embassy_executor::Spawner; |
| 16 | use embassy_stm32::gpio::OutputType; | 16 | use embassy_stm32::gpio::OutputType; |
| 17 | use embassy_stm32::time::khz; | 17 | use embassy_stm32::time::khz; |
| 18 | use embassy_stm32::timer::Channel; | ||
| 18 | use embassy_stm32::timer::low_level::CountingMode; | 19 | use embassy_stm32::timer::low_level::CountingMode; |
| 19 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 20 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 20 | use embassy_stm32::timer::Channel; | ||
| 21 | use embassy_time::{Duration, Ticker, Timer}; | 21 | use embassy_time::{Duration, Ticker, Timer}; |
| 22 | use {defmt_rtt as _, panic_probe as _}; | 22 | use {defmt_rtt as _, panic_probe as _}; |
| 23 | 23 | ||
