Struct atsamd_hal::gpio::dynpin::DynPin

source ·
pub struct DynPin { /* private fields */ }
Expand description

A value-level pin, parameterized by DynPinId and DynPinMode

This type acts as a type-erased version of Pin. Every pin is represented by the same type, and pins are tracked and distinguished at run-time.

Implementations§

source§

impl DynPin

source

pub fn id(&self) -> DynPinId

Return a copy of the pin ID

source

pub fn mode(&self) -> DynPinMode

Return a copy of the pin mode

source

pub fn into_mode(&mut self, mode: DynPinMode)

Convert the pin to the requested DynPinMode

source

pub fn into_floating_disabled(&mut self)

Disable the pin and set it to float

source

pub fn into_pull_down_disabled(&mut self)

Disable the pin and set it to pull down

source

pub fn into_pull_up_disabled(&mut self)

Disable the pin and set it to pull up

source

pub fn into_floating_input(&mut self)

Configure the pin to operate as a floating input

source

pub fn into_pull_down_input(&mut self)

Configure the pin to operate as a pulled down input

source

pub fn into_pull_up_input(&mut self)

Configure the pin to operate as a pulled up input

source

pub fn into_floating_interrupt(&mut self)

Configure the pin to operate as a floating interrupt

source

pub fn into_pull_down_interrupt(&mut self)

Configure the pin to operate as a pulled down interrupt

source

pub fn into_pull_up_interrupt(&mut self)

Configure the pin to operate as a pulled up interrupt

source

pub fn into_push_pull_output(&mut self)

Configure the pin to operate as a push-pull output

source

pub fn into_readable_output(&mut self)

Configure the pin to operate as a readable push pull output

source

pub fn into_alternate(&mut self, config: DynAlternate)

Configure the pin to operate as the corresponding peripheral function.

The config argument indicates the desired peripheral function.

source

pub fn get_drive_strength(&self) -> bool

Read the current drive strength of the pin.

The drive strength is reset to normal on every change in pin mode.

source

pub fn set_drive_strength(&mut self, stronger: bool)

Set the drive strength for the pin.

The drive strength is reset to normal on every change in pin mode.

Trait Implementations§

source§

impl<I, M> From<Pin<I, M>> for DynPinwhere I: PinId, M: PinMode,

source§

fn from(_pin: Pin<I, M>) -> Self

Erase the type-level information in a Pin and return a value-level DynPin

source§

impl InputPin for DynPin

§

type Error = Error

Error type
source§

fn is_high(&self) -> Result<bool, Self::Error>

Is the input pin high?
source§

fn is_low(&self) -> Result<bool, Self::Error>

Is the input pin low?
source§

impl OutputPin for DynPin

§

type Error = Error

Error type
source§

fn set_high(&mut self) -> Result<(), Self::Error>

Drives the pin high Read more
source§

fn set_low(&mut self) -> Result<(), Self::Error>

Drives the pin low Read more
source§

fn set_state(&mut self, state: PinState) -> Result<(), Self::Error>

Drives the pin high or low depending on the provided value Read more
source§

impl StatefulOutputPin for DynPin

source§

fn is_set_high(&self) -> Result<bool, Self::Error>

Is the pin in drive high mode? Read more
source§

fn is_set_low(&self) -> Result<bool, Self::Error>

Is the pin in drive low mode? Read more
source§

impl ToggleableOutputPin for DynPin

§

type Error = Error

Error type
source§

fn toggle(&mut self) -> Result<(), Self::Error>

Toggle pin output.
source§

impl<I, M> TryFrom<DynPin> for Pin<I, M>where I: PinId, M: PinMode,

source§

fn try_from(pin: DynPin) -> Result<Self, Error>

Try to recreate a type-level Pin from a value-level DynPin

There is no way for the compiler to know if the conversion will be successful at compile-time. We must verify the conversion at run-time or refuse to perform it.

§

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.