diff options
| author | sakumisu <[email protected]> | 2024-04-29 11:32:54 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2024-04-29 11:32:54 +0800 |
| commit | 45e9a2fde8f4cf311e9d3b90d77eb4ee7b93a599 (patch) | |
| tree | 2adce9d1cf5799f6164aafa7eddd8ffc5f72318f | |
| parent | 5b72907f6d9f7566faa2be55d8033f3c8b552b8c (diff) | |
add usbd_get_ep_mps api
| -rw-r--r-- | core/usbd_core.c | 16 | ||||
| -rw-r--r-- | core/usbd_core.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/core/usbd_core.c b/core/usbd_core.c index a678c01e..2fdf94a8 100644 --- a/core/usbd_core.c +++ b/core/usbd_core.c @@ -20,6 +20,7 @@ struct usbd_tx_rx_msg { uint8_t ep; + uint16_t ep_mps; uint32_t nbytes; usbd_endpoint_callback cb; }; @@ -101,6 +102,12 @@ static bool usbd_set_endpoint(uint8_t busid, const struct usb_endpoint_descripto USB_GET_ENDPOINT_TYPE(ep->bmAttributes), USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize)); + if (ep->bEndpointAddress & 0x80) { + g_usbd_core[busid].tx_msg[ep->bEndpointAddress & 0x7f].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize) * (USB_GET_MULT(ep->wMaxPacketSize)); + } else { + g_usbd_core[busid].rx_msg[ep->bEndpointAddress & 0x7f].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize) * (USB_GET_MULT(ep->wMaxPacketSize)); + } + return usbd_ep_open(busid, ep) == 0 ? true : false; } /** @@ -1197,6 +1204,15 @@ void usbd_add_endpoint(uint8_t busid, struct usbd_endpoint *ep) } } +uint16_t usbd_get_ep_mps(uint8_t busid, uint8_t ep) +{ + if (ep & 0x80) { + return g_usbd_core[busid].tx_msg[ep & 0x7f].ep_mps; + } else { + return g_usbd_core[busid].rx_msg[ep & 0x7f].ep_mps; + } +} + bool usb_device_is_configured(uint8_t busid) { return g_usbd_core[busid].configuration; diff --git a/core/usbd_core.h b/core/usbd_core.h index 0014d967..a4155058 100644 --- a/core/usbd_core.h +++ b/core/usbd_core.h @@ -97,6 +97,7 @@ void usbd_bos_desc_register(uint8_t busid, struct usb_bos_descriptor *desc); void usbd_add_interface(uint8_t busid, struct usbd_interface *intf); void usbd_add_endpoint(uint8_t busid, struct usbd_endpoint *ep); +uint16_t usbd_get_ep_mps(uint8_t busid, uint8_t ep); bool usb_device_is_configured(uint8_t busid); int usbd_initialize(uint8_t busid, uint32_t reg_base, void (*event_handler)(uint8_t busid, uint8_t event)); int usbd_deinitialize(uint8_t busid); |
