aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp/src/qmi_cs1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-rp/src/qmi_cs1.rs')
-rw-r--r--embassy-rp/src/qmi_cs1.rs57
1 files changed, 57 insertions, 0 deletions
diff --git a/embassy-rp/src/qmi_cs1.rs b/embassy-rp/src/qmi_cs1.rs
new file mode 100644
index 000000000..b8ae41e35
--- /dev/null
+++ b/embassy-rp/src/qmi_cs1.rs
@@ -0,0 +1,57 @@
1//! QMI CS1 peripheral for RP235x
2//!
3//! This module provides access to the QMI CS1 functionality for use with external memory devices
4//! such as PSRAM. The QMI (Quad SPI) controller supports CS1 as a second chip select signal.
5//!
6//! This peripheral is only available on RP235x chips.
7
8#![cfg(feature = "_rp235x")]
9
10use embassy_hal_internal::{Peri, PeripheralType};
11
12use crate::gpio::Pin as GpioPin;
13use crate::{pac, peripherals};
14
15/// QMI CS1 driver.
16pub struct QmiCs1<'d> {
17 _inner: Peri<'d, peripherals::QMI_CS1>,
18}
19
20impl<'d> QmiCs1<'d> {
21 /// Create a new QMI CS1 instance.
22 pub fn new(qmi_cs1: Peri<'d, peripherals::QMI_CS1>, cs1: Peri<'d, impl QmiCs1Pin>) -> Self {
23 // Configure CS1 pin for QMI function (funcsel = 9)
24 cs1.gpio().ctrl().write(|w| w.set_funcsel(9));
25
26 // Configure pad settings for high-speed operation
27 cs1.pad_ctrl().write(|w| {
28 #[cfg(feature = "_rp235x")]
29 w.set_iso(false);
30 w.set_ie(true);
31 w.set_drive(pac::pads::vals::Drive::_12M_A);
32 w.set_slewfast(true);
33 });
34
35 Self { _inner: qmi_cs1 }
36 }
37}
38
39trait SealedInstance {}
40
41/// QMI CS1 instance trait.
42#[allow(private_bounds)]
43pub trait Instance: SealedInstance + PeripheralType {}
44
45impl SealedInstance for peripherals::QMI_CS1 {}
46
47impl Instance for peripherals::QMI_CS1 {}
48
49/// CS1 pin trait for QMI.
50pub trait QmiCs1Pin: GpioPin {}
51
52// Implement pin traits for CS1-capable GPIO pins
53impl QmiCs1Pin for peripherals::PIN_0 {}
54impl QmiCs1Pin for peripherals::PIN_8 {}
55impl QmiCs1Pin for peripherals::PIN_19 {}
56#[cfg(feature = "rp235xb")]
57impl QmiCs1Pin for peripherals::PIN_47 {}