mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
USBUS/cdc_acm: Adapt to xmit API
This commit is contained in:
parent
7d9a177f25
commit
1a0bc3d8bc
@ -142,6 +142,16 @@ struct usbus_cdcacm_device {
|
||||
usbus_cdcacm_line_state_t state; /**< Current line state */
|
||||
event_t flush; /**< device2host forced flush event */
|
||||
usb_req_cdcacm_coding_t coding; /**< Current coding configuration */
|
||||
|
||||
/**
|
||||
* @brief Host to device data buffer
|
||||
*/
|
||||
usbdev_ep_buf_t out_buf[CONFIG_USBUS_CDC_ACM_BULK_EP_SIZE];
|
||||
|
||||
/**
|
||||
* @brief Device to host data buffer
|
||||
*/
|
||||
usbdev_ep_buf_t in_buf[CONFIG_USBUS_CDC_ACM_STDIO_BUF_SIZE];
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -303,7 +303,8 @@ static int _control_handler(usbus_t *usbus, usbus_handler_t *handler,
|
||||
usbus_endpoint_t *data_out = usbus_interface_find_endpoint(
|
||||
&cdcacm->iface_data, USB_EP_TYPE_BULK, USB_EP_DIR_OUT);
|
||||
assert(data_out);
|
||||
usbdev_ep_ready(data_out->ep, 0);
|
||||
usbdev_ep_xmit(data_out->ep, cdcacm->out_buf,
|
||||
CONFIG_USBUS_CDC_ACM_BULK_EP_SIZE);
|
||||
usbus_cdc_acm_flush(cdcacm);
|
||||
}
|
||||
else {
|
||||
@ -329,13 +330,13 @@ static void _handle_in(usbus_cdcacm_device_t *cdcacm,
|
||||
unsigned old = irq_disable();
|
||||
while (!tsrb_empty(&cdcacm->tsrb)) {
|
||||
int c = tsrb_get_one(&cdcacm->tsrb);
|
||||
ep->buf[cdcacm->occupied++] = (uint8_t)c;
|
||||
cdcacm->in_buf[cdcacm->occupied++] = (uint8_t)c;
|
||||
if (cdcacm->occupied >= CONFIG_USBUS_CDC_ACM_BULK_EP_SIZE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
irq_restore(old);
|
||||
usbdev_ep_ready(ep, cdcacm->occupied);
|
||||
usbdev_ep_xmit(ep, cdcacm->in_buf, cdcacm->occupied);
|
||||
}
|
||||
|
||||
static void _transfer_handler(usbus_t *usbus, usbus_handler_t *handler,
|
||||
@ -349,9 +350,9 @@ static void _transfer_handler(usbus_t *usbus, usbus_handler_t *handler,
|
||||
/* Retrieve incoming data */
|
||||
usbdev_ep_get(ep, USBOPT_EP_AVAILABLE, &len, sizeof(size_t));
|
||||
if (len > 0) {
|
||||
cdcacm->cb(cdcacm, ep->buf, len);
|
||||
cdcacm->cb(cdcacm, cdcacm->out_buf, len);
|
||||
}
|
||||
usbdev_ep_ready(ep, 0);
|
||||
usbdev_ep_xmit(ep, cdcacm->out_buf, CONFIG_USBUS_CDC_ACM_BULK_EP_SIZE);
|
||||
}
|
||||
if ((ep->dir == USB_EP_DIR_IN) && (ep->type == USB_EP_TYPE_BULK)) {
|
||||
cdcacm->occupied = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user