From b99ab3d5d9d8fdee135956dcbc2111b00abd1d72 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 10 Feb 2022 21:38:03 +0100 Subject: stm32: Add standard crate-wide macros for pin/dma traits, switch all drivers to use them. --- examples/stm32f7/src/bin/eth.rs | 7 ++++--- examples/stm32h7/src/bin/eth.rs | 7 ++++--- examples/stm32h7/src/bin/low_level_timer_api.rs | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 14 deletions(-) (limited to 'examples') diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index 521b031e3..15169d2dc 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs @@ -4,6 +4,7 @@ #[path = "../example_common.rs"] mod example_common; +use embassy_stm32::peripherals::ETH; use example_common::config; use cortex_m_rt::entry; @@ -27,7 +28,7 @@ use peripherals::RNG; #[embassy::task] async fn main_task( - device: &'static mut Ethernet<'static, LAN8742A, 4, 4>, + device: &'static mut Ethernet<'static, ETH, LAN8742A, 4, 4>, config: &'static mut StaticConfigurator, spawner: Spawner, ) { @@ -82,8 +83,8 @@ fn _embassy_rand(buf: &mut [u8]) { static mut RNG_INST: Option> = None; static EXECUTOR: Forever = Forever::new(); -static STATE: Forever> = Forever::new(); -static ETH: Forever> = Forever::new(); +static STATE: Forever> = Forever::new(); +static ETH: Forever> = Forever::new(); static CONFIG: Forever = Forever::new(); static NET_RESOURCES: Forever> = Forever::new(); diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 9998bc4e9..47d8c5c56 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs @@ -4,6 +4,7 @@ #[path = "../example_common.rs"] mod example_common; +use embassy_stm32::peripherals::ETH; use example_common::config; use cortex_m_rt::entry; @@ -26,7 +27,7 @@ use peripherals::RNG; #[embassy::task] async fn main_task( - device: &'static mut Ethernet<'static, LAN8742A, 4, 4>, + device: &'static mut Ethernet<'static, ETH, LAN8742A, 4, 4>, config: &'static mut StaticConfigurator, spawner: Spawner, ) { @@ -81,8 +82,8 @@ fn _embassy_rand(buf: &mut [u8]) { static mut RNG_INST: Option> = None; static EXECUTOR: Forever = Forever::new(); -static STATE: Forever> = Forever::new(); -static ETH: Forever> = Forever::new(); +static STATE: Forever> = Forever::new(); +static ETH: Forever> = Forever::new(); static CONFIG: Forever = Forever::new(); static NET_RESOURCES: Forever> = Forever::new(); diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index 1bf69104d..0c99b0941 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs @@ -10,9 +10,10 @@ use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy::util::Unborrow; use embassy_hal_common::unborrow; -use embassy_stm32::pwm::{pins::*, Channel, OutputCompareMode}; +use embassy_stm32::gpio::low_level::AFType; +use embassy_stm32::gpio::Speed; +use embassy_stm32::pwm::*; use embassy_stm32::time::{Hertz, U32Ext}; -use embassy_stm32::timer::GeneralPurpose32bitInstance; use embassy_stm32::{Config, Peripherals}; use example_common::*; @@ -50,12 +51,12 @@ async fn main(_spawner: Spawner, p: Peripherals) { Timer::after(Duration::from_millis(300)).await; } } -pub struct SimplePwm32<'d, T: GeneralPurpose32bitInstance> { +pub struct SimplePwm32<'d, T: CaptureCompare32bitInstance> { phantom: PhantomData<&'d mut T>, inner: T, } -impl<'d, T: GeneralPurpose32bitInstance> SimplePwm32<'d, T> { +impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> { pub fn new>( tim: impl Unborrow + 'd, ch1: impl Unborrow> + 'd, @@ -70,10 +71,14 @@ impl<'d, T: GeneralPurpose32bitInstance> SimplePwm32<'d, T> { ::reset(); unsafe { - ch1.configure(); - ch2.configure(); - ch3.configure(); - ch4.configure(); + ch1.set_speed(Speed::VeryHigh); + ch1.set_as_af(ch1.af_num(), AFType::OutputPushPull); + ch2.set_speed(Speed::VeryHigh); + ch2.set_as_af(ch1.af_num(), AFType::OutputPushPull); + ch3.set_speed(Speed::VeryHigh); + ch3.set_as_af(ch1.af_num(), AFType::OutputPushPull); + ch4.set_speed(Speed::VeryHigh); + ch4.set_as_af(ch1.af_num(), AFType::OutputPushPull); } let mut this = Self { -- cgit