pub struct Pin<const P: char, const N: u8, MODE = Analog> { /* private fields */ }
Expand description
Generic pin type
MODE
is one of the pin modes (see Modes section).P
is port name:A
for GPIOA,B
for GPIOB, etc.N
is pin number: from0
to15
.
Implementations§
Source§impl<const P: char, const N: u8, const A: u8> Pin<P, N, Alternate<A, PushPull>>
impl<const P: char, const N: u8, const A: u8> Pin<P, N, Alternate<A, PushPull>>
Sourcepub fn set_open_drain(self) -> Pin<P, N, Alternate<A, OpenDrain>>
pub fn set_open_drain(self) -> Pin<P, N, Alternate<A, OpenDrain>>
Turns pin alternate configuration pin into open drain
Source§impl<const P: char, const N: u8, MODE: PinMode> Pin<P, N, MODE>
impl<const P: char, const N: u8, MODE: PinMode> Pin<P, N, MODE>
Sourcepub fn into_alternate<const A: u8>(self) -> Pin<P, N, Alternate<A, PushPull>>where
Self: IntoAf<A>,
pub fn into_alternate<const A: u8>(self) -> Pin<P, N, Alternate<A, PushPull>>where
Self: IntoAf<A>,
Configures the pin to operate alternate mode
Sourcepub fn into_alternate_af0(self) -> Pin<P, N, Alternate<0, PushPull>>where
Self: IntoAf<0>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af0(self) -> Pin<P, N, Alternate<0, PushPull>>where
Self: IntoAf<0>,
Configures the pin to operate in alternate function 0 mode
Sourcepub fn into_alternate_af1(self) -> Pin<P, N, Alternate<1, PushPull>>where
Self: IntoAf<1>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af1(self) -> Pin<P, N, Alternate<1, PushPull>>where
Self: IntoAf<1>,
Configures the pin to operate in alternate function 1 mode
Sourcepub fn into_alternate_af2(self) -> Pin<P, N, Alternate<2, PushPull>>where
Self: IntoAf<2>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af2(self) -> Pin<P, N, Alternate<2, PushPull>>where
Self: IntoAf<2>,
Configures the pin to operate in alternate function 2 mode
Sourcepub fn into_alternate_af3(self) -> Pin<P, N, Alternate<3, PushPull>>where
Self: IntoAf<3>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af3(self) -> Pin<P, N, Alternate<3, PushPull>>where
Self: IntoAf<3>,
Configures the pin to operate in alternate function 3 mode
Sourcepub fn into_alternate_af4(self) -> Pin<P, N, Alternate<4, PushPull>>where
Self: IntoAf<4>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af4(self) -> Pin<P, N, Alternate<4, PushPull>>where
Self: IntoAf<4>,
Configures the pin to operate in alternate function 4 mode
Sourcepub fn into_alternate_af5(self) -> Pin<P, N, Alternate<5, PushPull>>where
Self: IntoAf<5>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af5(self) -> Pin<P, N, Alternate<5, PushPull>>where
Self: IntoAf<5>,
Configures the pin to operate in alternate function 5 mode
Sourcepub fn into_alternate_af6(self) -> Pin<P, N, Alternate<6, PushPull>>where
Self: IntoAf<6>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af6(self) -> Pin<P, N, Alternate<6, PushPull>>where
Self: IntoAf<6>,
Configures the pin to operate in alternate function 6 mode
Sourcepub fn into_alternate_af7(self) -> Pin<P, N, Alternate<7, PushPull>>where
Self: IntoAf<7>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af7(self) -> Pin<P, N, Alternate<7, PushPull>>where
Self: IntoAf<7>,
Configures the pin to operate in alternate function 7 mode
Sourcepub fn into_alternate_af8(self) -> Pin<P, N, Alternate<8, PushPull>>where
Self: IntoAf<8>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af8(self) -> Pin<P, N, Alternate<8, PushPull>>where
Self: IntoAf<8>,
Configures the pin to operate in alternate function 8 mode
Sourcepub fn into_alternate_af9(self) -> Pin<P, N, Alternate<9, PushPull>>where
Self: IntoAf<9>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af9(self) -> Pin<P, N, Alternate<9, PushPull>>where
Self: IntoAf<9>,
Configures the pin to operate in alternate function 9 mode
Sourcepub fn into_alternate_af10(self) -> Pin<P, N, Alternate<10, PushPull>>where
Self: IntoAf<10>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af10(self) -> Pin<P, N, Alternate<10, PushPull>>where
Self: IntoAf<10>,
Configures the pin to operate in alternate function 10 mode
Sourcepub fn into_alternate_af11(self) -> Pin<P, N, Alternate<11, PushPull>>where
Self: IntoAf<11>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af11(self) -> Pin<P, N, Alternate<11, PushPull>>where
Self: IntoAf<11>,
Configures the pin to operate in alternate function 11 mode
Sourcepub fn into_alternate_af12(self) -> Pin<P, N, Alternate<12, PushPull>>where
Self: IntoAf<12>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af12(self) -> Pin<P, N, Alternate<12, PushPull>>where
Self: IntoAf<12>,
Configures the pin to operate in alternate function 12 mode
Sourcepub fn into_alternate_af13(self) -> Pin<P, N, Alternate<13, PushPull>>where
Self: IntoAf<13>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af13(self) -> Pin<P, N, Alternate<13, PushPull>>where
Self: IntoAf<13>,
Configures the pin to operate in alternate function 13 mode
Sourcepub fn into_alternate_af14(self) -> Pin<P, N, Alternate<14, PushPull>>where
Self: IntoAf<14>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af14(self) -> Pin<P, N, Alternate<14, PushPull>>where
Self: IntoAf<14>,
Configures the pin to operate in alternate function 14 mode
Sourcepub fn into_alternate_af15(self) -> Pin<P, N, Alternate<15, PushPull>>where
Self: IntoAf<15>,
👎Deprecated since 0.12.0: Use the .into_alternate() method instead
pub fn into_alternate_af15(self) -> Pin<P, N, Alternate<15, PushPull>>where
Self: IntoAf<15>,
Configures the pin to operate in alternate function 15 mode
Sourcepub fn into_alternate_open_drain<const A: u8>(
self,
) -> Pin<P, N, Alternate<A, OpenDrain>>where
Self: IntoAf<A>,
pub fn into_alternate_open_drain<const A: u8>(
self,
) -> Pin<P, N, Alternate<A, OpenDrain>>where
Self: IntoAf<A>,
Configures the pin to operate in alternate open drain mode
Sourcepub fn into_input(self) -> Pin<P, N, Input>
pub fn into_input(self) -> Pin<P, N, Input>
Configures the pin to operate as a input pin
Sourcepub fn into_floating_input(self) -> Pin<P, N, Input>
pub fn into_floating_input(self) -> Pin<P, N, Input>
Configures the pin to operate as a floating input pin
Sourcepub fn into_pull_down_input(self) -> Pin<P, N, Input>
pub fn into_pull_down_input(self) -> Pin<P, N, Input>
Configures the pin to operate as a pulled down input pin
Sourcepub fn into_pull_up_input(self) -> Pin<P, N, Input>
pub fn into_pull_up_input(self) -> Pin<P, N, Input>
Configures the pin to operate as a pulled up input pin
Sourcepub fn into_open_drain_output(self) -> Pin<P, N, Output<OpenDrain>>
pub fn into_open_drain_output(self) -> Pin<P, N, Output<OpenDrain>>
Configures the pin to operate as an open drain output pin Initial state will be low.
Sourcepub fn into_open_drain_output_in_state(
self,
initial_state: PinState,
) -> Pin<P, N, Output<OpenDrain>>
pub fn into_open_drain_output_in_state( self, 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.
Sourcepub fn into_push_pull_output(self) -> Pin<P, N, Output<PushPull>>
pub fn into_push_pull_output(self) -> Pin<P, N, Output<PushPull>>
Configures the pin to operate as an push pull output pin Initial state will be low.
Sourcepub fn into_push_pull_output_in_state(
self,
initial_state: PinState,
) -> Pin<P, N, Output<PushPull>>
pub fn into_push_pull_output_in_state( self, 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.
Sourcepub fn into_analog(self) -> Pin<P, N, Analog>
pub fn into_analog(self) -> Pin<P, N, Analog>
Configures the pin to operate as an analog input pin
Sourcepub fn into_dynamic(self) -> DynamicPin<P, N>
pub fn into_dynamic(self) -> DynamicPin<P, N>
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: PinMode,
impl<const P: char, const N: u8, MODE> Pin<P, N, MODE>where
MODE: PinMode,
Sourcepub fn with_input<R>(&mut self, f: impl FnOnce(&mut Pin<P, N, Input>) -> R) -> R
pub fn with_input<R>(&mut self, f: impl FnOnce(&mut Pin<P, N, Input>) -> R) -> R
Temporarily configures this pin as a input.
The closure f
is called with the reconfigured pin. After it returns,
the pin will be configured back.
Sourcepub fn with_analog<R>(
&mut self,
f: impl FnOnce(&mut Pin<P, N, Analog>) -> R,
) -> R
pub fn with_analog<R>( &mut self, f: impl FnOnce(&mut Pin<P, N, Analog>) -> 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.
Sourcepub fn with_open_drain_output<R>(
&mut self,
f: impl FnOnce(&mut Pin<P, N, Output<OpenDrain>>) -> R,
) -> R
pub fn with_open_drain_output<R>( &mut self, f: impl FnOnce(&mut Pin<P, N, Output<OpenDrain>>) -> 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
Sourcepub fn with_open_drain_output_in_state<R>(
&mut self,
state: PinState,
f: impl FnOnce(&mut Pin<P, N, Output<OpenDrain>>) -> R,
) -> R
pub fn with_open_drain_output_in_state<R>( &mut self, state: PinState, f: impl FnOnce(&mut Pin<P, N, Output<OpenDrain>>) -> 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
Sourcepub fn with_push_pull_output<R>(
&mut self,
f: impl FnOnce(&mut Pin<P, N, Output<PushPull>>) -> R,
) -> R
pub fn with_push_pull_output<R>( &mut self, f: impl FnOnce(&mut Pin<P, N, Output<PushPull>>) -> 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
Sourcepub fn with_push_pull_output_in_state<R>(
&mut self,
state: PinState,
f: impl FnOnce(&mut Pin<P, N, Output<PushPull>>) -> R,
) -> R
pub fn with_push_pull_output_in_state<R>( &mut self, state: PinState, f: impl FnOnce(&mut Pin<P, N, Output<PushPull>>) -> 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<const P: char, const N: u8, MODE> Pin<P, N, MODE>
impl<const P: char, const N: u8, MODE> Pin<P, N, MODE>
Sourcepub const fn interrupt(&self) -> Interrupt
pub const fn interrupt(&self) -> Interrupt
NVIC interrupt number of interrupt from this pin
Used to unmask / enable the interrupt with cortex_m::peripheral::NVIC::unmask()
.
This is also useful for all other cortex_m::peripheral::NVIC
functions.
Source§impl<const P: char, const N: u8, MODE> Pin<P, N, MODE>where
MODE: Active,
impl<const P: char, const N: u8, MODE> Pin<P, N, MODE>where
MODE: Active,
Sourcepub fn set_internal_resistor(&mut self, resistor: Pull)
pub fn set_internal_resistor(&mut self, resistor: Pull)
Set the internal pull-up and pull-down resistor
Sourcepub fn internal_resistor(self, resistor: Pull) -> Self
pub fn internal_resistor(self, resistor: Pull) -> Self
Set the internal pull-up and pull-down resistor
Sourcepub fn internal_pull_up(self, on: bool) -> Self
pub fn internal_pull_up(self, on: bool) -> Self
Enables / disables the internal pull up
Sourcepub fn internal_pull_down(self, on: bool) -> Self
pub fn internal_pull_down(self, on: bool) -> Self
Enables / disables the internal pull down
Source§impl<const P: char, const N: u8, MODE> Pin<P, N, MODE>
impl<const P: char, const N: u8, MODE> Pin<P, N, MODE>
Sourcepub fn erase_number(self) -> PartiallyErasedPin<P, MODE>
pub fn erase_number(self) -> PartiallyErasedPin<P, MODE>
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§impl<const P: char, const N: u8, MODE> Pin<P, N, Output<MODE>>
impl<const P: char, const N: u8, MODE> Pin<P, N, Output<MODE>>
Sourcepub fn set_state(&mut self, state: PinState)
pub fn set_state(&mut self, state: PinState)
Drives the pin high or low depending on the provided value
Sourcepub fn is_set_high(&self) -> bool
pub fn is_set_high(&self) -> bool
Is the pin in drive high mode?
Sourcepub fn is_set_low(&self) -> bool
pub fn is_set_low(&self) -> bool
Is the pin in drive low mode?
Trait Implementations§
Source§impl From<Pin<'C', 2, Alternate<10>>> for Usb1UlpiDirPin
Available on crate feature usb_hs
only.
impl From<Pin<'C', 2, Alternate<10>>> for Usb1UlpiDirPin
usb_hs
only.Source§impl From<Pin<'C', 3, Alternate<10>>> for Usb1UlpiNxtPin
Available on crate feature usb_hs
only.
impl From<Pin<'C', 3, Alternate<10>>> for Usb1UlpiNxtPin
usb_hs
only.Source§impl From<Pin<'H', 4, Alternate<10>>> for Usb1UlpiNxtPin
Available on crate feature usb_hs
only.
impl From<Pin<'H', 4, Alternate<10>>> for Usb1UlpiNxtPin
usb_hs
only.Source§impl From<Pin<'I', 11, Alternate<10>>> for Usb1UlpiDirPin
Available on crate feature usb_hs
only.
impl From<Pin<'I', 11, Alternate<10>>> for Usb1UlpiDirPin
usb_hs
only.