summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-11-23 09:52:11 +0700
committerhathach <[email protected]>2021-11-23 09:52:11 +0700
commitc9e9f4785f68c9f9e99c4832af8615847c5fae92 (patch)
treee38c882d40fea8455a2759848d7b83c3ab02dc16 /src
parent0fc11746c0e6d9f64750e02d1d46d901c11e0373 (diff)
more clean up
Diffstat (limited to 'src')
-rw-r--r--src/portable/nordic/nrf5x/dcd_nrf5x.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c
index bee9fc0b6..2bcd56b8a 100644
--- a/src/portable/nordic/nrf5x/dcd_nrf5x.c
+++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c
@@ -82,9 +82,8 @@ static struct
// +1 for ISO endpoints
xfer_td_t xfer[EP_CBI_COUNT + 1][2];
- // Number of pending DMA that is started but not handled yet by dcd_int_handler().
- // Since nRF can only carry one DMA can run at a time, this value is normally be either 0 or 1.
- volatile uint8_t dma_pending;
+ // nRF can only carry one DMA at a time, this is used to guard the access to EasyDMA
+ volatile bool dma_running;
}_dcd;
/*------------------------------------------------------------------*/
@@ -115,7 +114,7 @@ TU_ATTR_ALWAYS_INLINE static inline bool is_in_isr(void)
// helper to start DMA
static void start_dma(volatile uint32_t* reg_startep)
{
- _dcd.dma_pending = true;
+ _dcd.dma_running = true;
(*reg_startep) = 1;
__ISB(); __DSB();
@@ -125,7 +124,7 @@ static void start_dma(volatile uint32_t* reg_startep)
// Therefore dma_pending is corrected right away
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
if ( is_in_isr() || __get_PRIMASK() || !NVIC_GetEnableIRQ(USBD_IRQn) )
{
- if (_dcd.dma_pending)
+ if (_dcd.dma_running)
{
//use usbd task to defer later
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
dcd_int_disable(rhport);
- if ( !_dcd.dma_pending )
+ if ( !_dcd.dma_running )
{
start_dma(reg_startep);
started = true;
@@ -173,8 +172,8 @@ static void edpt_dma_start(volatile uint32_t* reg_startep)
// DMA is complete
static void edpt_dma_end(void)
{
- TU_ASSERT(_dcd.dma_pending, );
- _dcd.dma_pending = false;
+ TU_ASSERT(_dcd.dma_running, );
+ _dcd.dma_running = false;
}
// helper getting td