usbpd::protocol_layer

Struct ProtocolLayer

Source
pub struct ProtocolLayer<DRIVER: Driver, TIMER: Timer> { /* private fields */ }
Expand description

The USB PD protocol layer.

Implementations§

Source§

impl<DRIVER: Driver, TIMER: Timer> ProtocolLayer<DRIVER, TIMER>

Source

pub fn new(driver: DRIVER, default_header: Header) -> Self

Create a new protocol layer from a driver and default header.

Source

pub fn reset(&mut self)

Reset the protocol layer.

Source

pub fn get_timer(timer_type: TimerType) -> impl Future<Output = ()>

Get a timer future for a given type.

Source

pub async fn transmit(&mut self, message: Message) -> Result<(), Error>

Transmit a message.

Source

pub async fn receive_message(&mut self) -> Result<Message, Error>

Receive a message.

Source

pub async fn receive_message_type( &mut self, message_types: &[MessageType], timer_type: TimerType, ) -> Result<Message, Error>

Wait until a message of one of the chosen types is received, or a timeout occurs.

Source

pub async fn hard_reset(&mut self) -> Result<(), Error>

Perform a hard-reset procedure.

Source

pub async fn wait_for_vbus(&mut self)

Wait for VBUS to be available.

FIXME: Check what the logic should be.

Source

pub async fn wait_for_source_capabilities(&mut self) -> Result<Message, Error>

Wait for the source to provide its capabilities.

Source

pub async fn transmit_control_message( &mut self, control_message_type: ControlMessageType, ) -> Result<(), Error>

Transmit a control message of the provided type.

Source

pub async fn request_power( &mut self, supply: PowerSourceRequest, ) -> Result<(), Error>

Request a certain power level from the source.

Trait Implementations§

Source§

impl<DRIVER: Debug + Driver, TIMER: Debug + Timer> Debug for ProtocolLayer<DRIVER, TIMER>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<DRIVER, TIMER> Freeze for ProtocolLayer<DRIVER, TIMER>
where DRIVER: Freeze,

§

impl<DRIVER, TIMER> RefUnwindSafe for ProtocolLayer<DRIVER, TIMER>
where DRIVER: RefUnwindSafe, TIMER: RefUnwindSafe,

§

impl<DRIVER, TIMER> Send for ProtocolLayer<DRIVER, TIMER>
where DRIVER: Send, TIMER: Send,

§

impl<DRIVER, TIMER> Sync for ProtocolLayer<DRIVER, TIMER>
where DRIVER: Sync, TIMER: Sync,

§

impl<DRIVER, TIMER> Unpin for ProtocolLayer<DRIVER, TIMER>
where DRIVER: Unpin, TIMER: Unpin,

§

impl<DRIVER, TIMER> UnwindSafe for ProtocolLayer<DRIVER, TIMER>
where DRIVER: UnwindSafe, TIMER: 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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

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

Source§

unsafe fn unsafe_from(other: U) -> T

Calls U::into(other).

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

Source§

impl<T, U> UnsafeInto<U> for T
where U: UnsafeFrom<T>,

Source§

unsafe fn unsafe_into(self) -> U

Calls U::unsafe_from(self).

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