pub struct EndpointState<const COUNT: usize = imxrt_usbd::::state::EndpointState::{constant#0}> { /* private fields */ }
Expand description

Driver state associated with endpoints.

Each USB driver needs an EndpointState. Allocate a static object and supply it to your USB constructor. Make sure that states are not shared across USB instances; otherwise, the driver constructor panics.

Use max_endpoints() if you’re not interested in reducing the memory used by this allocation. The default object holds enough state for all supported endpoints.

use imxrt_usbd::EndpointState;

static EP_STATE: EndpointState = EndpointState::max_endpoints();

If you know that you can use fewer endpoints, you can control the memory utilization with the const generic COUNT. You’re expected to provide at least two endpoints – one in each direction – for control endpoints.

Know that endpoints are allocated in pairs; all even endpoints are OUT, and all odd endpoints are IN. For example, a COUNT of 5 will have 3 out endpoints, and 2 in endpoints. You can never have more IN that OUT endpoints without overallocating OUT endpoints.

use imxrt_usbd::EndpointState;

static EP_STATE: EndpointState<5> = EndpointState::new();

Any endpoint state allocated beyond MAX_ENDPOINTS are wasted.

Implementations§

source§

impl EndpointState<imxrt_usbd::::state::{impl#4}::{constant#0}>

source

pub const fn max_endpoints( ) -> EndpointState<imxrt_usbd::::state::{impl#4}::{constant#0}>

Allocate space for the maximum number of endpoints.

Use this if you don’t want to consider the exact number of endpoints that you might need.

source§

impl<const COUNT: usize> EndpointState<COUNT>

source

pub const fn new() -> EndpointState<COUNT>

Allocate state for COUNT endpoints.

Trait Implementations§

source§

impl<const COUNT: usize> Sync for EndpointState<COUNT>

Auto Trait Implementations§

§

impl<const COUNT: usize = imxrt_usbd::::state::EndpointState::{constant#0}> !RefUnwindSafe for EndpointState<COUNT>

§

impl<const COUNT: usize> Send for EndpointState<COUNT>

§

impl<const COUNT: usize> Unpin for EndpointState<COUNT>

§

impl<const COUNT: usize = imxrt_usbd::::state::EndpointState::{constant#0}> !UnwindSafe for EndpointState<COUNT>

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>,

§

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>,

§

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.