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>
This commit is contained in:
parent
f95f5ae41e
commit
c8208a399a
1 changed files with 41 additions and 0 deletions
|
@ -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 = ®S->DEVICE;
|
||||
u8_t ep_num = ep & ~USB_EP_DIR_MASK;
|
||||
UsbDeviceEndpoint *endpoint = ®s->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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue