Remove Peripheral trait, rename PeripheralRef->Peri.

This commit is contained in:
Dario Nieuwenhuis
2025-03-26 16:01:37 +01:00
parent 9edf5b7f04
commit d41eeeae79
225 changed files with 2645 additions and 3215 deletions

View File

@@ -30,7 +30,7 @@ async fn main(_spawner: Spawner) {
// To synchronise to the bus the RX input needs to see a high level.
// Use `mem::forget()` to release the borrow on the pin but keep the
// pull-up resistor enabled.
let rx_pin = Input::new(&mut p.PA11, Pull::Up);
let rx_pin = Input::new(p.PA11.reborrow(), Pull::Up);
core::mem::forget(rx_pin);
let mut can = Can::new(p.CAN1, p.PA11, p.PA12, Irqs);

View File

@@ -3,9 +3,9 @@
use defmt::{info, unwrap};
use embassy_executor::Spawner;
use embassy_stm32::bind_interrupts;
use embassy_stm32::flash::{Flash, InterruptHandler};
use embassy_stm32::gpio::{AnyPin, Level, Output, Pin, Speed};
use embassy_stm32::gpio::{AnyPin, Level, Output, Speed};
use embassy_stm32::{bind_interrupts, Peri};
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};
@@ -21,14 +21,14 @@ async fn main(spawner: Spawner) {
let mut f = Flash::new(p.FLASH, Irqs);
// Led should blink uninterrupted during ~2sec erase operation
spawner.spawn(blinky(p.PB7.degrade())).unwrap();
spawner.spawn(blinky(p.PB7.into())).unwrap();
// Test on bank 2 in order not to stall CPU.
test_flash(&mut f, 1024 * 1024, 128 * 1024).await;
}
#[embassy_executor::task]
async fn blinky(p: AnyPin) {
async fn blinky(p: Peri<'static, AnyPin>) {
let mut led = Output::new(p, Level::High, Speed::Low);
loop {

View File

@@ -7,14 +7,14 @@ use embassy_stm32::gpio::{Level, Output, Pull, Speed};
use embassy_stm32::time::khz;
use embassy_stm32::timer::input_capture::{CapturePin, InputCapture};
use embassy_stm32::timer::{self, Channel};
use embassy_stm32::{bind_interrupts, peripherals};
use embassy_stm32::{bind_interrupts, peripherals, Peri};
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};
/// Connect PB2 and PB10 with a 1k Ohm resistor
#[embassy_executor::task]
async fn blinky(led: peripherals::PB2) {
async fn blinky(led: Peri<'static, peripherals::PB2>) {
let mut led = Output::new(led, Level::High, Speed::Low);
loop {

View File

@@ -6,14 +6,14 @@ use embassy_executor::Spawner;
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
use embassy_stm32::time::khz;
use embassy_stm32::timer::pwm_input::PwmInput;
use embassy_stm32::{bind_interrupts, peripherals, timer};
use embassy_stm32::{bind_interrupts, peripherals, timer, Peri};
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};
/// Connect PB2 and PA6 with a 1k Ohm resistor
#[embassy_executor::task]
async fn blinky(led: peripherals::PB2) {
async fn blinky(led: Peri<'static, peripherals::PB2>) {
let mut led = Output::new(led, Level::High, Speed::Low);
loop {

View File

@@ -92,7 +92,7 @@ async fn main(_spawner: Spawner) {
loop {
for &color in color_list {
// with &mut, we can easily reuse same DMA channel multiple times
ws2812_pwm.waveform_up(&mut dp.DMA1_CH2, pwm_channel, color).await;
ws2812_pwm.waveform_up(dp.DMA1_CH2.reborrow(), pwm_channel, color).await;
// ws2812 need at least 50 us low level input to confirm the input data and change it's state
Timer::after_micros(50).await;
// wait until ticker tick