Struct Pins

Source
pub struct Pins {
Show 21 fields pub tx0: Pin<Gpio0, <Gpio0 as DefaultTypeState>::Function, <Gpio0 as DefaultTypeState>::PullType>, pub rx0: Pin<Gpio1, <Gpio1 as DefaultTypeState>::Function, <Gpio1 as DefaultTypeState>::PullType>, pub gpio2: Pin<Gpio2, <Gpio2 as DefaultTypeState>::Function, <Gpio2 as DefaultTypeState>::PullType>, pub gpio3: Pin<Gpio3, <Gpio3 as DefaultTypeState>::Function, <Gpio3 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 tx1: Pin<Gpio8, <Gpio8 as DefaultTypeState>::Function, <Gpio8 as DefaultTypeState>::PullType>, pub rx1: Pin<Gpio9, <Gpio9 as DefaultTypeState>::Function, <Gpio9 as DefaultTypeState>::PullType>, pub sda: Pin<Gpio16, <Gpio16 as DefaultTypeState>::Function, <Gpio16 as DefaultTypeState>::PullType>, pub scl: Pin<Gpio17, <Gpio17 as DefaultTypeState>::Function, <Gpio17 as DefaultTypeState>::PullType>, pub cipo: Pin<Gpio20, <Gpio20 as DefaultTypeState>::Function, <Gpio20 as DefaultTypeState>::PullType>, pub ncs: Pin<Gpio21, <Gpio21 as DefaultTypeState>::Function, <Gpio21 as DefaultTypeState>::PullType>, pub sck: Pin<Gpio22, <Gpio22 as DefaultTypeState>::Function, <Gpio22 as DefaultTypeState>::PullType>, pub copi: Pin<Gpio23, <Gpio23 as DefaultTypeState>::Function, <Gpio23 as DefaultTypeState>::PullType>, pub led: Pin<Gpio25, <Gpio25 as DefaultTypeState>::Function, <Gpio25 as DefaultTypeState>::PullType>, pub adc0: Pin<Gpio26, <Gpio26 as DefaultTypeState>::Function, <Gpio26 as DefaultTypeState>::PullType>, pub adc1: Pin<Gpio27, <Gpio27 as DefaultTypeState>::Function, <Gpio27 as DefaultTypeState>::PullType>, pub adc2: Pin<Gpio28, <Gpio28 as DefaultTypeState>::Function, <Gpio28 as DefaultTypeState>::PullType>, pub adc3: Pin<Gpio29, <Gpio29 as DefaultTypeState>::Function, <Gpio29 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§

§tx0: Pin<Gpio0, <Gpio0 as DefaultTypeState>::Function, <Gpio0 as DefaultTypeState>::PullType>§rx0: Pin<Gpio1, <Gpio1 as DefaultTypeState>::Function, <Gpio1 as DefaultTypeState>::PullType>§gpio2: Pin<Gpio2, <Gpio2 as DefaultTypeState>::Function, <Gpio2 as DefaultTypeState>::PullType>§gpio3: Pin<Gpio3, <Gpio3 as DefaultTypeState>::Function, <Gpio3 as DefaultTypeState>::PullType>§gpio4: Pin<Gpio4, <Gpio4 as DefaultTypeState>::Function, <Gpio4 as DefaultTypeState>::PullType>§gpio5: Pin<Gpio5, <Gpio5 as DefaultTypeState>::Function, <Gpio5 as DefaultTypeState>::PullType>§gpio6: Pin<Gpio6, <Gpio6 as DefaultTypeState>::Function, <Gpio6 as DefaultTypeState>::PullType>§gpio7: Pin<Gpio7, <Gpio7 as DefaultTypeState>::Function, <Gpio7 as DefaultTypeState>::PullType>§tx1: Pin<Gpio8, <Gpio8 as DefaultTypeState>::Function, <Gpio8 as DefaultTypeState>::PullType>§rx1: Pin<Gpio9, <Gpio9 as DefaultTypeState>::Function, <Gpio9 as DefaultTypeState>::PullType>§sda: Pin<Gpio16, <Gpio16 as DefaultTypeState>::Function, <Gpio16 as DefaultTypeState>::PullType>§scl: Pin<Gpio17, <Gpio17 as DefaultTypeState>::Function, <Gpio17 as DefaultTypeState>::PullType>§cipo: Pin<Gpio20, <Gpio20 as DefaultTypeState>::Function, <Gpio20 as DefaultTypeState>::PullType>§ncs: Pin<Gpio21, <Gpio21 as DefaultTypeState>::Function, <Gpio21 as DefaultTypeState>::PullType>§sck: Pin<Gpio22, <Gpio22 as DefaultTypeState>::Function, <Gpio22 as DefaultTypeState>::PullType>§copi: Pin<Gpio23, <Gpio23 as DefaultTypeState>::Function, <Gpio23 as DefaultTypeState>::PullType>§led: Pin<Gpio25, <Gpio25 as DefaultTypeState>::Function, <Gpio25 as DefaultTypeState>::PullType>§adc0: Pin<Gpio26, <Gpio26 as DefaultTypeState>::Function, <Gpio26 as DefaultTypeState>::PullType>§adc1: Pin<Gpio27, <Gpio27 as DefaultTypeState>::Function, <Gpio27 as DefaultTypeState>::PullType>§adc2: Pin<Gpio28, <Gpio28 as DefaultTypeState>::Function, <Gpio28 as DefaultTypeState>::PullType>§adc3: Pin<Gpio29, <Gpio29 as DefaultTypeState>::Function, <Gpio29 as DefaultTypeState>::PullType>

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.