summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorMengsk <[email protected]>2022-12-29 19:19:27 +0100
committerMengsk <[email protected]>2022-12-29 19:19:27 +0100
commitfe8c170c98c40a2fb517cbeaa49336b5af572c0f (patch)
treef3309f0109ba72dc5373ad82d5229b7a0d6d1549 /src/device
parentcece59df22cdd6d07f49676ff356a781d4536245 (diff)
Add dcd_edpt_iso_alloc() / dcd_edpt_iso_activate() for ISO EP buffer management.
Diffstat (limited to 'src/device')
-rw-r--r--src/device/dcd.h6
-rw-r--r--src/device/usbd.c19
-rw-r--r--src/device/usbd_pvt.h6
3 files changed, 31 insertions, 0 deletions
diff --git a/src/device/dcd.h b/src/device/dcd.h
index c1780f656..ef92d71d0 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -167,6 +167,12 @@ void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr);
// This API never calls with control endpoints, since it is auto cleared when receiving setup packet
void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr);
+// Allocate packet buffer used by ISO endpoints
+// Some MCU need manual packet buffer allocation, we allocation largest size to avoid clustering
+bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size);
+
+// Configure and enable an ISO endpoint according to descriptor
+bool dcd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc);
//--------------------------------------------------------------------+
// Event API (implemented by stack)
//--------------------------------------------------------------------+
diff --git a/src/device/usbd.c b/src/device/usbd.c
index f652a878e..8b5e4d745 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -1380,4 +1380,23 @@ void usbd_sof_enable(uint8_t rhport, bool en)
dcd_sof_enable(rhport, en);
}
+bool usbd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size)
+{
+ rhport = _usbd_rhport;
+
+ TU_ASSERT(tu_edpt_number(ep_addr) < CFG_TUD_ENDPPOINT_MAX);
+
+ return dcd_edpt_iso_alloc(rhport, ep_addr, largest_packet_size);
+}
+
+bool usbd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * desc_ep)
+{
+ rhport = _usbd_rhport;
+
+ TU_ASSERT(tu_edpt_number(desc_ep->bEndpointAddress) < CFG_TUD_ENDPPOINT_MAX);
+ TU_ASSERT(tu_edpt_validate(desc_ep, (tusb_speed_t) _usbd_dev.speed));
+
+ return dcd_edpt_iso_activate(rhport, desc_ep);
+}
+
#endif
diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h
index 6fad46db3..f860ab0a1 100644
--- a/src/device/usbd_pvt.h
+++ b/src/device/usbd_pvt.h
@@ -96,6 +96,12 @@ void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr);
// Check if endpoint is stalled
bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr);
+// Allocate packet buffer used by ISO endpoints
+bool usbd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size);
+
+// Configure and enable an ISO endpoint according to descriptor
+bool usbd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc);
+
// Check if endpoint is ready (not busy and not stalled)
TU_ATTR_ALWAYS_INLINE static inline
bool usbd_edpt_ready(uint8_t rhport, uint8_t ep_addr)