aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32f4
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-03-26 16:01:37 +0100
committerDario Nieuwenhuis <[email protected]>2025-03-27 15:18:06 +0100
commitd41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch)
tree678b6fc732216e529dc38e6f65b72a309917ac32 /examples/stm32f4
parent9edf5b7f049f95742b60b041e4443967d8a6b708 (diff)
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'examples/stm32f4')
-rw-r--r--examples/stm32f4/src/bin/can.rs2
-rw-r--r--examples/stm32f4/src/bin/flash_async.rs8
-rw-r--r--examples/stm32f4/src/bin/input_capture.rs4
-rw-r--r--examples/stm32f4/src/bin/pwm_input.rs4
-rw-r--r--examples/stm32f4/src/bin/ws2812_pwm.rs2
5 files changed, 10 insertions, 10 deletions
diff --git a/examples/stm32f4/src/bin/can.rs b/examples/stm32f4/src/bin/can.rs
index 8e3beee24..fd90e0d6d 100644
--- a/examples/stm32f4/src/bin/can.rs
+++ b/examples/stm32f4/src/bin/can.rs
@@ -30,7 +30,7 @@ async fn main(_spawner: Spawner) {
30 // To synchronise to the bus the RX input needs to see a high level. 30 // To synchronise to the bus the RX input needs to see a high level.
31 // Use `mem::forget()` to release the borrow on the pin but keep the 31 // Use `mem::forget()` to release the borrow on the pin but keep the
32 // pull-up resistor enabled. 32 // pull-up resistor enabled.
33 let rx_pin = Input::new(&mut p.PA11, Pull::Up); 33 let rx_pin = Input::new(p.PA11.reborrow(), Pull::Up);
34 core::mem::forget(rx_pin); 34 core::mem::forget(rx_pin);
35 35
36 let mut can = Can::new(p.CAN1, p.PA11, p.PA12, Irqs); 36 let mut can = Can::new(p.CAN1, p.PA11, p.PA12, Irqs);
diff --git a/examples/stm32f4/src/bin/flash_async.rs b/examples/stm32f4/src/bin/flash_async.rs
index 493a536f3..755713542 100644
--- a/examples/stm32f4/src/bin/flash_async.rs
+++ b/examples/stm32f4/src/bin/flash_async.rs
@@ -3,9 +3,9 @@
3 3
4use defmt::{info, unwrap}; 4use defmt::{info, unwrap};
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_stm32::bind_interrupts;
7use embassy_stm32::flash::{Flash, InterruptHandler}; 6use embassy_stm32::flash::{Flash, InterruptHandler};
8use embassy_stm32::gpio::{AnyPin, Level, Output, Pin, Speed}; 7use embassy_stm32::gpio::{AnyPin, Level, Output, Speed};
8use embassy_stm32::{bind_interrupts, Peri};
9use embassy_time::Timer; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
@@ -21,14 +21,14 @@ 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.degrade())).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;
28} 28}
29 29
30#[embassy_executor::task] 30#[embassy_executor::task]
31async fn blinky(p: AnyPin) { 31async fn blinky(p: Peri<'static, AnyPin>) {
32 let mut led = Output::new(p, Level::High, Speed::Low); 32 let mut led = Output::new(p, Level::High, Speed::Low);
33 33
34 loop { 34 loop {
diff --git a/examples/stm32f4/src/bin/input_capture.rs b/examples/stm32f4/src/bin/input_capture.rs
index 49de33d2b..fe5e2bdfc 100644
--- a/examples/stm32f4/src/bin/input_capture.rs
+++ b/examples/stm32f4/src/bin/input_capture.rs
@@ -7,14 +7,14 @@ use embassy_stm32::gpio::{Level, Output, Pull, Speed};
7use embassy_stm32::time::khz; 7use embassy_stm32::time::khz;
8use embassy_stm32::timer::input_capture::{CapturePin, InputCapture}; 8use embassy_stm32::timer::input_capture::{CapturePin, InputCapture};
9use embassy_stm32::timer::{self, Channel}; 9use embassy_stm32::timer::{self, Channel};
10use embassy_stm32::{bind_interrupts, peripherals}; 10use embassy_stm32::{bind_interrupts, peripherals, Peri};
11use embassy_time::Timer; 11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _}; 12use {defmt_rtt as _, panic_probe as _};
13 13
14/// Connect PB2 and PB10 with a 1k Ohm resistor 14/// Connect PB2 and PB10 with a 1k Ohm resistor
15 15
16#[embassy_executor::task] 16#[embassy_executor::task]
17async fn blinky(led: peripherals::PB2) { 17async fn blinky(led: Peri<'static, peripherals::PB2>) {
18 let mut led = Output::new(led, Level::High, Speed::Low); 18 let mut led = Output::new(led, Level::High, Speed::Low);
19 19
20 loop { 20 loop {
diff --git a/examples/stm32f4/src/bin/pwm_input.rs b/examples/stm32f4/src/bin/pwm_input.rs
index ce200549d..465cbe4f5 100644
--- a/examples/stm32f4/src/bin/pwm_input.rs
+++ b/examples/stm32f4/src/bin/pwm_input.rs
@@ -6,14 +6,14 @@ use embassy_executor::Spawner;
6use embassy_stm32::gpio::{Level, Output, Pull, Speed}; 6use embassy_stm32::gpio::{Level, Output, Pull, Speed};
7use embassy_stm32::time::khz; 7use embassy_stm32::time::khz;
8use embassy_stm32::timer::pwm_input::PwmInput; 8use embassy_stm32::timer::pwm_input::PwmInput;
9use embassy_stm32::{bind_interrupts, peripherals, timer}; 9use embassy_stm32::{bind_interrupts, peripherals, timer, Peri};
10use embassy_time::Timer; 10use embassy_time::Timer;
11use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
12 12
13/// Connect PB2 and PA6 with a 1k Ohm resistor 13/// Connect PB2 and PA6 with a 1k Ohm resistor
14 14
15#[embassy_executor::task] 15#[embassy_executor::task]
16async fn blinky(led: peripherals::PB2) { 16async fn blinky(led: Peri<'static, peripherals::PB2>) {
17 let mut led = Output::new(led, Level::High, Speed::Low); 17 let mut led = Output::new(led, Level::High, Speed::Low);
18 18
19 loop { 19 loop {
diff --git a/examples/stm32f4/src/bin/ws2812_pwm.rs b/examples/stm32f4/src/bin/ws2812_pwm.rs
index 3ab93d6e0..ca924e181 100644
--- a/examples/stm32f4/src/bin/ws2812_pwm.rs
+++ b/examples/stm32f4/src/bin/ws2812_pwm.rs
@@ -92,7 +92,7 @@ async fn main(_spawner: Spawner) {
92 loop { 92 loop {
93 for &color in color_list { 93 for &color in color_list {
94 // with &mut, we can easily reuse same DMA channel multiple times 94 // with &mut, we can easily reuse same DMA channel multiple times
95 ws2812_pwm.waveform_up(&mut dp.DMA1_CH2, pwm_channel, color).await; 95 ws2812_pwm.waveform_up(dp.DMA1_CH2.reborrow(), pwm_channel, color).await;
96 // ws2812 need at least 50 us low level input to confirm the input data and change it's state 96 // ws2812 need at least 50 us low level input to confirm the input data and change it's state
97 Timer::after_micros(50).await; 97 Timer::after_micros(50).await;
98 // wait until ticker tick 98 // wait until ticker tick