Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 47 additions & 8 deletions tests/drivers/udc/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,25 @@ static void test_udc_ep_try_config(const struct device *dev,
uint16_t mps = sys_le16_to_cpu(ed->wMaxPacketSize);
int err;

err = udc_ep_try_config(dev, ed->bEndpointAddress,
ed->bmAttributes, &mps,
ed->bInterval);
for (int idx = 0; idx < 16U; idx++) {
uint8_t ep;

if (USB_EP_DIR_IS_IN(ed->bEndpointAddress)) {
ep = USB_EP_DIR_IN | idx;
} else {
ep = USB_EP_DIR_OUT | idx;
}

err = udc_ep_try_config(dev, ep,
ed->bmAttributes, &mps,
ed->bInterval);

if (!err) {
ed->bEndpointAddress = ep;
break;
}
}

zassert_equal(err, 0, "Failed to test endpoint configuration");

if (ed->bmAttributes == USB_EP_TYPE_CONTROL ||
Expand Down Expand Up @@ -365,7 +381,10 @@ static void test_udc_ep_mps(uint8_t type)
.bInterval = 0,
};
const struct device *dev;
uint16_t supported = 0;
uint16_t out_supported = 0;
uint16_t in_supported = 0;
uint16_t out_ep = 0;
uint16_t in_ep = 0;
int err;

dev = DEVICE_DT_GET(DT_NODELABEL(zephyr_udc0));
Expand All @@ -383,25 +402,45 @@ static void test_udc_ep_mps(uint8_t type)

for (uint8_t i = 1; i < 16U; i++) {
err = udc_ep_try_config(dev, i,
ed.bmAttributes, &supported,
ed.bmAttributes, &out_supported,
ed.bInterval);
if (!err) {
out_ep = i;
break;
}
}

for (uint8_t i = 1; i < 16U; i++) {
err = udc_ep_try_config(dev, i | USB_EP_DIR_IN,
ed.bmAttributes, &in_supported,
ed.bInterval);
if (!err) {
ed.bEndpointAddress = i;
in_ep = i | USB_EP_DIR_IN;
break;
}
}

zassert_ok(err, "Failed to determine MPS");

for (int i = 0; i < ARRAY_SIZE(mps); i++) {
if (mps[i] > supported) {
if (mps[i] > out_supported) {
continue;
}

ed.bEndpointAddress = out_ep;
ed.wMaxPacketSize = sys_cpu_to_le16(mps[i]);

test_udc_ep_api(dev, &ed);
}

for (int i = 0; i < ARRAY_SIZE(mps); i++) {
if (mps[i] > in_supported) {
continue;
}

ed.bEndpointAddress = in_ep;
ed.wMaxPacketSize = sys_cpu_to_le16(mps[i]);

ed.bEndpointAddress |= USB_EP_DIR_IN;
test_udc_ep_api(dev, &ed);
}

Expand Down
Loading