Struct imxrt_hal::usbd::EndpointState
source · 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}>
impl EndpointState<imxrt_usbd::::state::{impl#4}::{constant#0}>
sourcepub const fn max_endpoints(
) -> EndpointState<imxrt_usbd::::state::{impl#4}::{constant#0}>
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>
impl<const COUNT: usize> EndpointState<COUNT>
sourcepub const fn new() -> EndpointState<COUNT>
pub const fn new() -> EndpointState<COUNT>
Allocate state for COUNT
endpoints.