diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-03-26 16:01:37 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-03-27 15:18:06 +0100 |
| commit | d41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch) | |
| tree | 678b6fc732216e529dc38e6f65b72a309917ac32 /embassy-stm32/src/tsc | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-stm32/src/tsc')
| -rw-r--r-- | embassy-stm32/src/tsc/mod.rs | 5 | ||||
| -rw-r--r-- | embassy-stm32/src/tsc/pin_groups.rs | 14 | ||||
| -rw-r--r-- | embassy-stm32/src/tsc/tsc.rs | 22 |
3 files changed, 13 insertions, 28 deletions
diff --git a/embassy-stm32/src/tsc/mod.rs b/embassy-stm32/src/tsc/mod.rs index 0d5c27465..9359d83e9 100644 --- a/embassy-stm32/src/tsc/mod.rs +++ b/embassy-stm32/src/tsc/mod.rs | |||
| @@ -98,6 +98,7 @@ use core::marker::PhantomData; | |||
| 98 | 98 | ||
| 99 | pub use acquisition_banks::*; | 99 | pub use acquisition_banks::*; |
| 100 | pub use config::*; | 100 | pub use config::*; |
| 101 | use embassy_hal_internal::PeripheralType; | ||
| 101 | use embassy_sync::waitqueue::AtomicWaker; | 102 | use embassy_sync::waitqueue::AtomicWaker; |
| 102 | pub use errors::*; | 103 | pub use errors::*; |
| 103 | pub use io_pin::*; | 104 | pub use io_pin::*; |
| @@ -106,7 +107,7 @@ pub use tsc::*; | |||
| 106 | pub use types::*; | 107 | pub use types::*; |
| 107 | 108 | ||
| 108 | use crate::rcc::RccPeripheral; | 109 | use crate::rcc::RccPeripheral; |
| 109 | use crate::{interrupt, peripherals, Peripheral}; | 110 | use crate::{interrupt, peripherals}; |
| 110 | 111 | ||
| 111 | #[cfg(tsc_v1)] | 112 | #[cfg(tsc_v1)] |
| 112 | const TSC_NUM_GROUPS: usize = 6; | 113 | const TSC_NUM_GROUPS: usize = 6; |
| @@ -142,7 +143,7 @@ pub(crate) trait SealedInstance { | |||
| 142 | 143 | ||
| 143 | /// TSC instance trait | 144 | /// TSC instance trait |
| 144 | #[allow(private_bounds)] | 145 | #[allow(private_bounds)] |
| 145 | pub trait Instance: Peripheral<P = Self> + SealedInstance + RccPeripheral { | 146 | pub trait Instance: SealedInstance + PeripheralType + RccPeripheral { |
| 146 | /// Interrupt for this TSC instance | 147 | /// Interrupt for this TSC instance |
| 147 | type Interrupt: interrupt::typelevel::Interrupt; | 148 | type Interrupt: interrupt::typelevel::Interrupt; |
| 148 | } | 149 | } |
diff --git a/embassy-stm32/src/tsc/pin_groups.rs b/embassy-stm32/src/tsc/pin_groups.rs index 1f3aafa35..6f914a94e 100644 --- a/embassy-stm32/src/tsc/pin_groups.rs +++ b/embassy-stm32/src/tsc/pin_groups.rs | |||
| @@ -1,13 +1,11 @@ | |||
| 1 | use core::marker::PhantomData; | 1 | use core::marker::PhantomData; |
| 2 | use core::ops::BitOr; | 2 | use core::ops::BitOr; |
| 3 | 3 | ||
| 4 | use embassy_hal_internal::{into_ref, PeripheralRef}; | ||
| 5 | |||
| 6 | use super::errors::GroupError; | 4 | use super::errors::GroupError; |
| 7 | use super::io_pin::*; | 5 | use super::io_pin::*; |
| 8 | use super::Instance; | 6 | use super::Instance; |
| 9 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; | 7 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; |
| 10 | use crate::Peripheral; | 8 | use crate::Peri; |
| 11 | 9 | ||
| 12 | /// Pin type definition to control IO parameters | 10 | /// Pin type definition to control IO parameters |
| 13 | #[derive(PartialEq, Clone, Copy)] | 11 | #[derive(PartialEq, Clone, Copy)] |
| @@ -23,7 +21,7 @@ pub enum PinType { | |||
| 23 | /// Pin struct that maintains usage | 21 | /// Pin struct that maintains usage |
| 24 | #[allow(missing_docs)] | 22 | #[allow(missing_docs)] |
| 25 | pub struct Pin<'d, T, Group> { | 23 | pub struct Pin<'d, T, Group> { |
| 26 | _pin: PeripheralRef<'d, AnyPin>, | 24 | _pin: Peri<'d, AnyPin>, |
| 27 | role: PinType, | 25 | role: PinType, |
| 28 | tsc_io_pin: IOPin, | 26 | tsc_io_pin: IOPin, |
| 29 | phantom: PhantomData<(T, Group)>, | 27 | phantom: PhantomData<(T, Group)>, |
| @@ -426,17 +424,13 @@ macro_rules! trait_to_io_pin { | |||
| 426 | macro_rules! impl_set_io { | 424 | macro_rules! impl_set_io { |
| 427 | ($method:ident, $group:ident, $trait:ident, $index:expr) => { | 425 | ($method:ident, $group:ident, $trait:ident, $index:expr) => { |
| 428 | #[doc = concat!("Create a new pin1 for ", stringify!($group), " TSC group instance.")] | 426 | #[doc = concat!("Create a new pin1 for ", stringify!($group), " TSC group instance.")] |
| 429 | pub fn $method<Role: pin_roles::Role>( | 427 | pub fn $method<Role: pin_roles::Role>(&mut self, pin: Peri<'d, impl $trait<T>>) -> IOPinWithRole<$group, Role> { |
| 430 | &mut self, | ||
| 431 | pin: impl Peripheral<P = impl $trait<T>> + 'd, | ||
| 432 | ) -> IOPinWithRole<$group, Role> { | ||
| 433 | into_ref!(pin); | ||
| 434 | critical_section::with(|_| { | 428 | critical_section::with(|_| { |
| 435 | pin.set_low(); | 429 | pin.set_low(); |
| 436 | pin.set_as_af(pin.af_num(), AfType::output(Role::output_type(), Speed::VeryHigh)); | 430 | pin.set_as_af(pin.af_num(), AfType::output(Role::output_type(), Speed::VeryHigh)); |
| 437 | let tsc_io_pin = trait_to_io_pin!($trait); | 431 | let tsc_io_pin = trait_to_io_pin!($trait); |
| 438 | let new_pin = Pin { | 432 | let new_pin = Pin { |
| 439 | _pin: pin.map_into(), | 433 | _pin: pin.into(), |
| 440 | role: Role::pin_type(), | 434 | role: Role::pin_type(), |
| 441 | tsc_io_pin, | 435 | tsc_io_pin, |
| 442 | phantom: PhantomData, | 436 | phantom: PhantomData, |
diff --git a/embassy-stm32/src/tsc/tsc.rs b/embassy-stm32/src/tsc/tsc.rs index 17d2da82f..e92479c26 100644 --- a/embassy-stm32/src/tsc/tsc.rs +++ b/embassy-stm32/src/tsc/tsc.rs | |||
| @@ -3,7 +3,7 @@ use core::marker::PhantomData; | |||
| 3 | use core::ops::BitOr; | 3 | use core::ops::BitOr; |
| 4 | use core::task::Poll; | 4 | use core::task::Poll; |
| 5 | 5 | ||
| 6 | use embassy_hal_internal::{into_ref, PeripheralRef}; | 6 | use embassy_hal_internal::Peri; |
| 7 | 7 | ||
| 8 | use super::acquisition_banks::*; | 8 | use super::acquisition_banks::*; |
| 9 | use super::config::*; | 9 | use super::config::*; |
| @@ -14,7 +14,7 @@ use super::types::*; | |||
| 14 | use super::{Instance, InterruptHandler, TSC_NUM_GROUPS}; | 14 | use super::{Instance, InterruptHandler, TSC_NUM_GROUPS}; |
| 15 | use crate::interrupt::typelevel::Interrupt; | 15 | use crate::interrupt::typelevel::Interrupt; |
| 16 | use crate::mode::{Async, Blocking, Mode as PeriMode}; | 16 | use crate::mode::{Async, Blocking, Mode as PeriMode}; |
| 17 | use crate::{interrupt, rcc, Peripheral}; | 17 | use crate::{interrupt, rcc}; |
| 18 | 18 | ||
| 19 | /// Internal structure holding masks for different types of TSC IOs. | 19 | /// Internal structure holding masks for different types of TSC IOs. |
| 20 | /// | 20 | /// |
| @@ -31,7 +31,7 @@ struct IOMasks { | |||
| 31 | 31 | ||
| 32 | /// TSC driver | 32 | /// TSC driver |
| 33 | pub struct Tsc<'d, T: Instance, K: PeriMode> { | 33 | pub struct Tsc<'d, T: Instance, K: PeriMode> { |
| 34 | _peri: PeripheralRef<'d, T>, | 34 | _peri: Peri<'d, T>, |
| 35 | _pin_groups: PinGroups<'d, T>, | 35 | _pin_groups: PinGroups<'d, T>, |
| 36 | state: State, | 36 | state: State, |
| 37 | config: Config, | 37 | config: Config, |
| @@ -218,13 +218,7 @@ impl<'d, T: Instance, K: PeriMode> Tsc<'d, T, K> { | |||
| 218 | groups | 218 | groups |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | fn new_inner( | 221 | fn new_inner(peri: Peri<'d, T>, pin_groups: PinGroups<'d, T>, config: Config) -> Result<Self, GroupError> { |
| 222 | peri: impl Peripheral<P = T> + 'd, | ||
| 223 | pin_groups: PinGroups<'d, T>, | ||
| 224 | config: Config, | ||
| 225 | ) -> Result<Self, GroupError> { | ||
| 226 | into_ref!(peri); | ||
| 227 | |||
| 228 | pin_groups.check()?; | 222 | pin_groups.check()?; |
| 229 | 223 | ||
| 230 | let masks = IOMasks { | 224 | let masks = IOMasks { |
| @@ -410,7 +404,7 @@ impl<'d, T: Instance, K: PeriMode> Drop for Tsc<'d, T, K> { | |||
| 410 | impl<'d, T: Instance> Tsc<'d, T, Async> { | 404 | impl<'d, T: Instance> Tsc<'d, T, Async> { |
| 411 | /// Create a Tsc instance that can be awaited for completion | 405 | /// Create a Tsc instance that can be awaited for completion |
| 412 | pub fn new_async( | 406 | pub fn new_async( |
| 413 | peri: impl Peripheral<P = T> + 'd, | 407 | peri: Peri<'d, T>, |
| 414 | pin_groups: PinGroups<'d, T>, | 408 | pin_groups: PinGroups<'d, T>, |
| 415 | config: Config, | 409 | config: Config, |
| 416 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 410 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| @@ -441,11 +435,7 @@ impl<'d, T: Instance> Tsc<'d, T, Async> { | |||
| 441 | 435 | ||
| 442 | impl<'d, T: Instance> Tsc<'d, T, Blocking> { | 436 | impl<'d, T: Instance> Tsc<'d, T, Blocking> { |
| 443 | /// Create a Tsc instance that must be polled for completion | 437 | /// Create a Tsc instance that must be polled for completion |
| 444 | pub fn new_blocking( | 438 | pub fn new_blocking(peri: Peri<'d, T>, pin_groups: PinGroups<'d, T>, config: Config) -> Result<Self, GroupError> { |
| 445 | peri: impl Peripheral<P = T> + 'd, | ||
| 446 | pin_groups: PinGroups<'d, T>, | ||
| 447 | config: Config, | ||
| 448 | ) -> Result<Self, GroupError> { | ||
| 449 | Self::new_inner(peri, pin_groups, config) | 439 | Self::new_inner(peri, pin_groups, config) |
| 450 | } | 440 | } |
| 451 | 441 | ||
