Start of sampling works.

This commit is contained in:
Reinhard Panhuber 2020-09-06 11:37:59 +02:00
parent 12562fc966
commit 4e789b240d
2 changed files with 59 additions and 49 deletions

View File

@ -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) if (tu_desc_type(p_desc) == TUSB_DESC_ENDPOINT)
{ {
TU_ASSERT(usbd_edpt_open(rhport, (tusb_desc_endpoint_t const *)p_desc)); 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; 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 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 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; uint16_t n_bytes_copied;
TU_VERIFY(audiod_tx_done_cb(rhport, &_audiod_itf[idxDriver], &n_bytes_copied)); TU_VERIFY(audiod_tx_done_cb(rhport, &_audiod_itf[idxDriver], &n_bytes_copied));
if (n_bytes_copied == 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); // // Load with ZLP
} // return usbd_edpt_xfer(rhport, ep_addr, NULL, 0);
// }
return true; return true;
} }

View File

@ -682,42 +682,42 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc_edpt)
return true; return true;
} }
/** ///**
* Close an EP. // * Close an EP.
* // *
* Currently, we only deactivate the EPs and do not fully disable them - this might not be necessary! // * 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 dcd_edpt_close (uint8_t rhport, uint8_t ep_addr)
{ //{
(void)rhport; // (void)rhport;
uint32_t const epnum = tu_edpt_number(ep_addr); // uint32_t const epnum = tu_edpt_number(ep_addr);
uint32_t const dir = tu_edpt_dir(ep_addr); // uint32_t const dir = tu_edpt_dir(ep_addr);
//
USB_OTG_DeviceTypeDef * dev = DEVICE_BASE(rhport); // USB_OTG_DeviceTypeDef * dev = DEVICE_BASE(rhport);
//
if(dir == TUSB_DIR_IN) // if(dir == TUSB_DIR_IN)
{ // {
USB_OTG_INEndpointTypeDef * in_ep = IN_EP_BASE(rhport); // USB_OTG_INEndpointTypeDef * in_ep = IN_EP_BASE(rhport);
//
// Disable interrupt for this EP // // Disable interrupt for this EP
dev->DAINTMSK &= ~(1 << (USB_OTG_DAINTMSK_IEPM_Pos + epnum)); // dev->DAINTMSK &= ~(1 << (USB_OTG_DAINTMSK_IEPM_Pos + epnum));
//
// Clear USB active EP // // Clear USB active EP
in_ep[epnum].DIEPCTL &= ~USB_OTG_DIEPCTL_USBAEP; // in_ep[epnum].DIEPCTL &= ~USB_OTG_DIEPCTL_USBAEP;
} // }
else // else
{ // {
USB_OTG_OUTEndpointTypeDef * out_ep = OUT_EP_BASE(rhport); // USB_OTG_OUTEndpointTypeDef * out_ep = OUT_EP_BASE(rhport);
//
// Disable interrupt for this EP // // Disable interrupt for this EP
dev->DAINTMSK &= ~(1 << (USB_OTG_DAINTMSK_OEPM_Pos + epnum));; // dev->DAINTMSK &= ~(1 << (USB_OTG_DAINTMSK_OEPM_Pos + epnum));;
//
// Clear USB active EP bit // // Clear USB active EP bit
out_ep[epnum].DOEPCTL &= ~USB_OTG_DOEPCTL_USBAEP; // 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) 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); uint8_t const dir = tu_edpt_dir(ep_addr);
dcd_edpt_disable(rhport, ep_addr, false); dcd_edpt_disable(rhport, ep_addr, false);
if (dir == TUSB_DIR_IN) // 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_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; // 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. // // 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,); // TU_ASSERT(fifo_start + fifo_size == _allocated_fifo_words,);
_allocated_fifo_words -= fifo_size; // _allocated_fifo_words -= fifo_size;
} // }
} }
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) 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 // IEPINT bit read-only
handle_epin_ints(rhport, dev, in_ep); 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. // Helper function which parses through the current configuration descriptors to find the biggest EPs in size.