Port

Struct Port 

Source
pub struct Port<MODE> { /* private fields */ }

Implementations§

Source§

impl Port<()>

Source

pub fn new(gpio: PortNum, mask: u16, regs: &'static PortReg) -> Self

Creates a new GPIO port instance.

§Arguments
  • gpio - The port number.
  • mask - A bit mask specifying which pins are part of this port.
§Returns

A new Port instance with uninitialized mode.

Source

pub fn into_input(&self, mode: PortModeInput) -> Port<InputPort>

Converts the port to an input mode.

§Arguments
  • mode - The input mode configuration.
§Returns

A new Port instance configured as an input port.

Source

pub fn into_output(&self, mode: PortModeOutput) -> Port<OutputPort>

Converts the port to an output mode.

§Arguments
  • mode - The output mode configuration.
§Returns

A new Port instance configured as an output port.

Source§

impl Port<OutputPort>

Source

pub unsafe fn set_bits_uncheck(&mut self, bits: u16)

Sets the specified bits of the output register without checking bounds or validity.

§Safety

This function must only be called when it is safe to modify the output register directly.

Source

pub unsafe fn clr_bits_uncheck(&mut self, bits: u16)

Clears the specified bits of the output register without checking bounds or validity.

§Safety

This function must only be called when it is safe to modify the output register directly.

Source

pub unsafe fn read_output_bits_uncheck(&mut self) -> u16

Reads the current value of the output register without checking bounds or validity.

§Safety

This function must only be called when it is safe to read from the output register directly.

Source

pub unsafe fn write_bits_uncheck(&mut self, bits: u16)

Writes a value to the output register without checking bounds or validity.

§Safety

This function must only be called when it is safe to modify the output register directly.

Source

pub fn set_bits(&mut self, bits: u16)

Sets the specified bits of the output register, applying the bit mask.

Source

pub fn clr_bits(&mut self, bits: u16)

Clears the specified bits of the output register, applying the bit mask.

Source

pub fn read_output_bits(&mut self) -> u16

Reads the current value of the output register, applying the bit mask.

Source

pub fn write_bits(&mut self, bits: u16)

Writes a value to the output register, applying the bit mask.

Source

pub fn read_input_bits(&mut self) -> u16

Reads the current value of the input register, applying the bit mask.

Source§

impl Port<InputPort>

Source

pub unsafe fn read_input_bits_uncheck(&mut self) -> u16

Reads the current value of the input register without checking bounds or validity.

§Safety

This function must only be called when it is safe to read from the input register directly.

Source

pub fn read_input_bits(&mut self) -> u16

Reads the current value of the input register, applying the bit mask.

Trait Implementations§

Source§

impl<MODE: Clone> Clone for Port<MODE>

Source§

fn clone(&self) -> Port<MODE>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<MODE: Debug> Debug for Port<MODE>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<MODE> ErrorType for Port<MODE>

Source§

type Error = Infallible

Error type
Source§

impl InputPin for Port<InputPort>

Source§

fn is_high(&mut self) -> Result<bool, Self::Error>

Is the input pin high?
Source§

fn is_low(&mut self) -> Result<bool, Self::Error>

Is the input pin low?
Source§

impl InputPin for Port<OutputPort>

Source§

fn is_high(&mut self) -> Result<bool, Self::Error>

Is the input pin high?
Source§

fn is_low(&mut self) -> Result<bool, Self::Error>

Is the input pin low?
Source§

impl OutputPin for Port<OutputPort>

Source§

fn set_high(&mut self) -> Result<(), Self::Error>

Drives the pin high. Read more
Source§

fn set_low(&mut self) -> Result<(), Self::Error>

Drives the pin low. Read more
Source§

fn set_state(&mut self, state: PinState) -> Result<(), Self::Error>

Drives the pin high or low depending on the provided value. Read more
Source§

impl StatefulOutputPin for Port<OutputPort>

Source§

fn is_set_high(&mut self) -> Result<bool, Self::Error>

Is the pin in drive high mode? Read more
Source§

fn is_set_low(&mut self) -> Result<bool, Self::Error>

Is the pin in drive low mode? Read more
Source§

fn toggle(&mut self) -> Result<(), Self::Error>

Toggle pin output.
Source§

impl<MODE: Copy> Copy for Port<MODE>

Auto Trait Implementations§

§

impl<MODE> Freeze for Port<MODE>

§

impl<MODE> RefUnwindSafe for Port<MODE>
where MODE: RefUnwindSafe,

§

impl<MODE> Send for Port<MODE>
where MODE: Send,

§

impl<MODE> Sync for Port<MODE>
where MODE: Sync,

§

impl<MODE> Unpin for Port<MODE>
where MODE: Unpin,

§

impl<MODE> UnwindSafe for Port<MODE>
where MODE: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.