diff options
author | Matt Johnston <matt@ucc.asn.au> | 2022-10-08 11:35:11 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2022-10-08 11:44:06 +0800 |
commit | aa8ba2115c4606b53dedce1af2da5de2fd59f563 (patch) | |
tree | 42f8aa4de9dd5cfe83f0746a678a50c7b67e4469 | |
parent | f8fd6ab208fd09142ab9789078e9b23ba8c3e6a9 (diff) | |
download | embassy-aa8ba2115c4606b53dedce1af2da5de2fd59f563.zip |
Expose Pin::pin() and Pin::bank() as public
-rw-r--r-- | embassy-rp/src/gpio.rs | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index a28bae96..f79f592b 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs @@ -599,12 +599,12 @@ pub(crate) mod sealed { fn pin_bank(&self) -> u8; #[inline] - fn pin(&self) -> u8 { + fn _pin(&self) -> u8 { self.pin_bank() & 0x1f } #[inline] - fn bank(&self) -> Bank { + fn _bank(&self) -> Bank { if self.pin_bank() & 0x20 == 0 { Bank::Bank0 } else { @@ -613,35 +613,35 @@ pub(crate) mod sealed { } fn io(&self) -> pac::io::Gpio { - let block = match self.bank() { + let block = match self._bank() { Bank::Bank0 => crate::pac::IO_BANK0, Bank::Qspi => crate::pac::IO_QSPI, }; - block.gpio(self.pin() as _) + block.gpio(self._pin() as _) } fn pad_ctrl(&self) -> Reg<pac::pads::regs::GpioCtrl, RW> { - let block = match self.bank() { + let block = match self._bank() { Bank::Bank0 => crate::pac::PADS_BANK0, Bank::Qspi => crate::pac::PADS_QSPI, }; - block.gpio(self.pin() as _) + block.gpio(self._pin() as _) } fn sio_out(&self) -> pac::sio::Gpio { - SIO.gpio_out(self.bank() as _) + SIO.gpio_out(self._bank() as _) } fn sio_oe(&self) -> pac::sio::Gpio { - SIO.gpio_oe(self.bank() as _) + SIO.gpio_oe(self._bank() as _) } fn sio_in(&self) -> Reg<u32, RW> { - SIO.gpio_in(self.bank() as _) + SIO.gpio_in(self._bank() as _) } fn int_proc(&self) -> pac::io::Int { - let io_block = match self.bank() { + let io_block = match self._bank() { Bank::Bank0 => crate::pac::IO_BANK0, Bank::Qspi => crate::pac::IO_QSPI, }; @@ -658,6 +658,18 @@ pub trait Pin: Peripheral<P = Self> + Into<AnyPin> + sealed::Pin + Sized + 'stat pin_bank: self.pin_bank(), } } + + /// Returns the pin number within a bank + #[inline] + fn pin(&self) -> u8 { + self._pin() + } + + /// Returns the bank of this pin + #[inline] + fn bank(&self) -> Bank { + self._bank() + } } pub struct AnyPin { |