aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp
diff options
context:
space:
mode:
authorpennae <[email protected]>2023-07-31 19:13:10 +0200
committerpennae <[email protected]>2023-07-31 19:13:10 +0200
commitdca1777a2f3659b1acaa87aba31caf9afb09eae4 (patch)
tree3cd5c12c9980c3616220a1364c05bfcd2e0abfa8 /embassy-rp
parent2c6fcdbd3f6ff40d77e200fdd98b727164379769 (diff)
rp: make QSPI gpio support optional
this will be mostly not useful to anyone since flash is attached to qspi, and using flash chips that don't use the *entire* qspi interface will severly slow down the chip. the code overhead is minimal right now, but if we also fix interrupt support on qspi pins this will change (adding more code to potentially hot paths, using more memory for wakers that are never used, and preventing the qspi gpio irq from being used in software interrupts as RTIC applications may want to do).
Diffstat (limited to 'embassy-rp')
-rw-r--r--embassy-rp/Cargo.toml4
-rw-r--r--embassy-rp/src/gpio.rs17
2 files changed, 17 insertions, 4 deletions
diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml
index 6310ffb62..564d44ecd 100644
--- a/embassy-rp/Cargo.toml
+++ b/embassy-rp/Cargo.toml
@@ -42,6 +42,10 @@ boot2-ram-memcpy = []
42boot2-w25q080 = [] 42boot2-w25q080 = []
43boot2-w25x10cl = [] 43boot2-w25x10cl = []
44 44
45# Allow using QSPI pins as GPIO pins. This is mostly not what you want (because your flash lives there)
46# and would add both code and memory overhead when enabled needlessly.
47qspi-as-gpio = []
48
45# Indicate code is running from RAM. 49# Indicate code is running from RAM.
46# Set this if all code is in RAM, and the cores never access memory-mapped flash memory through XIP. 50# Set this if all code is in RAM, and the cores never access memory-mapped flash memory through XIP.
47# This allows the flash driver to not force pausing execution on both cores when doing flash operations. 51# This allows the flash driver to not force pausing execution on both cores when doing flash operations.
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs
index bac126d43..9861429f3 100644
--- a/embassy-rp/src/gpio.rs
+++ b/embassy-rp/src/gpio.rs
@@ -67,6 +67,7 @@ pub enum SlewRate {
67#[derive(Debug, Eq, PartialEq)] 67#[derive(Debug, Eq, PartialEq)]
68pub enum Bank { 68pub enum Bank {
69 Bank0 = 0, 69 Bank0 = 0,
70 #[cfg(feature = "qspi-as-gpio")]
70 Qspi = 1, 71 Qspi = 1,
71} 72}
72 73
@@ -636,16 +637,17 @@ pub(crate) mod sealed {
636 637
637 #[inline] 638 #[inline]
638 fn _bank(&self) -> Bank { 639 fn _bank(&self) -> Bank {
639 if self.pin_bank() & 0x20 == 0 { 640 match self.pin_bank() & 0x20 {
640 Bank::Bank0 641 #[cfg(feature = "qspi-as-gpio")]
641 } else { 642 1 => Bank::Qspi,
642 Bank::Qspi 643 _ => Bank::Bank0,
643 } 644 }
644 } 645 }
645 646
646 fn io(&self) -> pac::io::Io { 647 fn io(&self) -> pac::io::Io {
647 match self._bank() { 648 match self._bank() {
648 Bank::Bank0 => crate::pac::IO_BANK0, 649 Bank::Bank0 => crate::pac::IO_BANK0,
650 #[cfg(feature = "qspi-as-gpio")]
649 Bank::Qspi => crate::pac::IO_QSPI, 651 Bank::Qspi => crate::pac::IO_QSPI,
650 } 652 }
651 } 653 }
@@ -657,6 +659,7 @@ pub(crate) mod sealed {
657 fn pad_ctrl(&self) -> Reg<pac::pads::regs::GpioCtrl, RW> { 659 fn pad_ctrl(&self) -> Reg<pac::pads::regs::GpioCtrl, RW> {
658 let block = match self._bank() { 660 let block = match self._bank() {
659 Bank::Bank0 => crate::pac::PADS_BANK0, 661 Bank::Bank0 => crate::pac::PADS_BANK0,
662 #[cfg(feature = "qspi-as-gpio")]
660 Bank::Qspi => crate::pac::PADS_QSPI, 663 Bank::Qspi => crate::pac::PADS_QSPI,
661 }; 664 };
662 block.gpio(self._pin() as _) 665 block.gpio(self._pin() as _)
@@ -766,11 +769,17 @@ impl_pin!(PIN_27, Bank::Bank0, 27);
766impl_pin!(PIN_28, Bank::Bank0, 28); 769impl_pin!(PIN_28, Bank::Bank0, 28);
767impl_pin!(PIN_29, Bank::Bank0, 29); 770impl_pin!(PIN_29, Bank::Bank0, 29);
768 771
772#[cfg(feature = "qspi-as-gpio")]
769impl_pin!(PIN_QSPI_SCLK, Bank::Qspi, 0); 773impl_pin!(PIN_QSPI_SCLK, Bank::Qspi, 0);
774#[cfg(feature = "qspi-as-gpio")]
770impl_pin!(PIN_QSPI_SS, Bank::Qspi, 1); 775impl_pin!(PIN_QSPI_SS, Bank::Qspi, 1);
776#[cfg(feature = "qspi-as-gpio")]
771impl_pin!(PIN_QSPI_SD0, Bank::Qspi, 2); 777impl_pin!(PIN_QSPI_SD0, Bank::Qspi, 2);
778#[cfg(feature = "qspi-as-gpio")]
772impl_pin!(PIN_QSPI_SD1, Bank::Qspi, 3); 779impl_pin!(PIN_QSPI_SD1, Bank::Qspi, 3);
780#[cfg(feature = "qspi-as-gpio")]
773impl_pin!(PIN_QSPI_SD2, Bank::Qspi, 4); 781impl_pin!(PIN_QSPI_SD2, Bank::Qspi, 4);
782#[cfg(feature = "qspi-as-gpio")]
774impl_pin!(PIN_QSPI_SD3, Bank::Qspi, 5); 783impl_pin!(PIN_QSPI_SD3, Bank::Qspi, 5);
775 784
776// ==================== 785// ====================