Struct Pin

Source
pub struct Pin<const P: char, const N: u8, MODE = Input<Floating>> { /* private fields */ }
Expand description

Generic pin type

  • P is port name: A for GPIOA, B for GPIOB, etc.
  • N is pin number: from 0 to 15.
  • MODE is one of the pin modes (see Modes section).

Implementations§

Source§

impl<const N: u8, MODE> Pin<'A', N, MODE>
where MODE: Active,

Source

pub fn erase(self) -> ErasedPin<MODE>

Erases the pin number and port from the type

This is useful when you want to collect the pins into an array where you need all the elements to have the same type

Source§

impl<const N: u8, MODE> Pin<'B', N, MODE>
where MODE: Active,

Source

pub fn erase(self) -> ErasedPin<MODE>

Erases the pin number and port from the type

This is useful when you want to collect the pins into an array where you need all the elements to have the same type

Source§

impl<const N: u8, MODE> Pin<'C', N, MODE>
where MODE: Active,

Source

pub fn erase(self) -> ErasedPin<MODE>

Erases the pin number and port from the type

This is useful when you want to collect the pins into an array where you need all the elements to have the same type

Source§

impl<const N: u8, MODE> Pin<'D', N, MODE>
where MODE: Active,

Source

pub fn erase(self) -> ErasedPin<MODE>

Erases the pin number and port from the type

This is useful when you want to collect the pins into an array where you need all the elements to have the same type

Source§

impl<const N: u8, MODE> Pin<'E', N, MODE>
where MODE: Active,

Source

pub fn erase(self) -> ErasedPin<MODE>

Erases the pin number and port from the type

This is useful when you want to collect the pins into an array where you need all the elements to have the same type

Source§

impl<const N: u8, MODE> Pin<'F', N, MODE>
where MODE: Active,

Source

pub fn erase(self) -> ErasedPin<MODE>

Erases the pin number and port from the type

This is useful when you want to collect the pins into an array where you need all the elements to have the same type

Source§

impl<const N: u8, MODE> Pin<'G', N, MODE>
where MODE: Active,

Source

pub fn erase(self) -> ErasedPin<MODE>

Erases the pin number and port from the type

This is useful when you want to collect the pins into an array where you need all the elements to have the same type

Source§

impl<const P: char, const N: u8, MODE> Pin<P, N, MODE>
where MODE: Active,

Source

pub fn erase_number(self) -> PartiallyErasedPin<P, MODE>

Erases the pin number from the type

Source§

impl<const P: char, const N: u8, MODE> Pin<P, N, Output<MODE>>

Source

pub fn set_high(&mut self)

Source

pub fn set_low(&mut self)

Source

pub fn get_state(&self) -> PinState

Source

pub fn set_state(&mut self, state: PinState)

Source

pub fn is_set_high(&self) -> bool

Source

pub fn is_set_low(&self) -> bool

Source

pub fn toggle(&mut self)

Source§

impl<const P: char, const N: u8, MODE> Pin<P, N, Input<MODE>>

Source

pub fn is_high(&self) -> bool

Source

pub fn is_low(&self) -> bool

Source§

impl<const P: char, const N: u8> Pin<P, N, Output<OpenDrain>>

Source

pub fn is_high(&self) -> bool

Source

pub fn is_low(&self) -> bool

Source§

impl<const P: char, const N: u8, MODE> Pin<P, N, MODE>
where MODE: Active, Self: HL,

Source

pub fn into_alternate_push_pull( self, cr: &mut <Self as HL>::Cr, ) -> Pin<P, N, Alternate<PushPull>>

Configures the pin to operate as an alternate function push-pull output pin.

Source

pub fn into_alternate_open_drain( self, cr: &mut <Self as HL>::Cr, ) -> Pin<P, N, Alternate<OpenDrain>>

Configures the pin to operate as an alternate function open-drain output pin.

Source

pub fn into_floating_input( self, cr: &mut <Self as HL>::Cr, ) -> Pin<P, N, Input<Floating>>

Configures the pin to operate as a floating input pin

Source

