Struct Pins

Source
pub struct Pins {
Show 19 fields pub gpio0: Pin<Gpio0, <Gpio0 as DefaultTypeState>::Function, <Gpio0 as DefaultTypeState>::PullType>, pub gpio1: Pin<Gpio1, <Gpio1 as DefaultTypeState>::Function, <Gpio1 as DefaultTypeState>::PullType>, pub gpio16: Pin<Gpio16, <Gpio16 as DefaultTypeState>::Function, <Gpio16 as DefaultTypeState>::PullType>, pub gpio17: Pin<Gpio17, <Gpio17 as DefaultTypeState>::Function, <Gpio17 as DefaultTypeState>::PullType>, pub gpio4: Pin<Gpio4, <Gpio4 as DefaultTypeState>::Function, <Gpio4 as DefaultTypeState>::PullType>, pub gpio5: Pin<Gpio5, <Gpio5 as DefaultTypeState>::Function, <Gpio5 as DefaultTypeState>::PullType>, pub gpio6: Pin<Gpio6, <Gpio6 as DefaultTypeState>::Function, <Gpio6 as DefaultTypeState>::PullType>, pub gpio7: Pin<Gpio7, <Gpio7 as DefaultTypeState>::Function, <Gpio7 as DefaultTypeState>::PullType>, pub gpio8: Pin<Gpio8, <Gpio8 as DefaultTypeState>::Function, <Gpio8 as DefaultTypeState>::PullType>, pub gpio9: Pin<Gpio9, <Gpio9 as DefaultTypeState>::Function, <Gpio9 as DefaultTypeState>::PullType>, pub gpio29: Pin<Gpio29, <Gpio29 as DefaultTypeState>::Function, <Gpio29 as DefaultTypeState>::PullType>, pub gpio28: Pin<Gpio28, <Gpio28 as DefaultTypeState>::Function, <Gpio28 as DefaultTypeState>::PullType>, pub gpio27: Pin<Gpio27, <Gpio27 as DefaultTypeState>::Function, <Gpio27 as DefaultTypeState>::PullType>, pub gpio26: Pin<Gpio26, <Gpio26 as DefaultTypeState>::Function, <Gpio26 as DefaultTypeState>::PullType>, pub gpio22: Pin<Gpio22, <Gpio22 as DefaultTypeState>::Function, <Gpio22 as DefaultTypeState>::PullType>, pub gpio20: Pin<Gpio20, <Gpio20 as DefaultTypeState>::Function, <Gpio20 as DefaultTypeState>::PullType>, pub gpio23: Pin<Gpio23, <Gpio23 as DefaultTypeState>::Function, <Gpio23 as DefaultTypeState>::PullType>, pub gpio21: Pin<Gpio21, <Gpio21 as DefaultTypeState>::Function, <Gpio21 as DefaultTypeState>::PullType>, pub neopixel: Pin<Gpio25, <Gpio25 as DefaultTypeState>::Function, <Gpio25 as DefaultTypeState>::PullType>,
}
Expand description

BSP replacement for the HAL Pins type

This type is intended to provide more meaningful names for the given pins.

To enable specific functions of the pins you can use the [rp2040_hal::gpio::pin::Pin::into_function] function with one of:

like this:

 use rp2040_hal::{pac, gpio::{bank0::Gpio12, Pin, Pins}, sio::Sio};

 let mut peripherals = pac::Peripherals::take().unwrap();
 let sio = Sio::new(peripherals.SIO);
 let pins = Pins::new(peripherals.IO_BANK0,peripherals.PADS_BANK0,sio.gpio_bank0, &mut peripherals.RESETS);

 let _spi_sclk = pins.gpio2.into_function::<rp2040_hal::gpio::FunctionSpi>();
 let _spi_mosi = pins.gpio3.into_function::<rp2040_hal::gpio::FunctionSpi>();
 let _spi_miso = pins.gpio4.into_function::<rp2040_hal::gpio::FunctionSpi>();

See also rp2040_hal::gpio for more in depth information about this!

Fields§

§gpio0: Pin<Gpio0, <Gpio0 as DefaultTypeState>::Function, <Gpio0 as DefaultTypeState>::PullType>

GPIO 0 supports following functions:

FunctionAlias with applied function
SPI0 RXcrate::Gp0Spi0Rx
UART0 TXcrate::Gp0Uart0Tx
I2C0 SDAcrate::Gp0I2C0Sda
PWM0 Acrate::Gp0Pwm0A
PIO0crate::Gp0Pio0
PIO1crate::Gp0Pio1
§gpio1: Pin<Gpio1, <Gpio1 as DefaultTypeState>::Function, <Gpio1 as DefaultTypeState>::PullType>

GPIO 1 supports following functions:

