Struct stm32l4xx_hal::gpio::Pin
source · [−]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: from0
to15
.
Implementations
sourceimpl<MODE, HL, const P: char, const N: u8> Pin<MODE, HL, P, N>
impl<MODE, HL, const P: char, const N: u8> Pin<MODE, HL, P, N>
sourcepub 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>
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
sourcepub 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>
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
)
sourcepub 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>
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
sourcepub fn into_floating_input(
self,
_moder: &mut MODER<P>,
_pupdr: &mut PUPDR<P>
) -> Pin<Input<Floating>, HL, P, N>
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
sourcepub fn into_pull_down_input(
self,
_moder: &mut MODER<P>,
_pupdr: &mut PUPDR<P>
) -> Pin<Input<PullDown>, HL, P, N>
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
sourcepub fn into_pull_up_input(
self,
_moder: &mut MODER<P>,
_pupdr: &mut PUPDR<P>
) -> Pin<Input<PullUp>, HL, P, N>
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
sourcepub fn into_open_drain_output(
self,
_moder: &mut MODER<P>,
_otyper: &mut OTYPER<P>
) -> Pin<Output<OpenDrain>, HL, P, N>
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.
sourcepub 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>
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.
sourcepub fn into_push_pull_output(
self,
_moder: &mut MODER<P>,
_otyper: &mut OTYPER<P>
) -> Pin<Output<PushPull>, HL, P, N>
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.
sourceimpl<MODE, HL, const P: char, const N: u8> Pin<MODE, HL, P, N> where
MODE: PinMode,
impl<MODE, HL, const P: char, const N: u8> Pin<MODE, HL, P, N> where
MODE: PinMode,
sourcepub fn with_floating_input<R>(
&mut self,
f: impl FnOnce(&mut Pin<Input<Floating>, HL, P, N>) -> R
) -> R
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.
sourcepub fn with_pull_down_input<R>(
&mut self,
f: impl FnOnce(&mut Pin<Input<PullDown>, HL, P, N>) -> R
) -> R
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.
sourcepub fn with_pull_up_input<R>(
&mut self,
f: impl FnOnce(&mut Pin<Input<PullUp>, HL, P, N>) -> R
) -> R
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.
sourcepub fn with_analog<R>(
&mut self,
f: impl FnOnce(&mut Pin<Analog, HL, P, N>) -> R
) -> R
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.
sourcepub fn with_open_drain_output<R>(
&mut self,
f: impl FnOnce(&mut Pin<Output<OpenDrain>, HL, P, N>) -> R
) -> R
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
sourcepub fn with_open_drain_output_in_state<R>(
&mut self,
state: PinState,
f: impl FnOnce(&mut Pin<Output<OpenDrain>, HL, P, N>) -> R
) -> R
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
sourcepub fn with_push_pull_output<R>(
&mut self,
f: impl FnOnce(&mut Pin<Output<PushPull>, HL, P, N>) -> R
) -> R
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
sourcepub fn with_push_pull_output_in_state<R>(
&mut self,
state: PinState,
f: impl FnOnce(&mut Pin<Output<PushPull>, HL, P, N>) -> R
) -> R
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
sourceimpl<HL, const P: char, const N: u8> Pin<Output<OpenDrain>, HL, P, N>
impl<HL, const P: char, const N: u8> Pin<Output<OpenDrain>, HL, P, N>
sourcepub fn internal_pull_up(&mut self, _pupdr: &mut PUPDR<P>, on: bool)
pub fn internal_pull_up(&mut self, _pupdr: &mut PUPDR<P>, on: bool)
Enables / disables the internal pull up
sourceimpl<HL, const P: char, const N: u8, const A: u8> Pin<Alternate<PushPull, A>, HL, P, N>
impl<HL, const P: char, const N: u8, const A: u8> Pin<Alternate<PushPull, A>, HL, P, N>
sourcepub fn set_open_drain(self) -> Pin<Alternate<OpenDrain, A>, HL, P, N>
pub fn set_open_drain(self) -> Pin<Alternate<OpenDrain, A>, HL, P, N>
Turns pin alternate configuration pin into open drain
sourceimpl<MODE, HL, const P: char, const N: u8> Pin<MODE, HL, P, N>
impl<MODE, HL, const P: char, const N: u8> Pin<MODE, HL, P, N>
sourcepub fn erase_number(self) -> PEPin<MODE, P>
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
Trait Implementations
sourceimpl<MODE, HL, const P: char, const N: u8> OutputPin for Pin<Output<MODE>, HL, P, N>
impl<MODE, HL, const P: char, const N: u8> OutputPin for Pin<Output<MODE>, HL, P, N>
type Error = Infallible
type Error = Infallible
Error type
Auto Trait Implementations
impl<MODE, HL, const P: char, const N: u8> RefUnwindSafe for Pin<MODE, HL, P, N> where
HL: RefUnwindSafe,
MODE: RefUnwindSafe,
impl<MODE, HL, const P: char, const N: u8> Send for Pin<MODE, HL, P, N> where
HL: Send,
MODE: Send,
impl<MODE, HL, const P: char, const N: u8> Sync for Pin<MODE, HL, P, N> where
HL: Sync,
MODE: Sync,
impl<MODE, HL, const P: char, const N: u8> Unpin for Pin<MODE, HL, P, N> where
HL: Unpin,
MODE: Unpin,
impl<MODE, HL, const P: char, const N: u8> UnwindSafe for Pin<MODE, HL, P, N> where
HL: UnwindSafe,
MODE: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more