pub struct Pin<const P: char, const N: u8, MODE = Input> { /* 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: from 0 to 15.

Implementations

Turns pin alternate configuration pin into open drain

Configures the pin to operate alternate mode

Configures the pin to operate in alternate open drain mode

Configures the pin to operate as a input pin

Configures the pin to operate as a floating input pin

Configures the pin to operate as a pulled down input pin

Configures the pin to operate as a pulled up input pin

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

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

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

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

Configures the pin to operate as an analog input pin

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

Converts pin into specified mode

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.

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.

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

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

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

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

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.

Set pin speed

Set pin speed

Set the internal pull-up and pull-down resistor

Set the internal pull-up and pull-down resistor

Enables / disables the internal pull up

Enables / disables the internal pull down

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

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

Drives the pin high

Drives the pin low

Is the pin in drive high or low mode?

Drives the pin high or low depending on the provided value

Is the pin in drive high mode?

Is the pin in drive low mode?

Toggle pin output

Is the input pin high?

Is the input pin low?

Trait Implementations

Formats the value using the given formatter. Read more
Error type
Writes the defmt representation of self to fmt.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

Pin-to-erased pin conversion using the From trait.

Note that From is the reciprocal of Into.

Pin-to-partially erased pin conversion using the From trait.

Note that From is the reciprocal of Into.

Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Error type
Is the input pin high?
Is the input pin low?
Is the input pin high?
Is the input pin low?
Error type.
Tries to convert this pin to input mode. Read more
Tries to convert this pin to output mode with the given initial state. Read more
Error type.
Tries to convert this pin to input mode. Read more
Tries to convert this pin to output mode with the given initial state. Read more
Error type.
Tries to convert this pin to input mode. Read more
Tries to convert this pin to output mode with the given initial state. Read more
Error type.
Tries to convert this pin to input mode. Read more
Tries to convert this pin to output mode with the given initial state. Read more
Error type.
Tries to convert this pin to input mode. Read more
Tries to convert this pin to output mode with the given initial state. Read more
Error type.
Tries to convert this pin to input mode. Read more
Tries to convert this pin to output mode with the given initial state. Read more
Error type
Drives the pin high Read more
Drives the pin low Read more
Drives the pin high or low depending on the provided value Read more
Drives the pin high Read more
Drives the pin low Read more
Drives the pin high or low depending on the provided value Read more
Current pin mode
Pin number
Port number starting from 0
Is the pin in drive high mode? Read more
Is the pin in drive low mode? Read more
Is the pin in drive high mode? Read more
Is the pin in drive low mode? Read more
Error type
Toggle pin output.
Toggle pin output.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.