Skip to content
Permalink
Browse files

usb: sam0: Implement missing API functions

This implements three API functions that are required for
tests/subsys/usb/device to build:

 - usb_dc_ep_disable()
 - usb_dc_ep_halt()
 - usb_dc_ep_flush()

While halt and disable are trivial, flush is just a stub for now.

Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
  • Loading branch information...
benpicco authored and galak committed Apr 23, 2019
1 parent f95f5ae commit c8208a399a4c3deb75fab0c1c862f525c33b0d34
Showing with 41 additions and 0 deletions.
  1. +41 −0 drivers/usb/device/usb_dc_sam0.c
@@ -423,6 +423,28 @@ int usb_dc_ep_is_stalled(const u8_t ep, u8_t *stalled)
return 0;
}

/* Halt the selected endpoint */
int usb_dc_ep_halt(u8_t ep)
{
return usb_dc_ep_set_stall(ep);
}

/* Flush the selected endpoint */
int usb_dc_ep_flush(u8_t ep)
{
u8_t ep_num = ep & ~USB_EP_DIR_MASK;

if (ep_num >= USB_NUM_ENDPOINTS) {
LOG_ERR("endpoint index/address out of range");
return -1;
}

/* TODO */
LOG_WRN("flush not implemented");

return 0;
}

/* Enable an endpoint and the endpoint interrupts */
int usb_dc_ep_enable(const u8_t ep)
{
@@ -449,6 +471,25 @@ int usb_dc_ep_enable(const u8_t ep)
return 0;
}

/* Disable the selected endpoint */
int usb_dc_ep_disable(u8_t ep)
{
UsbDevice *regs = &REGS->DEVICE;
u8_t ep_num = ep & ~USB_EP_DIR_MASK;
UsbDeviceEndpoint *endpoint = &regs->DeviceEndpoint[ep_num];

if (ep_num >= USB_NUM_ENDPOINTS) {
LOG_ERR("endpoint index/address out of range");
return -1;
}

endpoint->EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRCPT0
| USB_DEVICE_EPINTENCLR_TRCPT1
| USB_DEVICE_EPINTENCLR_RXSTP;

return 0;
}

/* Write a single payload to the IN buffer on the endpoint */
int usb_dc_ep_write(u8_t ep, const u8_t *buf, u32_t len, u32_t *ret_bytes)
{

0 comments on commit c8208a3

Please sign in to comment.
You can’t perform that action at this time.