From 8a9d2f59af004902d3978a2922843833b98bcce0 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sat, 23 Jul 2022 01:29:35 +0200 Subject: Update embassy-stm32 --- examples/stm32f4/src/bin/sdmmc.rs | 11 ++++++++--- examples/stm32f7/src/bin/sdmmc.rs | 11 ++++++++--- examples/stm32h7/src/bin/low_level_timer_api.rs | 12 +++--------- examples/stm32h7/src/bin/sdmmc.rs | 9 +++++++-- 4 files changed, 26 insertions(+), 17 deletions(-) (limited to 'examples') diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs index 665670261..752ad57bf 100644 --- a/examples/stm32f4/src/bin/sdmmc.rs +++ b/examples/stm32f4/src/bin/sdmmc.rs @@ -21,12 +21,17 @@ async fn main(_spawner: Spawner, p: Peripherals) -> ! { let irq = interrupt::take!(SDIO); - let mut sdmmc = Sdmmc::new( + let mut sdmmc = Sdmmc::new_4bit( p.SDIO, - (p.PC12, p.PD2, p.PC8, p.PC9, p.PC10, p.PC11), irq, - Default::default(), p.DMA2_CH3, + p.PC12, + p.PD2, + p.PC8, + p.PC9, + p.PC10, + p.PC11, + Default::default(), ); // Should print 400kHz for initialization diff --git a/examples/stm32f7/src/bin/sdmmc.rs b/examples/stm32f7/src/bin/sdmmc.rs index 011e1fd95..be1c2b152 100644 --- a/examples/stm32f7/src/bin/sdmmc.rs +++ b/examples/stm32f7/src/bin/sdmmc.rs @@ -21,12 +21,17 @@ async fn main(_spawner: Spawner, p: Peripherals) -> ! { let irq = interrupt::take!(SDMMC1); - let mut sdmmc = Sdmmc::new( + let mut sdmmc = Sdmmc::new_4bit( p.SDMMC1, - (p.PC12, p.PD2, p.PC8, p.PC9, p.PC10, p.PC11), irq, - Default::default(), p.DMA2_CH3, + p.PC12, + p.PD2, + p.PC8, + p.PC9, + p.PC10, + p.PC11, + Default::default(), ); // Should print 400kHz for initialization diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index fc19d84e4..e54f1bb67 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs @@ -2,8 +2,6 @@ #![no_main] #![feature(type_alias_impl_trait)] -use core::marker::PhantomData; - use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; @@ -11,7 +9,7 @@ use embassy_stm32::gpio::low_level::AFType; use embassy_stm32::gpio::Speed; use embassy_stm32::pwm::*; use embassy_stm32::time::{khz, mhz, Hertz}; -use embassy_stm32::{unborrow, Config, Peripherals, Unborrow}; +use embassy_stm32::{unborrow, Config, Peripherals, Unborrow, Unborrowed}; use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { @@ -49,8 +47,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { } } pub struct SimplePwm32<'d, T: CaptureCompare32bitInstance> { - phantom: PhantomData<&'d mut T>, - inner: T, + inner: Unborrowed<'d, T>, } impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> { @@ -78,10 +75,7 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> { ch4.set_as_af(ch1.af_num(), AFType::OutputPushPull); } - let mut this = Self { - inner: tim, - phantom: PhantomData, - }; + let mut this = Self { inner: tim }; this.set_freq(freq); this.inner.start(); diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs index 787f700ae..163807d86 100644 --- a/examples/stm32h7/src/bin/sdmmc.rs +++ b/examples/stm32h7/src/bin/sdmmc.rs @@ -21,10 +21,15 @@ async fn main(_spawner: Spawner, p: Peripherals) -> ! { let irq = interrupt::take!(SDMMC1); - let mut sdmmc = Sdmmc::new( + let mut sdmmc = Sdmmc::new_4bit( p.SDMMC1, - (p.PC12, p.PD2, p.PC8, p.PC9, p.PC10, p.PC11), irq, + p.PC12, + p.PD2, + p.PC8, + p.PC9, + p.PC10, + p.PC11, Default::default(), ); -- cgit From 4901c34d9c4cd326ab9bca02dd099a663da2567f Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sat, 23 Jul 2022 14:00:19 +0200 Subject: Rename Unborrowed -> PeripheralRef, Unborrow -> Peripheral --- examples/stm32h7/src/bin/low_level_timer_api.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index e54f1bb67..d7c6da5bd 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs @@ -9,7 +9,7 @@ use embassy_stm32::gpio::low_level::AFType; use embassy_stm32::gpio::Speed; use embassy_stm32::pwm::*; use embassy_stm32::time::{khz, mhz, Hertz}; -use embassy_stm32::{unborrow, Config, Peripherals, Unborrow, Unborrowed}; +use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef, Peripherals}; use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { @@ -47,19 +47,19 @@ async fn main(_spawner: Spawner, p: Peripherals) { } } pub struct SimplePwm32<'d, T: CaptureCompare32bitInstance> { - inner: Unborrowed<'d, T>, + inner: PeripheralRef<'d, T>, } impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> { pub fn new( - tim: impl Unborrow + 'd, - ch1: impl Unborrow> + 'd, - ch2: impl Unborrow> + 'd, - ch3: impl Unborrow> + 'd, - ch4: impl Unborrow> + 'd, + tim: impl Peripheral

+ 'd, + ch1: impl Peripheral

> + 'd, + ch2: impl Peripheral

> + 'd, + ch3: impl Peripheral

> + 'd, + ch4: impl Peripheral

> + 'd, freq: Hertz, ) -> Self { - unborrow!(tim, ch1, ch2, ch3, ch4); + into_ref!(tim, ch1, ch2, ch3, ch4); T::enable(); ::reset(); -- cgit