diff options
| author | Reinhard Panhuber <[email protected]> | 2020-08-16 13:48:25 +0200 |
|---|---|---|
| committer | Reinhard Panhuber <[email protected]> | 2020-08-16 13:48:25 +0200 |
| commit | 444e4d282137953e6834360a9fb866331d21d954 (patch) | |
| tree | 9eca05977d46094a885eafc4aa937eeb71541189 /src/portable | |
| parent | c557bf7b2e35482e8743eebfca7b5ff28b0b6d86 (diff) | |
Add EP close. Fix bug in set_interface within audio.
Diffstat (limited to 'src/portable')
| -rw-r--r-- | src/portable/st/synopsys/dcd_synopsys.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/portable/st/synopsys/dcd_synopsys.c b/src/portable/st/synopsys/dcd_synopsys.c index 133a3736a..68c30c4b5 100644 --- a/src/portable/st/synopsys/dcd_synopsys.c +++ b/src/portable/st/synopsys/dcd_synopsys.c @@ -673,6 +673,43 @@ 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; + + } +} + bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes) { uint8_t const epnum = tu_edpt_number(ep_addr); |
