diff --git a/src/class/audio/audio_device.c b/src/class/audio/audio_device.c index 942933b5d..ebb8434cd 100644 --- a/src/class/audio/audio_device.c +++ b/src/class/audio/audio_device.c @@ -780,8 +780,12 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const * if (tu_desc_type(p_desc) == TUSB_DESC_ENDPOINT) { TU_ASSERT(usbd_edpt_open(rhport, (tusb_desc_endpoint_t const *)p_desc)); + uint8_t ep_addr = ((tusb_desc_endpoint_t const *) p_desc)->bEndpointAddress; + // We need to set EP non busy since this is not taken care of right now in ep_close() - THIS IS A WORKAROUND! + usbd_edpt_clear_stall(rhport, ep_addr); + #if CFG_TUD_AUDIO_EPSIZE_IN > 0 if (tu_edpt_dir(ep_addr) == TUSB_DIR_IN && ((tusb_desc_endpoint_t const *) p_desc)->bmAttributes.usage == 0x00) // Check if usage is data EP { @@ -1081,11 +1085,12 @@ bool audiod_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint3 uint16_t n_bytes_copied; TU_VERIFY(audiod_tx_done_cb(rhport, &_audiod_itf[idxDriver], &n_bytes_copied)); - if (n_bytes_copied == 0) - { - // Load with ZLP - return usbd_edpt_xfer(rhport, ep_addr, NULL, 0); - } + // Transmission of ZLP is done by audiod_tx_done_cb() +// if (n_bytes_copied == 0) +// { +// // Load with ZLP +// return usbd_edpt_xfer(rhport, ep_addr, NULL, 0); +// } return true; } diff --git a/src/portable/st/synopsys/dcd_synopsys.c b/src/portable/st/synopsys/dcd_synopsys.c index d1f24916c..c1b087dac 100644 --- a/src/portable/st/synopsys/dcd_synopsys.c +++ b/src/portable/st/synopsys/dcd_synopsys.c @@ -682,42 +682,42 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc_edpt) return true; } -/** - * Close an EP. - * - * Currently, we only deactivate the EPs and do not fully disable them - this might not be necessary! - * - */ -void dcd_edpt_close (uint8_t rhport, uint8_t ep_addr) -{ - (void)rhport; - uint32_t const epnum = tu_edpt_number(ep_addr); - uint32_t const dir = tu_edpt_dir(ep_addr); - - USB_OTG_DeviceTypeDef * dev = DEVICE_BASE(rhport); - - if(dir == TUSB_DIR_IN) - { - USB_OTG_INEndpointTypeDef * in_ep = IN_EP_BASE(rhport); - - // Disable interrupt for this EP - dev->DAINTMSK &= ~(1 << (USB_OTG_DAINTMSK_IEPM_Pos + epnum)); - - // Clear USB active EP - in_ep[epnum].DIEPCTL &= ~USB_OTG_DIEPCTL_USBAEP; - } - else - { - USB_OTG_OUTEndpointTypeDef * out_ep = OUT_EP_BASE(rhport); - - // Disable interrupt for this EP - dev->DAINTMSK &= ~(1 << (USB_OTG_DAINTMSK_OEPM_Pos + epnum));; - - // Clear USB active EP bit - out_ep[epnum].DOEPCTL &= ~USB_OTG_DOEPCTL_USBAEP; - - } -} +///** +// * Close an EP. +// * +// * Currently, we only deactivate the EPs and do not fully disable them - this might not be necessary! +// * +// */ +//void dcd_edpt_close (uint8_t rhport, uint8_t ep_addr) +//{ +// (void)rhport; +// uint32_t const epnum = tu_edpt_number(ep_addr); +// uint32_t const dir = tu_edpt_dir(ep_addr); +// +// USB_OTG_DeviceTypeDef * dev = DEVICE_BASE(rhport); +// +// if(dir == TUSB_DIR_IN) +// { +// USB_OTG_INEndpointTypeDef * in_ep = IN_EP_BASE(rhport); +// +// // Disable interrupt for this EP +// dev->DAINTMSK &= ~(1 << (USB_OTG_DAINTMSK_IEPM_Pos + epnum)); +// +// // Clear USB active EP +// in_ep[epnum].DIEPCTL &= ~USB_OTG_DIEPCTL_USBAEP; +// } +// else +// { +// USB_OTG_OUTEndpointTypeDef * out_ep = OUT_EP_BASE(rhport); +// +// // Disable interrupt for this EP +// dev->DAINTMSK &= ~(1 << (USB_OTG_DAINTMSK_OEPM_Pos + epnum));; +// +// // Clear USB active EP bit +// out_ep[epnum].DOEPCTL &= ~USB_OTG_DOEPCTL_USBAEP; +// +// } +//} bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes) { @@ -815,14 +815,14 @@ void dcd_edpt_close (uint8_t rhport, uint8_t ep_addr) uint8_t const dir = tu_edpt_dir(ep_addr); dcd_edpt_disable(rhport, ep_addr, false); - if (dir == TUSB_DIR_IN) - { - uint16_t const fifo_size = (usb_otg->DIEPTXF[epnum - 1] & USB_OTG_DIEPTXF_INEPTXFD_Msk) >> USB_OTG_DIEPTXF_INEPTXFD_Pos; - uint16_t const fifo_start = (usb_otg->DIEPTXF[epnum - 1] & USB_OTG_DIEPTXF_INEPTXSA_Msk) >> USB_OTG_DIEPTXF_INEPTXSA_Pos; - // For now only endpoint that has FIFO at the end of FIFO memory can be closed without fuss. - TU_ASSERT(fifo_start + fifo_size == _allocated_fifo_words,); - _allocated_fifo_words -= fifo_size; - } +// if (dir == TUSB_DIR_IN) +// { +// uint16_t const fifo_size = (usb_otg->DIEPTXF[epnum - 1] & USB_OTG_DIEPTXF_INEPTXFD_Msk) >> USB_OTG_DIEPTXF_INEPTXFD_Pos; +// uint16_t const fifo_start = (usb_otg->DIEPTXF[epnum - 1] & USB_OTG_DIEPTXF_INEPTXSA_Msk) >> USB_OTG_DIEPTXF_INEPTXSA_Pos; +// // For now only endpoint that has FIFO at the end of FIFO memory can be closed without fuss. +// TU_ASSERT(fifo_start + fifo_size == _allocated_fifo_words,); +// _allocated_fifo_words -= fifo_size; +// } } void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) @@ -1156,6 +1156,11 @@ void dcd_int_handler(uint8_t rhport) // IEPINT bit read-only handle_epin_ints(rhport, dev, in_ep); } + + // Check for Incomplete isochronous IN transfer + if(int_status & USB_OTG_GINTSTS_IISOIXFR) { + TU_LOG2(" IISOIXFR!\r\n"); + } } // Helper function which parses through the current configuration descriptors to find the biggest EPs in size.