diff options
| author | Eekle <[email protected]> | 2024-07-02 20:46:05 +0200 |
|---|---|---|
| committer | Eekle <[email protected]> | 2024-07-02 20:46:05 +0200 |
| commit | d3f8905e938eecfe7789841c6232cb34b5f43a20 (patch) | |
| tree | 12e89c9e420e981de135f9aefbb9a942db4217d2 | |
| parent | 67f5b8d974c23854676cff3a6797cf4aaf41a402 (diff) | |
Use crate level PeriMode
| -rw-r--r-- | embassy-stm32/src/tsc/mod.rs | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/embassy-stm32/src/tsc/mod.rs b/embassy-stm32/src/tsc/mod.rs index cd7ae4a53..5cb58e918 100644 --- a/embassy-stm32/src/tsc/mod.rs +++ b/embassy-stm32/src/tsc/mod.rs | |||
| @@ -75,6 +75,7 @@ pub use enums::*; | |||
| 75 | 75 | ||
| 76 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; | 76 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; |
| 77 | use crate::interrupt::typelevel::Interrupt; | 77 | use crate::interrupt::typelevel::Interrupt; |
| 78 | use crate::mode::{Async, Blocking, Mode as PeriMode}; | ||
| 78 | use crate::rcc::{self, RccPeripheral}; | 79 | use crate::rcc::{self, RccPeripheral}; |
| 79 | use crate::{interrupt, peripherals, Peripheral}; | 80 | use crate::{interrupt, peripherals, Peripheral}; |
| 80 | 81 | ||
| @@ -93,23 +94,6 @@ pub enum Error { | |||
| 93 | Test, | 94 | Test, |
| 94 | } | 95 | } |
| 95 | 96 | ||
| 96 | /// Async acquisition API marker | ||
| 97 | pub struct Async; | ||
| 98 | /// Blocking acquisition API marker | ||
| 99 | pub struct Blocking; | ||
| 100 | |||
| 101 | trait SealedDriverKind {} | ||
| 102 | |||
| 103 | impl SealedDriverKind for Async {} | ||
| 104 | impl SealedDriverKind for Blocking {} | ||
| 105 | |||
| 106 | #[allow(private_bounds)] | ||
| 107 | /// Driver variant marker for the TSC peripheral | ||
| 108 | pub trait DriverKind: SealedDriverKind {} | ||
| 109 | |||
| 110 | impl DriverKind for Async {} | ||
| 111 | impl DriverKind for Blocking {} | ||
| 112 | |||
| 113 | /// TSC interrupt handler. | 97 | /// TSC interrupt handler. |
| 114 | pub struct InterruptHandler<T: Instance> { | 98 | pub struct InterruptHandler<T: Instance> { |
| 115 | _phantom: PhantomData<T>, | 99 | _phantom: PhantomData<T>, |
| @@ -522,7 +506,7 @@ pub enum G7 {} | |||
| 522 | pub enum G8 {} | 506 | pub enum G8 {} |
| 523 | 507 | ||
| 524 | /// TSC driver | 508 | /// TSC driver |
| 525 | pub struct Tsc<'d, T: Instance, K: DriverKind> { | 509 | pub struct Tsc<'d, T: Instance, K: PeriMode> { |
| 526 | _peri: PeripheralRef<'d, T>, | 510 | _peri: PeripheralRef<'d, T>, |
| 527 | _g1: Option<PinGroup<'d, T, G1>>, | 511 | _g1: Option<PinGroup<'d, T, G1>>, |
| 528 | _g2: Option<PinGroup<'d, T, G2>>, | 512 | _g2: Option<PinGroup<'d, T, G2>>, |
| @@ -703,7 +687,7 @@ impl<'d, T: Instance> Tsc<'d, T, Blocking> { | |||
| 703 | } | 687 | } |
| 704 | } | 688 | } |
| 705 | 689 | ||
| 706 | impl<'d, T: Instance, K: DriverKind> Tsc<'d, T, K> { | 690 | impl<'d, T: Instance, K: PeriMode> Tsc<'d, T, K> { |
| 707 | /// Create new TSC driver | 691 | /// Create new TSC driver |
| 708 | fn check_shields( | 692 | fn check_shields( |
| 709 | g1: &Option<PinGroup<'d, T, G1>>, | 693 | g1: &Option<PinGroup<'d, T, G1>>, |
| @@ -969,7 +953,7 @@ impl<'d, T: Instance, K: DriverKind> Tsc<'d, T, K> { | |||
| 969 | } | 953 | } |
| 970 | } | 954 | } |
| 971 | 955 | ||
| 972 | impl<'d, T: Instance, K: DriverKind> Drop for Tsc<'d, T, K> { | 956 | impl<'d, T: Instance, K: PeriMode> Drop for Tsc<'d, T, K> { |
| 973 | fn drop(&mut self) { | 957 | fn drop(&mut self) { |
| 974 | rcc::disable::<T>(); | 958 | rcc::disable::<T>(); |
| 975 | } | 959 | } |