pub fn into_pull_down_input( self, cr: &mut <Self as HL>::Cr, ) -> Pin<P, N, Input<PullDown>>

Configures the pin to operate as a pulled down input pin

Source

pub fn into_pull_up_input( self, cr: &mut <Self as HL>::Cr, ) -> Pin<P, N, Input<PullUp>>

Configures the pin to operate as a pulled up input pin

Source

pub fn into_open_drain_output( self, cr: &mut <Self as HL>::Cr, ) -> Pin<P, N, Output<OpenDrain>>

Configures the pin to operate as an open-drain output pin. Initial state will be low.

Source

pub fn into_open_drain_output_with_state( self, cr: &mut <Self as HL>::Cr, initial_state: PinState, ) -> Pin<P, N, Output<OpenDrain>>

Configures the pin to operate as an open-drain output pin. initial_state specifies whether the pin should be initially high or low.

Source

pub fn into_push_pull_output( self, cr: &mut <Self as HL>::Cr, ) -> Pin<P, N, Output<PushPull>>

Configures the pin to operate as an push-pull output pin. Initial state will be low.

Source

pub fn into_push_pull_output_with_state( self, cr: &mut <Self as HL>::Cr, initial_state: PinState, ) -> Pin<P, N, Output<PushPull>>

Configures the pin to operate as an push-pull output pin. initial_state specifies whether the pin should be initially high or low.

Source

pub fn into_analog(self, cr: &mut <Self as HL>::Cr) -> Pin<P, N, Analog>

Configures the pin to operate as an analog input pin

Source

pub fn into_dynamic(self, cr: &mut <Self as HL>::Cr) -> Pin<P, N, Dynamic>

Configures the pin as a pin that can change between input and output without changing the type. It starts out as a floating input

Source§

impl<const P: char, const N: u8, MODE> Pin<P, N, MODE>
where MODE: Active + PinMode, Self: HL,

Source

pub fn as_push_pull_output( &mut self, cr: &mut <Self as HL>::Cr, f: impl FnMut(&mut Pin<P, N, Output<PushPull>>), )

Temporarily change the mode of the pin.

The value of the pin after conversion is undefined. If you want to control it, use $stateful_fn_name

Source

pub fn as_push_pull_output_with_state( &mut self, cr: &mut <Self as HL>::Cr, state: PinState, f: impl FnMut(&mut Pin<P, N, Output<PushPull>>), )

Temporarily change the mode of the pin.

Note that the new state is set slightly before conversion happens. This can cause a short output glitch if switching between output modes

Source

pub fn as_open_drain_output( &mut self, cr: &mut <Self as HL>::Cr, f: impl FnMut(&mut Pin<P, N, Output<OpenDrain>>), )

Temporarily change the mode of the pin.

The value of the pin after conversion is undefined. If you want to control it, use $stateful_fn_name

Source

pub fn as_open_drain_output_with_state( &mut self, cr: &mut <Self as HL>::Cr, state: PinState, f: impl FnMut(&mut Pin<P, N, Output<OpenDrain>>), )

Temporarily change the mode of the pin.

Note that the new state is set slightly before conversion happens. This can cause a short output glitch if switching between output modes

Source

pub fn as_floating_input( &mut self, cr: &mut <Self as HL>::Cr, f: impl FnMut(&mut Pin<P, N, Input<Floating>>), )

Temporarily change the mode of the pin.

Source

pub fn as_pull_up_input( &mut self, cr: &mut <Self as HL>::Cr, f: impl FnMut(&mut Pin<P, N, Input<PullUp>>), )

Temporarily change the mode of the pin.

Source

pub fn as_pull_down_input( &mut self, cr: &mut <Self as HL>::Cr, f: impl FnMut(&mut Pin<P, N, Input<PullDown>>), )

Temporarily change the mode of the pin.

Source§

impl<const P: char, const N: u8> Pin<P, N, Dynamic>
where Self: HL,

Source

pub fn make_pull_up_input(&mut self, cr: &mut <Self as HL>::Cr)

Source

pub fn make_pull_down_input(&mut self, cr: &mut <Self as HL>::Cr)

