pub struct GpioPin<P, D> { /* private fields */ }
Expand description

A pin used for general purpose I/O (GPIO).

This struct is a wrapper around the representation of a specific pin P– it enables said pin to be used as a GPIO pin.

You can get access to an instance of this struct by switching a pin to the GPIO state, using Pin::into_input_pin or Pin::into_output_pin.

embedded-hal traits

Implementations

Get identifying information about this pin in the form of a pins::Trait

Set pin direction to output

This method is only available while the pin is in input mode.

Consumes the pin instance and returns a new instance that is in output mode, making the methods to set the output level available.

Set pin direction to dynamic (i.e. changeable at runtime)

This method is only available when the pin is not already in dynamic mode.

Consumes the pin instance and returns a new instance that is in dynamic mode, making the methods to change direction as well as read/set levels (depending on the current diection) available.

Indicates wether the voltage at the pin is currently HIGH

This method is only available, if two conditions are met:

  • The pin is in the GPIO state.
  • The pin direction is set to input.

See Pin::into_input_pin and into_input. Unless both of these conditions are met, code trying to call this method will not compile.

Indicates wether the pin input is LOW

This method is only available, if two conditions are met:

  • The pin is in the GPIO state.
  • The pin direction is set to input.

See Pin::into_input_pin and into_input. Unless both of these conditions are met, code trying to call this method will not compile.

Returns the current voltage level at this pin.

This method is only available, if two conditions are met:

  • The pin is in the GPIO state.
  • The pin direction is set to input.

See Pin::into_input_pin and into_input. Unless both of these conditions are met, code trying to call this method will not compile.

Set pin direction to input

This method is only available while the pin is in output mode.

Consumes the pin instance and returns a new instance that is in output mode, making the methods to set the output level available.

Set pin direction to dynamic (i.e. changeable at runtime)

This method is only available when the pin is not already in dynamic mode.

Consumes the pin instance and returns a new instance that is in dynamic mode, making the methods to change direction as well as read/set levels (depending on the current diection) available.

Set the pin output to HIGH

This method is only available, if two conditions are met:

  • The pin is in the GPIO state.
  • The pin direction is set to output.

See Pin::into_output_pin and into_output. Unless both of these conditions are met, code trying to call this method will not compile.

Set the pin output to LOW

This method is only available, if two conditions are met:

  • The pin is in the GPIO state.
  • The pin direction is set to output.

See Pin::into_output_pin and into_output. Unless both of these conditions are met, code trying to call this method will not compile.

Indicates whether the pin output is currently set to HIGH

This method is only available, if two conditions are met:

  • The pin is in the GPIO state.
  • The pin direction is set to output.

See Pin::into_output_pin and into_output. Unless both of these conditions are met, code trying to call this method will not compile.

Indicates whether the pin output is currently set to LOW

This method is only available, if two conditions are met:

  • The pin is in the GPIO state.
  • The pin direction is set to output.

See Pin::into_output_pin and into_output. Unless both of these conditions are met, code trying to call this method will not compile.

Returns the level to which this pin is currently set

This method is only available, if two conditions are met:

  • The pin is in the GPIO state.
  • The pin direction is set to output.

See Pin::into_output_pin and into_output. Unless both of these conditions are met, code trying to call this method will not compile.

Toggle the pin output

This method is only available, if two conditions are met:

  • The pin is in the GPIO state.
  • The pin direction is set to output.

See Pin::into_output_pin and into_output. Unless both of these conditions are met, code trying to call this method will not compile.

Tell us whether this pin’s direction is currently set to Output.

Tell us whether this pin’s direction is currently set to Input.

Switch pin direction to input. If the pin is already an input pin, this does nothing.

Switch pin direction to output with output level set to level. If the pin is already an output pin, this function only switches its level to level.

Set the pin level to High. Note that this will be executed regardless of the current pin direction. This enables you to set the initial pin level before switching to output

Set the pin level to Low. Note that this will be executed regardless of the current pin direction. This enables you to set the initial pin level before switching to output

Returns the current voltage level at this pin. This can be used when the pin is in any direction:

If it is currently an Output pin, it indicates to which level the pin is set If it is currently an Input pin, it indicates the level currently present at this pin

This method is only available, if the pin has been set to dynamic mode. See Pin::into_dynamic_pin. Unless this condition is met, code trying to call this method will not compile.

Trait Implementations

Error type
Is the input pin high?
Is the input pin low?
Error type
Is the input pin high?
Is the input pin low?
Error type
Is the input pin high?
Is the input pin low?
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
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
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
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
Is the pin in drive high mode? Read more
Is the pin in drive low mode? Read more
Error type
Toggle pin output.
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.