1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 04:52:59 +01:00

driver/usbdev_synopsys_dwc2: use correct number of EPs

This commit fixes the problem that the driver uses the wrong number of EPs when using the USB OTG HS core. The reason is that the constant `DWC2_USB_OTG_FS_NUM_EP` is used in several places even though there is a function `_max_endpoints` which takes into account the configuration used. For most MCUs this is not a problem, because they have only a USB OTG FS core anyway. But for MCUs like the STM32, which has both a USB OTG FS core and a USB OTG HS core, it matters.
This commit is contained in:
Gunar Schorcht 2023-03-11 16:56:32 +01:00
parent 19da279ba5
commit 4d19f21703

View File

@ -451,7 +451,7 @@ static void _set_address(dwc2_usb_otg_fshs_t *usbdev, uint8_t address)
static usbdev_ep_t *_get_ep(dwc2_usb_otg_fshs_t *usbdev, unsigned num,
usb_ep_dir_t dir)
{
if (num >= DWC2_USB_OTG_FS_NUM_EP) {
if (num >= _max_endpoints(usbdev->config)) {
return NULL;
}
return dir == USB_EP_DIR_IN ? &usbdev->in[num] : &usbdev->out[num].ep;
@ -532,7 +532,7 @@ static usbdev_ep_t *_usbdev_new_ep(usbdev_t *dev, usb_ep_type_t type,
}
else {
/* Find the first unassigned ep with matching direction */
for (unsigned idx = 1; idx < DWC2_USB_OTG_FS_NUM_EP && !ep; idx++) {
for (unsigned idx = 1; idx < _max_endpoints(usbdev->config) && !ep; idx++) {
usbdev_ep_t *candidate_ep = _get_ep(usbdev, idx, dir);
if (candidate_ep->type == USB_EP_TYPE_NONE) {
ep = candidate_ep;