Source

pub fn make_floating_input(&mut self, cr: &mut <Self as HL>::Cr)

Source

pub fn make_push_pull_output(&mut self, cr: &mut <Self as HL>::Cr)

Source

pub fn make_open_drain_output(&mut self, cr: &mut <Self as HL>::Cr)

Trait Implementations§

Source§

impl<const P: char, MODE> HL for Pin<P, 0, MODE>

Source§

type Cr = Cr<P, false>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 1, MODE>

Source§

type Cr = Cr<P, false>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 10, MODE>

Source§

type Cr = Cr<P, true>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 11, MODE>

Source§

type Cr = Cr<P, true>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 12, MODE>

Source§

type Cr = Cr<P, true>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 13, MODE>

Source§

type Cr = Cr<P, true>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 14, MODE>

Source§

type Cr = Cr<P, true>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 15, MODE>

Source§

type Cr = Cr<P, true>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 2, MODE>

Source§

type Cr = Cr<P, false>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 3, MODE>

Source§

type Cr = Cr<P, false>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 4, MODE>

Source§

type Cr = Cr<P, false>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 5, MODE>

Source§

type Cr = Cr<P, false>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 6, MODE>

Source§

type Cr = Cr<P, false>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 7, MODE>

Source§

type Cr = Cr<P, false>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 8, MODE>

Source§

type Cr = Cr<P, true>

Configuration register associated to pin
Source§

impl<const P: char, MODE> HL for Pin<P, 9, MODE>

Source§

type Cr = Cr<P, true>

Configuration register associated to pin
Source§

impl<const P: char, const N: u8> InputPin for Pin<P, N, Dynamic>

Source§

type Error = PinModeError

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<const P: char, const N: u8, MODE> InputPin for Pin<P, N, Input<MODE>>

Source§

type Error = Infallible

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<const P: char, const N: u8> InputPin for Pin<P, N, Output<OpenDrain>>

Source§

type Error = Infallible

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<const P: char, const N: u8> OutputPin for Pin<P, N, Dynamic>

Source§

type Error = PinModeError

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<const P: char, const N: u8, MODE> OutputPin for Pin<P, N, Output<MODE>>

Source§

type Error = Infallible

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<const P: char, const N: u8> OutputSpeed for Pin<P, N, Alternate<PushPull>>
where Self: HL,

Source§

fn set_speed(&mut self, cr: &mut <Self as HL>::Cr, speed: IOPinSpeed)

Source§

impl<const P: char, const N: u8, MODE> OutputSpeed for Pin<P, N, Output<MODE>>
where Self: HL,

Source§

fn set_speed(&mut self, cr: &mut <Self as HL>::Cr, speed: IOPinSpeed)

Source§

impl<const P: char, const N: u8, MODE> PinExt for Pin<P, N, MODE>

Source§

type Mode = MODE

Source§

fn pin_id(&self) -> u8

Return pin number
Source§

fn port_id(&self) -> u8

Return port number
Source§

impl<const P: char, const N: u8, MODE> StatefulOutputPin for Pin<P, N, Output<MODE>>

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<const P: char, const N: u8, MODE> ToggleableOutputPin for Pin<P, N, Output<MODE>>

Source§

type Error = Infallible

Error type
Source§

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

Toggle pin output.

Auto Trait Implementations§

§

impl<const P: char, const N: u8, MODE> Freeze for Pin<P, N, MODE>
where MODE: Freeze,

§

impl<const P: char, const N: u8, MODE> RefUnwindSafe for Pin<P, N, MODE>
where MODE: RefUnwindSafe,

§

impl<const P: char, const N: u8, MODE> Send for Pin<P, N, MODE>
where MODE: Send,

§

impl<const P: char, const N: u8, MODE> Sync for Pin<P, N, MODE>
where MODE: Sync,

§

impl<const P: char, const N: u8, MODE> Unpin for Pin<P, N, MODE>
where MODE: Unpin,

§

impl<const P: char, const N: u8, MODE> UnwindSafe for Pin<P, N, MODE>
where MODE: UnwindSafe,

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<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, 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.