[][src]Struct lpc8xx_hal::swm::Function

pub struct Function<T, State> { /* fields omitted */ }

A fixed or movable function that can be assigned to a pin

The type parameter T identifies the fixed or movable function that an instance of Function controls. The other type paramter, State, tracks whether this function is assigned to a pin, and which pin it is assigned to.

Methods

impl<T> Function<T, Unassigned>[src]

pub fn assign<P, S>(
    self,
    pin: Pin<P, S>,
    swm: &mut Handle
) -> (Function<T, Assigned<P>>, <Pin<P, S> as AssignFunction<T, T::Kind>>::Assigned) where
    T: FunctionTrait<P>,
    P: PinTrait,
    S: PinState,
    Pin<P, S>: AssignFunction<T, T::Kind>, 
[src]

Assign this function to a pin

This method is only available if a number of requirements are met:

  • Function must be in the Unassigned state, as a function can only be assigned to one pin.
  • The Pin must be in the SWM state (pin_state::Swm). See documentation on Pin for information on pin state management.
  • The function must be assignable to the pin. Movable functions can be assigned to any pin, but fixed functions can be assigned to only one pin.
  • The state of the pin must allow another function of this type to be assigned. Input functions can always be assigned, but only one output or bidirectional function can be assigned to a given pin at any time.

Code attempting to call this method while these requirement are not met, will not compile.

Consumes this instance of Function, as well as the provided Pin, and returns new instances. The returned Function instance will have its state set to indicate that it has been assigned to the pin. The returned Pin will have its state updated to indicate that a function of this Function's type has been assigned.

Examples

Assign one output and one input function to the same pin:

use lpc82x_hal::Peripherals;

let p = Peripherals::take().unwrap();

let mut swm = p.SWM.split();

// Assign output function to a pin
let (u0_txd, pio0_0) = swm.movable_functions.u0_txd.assign(
    swm.pins.pio0_0.into_swm_pin(),
    &mut swm.handle,
);

// Assign input function to the same pin
let (u1_rxd, pio0_0) = swm.movable_functions.u1_rxd.assign(
    pio0_0,
    &mut swm.handle,
);

impl<T, P> Function<T, Assigned<P>>[src]

pub fn unassign<S>(
    self,
    pin: Pin<P, S>,
    swm: &mut Handle
) -> (Function<T, Unassigned>, <Pin<P, S> as UnassignFunction<T, T::Kind>>::Unassigned) where
    T: FunctionTrait<P>,
    P: PinTrait,
    S: PinState,
    Pin<P, S>: UnassignFunction<T, T::Kind>, 
[src]

Unassign this function from a pin

This method is only available if a number of requirements are met:

  • The function must be assigned to the provided pin. This means Function must be in the Assigned state, and the type parameter of Assigned must indicate that the function is assigned to the same pin that is provided as an argument.
  • The Pin must be in the SWM state (pin_state::Swm), and the state must indicate that a function of this Function's type is currently assigned. This should always be the case, if the previous condition is met, as it should be impossible to create inconsistent states between Functions and Pins without using unsafe.

Code attempting to call this method while these requirement are not met, will not compile.

Consumes this instance of Function, as well as the provided Pin, and returns new instances. The returned Function instance will have its state set to indicate that it is no longer assigned to a pin. The returned Pin will have its state updated to indicate that one fewer function of this type is now assigned.

Examples

Unassign a function that has been previously assigned to a pin:

// U0_TXD must have been previously assigned to the pin, or the
// following code will not compile. See documentation of
// `Function::assign`.
let (u0_txd, pio0_0) = u0_txd.unassign(pio0_0, &mut swm.handle);

Auto Trait Implementations

impl<T, State> Unpin for Function<T, State> where
    State: Unpin,
    T: Unpin

impl<T, State> Send for Function<T, State> where
    State: Send,
    T: Send

impl<T, State> Sync for Function<T, State> where
    State: Sync,
    T: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self