more clean up
This commit is contained in:
parent
0fc11746c0
commit
c9e9f4785f
|
@ -82,9 +82,8 @@ static struct
|
||||||
// +1 for ISO endpoints
|
// +1 for ISO endpoints
|
||||||
xfer_td_t xfer[EP_CBI_COUNT + 1][2];
|
xfer_td_t xfer[EP_CBI_COUNT + 1][2];
|
||||||
|
|
||||||
// Number of pending DMA that is started but not handled yet by dcd_int_handler().
|
// nRF can only carry one DMA at a time, this is used to guard the access to EasyDMA
|
||||||
// Since nRF can only carry one DMA can run at a time, this value is normally be either 0 or 1.
|
volatile bool dma_running;
|
||||||
volatile uint8_t dma_pending;
|
|
||||||
}_dcd;
|
}_dcd;
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
@ -115,7 +114,7 @@ TU_ATTR_ALWAYS_INLINE static inline bool is_in_isr(void)
|
||||||
// helper to start DMA
|
// helper to start DMA
|
||||||
static void start_dma(volatile uint32_t* reg_startep)
|
static void start_dma(volatile uint32_t* reg_startep)
|
||||||
{
|
{
|
||||||
_dcd.dma_pending = true;
|
_dcd.dma_running = true;
|
||||||
|
|
||||||
(*reg_startep) = 1;
|
(*reg_startep) = 1;
|
||||||
__ISB(); __DSB();
|
__ISB(); __DSB();
|
||||||
|
@ -125,7 +124,7 @@ static void start_dma(volatile uint32_t* reg_startep)
|
||||||
// Therefore dma_pending is corrected right away
|
// Therefore dma_pending is corrected right away
|
||||||
if ( (reg_startep == &NRF_USBD->TASKS_EP0STATUS) || (reg_startep == &NRF_USBD->TASKS_EP0RCVOUT) )
|
if ( (reg_startep == &NRF_USBD->TASKS_EP0STATUS) || (reg_startep == &NRF_USBD->TASKS_EP0RCVOUT) )
|
||||||
{
|
{
|
||||||
_dcd.dma_pending = false;
|
_dcd.dma_running = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +136,7 @@ static void edpt_dma_start(volatile uint32_t* reg_startep)
|
||||||
// Called in critical section i.e within USB ISR, or USB/Global interrupt disabled
|
// Called in critical section i.e within USB ISR, or USB/Global interrupt disabled
|
||||||
if ( is_in_isr() || __get_PRIMASK() || !NVIC_GetEnableIRQ(USBD_IRQn) )
|
if ( is_in_isr() || __get_PRIMASK() || !NVIC_GetEnableIRQ(USBD_IRQn) )
|
||||||
{
|
{
|
||||||
if (_dcd.dma_pending)
|
if (_dcd.dma_running)
|
||||||
{
|
{
|
||||||
//use usbd task to defer later
|
//use usbd task to defer later
|
||||||
usbd_defer_func((osal_task_func_t) edpt_dma_start, (void*) (uintptr_t) reg_startep, true);
|
usbd_defer_func((osal_task_func_t) edpt_dma_start, (void*) (uintptr_t) reg_startep, true);
|
||||||
|
@ -157,7 +156,7 @@ static void edpt_dma_start(volatile uint32_t* reg_startep)
|
||||||
// use osal mutex to guard against multiple core MCUs such as nRF53
|
// use osal mutex to guard against multiple core MCUs such as nRF53
|
||||||
dcd_int_disable(rhport);
|
dcd_int_disable(rhport);
|
||||||
|
|
||||||
if ( !_dcd.dma_pending )
|
if ( !_dcd.dma_running )
|
||||||
{
|
{
|
||||||
start_dma(reg_startep);
|
start_dma(reg_startep);
|
||||||
started = true;
|
started = true;
|
||||||
|
@ -173,8 +172,8 @@ static void edpt_dma_start(volatile uint32_t* reg_startep)
|
||||||
// DMA is complete
|
// DMA is complete
|
||||||
static void edpt_dma_end(void)
|
static void edpt_dma_end(void)
|
||||||
{
|
{
|
||||||
TU_ASSERT(_dcd.dma_pending, );
|
TU_ASSERT(_dcd.dma_running, );
|
||||||
_dcd.dma_pending = false;
|
_dcd.dma_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper getting td
|
// helper getting td
|
||||||
|
|
Loading…
Reference in New Issue