Skip to content

Commit 7791f58

Browse files
pawelzadrozniakcarlescufi
authored andcommitted
drivers: usb: nordic: Fix max packet size handling
This commit fixes the issue with non-default max packet size (<64). The max packet size value was not passed to low-level driver in norfic hal (nrfx_usbd) causing 64-byte being send regardless of configured endpoint size. Size mismatch results in communication error on Linux hosts. Signed-off-by: Paweł Zadrożniak <[email protected]>
1 parent 9f7e25a commit 7791f58

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/usb/device/usb_dc_nrfx.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,13 @@ int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data *const ep_cfg)
11921192
ep_ctx->cfg.type = ep_cfg->ep_type;
11931193
ep_ctx->cfg.max_sz = ep_cfg->ep_mps;
11941194

1195+
if ((ep_cfg->ep_mps & (ep_cfg->ep_mps - 1)) != 0) {
1196+
LOG_ERR("EP max packet size must be a power of 2.");
1197+
return -EINVAL;
1198+
}
1199+
nrfx_usbd_ep_max_packet_size_set(ep_addr_to_nrfx(ep_cfg->ep_addr),
1200+
ep_cfg->ep_mps);
1201+
11951202
return 0;
11961203
}
11971204

0 commit comments

Comments
 (0)