diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-08-01 08:18:39 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-08-01 08:18:39 +0000 |
| commit | ef3b1f46a99bd44f4702459adcc42a176a36b2f8 (patch) | |
| tree | 9b04a5daeea03b4bde804b7098f9041e239c38bb | |
| parent | 5e4f65fe1f64f44d5680b42f02f2d7e5ef9ed6c3 (diff) | |
| parent | f3ad0c6adeb4212af52f4ff974a488765551e81e (diff) | |
Merge pull request #1728 from pennae/rp-gpio-banks
rp: fix qspi gpio interrupts, make qspi gpio optional
| -rwxr-xr-x | ci.sh | 1 | ||||
| -rwxr-xr-x | ci_stable.sh | 1 | ||||
| -rw-r--r-- | embassy-rp/Cargo.toml | 4 | ||||
| -rw-r--r-- | embassy-rp/src/clocks.rs | 8 | ||||
| -rw-r--r-- | embassy-rp/src/gpio.rs | 83 | ||||
| -rw-r--r-- | embassy-rp/src/i2c.rs | 4 | ||||
| -rw-r--r-- | embassy-rp/src/pio.rs | 2 | ||||
| -rw-r--r-- | embassy-rp/src/pwm.rs | 8 | ||||
| -rw-r--r-- | embassy-rp/src/spi.rs | 8 | ||||
| -rw-r--r-- | embassy-rp/src/uart/mod.rs | 8 |
10 files changed, 84 insertions, 43 deletions
| @@ -58,6 +58,7 @@ cargo batch \ | |||
| 58 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits \ | 58 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits \ |
| 59 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly \ | 59 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly \ |
| 60 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,intrinsics \ | 60 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,intrinsics \ |
| 61 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,qspi-as-gpio \ | ||
| 61 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time-driver-any,unstable-traits \ | 62 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time-driver-any,unstable-traits \ |
| 62 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time-driver-any \ | 63 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time-driver-any \ |
| 63 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time-driver-any \ | 64 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time-driver-any \ |
diff --git a/ci_stable.sh b/ci_stable.sh index daae98961..56f72131f 100755 --- a/ci_stable.sh +++ b/ci_stable.sh | |||
| @@ -36,6 +36,7 @@ cargo batch \ | |||
| 36 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,defmt \ | 36 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,defmt \ |
| 37 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,log \ | 37 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,log \ |
| 38 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi \ | 38 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi \ |
| 39 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features qspi-as-gpio \ | ||
| 39 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any,unstable-traits \ | 40 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any,unstable-traits \ |
| 40 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any,unstable-traits \ | 41 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any,unstable-traits \ |
| 41 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any,unstable-traits \ | 42 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any,unstable-traits \ |
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 = [] | |||
| 42 | boot2-w25q080 = [] | 42 | boot2-w25q080 = [] |
| 43 | boot2-w25x10cl = [] | 43 | boot2-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. | ||
| 47 | qspi-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/clocks.rs b/embassy-rp/src/clocks.rs index 976d06de7..a33980230 100644 --- a/embassy-rp/src/clocks.rs +++ b/embassy-rp/src/clocks.rs | |||
| @@ -702,7 +702,7 @@ impl<'d, T: Pin> Gpin<'d, T> { | |||
| 702 | pub fn new<P: GpinPin>(gpin: impl Peripheral<P = P> + 'd) -> Gpin<'d, P> { | 702 | pub fn new<P: GpinPin>(gpin: impl Peripheral<P = P> + 'd) -> Gpin<'d, P> { |
| 703 | into_ref!(gpin); | 703 | into_ref!(gpin); |
| 704 | 704 | ||
| 705 | gpin.io().ctrl().write(|w| w.set_funcsel(0x08)); | 705 | gpin.gpio().ctrl().write(|w| w.set_funcsel(0x08)); |
| 706 | 706 | ||
| 707 | Gpin { | 707 | Gpin { |
| 708 | gpin: gpin.map_into(), | 708 | gpin: gpin.map_into(), |
| @@ -718,7 +718,7 @@ impl<'d, T: Pin> Gpin<'d, T> { | |||
| 718 | impl<'d, T: Pin> Drop for Gpin<'d, T> { | 718 | impl<'d, T: Pin> Drop for Gpin<'d, T> { |
| 719 | fn drop(&mut self) { | 719 | fn drop(&mut self) { |
| 720 | self.gpin | 720 | self.gpin |
| 721 | .io() | 721 | .gpio() |
| 722 | .ctrl() | 722 | .ctrl() |
| 723 | .write(|w| w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::NULL as _)); | 723 | .write(|w| w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::NULL as _)); |
| 724 | } | 724 | } |
| @@ -766,7 +766,7 @@ impl<'d, T: GpoutPin> Gpout<'d, T> { | |||
| 766 | pub fn new(gpout: impl Peripheral<P = T> + 'd) -> Self { | 766 | pub fn new(gpout: impl Peripheral<P = T> + 'd) -> Self { |
| 767 | into_ref!(gpout); | 767 | into_ref!(gpout); |
| 768 | 768 | ||
| 769 | gpout.io().ctrl().write(|w| w.set_funcsel(0x08)); | 769 | gpout.gpio().ctrl().write(|w| w.set_funcsel(0x08)); |
| 770 | 770 | ||
| 771 | Self { gpout } | 771 | Self { gpout } |
| 772 | } | 772 | } |
| @@ -831,7 +831,7 @@ impl<'d, T: GpoutPin> Drop for Gpout<'d, T> { | |||
| 831 | fn drop(&mut self) { | 831 | fn drop(&mut self) { |
| 832 | self.disable(); | 832 | self.disable(); |
| 833 | self.gpout | 833 | self.gpout |
| 834 | .io() | 834 | .gpio() |
| 835 | .ctrl() | 835 | .ctrl() |
| 836 | .write(|w| w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::NULL as _)); | 836 | .write(|w| w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::NULL as _)); |
| 837 | } | 837 | } |
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index 2807eb678..73e893523 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs | |||
| @@ -11,9 +11,13 @@ use crate::pac::common::{Reg, RW}; | |||
| 11 | use crate::pac::SIO; | 11 | use crate::pac::SIO; |
| 12 | use crate::{interrupt, pac, peripherals, Peripheral, RegExt}; | 12 | use crate::{interrupt, pac, peripherals, Peripheral, RegExt}; |
| 13 | 13 | ||
| 14 | const PIN_COUNT: usize = 30; | ||
| 15 | const NEW_AW: AtomicWaker = AtomicWaker::new(); | 14 | const NEW_AW: AtomicWaker = AtomicWaker::new(); |
| 16 | static INTERRUPT_WAKERS: [AtomicWaker; PIN_COUNT] = [NEW_AW; PIN_COUNT]; | 15 | const BANK0_PIN_COUNT: usize = 30; |
| 16 | static BANK0_WAKERS: [AtomicWaker; BANK0_PIN_COUNT] = [NEW_AW; BANK0_PIN_COUNT]; | ||
| 17 | #[cfg(feature = "qspi-as-gpio")] | ||
| 18 | const QSPI_PIN_COUNT: usize = 6; | ||
| 19 | #[cfg(feature = "qspi-as-gpio")] | ||
| 20 | static QSPI_WAKERS: [AtomicWaker; QSPI_PIN_COUNT] = [NEW_AW; QSPI_PIN_COUNT]; | ||
| 17 | 21 | ||
| 18 | /// Represents a digital input or output level. | 22 | /// Represents a digital input or output level. |
| 19 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] | 23 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] |
| @@ -67,6 +71,7 @@ pub enum SlewRate { | |||
| 67 | #[derive(Debug, Eq, PartialEq)] | 71 | #[derive(Debug, Eq, PartialEq)] |
| 68 | pub enum Bank { | 72 | pub enum Bank { |
| 69 | Bank0 = 0, | 73 | Bank0 = 0, |
| 74 | #[cfg(feature = "qspi-as-gpio")] | ||
| 70 | Qspi = 1, | 75 | Qspi = 1, |
| 71 | } | 76 | } |
| 72 | 77 | ||
| @@ -140,17 +145,23 @@ pub(crate) unsafe fn init() { | |||
| 140 | interrupt::IO_IRQ_BANK0.disable(); | 145 | interrupt::IO_IRQ_BANK0.disable(); |
| 141 | interrupt::IO_IRQ_BANK0.set_priority(interrupt::Priority::P3); | 146 | interrupt::IO_IRQ_BANK0.set_priority(interrupt::Priority::P3); |
| 142 | interrupt::IO_IRQ_BANK0.enable(); | 147 | interrupt::IO_IRQ_BANK0.enable(); |
| 148 | |||
| 149 | #[cfg(feature = "qspi-as-gpio")] | ||
| 150 | { | ||
| 151 | interrupt::IO_IRQ_QSPI.disable(); | ||
| 152 | interrupt::IO_IRQ_QSPI.set_priority(interrupt::Priority::P3); | ||
| 153 | interrupt::IO_IRQ_QSPI.enable(); | ||
| 154 | } | ||
| 143 | } | 155 | } |
| 144 | 156 | ||
| 145 | #[cfg(feature = "rt")] | 157 | #[cfg(feature = "rt")] |
| 146 | #[interrupt] | 158 | fn irq_handler<const N: usize>(bank: pac::io::Io, wakers: &[AtomicWaker; N]) { |
| 147 | fn IO_IRQ_BANK0() { | ||
| 148 | let cpu = SIO.cpuid().read() as usize; | 159 | let cpu = SIO.cpuid().read() as usize; |
| 149 | // There are two sets of interrupt registers, one for cpu0 and one for cpu1 | 160 | // There are two sets of interrupt registers, one for cpu0 and one for cpu1 |
| 150 | // and here we are selecting the set that belongs to the currently executing | 161 | // and here we are selecting the set that belongs to the currently executing |
| 151 | // cpu. | 162 | // cpu. |
| 152 | let proc_intx: pac::io::Int = pac::IO_BANK0.int_proc(cpu); | 163 | let proc_intx: pac::io::Int = bank.int_proc(cpu); |
| 153 | for pin in 0..PIN_COUNT { | 164 | for pin in 0..N { |
| 154 | // There are 4 raw interrupt status registers, PROCx_INTS0, PROCx_INTS1, | 165 | // There are 4 raw interrupt status registers, PROCx_INTS0, PROCx_INTS1, |
| 155 | // PROCx_INTS2, and PROCx_INTS3, and we are selecting the one that the | 166 | // PROCx_INTS2, and PROCx_INTS3, and we are selecting the one that the |
| 156 | // current pin belongs to. | 167 | // current pin belongs to. |
| @@ -171,11 +182,23 @@ fn IO_IRQ_BANK0() { | |||
| 171 | w.set_level_high(pin_group, true); | 182 | w.set_level_high(pin_group, true); |
| 172 | w.set_level_low(pin_group, true); | 183 | w.set_level_low(pin_group, true); |
| 173 | }); | 184 | }); |
| 174 | INTERRUPT_WAKERS[pin as usize].wake(); | 185 | wakers[pin as usize].wake(); |
| 175 | } | 186 | } |
| 176 | } | 187 | } |
| 177 | } | 188 | } |
| 178 | 189 | ||
| 190 | #[cfg(feature = "rt")] | ||
| 191 | #[interrupt] | ||
| 192 | fn IO_IRQ_BANK0() { | ||
| 193 | irq_handler(pac::IO_BANK0, &BANK0_WAKERS); | ||
| 194 | } | ||
| 195 | |||
| 196 | #[cfg(all(feature = "rt", feature = "qspi-as-gpio"))] | ||
| 197 | #[interrupt] | ||
| 198 | fn IO_IRQ_QSPI() { | ||
| 199 | irq_handler(pac::IO_QSPI, &QSPI_WAKERS); | ||
| 200 | } | ||
| 201 | |||
| 179 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 202 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 180 | struct InputFuture<'a, T: Pin> { | 203 | struct InputFuture<'a, T: Pin> { |
| 181 | pin: PeripheralRef<'a, T>, | 204 | pin: PeripheralRef<'a, T>, |
| @@ -194,7 +217,7 @@ impl<'d, T: Pin> InputFuture<'d, T> { | |||
| 194 | // (the alternative being checking the current level and waiting for | 217 | // (the alternative being checking the current level and waiting for |
| 195 | // its inverse, but that requires reading the current level and thus | 218 | // its inverse, but that requires reading the current level and thus |
| 196 | // missing anything that happened before the level was read.) | 219 | // missing anything that happened before the level was read.) |
| 197 | pac::IO_BANK0.intr(pin.pin() as usize / 8).write(|w| { | 220 | pin.io().intr(pin.pin() as usize / 8).write(|w| { |
| 198 | w.set_edge_high(pin_group, true); | 221 | w.set_edge_high(pin_group, true); |
| 199 | w.set_edge_low(pin_group, true); | 222 | w.set_edge_low(pin_group, true); |
| 200 | }); | 223 | }); |
| @@ -234,7 +257,12 @@ impl<'d, T: Pin> Future for InputFuture<'d, T> { | |||
| 234 | fn poll(self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | 257 | fn poll(self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
| 235 | // We need to register/re-register the waker for each poll because any | 258 | // We need to register/re-register the waker for each poll because any |
| 236 | // calls to wake will deregister the waker. | 259 | // calls to wake will deregister the waker. |
| 237 | INTERRUPT_WAKERS[self.pin.pin() as usize].register(cx.waker()); | 260 | let waker = match self.pin.bank() { |
| 261 | Bank::Bank0 => &BANK0_WAKERS[self.pin.pin() as usize], | ||
| 262 | #[cfg(feature = "qspi-as-gpio")] | ||
| 263 | Bank::Qspi => &QSPI_WAKERS[self.pin.pin() as usize], | ||
| 264 | }; | ||
| 265 | waker.register(cx.waker()); | ||
| 238 | 266 | ||
| 239 | // self.int_proc() will get the register offset for the current cpu, | 267 | // self.int_proc() will get the register offset for the current cpu, |
| 240 | // then we want to access the interrupt enable register for our | 268 | // then we want to access the interrupt enable register for our |
| @@ -451,7 +479,7 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 451 | w.set_ie(true); | 479 | w.set_ie(true); |
| 452 | }); | 480 | }); |
| 453 | 481 | ||
| 454 | pin.io().ctrl().write(|w| { | 482 | pin.gpio().ctrl().write(|w| { |
| 455 | w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::SIO_0 as _); | 483 | w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::SIO_0 as _); |
| 456 | }); | 484 | }); |
| 457 | 485 | ||
| @@ -617,7 +645,7 @@ impl<'d, T: Pin> Drop for Flex<'d, T> { | |||
| 617 | #[inline] | 645 | #[inline] |
| 618 | fn drop(&mut self) { | 646 | fn drop(&mut self) { |
| 619 | self.pin.pad_ctrl().write(|_| {}); | 647 | self.pin.pad_ctrl().write(|_| {}); |
| 620 | self.pin.io().ctrl().write(|w| { | 648 | self.pin.gpio().ctrl().write(|w| { |
| 621 | w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::NULL as _); | 649 | w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::NULL as _); |
| 622 | }); | 650 | }); |
| 623 | } | 651 | } |
| @@ -636,24 +664,29 @@ pub(crate) mod sealed { | |||
| 636 | 664 | ||
| 637 | #[inline] | 665 | #[inline] |
| 638 | fn _bank(&self) -> Bank { | 666 | fn _bank(&self) -> Bank { |
| 639 | if self.pin_bank() & 0x20 == 0 { | 667 | match self.pin_bank() & 0x20 { |
| 640 | Bank::Bank0 | 668 | #[cfg(feature = "qspi-as-gpio")] |
| 641 | } else { | 669 | 1 => Bank::Qspi, |
| 642 | Bank::Qspi | 670 | _ => Bank::Bank0, |
| 643 | } | 671 | } |
| 644 | } | 672 | } |
| 645 | 673 | ||
| 646 | fn io(&self) -> pac::io::Gpio { | 674 | fn io(&self) -> pac::io::Io { |
| 647 | let block = match self._bank() { | 675 | match self._bank() { |
| 648 | Bank::Bank0 => crate::pac::IO_BANK0, | 676 | Bank::Bank0 => crate::pac::IO_BANK0, |
| 677 | #[cfg(feature = "qspi-as-gpio")] | ||
| 649 | Bank::Qspi => crate::pac::IO_QSPI, | 678 | Bank::Qspi => crate::pac::IO_QSPI, |
| 650 | }; | 679 | } |
| 651 | block.gpio(self._pin() as _) | 680 | } |
| 681 | |||
| 682 | fn gpio(&self) -> pac::io::Gpio { | ||
| 683 | self.io().gpio(self._pin() as _) | ||
| 652 | } | 684 | } |
| 653 | 685 | ||
| 654 | fn pad_ctrl(&self) -> Reg<pac::pads::regs::GpioCtrl, RW> { | 686 | fn pad_ctrl(&self) -> Reg<pac::pads::regs::GpioCtrl, RW> { |
| 655 | let block = match self._bank() { | 687 | let block = match self._bank() { |
| 656 | Bank::Bank0 => crate::pac::PADS_BANK0, | 688 | Bank::Bank0 => crate::pac::PADS_BANK0, |
| 689 | #[cfg(feature = "qspi-as-gpio")] | ||
| 657 | Bank::Qspi => crate::pac::PADS_QSPI, | 690 | Bank::Qspi => crate::pac::PADS_QSPI, |
| 658 | }; | 691 | }; |
| 659 | block.gpio(self._pin() as _) | 692 | block.gpio(self._pin() as _) |
| @@ -672,12 +705,8 @@ pub(crate) mod sealed { | |||
| 672 | } | 705 | } |
| 673 | 706 | ||
| 674 | fn int_proc(&self) -> pac::io::Int { | 707 | fn int_proc(&self) -> pac::io::Int { |
| 675 | let io_block = match self._bank() { | ||
| 676 | Bank::Bank0 => crate::pac::IO_BANK0, | ||
| 677 | Bank::Qspi => crate::pac::IO_QSPI, | ||
| 678 | }; | ||
| 679 | let proc = SIO.cpuid().read(); | 708 | let proc = SIO.cpuid().read(); |
| 680 | io_block.int_proc(proc as _) | 709 | self.io().int_proc(proc as _) |
| 681 | } | 710 | } |
| 682 | } | 711 | } |
| 683 | } | 712 | } |
| @@ -767,11 +796,17 @@ impl_pin!(PIN_27, Bank::Bank0, 27); | |||
| 767 | impl_pin!(PIN_28, Bank::Bank0, 28); | 796 | impl_pin!(PIN_28, Bank::Bank0, 28); |
| 768 | impl_pin!(PIN_29, Bank::Bank0, 29); | 797 | impl_pin!(PIN_29, Bank::Bank0, 29); |
| 769 | 798 | ||
| 799 | #[cfg(feature = "qspi-as-gpio")] | ||
| 770 | impl_pin!(PIN_QSPI_SCLK, Bank::Qspi, 0); | 800 | impl_pin!(PIN_QSPI_SCLK, Bank::Qspi, 0); |
| 801 | #[cfg(feature = "qspi-as-gpio")] | ||
| 771 | impl_pin!(PIN_QSPI_SS, Bank::Qspi, 1); | 802 | impl_pin!(PIN_QSPI_SS, Bank::Qspi, 1); |
| 803 | #[cfg(feature = "qspi-as-gpio")] | ||
| 772 | impl_pin!(PIN_QSPI_SD0, Bank::Qspi, 2); | 804 | impl_pin!(PIN_QSPI_SD0, Bank::Qspi, 2); |
| 805 | #[cfg(feature = "qspi-as-gpio")] | ||
| 773 | impl_pin!(PIN_QSPI_SD1, Bank::Qspi, 3); | 806 | impl_pin!(PIN_QSPI_SD1, Bank::Qspi, 3); |
| 807 | #[cfg(feature = "qspi-as-gpio")] | ||
| 774 | impl_pin!(PIN_QSPI_SD2, Bank::Qspi, 4); | 808 | impl_pin!(PIN_QSPI_SD2, Bank::Qspi, 4); |
| 809 | #[cfg(feature = "qspi-as-gpio")] | ||
| 775 | impl_pin!(PIN_QSPI_SD3, Bank::Qspi, 5); | 810 | impl_pin!(PIN_QSPI_SD3, Bank::Qspi, 5); |
| 776 | 811 | ||
| 777 | // ==================== | 812 | // ==================== |
diff --git a/embassy-rp/src/i2c.rs b/embassy-rp/src/i2c.rs index 536ad747d..7a5ddd325 100644 --- a/embassy-rp/src/i2c.rs +++ b/embassy-rp/src/i2c.rs | |||
| @@ -353,8 +353,8 @@ impl<'d, T: Instance + 'd, M: Mode> I2c<'d, T, M> { | |||
| 353 | p.ic_rx_tl().write(|w| w.set_rx_tl(0)); | 353 | p.ic_rx_tl().write(|w| w.set_rx_tl(0)); |
| 354 | 354 | ||
| 355 | // Configure SCL & SDA pins | 355 | // Configure SCL & SDA pins |
| 356 | scl.io().ctrl().write(|w| w.set_funcsel(3)); | 356 | scl.gpio().ctrl().write(|w| w.set_funcsel(3)); |
| 357 | sda.io().ctrl().write(|w| w.set_funcsel(3)); | 357 | sda.gpio().ctrl().write(|w| w.set_funcsel(3)); |
| 358 | 358 | ||
| 359 | scl.pad_ctrl().write(|w| { | 359 | scl.pad_ctrl().write(|w| { |
| 360 | w.set_schmitt(true); | 360 | w.set_schmitt(true); |
diff --git a/embassy-rp/src/pio.rs b/embassy-rp/src/pio.rs index 3de398af7..c09d09143 100644 --- a/embassy-rp/src/pio.rs +++ b/embassy-rp/src/pio.rs | |||
| @@ -852,7 +852,7 @@ impl<'d, PIO: Instance> Common<'d, PIO> { | |||
| 852 | /// of [`Pio`] do not keep pin registrations alive.** | 852 | /// of [`Pio`] do not keep pin registrations alive.** |
| 853 | pub fn make_pio_pin(&mut self, pin: impl Peripheral<P = impl PioPin + 'd> + 'd) -> Pin<'d, PIO> { | 853 | pub fn make_pio_pin(&mut self, pin: impl Peripheral<P = impl PioPin + 'd> + 'd) -> Pin<'d, PIO> { |
| 854 | into_ref!(pin); | 854 | into_ref!(pin); |
| 855 | pin.io().ctrl().write(|w| w.set_funcsel(PIO::FUNCSEL as _)); | 855 | pin.gpio().ctrl().write(|w| w.set_funcsel(PIO::FUNCSEL as _)); |
| 856 | // we can be relaxed about this because we're &mut here and nothing is cached | 856 | // we can be relaxed about this because we're &mut here and nothing is cached |
| 857 | PIO::state().used_pins.fetch_or(1 << pin.pin_bank(), Ordering::Relaxed); | 857 | PIO::state().used_pins.fetch_or(1 << pin.pin_bank(), Ordering::Relaxed); |
| 858 | Pin { | 858 | Pin { |
diff --git a/embassy-rp/src/pwm.rs b/embassy-rp/src/pwm.rs index c0ddb2a90..c297d69a2 100644 --- a/embassy-rp/src/pwm.rs +++ b/embassy-rp/src/pwm.rs | |||
| @@ -79,10 +79,10 @@ impl<'d, T: Channel> Pwm<'d, T> { | |||
| 79 | Self::configure(p, &config); | 79 | Self::configure(p, &config); |
| 80 | 80 | ||
| 81 | if let Some(pin) = &a { | 81 | if let Some(pin) = &a { |
| 82 | pin.io().ctrl().write(|w| w.set_funcsel(4)); | 82 | pin.gpio().ctrl().write(|w| w.set_funcsel(4)); |
| 83 | } | 83 | } |
| 84 | if let Some(pin) = &b { | 84 | if let Some(pin) = &b { |
| 85 | pin.io().ctrl().write(|w| w.set_funcsel(4)); | 85 | pin.gpio().ctrl().write(|w| w.set_funcsel(4)); |
| 86 | } | 86 | } |
| 87 | Self { | 87 | Self { |
| 88 | inner, | 88 | inner, |
| @@ -243,10 +243,10 @@ impl<'d, T: Channel> Drop for Pwm<'d, T> { | |||
| 243 | fn drop(&mut self) { | 243 | fn drop(&mut self) { |
| 244 | self.inner.regs().csr().write_clear(|w| w.set_en(false)); | 244 | self.inner.regs().csr().write_clear(|w| w.set_en(false)); |
| 245 | if let Some(pin) = &self.pin_a { | 245 | if let Some(pin) = &self.pin_a { |
| 246 | pin.io().ctrl().write(|w| w.set_funcsel(31)); | 246 | pin.gpio().ctrl().write(|w| w.set_funcsel(31)); |
| 247 | } | 247 | } |
| 248 | if let Some(pin) = &self.pin_b { | 248 | if let Some(pin) = &self.pin_b { |
| 249 | pin.io().ctrl().write(|w| w.set_funcsel(31)); | 249 | pin.gpio().ctrl().write(|w| w.set_funcsel(31)); |
| 250 | } | 250 | } |
| 251 | } | 251 | } |
| 252 | } | 252 | } |
diff --git a/embassy-rp/src/spi.rs b/embassy-rp/src/spi.rs index 544b542e8..46c440b84 100644 --- a/embassy-rp/src/spi.rs +++ b/embassy-rp/src/spi.rs | |||
| @@ -100,16 +100,16 @@ impl<'d, T: Instance, M: Mode> Spi<'d, T, M> { | |||
| 100 | p.cr1().write(|w| w.set_sse(true)); | 100 | p.cr1().write(|w| w.set_sse(true)); |
| 101 | 101 | ||
| 102 | if let Some(pin) = &clk { | 102 | if let Some(pin) = &clk { |
| 103 | pin.io().ctrl().write(|w| w.set_funcsel(1)); | 103 | pin.gpio().ctrl().write(|w| w.set_funcsel(1)); |
| 104 | } | 104 | } |
| 105 | if let Some(pin) = &mosi { | 105 | if let Some(pin) = &mosi { |
| 106 | pin.io().ctrl().write(|w| w.set_funcsel(1)); | 106 | pin.gpio().ctrl().write(|w| w.set_funcsel(1)); |
| 107 | } | 107 | } |
| 108 | if let Some(pin) = &miso { | 108 | if let Some(pin) = &miso { |
| 109 | pin.io().ctrl().write(|w| w.set_funcsel(1)); | 109 | pin.gpio().ctrl().write(|w| w.set_funcsel(1)); |
| 110 | } | 110 | } |
| 111 | if let Some(pin) = &cs { | 111 | if let Some(pin) = &cs { |
| 112 | pin.io().ctrl().write(|w| w.set_funcsel(1)); | 112 | pin.gpio().ctrl().write(|w| w.set_funcsel(1)); |
| 113 | } | 113 | } |
| 114 | Self { | 114 | Self { |
| 115 | inner, | 115 | inner, |
diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs index 69c6ac2f1..00070b80a 100644 --- a/embassy-rp/src/uart/mod.rs +++ b/embassy-rp/src/uart/mod.rs | |||
| @@ -565,7 +565,7 @@ impl<'d, T: Instance + 'd, M: Mode> Uart<'d, T, M> { | |||
| 565 | ) { | 565 | ) { |
| 566 | let r = T::regs(); | 566 | let r = T::regs(); |
| 567 | if let Some(pin) = &tx { | 567 | if let Some(pin) = &tx { |
| 568 | pin.io().ctrl().write(|w| { | 568 | pin.gpio().ctrl().write(|w| { |
| 569 | w.set_funcsel(2); | 569 | w.set_funcsel(2); |
| 570 | w.set_outover(if config.invert_tx { | 570 | w.set_outover(if config.invert_tx { |
| 571 | Outover::INVERT | 571 | Outover::INVERT |
| @@ -576,7 +576,7 @@ impl<'d, T: Instance + 'd, M: Mode> Uart<'d, T, M> { | |||
| 576 | pin.pad_ctrl().write(|w| w.set_ie(true)); | 576 | pin.pad_ctrl().write(|w| w.set_ie(true)); |
| 577 | } | 577 | } |
| 578 | if let Some(pin) = &rx { | 578 | if let Some(pin) = &rx { |
| 579 | pin.io().ctrl().write(|w| { | 579 | pin.gpio().ctrl().write(|w| { |
| 580 | w.set_funcsel(2); | 580 | w.set_funcsel(2); |
| 581 | w.set_inover(if config.invert_rx { | 581 | w.set_inover(if config.invert_rx { |
| 582 | Inover::INVERT | 582 | Inover::INVERT |
| @@ -587,7 +587,7 @@ impl<'d, T: Instance + 'd, M: Mode> Uart<'d, T, M> { | |||
| 587 | pin.pad_ctrl().write(|w| w.set_ie(true)); | 587 | pin.pad_ctrl().write(|w| w.set_ie(true)); |
| 588 | } | 588 | } |
| 589 | if let Some(pin) = &cts { | 589 | if let Some(pin) = &cts { |
| 590 | pin.io().ctrl().write(|w| { | 590 | pin.gpio().ctrl().write(|w| { |
| 591 | w.set_funcsel(2); | 591 | w.set_funcsel(2); |
| 592 | w.set_inover(if config.invert_cts { | 592 | w.set_inover(if config.invert_cts { |
| 593 | Inover::INVERT | 593 | Inover::INVERT |
| @@ -598,7 +598,7 @@ impl<'d, T: Instance + 'd, M: Mode> Uart<'d, T, M> { | |||
| 598 | pin.pad_ctrl().write(|w| w.set_ie(true)); | 598 | pin.pad_ctrl().write(|w| w.set_ie(true)); |
| 599 | } | 599 | } |
| 600 | if let Some(pin) = &rts { | 600 | if let Some(pin) = &rts { |
| 601 | pin.io().ctrl().write(|w| { | 601 | pin.gpio().ctrl().write(|w| { |
| 602 | w.set_funcsel(2); | 602 | w.set_funcsel(2); |
| 603 | w.set_outover(if config.invert_rts { | 603 | w.set_outover(if config.invert_rts { |
| 604 | Outover::INVERT | 604 | Outover::INVERT |