FunctionAlias with applied function
SPI0 CSncrate::Gp1Spi0Csn
UART0 RXcrate::Gp1Uart0Rx
I2C0 SCLcrate::Gp1I2C0Scl
PWM0 Bcrate::Gp1Pwm0B
PIO0crate::Gp1Pio0
PIO1crate::Gp1Pio1
§gpio16: Pin<Gpio16, <Gpio16 as DefaultTypeState>::Function, <Gpio16 as DefaultTypeState>::PullType>

GPIO 16 supports following functions:

FunctionAlias with applied function
SPI0 RXcrate::Gp16Spi0Rx
UART0 TXcrate::Gp16Uart0Tx
I2C0 SDAcrate::Gp16I2C0Sda
PWM0 Acrate::Gp16Pwm0A
PIO0crate::Gp16Pio0
PIO1crate::Gp16Pio1
§gpio17: Pin<Gpio17, <Gpio17 as DefaultTypeState>::Function, <Gpio17 as DefaultTypeState>::PullType>

GPIO 17 supports following functions:

FunctionAlias with applied function
SPI0 CSncrate::Gp17Spi0Csn
UART0 RXcrate::Gp17Uart0Rx
I2C0 SCLcrate::Gp17I2C0Scl
PWM0 Bcrate::Gp17Pwm0B
PIO0crate::Gp17Pio0
PIO1crate::Gp17Pio1
§gpio4: Pin<Gpio4, <Gpio4 as DefaultTypeState>::Function, <Gpio4 as DefaultTypeState>::PullType>

GPIO 4 supports following functions:

FunctionAlias with applied function
SPI0 RXcrate::Gp4Spi0Rx
UART1 TXcrate::Gp4Uart1Tx
I2C0 SDAcrate::Gp4I2C0Sda
PWM2 Acrate::Gp4Pwm2A
PIO0crate::Gp4Pio0
PIO1crate::Gp4Pio1
§gpio5: Pin<Gpio5, <Gpio5 as DefaultTypeState>::Function, <Gpio5 as DefaultTypeState>::PullType>

GPIO 5 supports following functions:

FunctionAlias with applied function
SPI0 CSncrate::Gp5Spi0Csn
UART1 RXcrate::Gp5Uart1Rx
I2C0 SCLcrate::Gp5I2C0Scl
PWM2 Bcrate::Gp5Pwm2B
PIO0crate::Gp5Pio0
PIO1crate::Gp5Pio1
§gpio6: Pin<Gpio6, <Gpio6 as DefaultTypeState>::Function, <Gpio6 as DefaultTypeState>::PullType>

GPIO 6 supports following functions:

FunctionAlias with applied function
SPI0 SCKcrate::Gp6Spi0Sck
UART1 CTScrate::Gp6Uart1Cts
I2C1 SDAcrate::Gp6I2C1Sda
PWM3 Acrate::Gp6Pwm3A
PIO0crate::Gp6Pio0
PIO1crate::Gp6Pio1
§gpio7: Pin<Gpio7, <Gpio7 as DefaultTypeState>::Function, <Gpio7 as DefaultTypeState>::PullType>

GPIO 7 supports following functions:

FunctionAlias with applied function
SPI0 TXcrate::Gp7Spi0Tx
UART1 RTScrate::Gp7Uart1Rts
I2C1 SCLcrate::Gp7I2C1Scl
PWM3 Bcrate::Gp7Pwm3B
PIO0crate::Gp7Pio0
PIO1crate::Gp7Pio1
§gpio8: Pin<Gpio8, <Gpio8 as DefaultTypeState>::Function, <Gpio8 as DefaultTypeState>::PullType>

GPIO 8 supports following functions:

FunctionAlias with applied function
SPI1 RXcrate::Gp8Spi1Rx
UART1 TXcrate::Gp8Uart1Tx
I2C0 SDAcrate::Gp8I2C0Sda
PWM4 Acrate::Gp8Pwm4A
PIO0crate::Gp8Pio0
PIO1crate::Gp8Pio1
§gpio9: Pin<Gpio9, <Gpio9 as DefaultTypeState>::Function, <Gpio9 as DefaultTypeState>::PullType>

GPIO 9 supports following functions:

FunctionAlias with applied function
SPI1 CSncrate::Gp9Spi1Csn
UART1 RXcrate::Gp9Uart1Rx
I2C0 SCLcrate::Gp9I2C0Scl
PWM4 Bcrate::Gp9Pwm4B
PIO0crate::Gp9Pio0
PIO1crate::Gp9Pio1
§gpio29: Pin<Gpio29, <Gpio29 as DefaultTypeState>::Function, <Gpio29 as DefaultTypeState>::PullType>

GPIO 29 supports following functions:

FunctionAlias with applied function
SPI1 CSncrate::Gp29Spi1Csn
UART0 RXcrate::Gp29Uart0Rx
I2C0 SCLcrate::Gp29I2C0Scl
PWM4 Bcrate::Gp29Pwm6B
PIO0crate::Gp29Pio0
PIO1crate::Gp29Pio1
§gpio28: Pin<Gpio28, <Gpio28 as DefaultTypeState>::Function, <Gpio28 as DefaultTypeState>::PullType>

