Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Custom timers structure */
- static TM_DELAY_Timers_t CustomTimers = {0};
- uint32_t TM_DELAY_Init(void) {
- #if !defined(STM32F0xx)
- uint32_t c;
- /* Enable TRC */
- CoreDebug->DEMCR &= ~0x01000000;
- CoreDebug->DEMCR |= 0x01000000;
- /* Enable counter */
- DWT->CTRL &= ~0x00000001;
- DWT->CTRL |= 0x00000001;
- /* Reset counter */
- DWT->CYCCNT = 0;
- /* Check if DWT has started */
- c = DWT->CYCCNT;
- /* 2 dummys */
- __ASM volatile ("NOP");
- __ASM volatile ("NOP");
- /* Return difference, if result is zero, DWT has not started */
- return (DWT->CYCCNT - c);
- #else
- /* Return OK */
- return 1;
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement