GPIO

Struct GPIO 

Source
pub struct GPIO<State = Enabled> {
    pub tokens: Tokens<State>,
    /* private fields */
}
Expand description

Interface to the GPIO peripheral

Controls the GPIO peripheral. Can be used to enable, disable, or free the peripheral. For GPIO-functionality directly related to pins, please refer to GpioPin.

Use Peripherals to gain access to an instance of this struct.

Please refer to the module documentation for more information.

Fields§

§tokens: Tokens<State>

Tokens representing all pins

Since the enable and disable methods consume self, they can only be called, if all tokens are available. This means, any tokens that have been moved out while the peripheral was enabled, prevent the peripheral from being disabled (unless those tokens are moved back into their original place).

As using a pin for GPIO requires such a token, it is impossible to disable the GPIO peripheral while pins are used for GPIO.

Implementations§

Source§

impl<State> GPIO<State>

Source

pub fn free(self) -> GPIO

Return the raw peripheral

This method serves as an escape hatch from the HAL API. It returns the raw peripheral, allowing you to do whatever you want with it, without limitations imposed by the API.

If you are using this method because a feature you need is missing from the HAL API, please open an issue or, if an issue for your feature request already exists, comment on the existing issue, so we can prioritize it accordingly.

Source§

impl GPIO<Disabled>

Source

pub fn enable(self, syscon: &mut Handle) -> GPIO<Enabled>

Enable the GPIO peripheral

This method is only available, if GPIO is in the Disabled state. Code that attempts to call this method when the peripheral is already enabled will not compile.

Consumes this instance of GPIO and returns another instance that has its State type parameter set to Enabled.

Source§

impl GPIO<Enabled>

Source

pub fn disable(self, syscon: &mut Handle) -> GPIO<Disabled>

Disable the GPIO peripheral

This method is only available, if GPIO is in the Enabled state. Code that attempts to call this method when the peripheral is already disabled will not compile.

Consumes this instance of GPIO and returns another instance that has its State type parameter set to Disabled.

Auto Trait Implementations§

§

impl<State> Freeze for GPIO<State>

§

impl<State> RefUnwindSafe for GPIO<State>
where State: RefUnwindSafe,

§

impl<State> Send for GPIO<State>
where State: Send,

§

impl<State = Enabled> !Sync for GPIO<State>

§

impl<State> Unpin for GPIO<State>
where State: Unpin,

§

impl<State> UnwindSafe for GPIO<State>
where State: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.