38 #ifndef __GR55xx_DELAY_H__
39 #define __GR55xx_DELAY_H__
48 #if defined ( __CC_ARM )
50 #ifndef __STATIC_FORCEINLINE
51 #define __STATIC_FORCEINLINE static __forceinline
54 #elif defined ( __GNUC__ )
56 #ifndef __STATIC_FORCEINLINE
57 #define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline
62 #ifndef __STATIC_FORCEINLINE
63 #define __STATIC_FORCEINLINE __STATIC_INLINE
78 void delay_us(uint32_t number_of_us);
82 const uint8_t clocks[] = {64, 48, 16, 24, 16, 32};
83 uint32_t cycles = number_of_us * (clocks[AON->PWR_RET01 & AON_PWR_REG01_SYS_CLK_SEL]);
85 if (number_of_us == 0)
91 uint32_t core_debug_initial = CoreDebug->DEMCR;
93 CoreDebug->DEMCR = core_debug_initial | CoreDebug_DEMCR_TRCENA_Msk;
96 uint32_t dwt_ctrl_initial = DWT->CTRL;
98 DWT->CTRL = dwt_ctrl_initial | DWT_CTRL_CYCCNTENA_Msk;
101 uint32_t cyccnt_initial = DWT->CYCCNT;
104 while ((DWT->CYCCNT - cyccnt_initial) < cycles)
108 DWT->CTRL = dwt_ctrl_initial;
109 CoreDebug->DEMCR = core_debug_initial;
125 #if defined(GR5515_E)
126 void delay_ms(uint32_t number_of_ms);