Struct rppal::gpio::IoPin[][src]

pub struct IoPin { /* fields omitted */ }
Expand description

GPIO pin that can be (re)configured for any mode or alternate function.

IoPins are constructed by converting a Pin using Pin::into_io. The pin’s mode is automatically set to the specified mode.

An IoPin can be reconfigured for any available mode. Depending on the mode, some methods may not have any effect. For instance, calling a method that alters the pin’s output state won’t cause any changes when the pin’s mode is set to Input.

The embedded-hal digital::OutputPin and PwmPin trait implementations for IoPin can be enabled by specifying the optional hal feature in the dependency declaration for the rppal crate.

The unproven embedded-hal digital::InputPin, digital::StatefulOutputPin, digital::ToggleableOutputPin and Pwm trait implementations for IoPin can be enabled by specifying the optional hal-unproven feature in the dependency declaration for the rppal crate.

Implementations

Returns the GPIO pin number.

Pins are addressed by their BCM numbers, rather than their physical location.

Returns the pin’s mode.

Sets the pin’s mode.

Configures the built-in pull-up/pull-down resistors.

Reads the pin’s logic level.

Reads the pin’s logic level, and returns true if it’s set to Low.

Reads the pin’s logic level, and returns true if it’s set to High.

Sets the pin’s output state.

Sets the pin’s output state to Low.

Sets the pin’s output state to High.

Toggles the pin’s output state between Low and High.

Configures a software-based PWM signal.

period indicates the time it takes to complete one cycle.

pulse_width indicates the amount of time the PWM signal is active during a single period.

Software-based PWM is inherently inaccurate on a multi-threaded OS due to scheduling/preemption. If an accurate or faster PWM signal is required, use the hardware Pwm peripheral instead. More information can be found here.

If set_pwm is called when a PWM thread is already active, the existing thread will be reconfigured at the end of the current cycle.

Configures a software-based PWM signal.

set_pwm_frequency is a convenience method that converts frequency to a period and duty_cycle to a pulse width, and then calls set_pwm.

frequency is specified in hertz (Hz).

duty_cycle is specified as a floating point value between 0.0 (0%) and 1.0 (100%).

Stops a previously configured software-based PWM signal.

The thread responsible for emulating the PWM signal is stopped at the end of the current cycle.

Returns the value of reset_on_drop.

When enabled, resets the pin’s mode to its original state and disables the built-in pull-up/pull-down resistors when the pin goes out of scope. By default, this is set to true.

Note

Drop methods aren’t called when a process is abnormally terminated, for instance when a user presses Ctrl + C, and the SIGINT signal isn’t caught. You can catch those using crates such as simple_signal.

Trait Implementations

Formats the value using the given formatter. Read more

Resets the pin’s mode and disables the built-in pull-up/pull-down resistors if reset_on_drop is set to true (default).

InputPin trait implementation for embedded-hal v1.0.0-alpha.5.

Error type

Is the input pin high?

Is the input pin low?

Unproven InputPin trait implementation for embedded-hal v0.2.6.

Error type

Is the input pin high?

Is the input pin low?

OutputPin trait implementation for embedded-hal v1.0.0-alpha.5.

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

OutputPin trait implementation for embedded-hal v0.2.6.

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Pwm trait implementation for embedded-hal v1.0.0-alpha.5.

Disables a PWM channel.

Enables a PWM channel.

Returns the current PWM period.

Returns the current duty cycle.

Returns the maximum duty cycle value.

Sets a new duty cycle.

Sets a new PWM period.

Type for the duty methods Read more

Enumeration of channels that can be used with this Pwm interface Read more

A time unit that can be converted into a human time unit (e.g. seconds)

Enumeration of Pwm errors

Unproven Pwm trait implementation for embedded-hal v0.2.6.

Disables a PWM channel.

Enables a PWM channel.

Returns the current PWM period.

Returns the current duty cycle.

Returns the maximum duty cycle value.

Sets a new duty cycle.

Sets a new PWM period.

Type for the duty methods Read more

Enumeration of channels that can be used with this Pwm interface Read more

A time unit that can be converted into a human time unit (e.g. seconds)

PwmPin trait implementation for embedded-hal v1.0.0-alpha.5.

Type for the duty methods Read more

Enumeration of PwmPin errors

Disables a PWM channel

Enables a PWM channel

Returns the current duty cycle Read more

Returns the maximum duty cycle value

Sets a new duty cycle

PwmPin trait implementation for embedded-hal v0.2.6.

Type for the duty methods Read more

Disables a PWM channel

Enables a PWM channel

Returns the current duty cycle

Returns the maximum duty cycle value

Sets a new duty cycle

StatefulOutputPin trait implementation for embedded-hal v1.0.0-alpha.5.

Is the pin in drive high mode? Read more

Is the pin in drive low mode? Read more

Unproven StatefulOutputPin trait implementation for embedded-hal v0.2.6.

Is the pin in drive high mode? Read more

Is the pin in drive low mode? Read more

ToggleableOutputPin trait implementation for embedded-hal v1.0.0-alpha.5.

Error type

Toggle pin output.

Unproven ToggleableOutputPin trait implementation for embedded-hal v0.2.6.

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

Performs the conversion.

Performs the conversion.

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.