Pin

Struct Pin 

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

Generic pin type

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

Implementations§

Source§

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

Source

pub fn into_alternate<const A: u8>( self, _moder: &mut MODER<P>, _otyper: &mut OTYPER<P>, _afr: &mut Afr<HL, P>, ) -> Pin<Alternate<PushPull, A>, HL, P, N>

Configures the pin to operate alternate mode

Source

pub fn into_alternate_push_pull<const A: u8>( self, moder: &mut MODER<P>, otyper: &mut OTYPER<P>, afr: &mut Afr<HL, P>, ) -> Pin<Alternate<PushPull, A>, HL, P, N>

Configures the pin to operate alternate mode (alias for into_alternate)

Source

pub fn into_alternate_open_drain<const A: u8>( self, moder: &mut MODER<P>, otyper: &mut OTYPER<P>, afr: &mut Afr<HL, P>, ) -> Pin<Alternate<OpenDrain, A>, HL, P, N>

Configures the pin to operate in alternate open drain mode

Source

pub fn into_floating_input( self, _moder: &mut MODER<P>, _pupdr: &mut PUPDR<P>, ) -> Pin<Input<Floating>, HL, P, N>

Configures the pin to operate as a floating input pin

Source

pub fn into_pull_down_input( self, _moder: &mut MODER<P>, _pupdr: &mut PUPDR<P>, ) -> Pin<Input<PullDown>, HL, P, N>

Configures the pin to operate as a pulled down input pin

Source

pub fn into_pull_up_input( self, _moder: &mut MODER<P>, _pupdr: &mut PUPDR<P>, ) -> Pin<Input<PullUp>, HL, P, N>

Configures the pin to operate as a pulled up input pin

Source

pub fn into_open_drain_output( self, _moder: &mut MODER<P>, _otyper: &mut OTYPER<P>, ) -> Pin<Output<OpenDrain>, HL, P, N>

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

Source

pub fn into_open_drain_output_in_state( self, _moder: &mut MODER<P>, _otyper: &mut OTYPER<P>, initial_state: PinState, ) -> Pin<Output<OpenDrain>, HL, P, N>

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, _moder: &mut MODER<P>, _otyper: &mut OTYPER<P>, ) -> Pin<Output<PushPull>, HL, P, N>

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

Source

pub fn into_push_pull_output_in_state( self, _moder: &mut MODER<P>, _otyper: &mut OTYPER<P>, initial_state: PinState, ) -> Pin<Output<PushPull>, HL, P, N>

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, _moder: &mut MODER<P>, _pupdr: &mut PUPDR<P>, ) -> Pin<Analog, HL, P, N>

Configures the pin to operate as an analog input pin

Source§

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

Source

pub fn with_floating_input<R>( &mut self, f: impl FnOnce(&mut Pin<Input<Floating>, HL, P, N>) -> R, ) -> R

Temporarily configures this pin as a floating input.

The closure f is called with the reconfigured pin. After it returns, the pin will be configured back.

Source

pub fn with_pull_down_input<R>( &mut self, f: impl FnOnce(&mut Pin<Input<PullDown>, HL, P, N>) -> R, ) -> R

Temporarily configures this pin as a pulled-down input.

The closure f is called with the reconfigured pin. After it returns, the pin will be configured back.

Source

pub fn with_pull_up_input<R>( &mut self, f: impl FnOnce(&mut Pin<Input<PullUp>, HL, P, N>) -> R, ) -> R

Temporarily configures this pin as a pulled-up input.

The closure f is called with the reconfigured pin. After it returns, the pin will be configured back.

Source

pub fn with_analog<R>( &mut self, f: impl FnOnce(&mut Pin<Analog, HL, P, N>) -> R, ) -> R

Temporarily configures this pin as an analog pin.

The closure f is called with the reconfigured pin. After it returns, the pin will be configured back.

Source

pub fn with_open_drain_output<R>( &mut self, f: impl FnOnce(&mut Pin<Output<OpenDrain>, HL, P, N>) -> R, ) -> R

Temporarily configures this pin as an open drain output.

The closure f is called with the reconfigured pin. After it returns, the pin will be configured back. The value of the pin after conversion is undefined. If you want to control it, use with_open_drain_output_in_state

Source

pub fn with_open_drain_output_in_state<R>( &mut self, state: PinState, f: impl FnOnce(&mut Pin<Output<OpenDrain>, HL, P, N>) -> R, ) -> R

Temporarily configures this pin as an open drain output .

The closure f is called with the reconfigured pin. After it returns, the pin will be configured back. 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 with_push_pull_output<R>( &mut self, f: impl FnOnce(&mut Pin<Output<PushPull>, HL, P, N>) -> R, ) -> R

Temporarily configures this pin as a push-pull output.

The closure f is called with the reconfigured pin. After it returns, the pin will be configured back. The value of the pin after conversion is undefined. If you want to control it, use with_push_pull_output_in_state

Source

pub fn with_push_pull_output_in_state<R>( &mut self, state: PinState, f: impl FnOnce(&mut Pin<Output<PushPull>, HL, P, N>) -> R, ) -> R

Temporarily configures this pin as a push-pull output.

The closure f is called with the reconfigured pin. After it returns, the pin will be configured back. Note that the new state is set slightly before conversion happens. This can cause a short output glitch if switching between output modes

Source§

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

Source

pub fn set_speed(self, speed: Speed) -> Self

Set pin speed

Source§

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

Source

pub fn internal_pull_up(&mut self, _pupdr: &mut PUPDR<P>, on: bool)

Enables / disables the internal pull up

Source§

impl<MODE, HL, const P: char, const N: u8, const A: u8> Pin<Alternate<MODE, A>, HL, P, N>

Source

pub fn set_speed(self, speed: Speed) -> Self

Set pin speed

Source

pub fn internal_pull_up(&mut self, _pupdr: &mut PUPDR<P>, on: bool)

Enables / disables the internal pull up

Source§

impl<HL, const P: char, const N: u8, const A: u8> Pin<Alternate<PushPull, A>, HL, P, N>

Source

pub fn set_open_drain(self) -> Pin<Alternate<OpenDrain, A>, HL, P, N>

Turns pin alternate configuration pin into open drain

Source§

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

Source

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

Erases the pin number 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

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

Erases the pin number and the 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<MODE, HL, const P: char, const N: u8> Pin<Output<MODE>, HL, P, N>

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

Source

pub fn is_high(&self) -> bool

Source

pub fn is_low(&self) -> bool

Source§

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

Source

pub fn is_high(&self) -> bool

Source

pub fn is_low(&self) -> bool

Trait Implementations§

Source§

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

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

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

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

Source§

type Mode = MODE

Source§

fn pin_id(&self) -> u8

Return pin number
Source§

fn port_id(&self) -> u8

Return port number
Source§

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

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

Source§

type Error = Infallible

Error type
Source§

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

Toggle pin output.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<MODE, HL, const P: char, const N: u8> UnwindSafe for Pin<MODE, HL, P, N>
where MODE: UnwindSafe, HL: 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.