summaryrefslogtreecommitdiff
path: root/src/portable/nxp
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2025-11-19 22:05:07 +0100
committerHiFiPhile <[email protected]>2025-11-19 22:05:07 +0100
commit85adf694e659bde41b34e2f585cb2db552279064 (patch)
tree6445badf0b427556fd47fb3d7b682bb8b439039e /src/portable/nxp
parent2f0a35f21af4c09154d6b4b5b118325af8990e51 (diff)
parent790c7a0d7a6099e88a0bf6bbc341504c8bdaa974 (diff)
Merge remote-tracking branch 'tinyusb/master' into copilot/fix-dcd-edpt-xfer-issue
Signed-off-by: HiFiPhile <[email protected]>
Diffstat (limited to 'src/portable/nxp')
-rw-r--r--src/portable/nxp/khci/dcd_khci.c66
-rw-r--r--src/portable/nxp/lpc17_40/dcd_lpc17_40.c15
-rw-r--r--src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c16
3 files changed, 57 insertions, 40 deletions
diff --git a/src/portable/nxp/khci/dcd_khci.c b/src/portable/nxp/khci/dcd_khci.c
index 8941ca766..ad27b8528 100644
--- a/src/portable/nxp/khci/dcd_khci.c
+++ b/src/portable/nxp/khci/dcd_khci.c
@@ -355,24 +355,21 @@ void dcd_sof_enable(uint8_t rhport, bool en)
//--------------------------------------------------------------------+
// Endpoint API
//--------------------------------------------------------------------+
-bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * ep_desc)
-{
- (void) rhport;
+static bool edpt_open(uint8_t rhport, uint8_t ep_addr, uint16_t max_packet_size, tusb_xfer_type_t xfer) {
+ (void)rhport;
- const unsigned ep_addr = ep_desc->bEndpointAddress;
- const unsigned epn = tu_edpt_number(ep_addr);
- const unsigned dir = tu_edpt_dir(ep_addr);
- const unsigned xfer = ep_desc->bmAttributes.xfer;
- endpoint_state_t *ep = &_dcd.endpoint[epn][dir];
- const unsigned odd = ep->odd;
- buffer_descriptor_t *bd = _dcd.bdt[epn][dir];
+ const unsigned epn = tu_edpt_number(ep_addr);
+ const unsigned dir = tu_edpt_dir(ep_addr);
+ endpoint_state_t *ep = &_dcd.endpoint[epn][dir];
+ const unsigned odd = ep->odd;
+ buffer_descriptor_t *bd = _dcd.bdt[epn][dir];
/* No support for control transfer */
TU_ASSERT(epn && (xfer != TUSB_XFER_CONTROL));
- ep->max_packet_size = tu_edpt_packet_size(ep_desc);
- unsigned val = USB_ENDPT_EPCTLDIS_MASK;
- val |= (xfer != TUSB_XFER_ISOCHRONOUS) ? USB_ENDPT_EPHSHK_MASK: 0;
+ ep->max_packet_size = max_packet_size;
+ unsigned val = USB_ENDPT_EPCTLDIS_MASK;
+ val |= (xfer != TUSB_XFER_ISOCHRONOUS) ? USB_ENDPT_EPHSHK_MASK : 0;
val |= dir ? USB_ENDPT_EPTXEN_MASK : USB_ENDPT_EPRXEN_MASK;
KHCI->ENDPOINT[epn].ENDPT |= val;
@@ -386,6 +383,26 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * ep_desc)
return true;
}
+bool dcd_edpt_open(uint8_t rhport, const tusb_desc_endpoint_t *ep_desc) {
+ return edpt_open(rhport, ep_desc->bEndpointAddress, tu_edpt_packet_size(ep_desc), ep_desc->bmAttributes.xfer);
+}
+
+bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size) {
+ return edpt_open(rhport, ep_addr, largest_packet_size, TUSB_XFER_ISOCHRONOUS);
+}
+
+bool dcd_edpt_iso_activate(uint8_t rhport, const tusb_desc_endpoint_t *ep_desc) {
+ const unsigned epn = tu_edpt_number(ep_desc->bEndpointAddress);
+ const unsigned dir = tu_edpt_dir(ep_desc->bEndpointAddress);
+ endpoint_state_t *ep = &_dcd.endpoint[epn][dir];
+
+ dcd_int_disable(rhport);
+ ep->max_packet_size = tu_edpt_packet_size(ep_desc);
+ dcd_int_enable(rhport);
+
+ return true;
+}
+
void dcd_edpt_close_all(uint8_t rhport)
{
(void) rhport;
@@ -408,30 +425,10 @@ void dcd_edpt_close_all(uint8_t rhport)
}
}
-void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
-{
- (void) rhport;
-
- const unsigned epn = tu_edpt_number(ep_addr);
- const unsigned dir = tu_edpt_dir(ep_addr);
- endpoint_state_t *ep = &_dcd.endpoint[epn][dir];
- buffer_descriptor_t *bd = _dcd.bdt[epn][dir];
- const unsigned msk = dir ? USB_ENDPT_EPTXEN_MASK : USB_ENDPT_EPRXEN_MASK;
- const unsigned ie = NVIC_GetEnableIRQ(USB0_IRQn);
- NVIC_DisableIRQ(USB0_IRQn);
- KHCI->ENDPOINT[epn].ENDPT &= ~msk;
- ep->max_packet_size = 0;
- ep->length = 0;
- ep->remaining = 0;
- bd[0].head = 0;
- bd[1].head = 0;
- if (ie) NVIC_EnableIRQ(USB0_IRQn);
-}
-
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
{
- (void) is_isr;
(void) rhport;
+ (void) is_isr;
const unsigned epn = tu_edpt_number(ep_addr);
const unsigned dir = tu_edpt_dir(ep_addr);
endpoint_state_t *ep = &_dcd.endpoint[epn][dir];
@@ -578,5 +575,4 @@ void dcd_int_handler(uint8_t rhport)
process_tokdne(rhport);
}
}
-
#endif
diff --git a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
index 364cf8de4..349229c8d 100644
--- a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
+++ b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
@@ -337,9 +337,17 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc)
return true;
}
-void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr) {
- (void) rhport; (void) ep_addr;
- // TODO implement dcd_edpt_close()
+bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size) {
+ (void)rhport;
+ (void)ep_addr;
+ (void)largest_packet_size;
+ return false;
+}
+
+bool dcd_edpt_iso_activate(uint8_t rhport, const tusb_desc_endpoint_t *desc_ep) {
+ (void)rhport;
+ (void)desc_ep;
+ return false;
}
void dcd_edpt_close_all (uint8_t rhport)
@@ -601,5 +609,4 @@ void dcd_int_handler(uint8_t rhport)
TU_BREAKPOINT();
}
}
-
#endif
diff --git a/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c b/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
index 143b0277c..5f4a441dc 100644
--- a/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
+++ b/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
@@ -432,6 +432,21 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
_dcd.ep[ep_id][0].cmd_sts.disable = _dcd.ep[ep_id][1].cmd_sts.disable = 1;
}
+#if 0
+bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size) {
+ (void)rhport;
+ (void)ep_addr;
+ (void)largest_packet_size;
+ return false;
+}
+
+bool dcd_edpt_iso_activate(uint8_t rhport, const tusb_desc_endpoint_t *desc_ep) {
+ (void)rhport;
+ (void)desc_ep;
+ return false;
+}
+#endif
+
static void prepare_ep_xfer(uint8_t rhport, uint8_t ep_id, uint16_t buf_offset, uint16_t total_bytes) {
uint16_t nbytes;
ep_cmd_sts_t* ep_cs = get_ep_cs(ep_id);
@@ -632,5 +647,4 @@ void dcd_int_handler(uint8_t rhport)
// Endpoint transfer complete interrupt
process_xfer_isr(rhport, int_status);
}
-
#endif