pub struct EndpointState<const COUNT: usize = MAX_ENDPOINTS> { /* 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<MAX_ENDPOINTS>
impl EndpointState<MAX_ENDPOINTS>
Sourcepub const fn max_endpoints() -> Self
pub const fn max_endpoints() -> Self
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.