Skip to content

Commit bfb23cc

Browse files
pdunajcarlescufi
authored andcommitted
drivers: usb: Do not enable non-existing USB endpoints
Number of USB endpoints is set via DTS, nevertheless USB driver tries to enable all endpoints as it uses number of endpoints from nRFx. This commit makes driver enable only these endpoints that were enabled in DTS. Signed-off-by: Pawel Dunaj <[email protected]>
1 parent fdce786 commit bfb23cc

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

drivers/usb/device/usb_dc_nrfx.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static void usbd_enable_endpoints(struct nrf_usbd_ctx *ctx)
507507
struct nrf_usbd_ep_ctx *ep_ctx;
508508
int i;
509509

510-
for (i = 0; i < NRF_USBD_EPIN_CNT; i++) {
510+
for (i = 0; i < CFG_EPIN_CNT; i++) {
511511
ep_ctx = in_endpoint_ctx(i);
512512
__ASSERT_NO_MSG(ep_ctx);
513513

@@ -516,14 +516,32 @@ static void usbd_enable_endpoints(struct nrf_usbd_ctx *ctx)
516516
}
517517
}
518518

519-
for (i = 0; i < NRF_USBD_EPOUT_CNT; i++) {
519+
if (CFG_EP_ISOIN_CNT) {
520+
ep_ctx = in_endpoint_ctx(NRF_USBD_EPIN(8));
521+
__ASSERT_NO_MSG(ep_ctx);
522+
523+
if (ep_ctx->cfg.en) {
524+
nrfx_usbd_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
525+
}
526+
}
527+
528+
for (i = 0; i < CFG_EPOUT_CNT; i++) {
520529
ep_ctx = out_endpoint_ctx(i);
521530
__ASSERT_NO_MSG(ep_ctx);
522531

523532
if (ep_ctx->cfg.en) {
524533
nrfx_usbd_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
525534
}
526535
}
536+
537+
if (CFG_EP_ISOOUT_CNT) {
538+
ep_ctx = out_endpoint_ctx(NRF_USBD_EPOUT(8));
539+
__ASSERT_NO_MSG(ep_ctx);
540+
541+
if (ep_ctx->cfg.en) {
542+
nrfx_usbd_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
543+
}
544+
}
527545
}
528546

529547
/**

0 commit comments

Comments
 (0)