aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/qspi
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-03-26 16:01:37 +0100
committerDario Nieuwenhuis <[email protected]>2025-03-27 15:18:06 +0100
commitd41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch)
tree678b6fc732216e529dc38e6f65b72a309917ac32 /embassy-stm32/src/qspi
parent9edf5b7f049f95742b60b041e4443967d8a6b708 (diff)
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-stm32/src/qspi')
-rw-r--r--embassy-stm32/src/qspi/mod.rs96
1 files changed, 47 insertions, 49 deletions
diff --git a/embassy-stm32/src/qspi/mod.rs b/embassy-stm32/src/qspi/mod.rs
index 411e533c9..0df057c53 100644
--- a/embassy-stm32/src/qspi/mod.rs
+++ b/embassy-stm32/src/qspi/mod.rs
@@ -6,7 +6,7 @@ pub mod enums;
6 6
7use core::marker::PhantomData; 7use core::marker::PhantomData;
8 8
9use embassy_hal_internal::{into_ref, PeripheralRef}; 9use embassy_hal_internal::PeripheralType;
10use enums::*; 10use enums::*;
11 11
12use crate::dma::ChannelAndRequest; 12use crate::dma::ChannelAndRequest;
@@ -14,7 +14,7 @@ use crate::gpio::{AfType, AnyPin, OutputType, Pull, Speed};
14use crate::mode::{Async, Blocking, Mode as PeriMode}; 14use crate::mode::{Async, Blocking, Mode as PeriMode};
15use crate::pac::quadspi::Quadspi as Regs; 15use crate::pac::quadspi::Quadspi as Regs;
16use crate::rcc::{self, RccPeripheral}; 16use crate::rcc::{self, RccPeripheral};
17use crate::{peripherals, Peripheral}; 17use crate::{peripherals, Peri};
18 18
19/// QSPI transfer configuration. 19/// QSPI transfer configuration.
20pub struct TransferConfig { 20pub struct TransferConfig {
@@ -75,13 +75,13 @@ impl Default for Config {
75/// QSPI driver. 75/// QSPI driver.
76#[allow(dead_code)] 76#[allow(dead_code)]
77pub struct Qspi<'d, T: Instance, M: PeriMode> { 77pub struct Qspi<'d, T: Instance, M: PeriMode> {
78 _peri: PeripheralRef<'d, T>, 78 _peri: Peri<'d, T>,
79 sck: Option<PeripheralRef<'d, AnyPin>>, 79 sck: Option<Peri<'d, AnyPin>>,
80 d0: Option<PeripheralRef<'d, AnyPin>>, 80 d0: Option<Peri<'d, AnyPin>>,
81 d1: Option<PeripheralRef<'d, AnyPin>>, 81 d1: Option<Peri<'d, AnyPin>>,
82 d2: Option<PeripheralRef<'d, AnyPin>>, 82 d2: Option<Peri<'d, AnyPin>>,
83 d3: Option<PeripheralRef<'d, AnyPin>>, 83 d3: Option<Peri<'d, AnyPin>>,
84 nss: Option<PeripheralRef<'d, AnyPin>>, 84 nss: Option<Peri<'d, AnyPin>>,
85 dma: Option<ChannelAndRequest<'d>>, 85 dma: Option<ChannelAndRequest<'d>>,
86 _phantom: PhantomData<M>, 86 _phantom: PhantomData<M>,
87 config: Config, 87 config: Config,
@@ -89,19 +89,17 @@ pub struct Qspi<'d, T: Instance, M: PeriMode> {
89 89
90impl<'d, T: Instance, M: PeriMode> Qspi<'d, T, M> { 90impl<'d, T: Instance, M: PeriMode> Qspi<'d, T, M> {
91 fn new_inner( 91 fn new_inner(
92 peri: impl Peripheral<P = T> + 'd, 92 peri: Peri<'d, T>,
93 d0: Option<PeripheralRef<'d, AnyPin>>, 93 d0: Option<Peri<'d, AnyPin>>,
94 d1: Option<PeripheralRef<'d, AnyPin>>, 94 d1: Option<Peri<'d, AnyPin>>,
95 d2: Option<PeripheralRef<'d, AnyPin>>, 95 d2: Option<Peri<'d, AnyPin>>,
96 d3: Option<PeripheralRef<'d, AnyPin>>, 96 d3: Option<Peri<'d, AnyPin>>,
97 sck: Option<PeripheralRef<'d, AnyPin>>, 97 sck: Option<Peri<'d, AnyPin>>,
98 nss: Option<PeripheralRef<'d, AnyPin>>, 98 nss: Option<Peri<'d, AnyPin>>,
99 dma: Option<ChannelAndRequest<'d>>, 99 dma: Option<ChannelAndRequest<'d>>,
100 config: Config, 100 config: Config,
101 fsel: FlashSelection, 101 fsel: FlashSelection,
102 ) -> Self { 102 ) -> Self {
103 into_ref!(peri);
104
105 rcc::enable_and_reset::<T>(); 103 rcc::enable_and_reset::<T>();
106 104
107 while T::REGS.sr().read().busy() {} 105 while T::REGS.sr().read().busy() {}
@@ -272,13 +270,13 @@ impl<'d, T: Instance, M: PeriMode> Qspi<'d, T, M> {
272impl<'d, T: Instance> Qspi<'d, T, Blocking> { 270impl<'d, T: Instance> Qspi<'d, T, Blocking> {
273 /// Create a new QSPI driver for bank 1, in blocking mode. 271 /// Create a new QSPI driver for bank 1, in blocking mode.
274 pub fn new_blocking_bank1( 272 pub fn new_blocking_bank1(
275 peri: impl Peripheral<P = T> + 'd, 273 peri: Peri<'d, T>,
276 d0: impl Peripheral<P = impl BK1D0Pin<T>> + 'd, 274 d0: Peri<'d, impl BK1D0Pin<T>>,
277 d1: impl Peripheral<P = impl BK1D1Pin<T>> + 'd, 275 d1: Peri<'d, impl BK1D1Pin<T>>,
278 d2: impl Peripheral<P = impl BK1D2Pin<T>> + 'd, 276 d2: Peri<'d, impl BK1D2Pin<T>>,
279 d3: impl Peripheral<P = impl BK1D3Pin<T>> + 'd, 277 d3: Peri<'d, impl BK1D3Pin<T>>,
280 sck: impl Peripheral<P = impl SckPin<T>> + 'd, 278 sck: Peri<'d, impl SckPin<T>>,
281 nss: impl Peripheral<P = impl BK1NSSPin<T>> + 'd, 279 nss: Peri<'d, impl BK1NSSPin<T>>,
282 config: Config, 280 config: Config,
283 ) -> Self { 281 ) -> Self {
284 Self::new_inner( 282 Self::new_inner(
@@ -300,13 +298,13 @@ impl<'d, T: Instance> Qspi<'d, T, Blocking> {
300 298
301 /// Create a new QSPI driver for bank 2, in blocking mode. 299 /// Create a new QSPI driver for bank 2, in blocking mode.
302 pub fn new_blocking_bank2( 300 pub fn new_blocking_bank2(
303 peri: impl Peripheral<P = T> + 'd, 301 peri: Peri<'d, T>,
304 d0: impl Peripheral<P = impl BK2D0Pin<T>> + 'd, 302 d0: Peri<'d, impl BK2D0Pin<T>>,
305 d1: impl Peripheral<P = impl BK2D1Pin<T>> + 'd, 303 d1: Peri<'d, impl BK2D1Pin<T>>,
306 d2: impl Peripheral<P = impl BK2D2Pin<T>> + 'd, 304 d2: Peri<'d, impl BK2D2Pin<T>>,
307 d3: impl Peripheral<P = impl BK2D3Pin<T>> + 'd, 305 d3: Peri<'d, impl BK2D3Pin<T>>,
308 sck: impl Peripheral<P = impl SckPin<T>> + 'd, 306 sck: Peri<'d, impl SckPin<T>>,
309 nss: impl Peripheral<P = impl BK2NSSPin<T>> + 'd, 307 nss: Peri<'d, impl BK2NSSPin<T>>,
310 config: Config, 308 config: Config,
311 ) -> Self { 309 ) -> Self {
312 Self::new_inner( 310 Self::new_inner(
@@ -330,14 +328,14 @@ impl<'d, T: Instance> Qspi<'d, T, Blocking> {
330impl<'d, T: Instance> Qspi<'d, T, Async> { 328impl<'d, T: Instance> Qspi<'d, T, Async> {
331 /// Create a new QSPI driver for bank 1. 329 /// Create a new QSPI driver for bank 1.
332 pub fn new_bank1( 330 pub fn new_bank1(
333 peri: impl Peripheral<P = T> + 'd, 331 peri: Peri<'d, T>,
334 d0: impl Peripheral<P = impl BK1D0Pin<T>> + 'd, 332 d0: Peri<'d, impl BK1D0Pin<T>>,
335 d1: impl Peripheral<P = impl BK1D1Pin<T>> + 'd, 333 d1: Peri<'d, impl BK1D1Pin<T>>,
336 d2: impl Peripheral<P = impl BK1D2Pin<T>> + 'd, 334 d2: Peri<'d, impl BK1D2Pin<T>>,
337 d3: impl Peripheral<P = impl BK1D3Pin<T>> + 'd, 335 d3: Peri<'d, impl BK1D3Pin<T>>,
338 sck: impl Peripheral<P = impl SckPin<T>> + 'd, 336 sck: Peri<'d, impl SckPin<T>>,
339 nss: impl Peripheral<P = impl BK1NSSPin<T>> + 'd, 337 nss: Peri<'d, impl BK1NSSPin<T>>,
340 dma: impl Peripheral<P = impl QuadDma<T>> + 'd, 338 dma: Peri<'d, impl QuadDma<T>>,
341 config: Config, 339 config: Config,
342 ) -> Self { 340 ) -> Self {
343 Self::new_inner( 341 Self::new_inner(
@@ -359,14 +357,14 @@ impl<'d, T: Instance> Qspi<'d, T, Async> {
359 357
360 /// Create a new QSPI driver for bank 2. 358 /// Create a new QSPI driver for bank 2.
361 pub fn new_bank2( 359 pub fn new_bank2(
362 peri: impl Peripheral<P = T> + 'd, 360 peri: Peri<'d, T>,
363 d0: impl Peripheral<P = impl BK2D0Pin<T>> + 'd, 361 d0: Peri<'d, impl BK2D0Pin<T>>,
364 d1: impl Peripheral<P = impl BK2D1Pin<T>> + 'd, 362 d1: Peri<'d, impl BK2D1Pin<T>>,
365 d2: impl Peripheral<P = impl BK2D2Pin<T>> + 'd, 363 d2: Peri<'d, impl BK2D2Pin<T>>,
366 d3: impl Peripheral<P = impl BK2D3Pin<T>> + 'd, 364 d3: Peri<'d, impl BK2D3Pin<T>>,
367 sck: impl Peripheral<P = impl SckPin<T>> + 'd, 365 sck: Peri<'d, impl SckPin<T>>,
368 nss: impl Peripheral<P = impl BK2NSSPin<T>> + 'd, 366 nss: Peri<'d, impl BK2NSSPin<T>>,
369 dma: impl Peripheral<P = impl QuadDma<T>> + 'd, 367 dma: Peri<'d, impl QuadDma<T>>,
370 config: Config, 368 config: Config,
371 ) -> Self { 369 ) -> Self {
372 Self::new_inner( 370 Self::new_inner(
@@ -465,7 +463,7 @@ trait SealedInstance {
465 463
466/// QSPI instance trait. 464/// QSPI instance trait.
467#[allow(private_bounds)] 465#[allow(private_bounds)]
468pub trait Instance: Peripheral<P = Self> + SealedInstance + RccPeripheral {} 466pub trait Instance: SealedInstance + PeripheralType + RccPeripheral {}
469 467
470pin_trait!(SckPin, Instance); 468pin_trait!(SckPin, Instance);
471pin_trait!(BK1D0Pin, Instance); 469pin_trait!(BK1D0Pin, Instance);