Skip to content

Conversation

@hathach
Copy link
Owner

@hathach hathach commented May 21, 2020

Describe the PR
This implement an alternative approach to #396 to solve issue when TinyUSB API is called within an critical section with CPSR-I bit disabled (global interrupt) and/or NVIC USB disabled. Due to the EasyDMA can only has 1 active transfer at a time, the dcd_edpt_xfer() must wait until the previous DMA complete before starting its own.

Although #396 work fine with noOS, with an RTOS such as freeRTOS, any queue push API called within critical section as result of dcd_init_handler() can potentially cause problem (even withISR API). Since freeRTOS and/or other RTOS probably use the CPSR-I for enterring critical section within the queue API as well.

This PR count the ENDED events comparing with pending dma to determine if previous DMA is complete and should be safe to use. This is really an edge case, user shouldn't call TinyUSB API within critical section in the first place !!!

Fix segger project for nrf52 cdc_msc example when debugging

Additional context
related to adafruit/circuitpython#2868

@hathach hathach requested a review from xobs May 21, 2020 14:42
@hathach hathach merged commit de88294 into master May 21, 2020
@hathach hathach deleted the fix-nrf-called-within-critical branch May 21, 2020 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants