|
Edited by rpidmx512 at 2018-6-15 11:38
There are several options to implement
- #define CNT64_CTRL_LATCH ((uint32_t)(1<<1))
- void udelay(uint32_t d) {
- #if defined (_USE_AVS_TIMER_UDELAY)
- uint32_t t1 = H3_TIMER->AVS_CNT1;
- const uint32_t t2 = t1 + d;
- do {
- t1 = H3_TIMER->AVS_CNT1;
- } while (t2 >= t1);
- #elif defined (_USE_HS_TIMER_UDELAY)
- h3_hs_timer_delay(100 * d);
- #else
- H3_CNT64->CTRL = CNT64_CTRL_LATCH;
- //isb();
- while ((H3_CNT64->CTRL & CNT64_CTRL_LATCH) == CNT64_CTRL_LATCH)
- ;
- const uint32_t low = H3_CNT64->LOW / 24;
- do {
- H3_CNT64->CTRL = CNT64_CTRL_LATCH;
- //isb();
- while ((H3_CNT64->CTRL & CNT64_CTRL_LATCH) == CNT64_CTRL_LATCH)
- ;
- } while (((H3_CNT64->LOW / 24) - low) < d);
- #endif
- }
Copy code
|
|