GPIO 28 supports following functions:

FunctionAlias with applied function
SPI1 RXcrate::Gp28Spi1Rx
UART0 TXcrate::Gp28Uart0Tx
I2C0 SDAcrate::Gp28I2C0Sda
PWM6 Acrate::Gp28Pwm6A
PIO0crate::Gp28Pio0
PIO1crate::Gp28Pio1
§gpio27: Pin<Gpio27, <Gpio27 as DefaultTypeState>::Function, <Gpio27 as DefaultTypeState>::PullType>

GPIO 27 supports following functions:

FunctionAlias with applied function
SPI1 TXcrate::Gp27Spi1Tx
UART1 RTScrate::Gp27Uart1Rts
I2C1 SCLcrate::Gp27I2C1Scl
PWM5 Bcrate::Gp27Pwm5B
PIO0crate::Gp27Pio0
PIO1crate::Gp27Pio1
§gpio26: Pin<Gpio26, <Gpio26 as DefaultTypeState>::Function, <Gpio26 as DefaultTypeState>::PullType>

GPIO 26 supports following functions:

FunctionAlias with applied function
SPI1 SCKcrate::Gp26Spi1Sck
UART1 CTScrate::Gp26Uart1Cts
I2C1 SDAcrate::Gp26I2C1Sda
PWM5 Acrate::Gp26Pwm5A
PIO0crate::Gp26Pio0
PIO1crate::Gp26Pio1
§gpio22: Pin<Gpio22, <Gpio22 as DefaultTypeState>::Function, <Gpio22 as DefaultTypeState>::PullType>

GPIO 22 supports following functions:

FunctionAlias with applied function
SPI0 SCKcrate::Gp22Spi0Sck
UART1 CTScrate::Gp22Uart1Cts
I2C1 SDAcrate::Gp22I2C1Sda
PWM3 Acrate::Gp22Pwm3A
PIO0crate::Gp22Pio0
PIO1crate::Gp22Pio1
§gpio20: Pin<Gpio20, <Gpio20 as DefaultTypeState>::Function, <Gpio20 as DefaultTypeState>::PullType>

GPIO 20 supports following functions:

FunctionAlias with applied function
SPI0 RXcrate::Gp20Spi0Rx
UART1 TXcrate::Gp20Uart1Tx
I2C0 SDAcrate::Gp20I2C0Sda
PWM2 Acrate::Gp20Pwm2A
PIO0crate::Gp20Pio0
PIO1crate::Gp20Pio1
§gpio23: Pin<Gpio23, <Gpio23 as DefaultTypeState>::Function, <Gpio23 as DefaultTypeState>::PullType>

GPIO 23 supports following functions:

FunctionAlias with applied function
SPI0 TXcrate::Gp23Spi0Tx
UART1 RTScrate::Gp23Uart1Rts
I2C1 SCLcrate::Gp23I2C1Scl
PWM3 Bcrate::Gp23Pwm3B
PIO0crate::Gp23Pio0
PIO1crate::Gp23Pio1
§gpio21: Pin<Gpio21, <Gpio21 as DefaultTypeState>::Function, <Gpio21 as DefaultTypeState>::PullType>

GPIO 21 supports following functions:

FunctionAlias with applied function
SPI0 CSncrate::Gp21Spi0Csn
UART1 RXcrate::Gp21Uart1Rx
I2C0 SCLcrate::Gp21I2C0Scl
PWM2 Bcrate::Gp21Pwm2B
PIO0crate::Gp21Pio0
PIO1crate::Gp21Pio1
§neopixel: Pin<Gpio25, <Gpio25 as DefaultTypeState>::Function, <Gpio25 as DefaultTypeState>::PullType>

GPIO 25 is connected to a neopixel on the top right of the board

Implementations§

Source§

impl Pins

Source

pub fn new( io: IO_BANK0, pads: PADS_BANK0, sio: SioGpioBank0, reset: &mut RESETS, ) -> Self

Take ownership of the PAC [PORT] and split it into discrete [Pin]s.

This struct serves as a replacement for the HAL Pins struct. It is intended to provide more meaningful names for each [Pin] in a BSP. Any [Pin] not defined by the BSP is dropped.

Pin Pins

Auto Trait Implementations§

§

impl Freeze for Pins

§

impl RefUnwindSafe for Pins

§

impl Send for Pins

§

impl Sync for Pins

§

impl Unpin for Pins

§

impl UnwindSafe for Pins

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Choices> CoproductSubsetter<CNil, HNil> for Choices

Source§

type Remainder = Choices

Source§

fn subset( self, ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

Source§

fn lift_into(self) -> U

Performs the indexed conversion.
Source§

impl<Source> Sculptor<HNil, HNil> for Source

Source§

type Remainder = Source

Source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.