Struct stm32_hal2::gpio::Pin

source ·
pub struct Pin {
    pub port: Port,
    pub pin: u8,
}
Expand description

Represents a single GPIO pin. Allows configuration, and reading/setting state.

Fields

port: Port

The GPIO Port letter. Eg A, B, C.

pin: u8

The pin number: 1 - 15.

Implementations

Create a new pin, with a specific mode. Enables the RCC peripheral clock to the port, if not already enabled. Example: let pa1 = Pin::new(Port::A, 1, PinMode::Output); Leaves settings other than mode and alternate function (if applicable) at their hardware defaults.

Set pin mode. Eg, Output, Input, Analog, or Alt. Sets the MODER register.

Set output type. Sets the OTYPER register.

Set output speed to Low, Medium, or High. Sets the OSPEEDR register.

Set internal pull resistor: Pull up, pull down, or floating. Sets the PUPDR register.

Lock or unlock a port configuration. Sets the LCKR register.

Read the input data register. Eg determine if the pin is high or low. See also is_high() and is_low(). Reads from the IDR register.

Set a pin state (ie set high or low output voltage level). See also set_high() and set_low(). Sets the BSRR register. Atomic.

Configure this pin as an interrupt source. Set the edge as Rising or Falling.

Check if the pin’s input voltage is high. Reads from the IDR register.

Check if the pin’s input voltage is low. Reads from the IDR register.

Set the pin’s output voltage to high. Sets the BSRR register. Atomic.

Set the pin’s output voltage to low. Sets the BSRR register. Atomic.

Trait Implementations

Error type
Is the input pin high?
Is the input pin low?
Error type
Drives the pin low Read more
Drives the pin high Read more
Drives the pin high or low depending on the provided value Read more
Error type
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.