Fix isochronous out endpoints only receiving data on odd frames (on the STM32f411 mcu) - #152
Open
theawsomeavr wants to merge 1 commit into
Open
Fix isochronous out endpoints only receiving data on odd frames (on the STM32f411 mcu)#152theawsomeavr wants to merge 1 commit into
theawsomeavr wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When using isochronous out endpoints for receiving USB audio packets on an
STM32f411, data is only received on odd frames, ignoring half of the USB audio data.
The reference manual RM0383
on page 789 under the internal data flow states that:
"The core receives data on an isochronous OUT endpoint in a particular frame only if the
following condition is met:
EONUM (in OTG_FS_DOEPCTLx) = SOFFN[0] (in OTG_FS_DSTS)."
The EONUM bit in the DOEPCTL register is normally set (for each endpoint using
bits SEVNFRM and SODDFRM) whenever a USB transfer complete interrupt is
triggered to the opposite value of the current frame, so the endpoint
receives data on the next frame.
The fix
Implemented the processing of the USB_OTG_GINTSTS_OEPINT OUT interrupt event
on evt_poll core function so that it can catch the transfer complete
interrupt event USB_OTG_DOEPINT_XFRC for each endpoint, and then update the
selected frame bit EONUM if the endpoint is isochronous.
Also unmasked the bits USB_OTG_DOEPMSK_XFRCM and USB_OTG_GINTMSK_OEPINT on
registers OTGD->DOEPMSK and OTG->GINTMSK respectively in order for the USB
core to trigger and set said flags.
I've implemented similar handling to what is done on tinyUSB's dcd_dwc2.c#L387 on
function edpt_schedule_packets which is called whenever an out endpoint triggers an interrupt.
Demo
https://github.com/theawsomeavr/libusb_stm32_audio