~ruther/stm32h747i-disco-usb-image-viewer

ref: c8fe27c955b05f63fefa02f9c19dbbfb47de11ee stm32h747i-disco-usb-image-viewer/include/delay.h -rw-r--r-- 689 bytes
c8fe27c9 — Rutherther feat: implement usb devicd cdc descriptors, init, setup 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef DELAY_H
#define DELAY_H

// TODO: define system clock well
/* #define SYSTEM_CLOCK    ((uint32_t)360000000UL) */
#define SYSTEM_CLOCK    ((uint32_t)64000000UL)

#define SYSTICK_CALIB 0x3E8
#define SYSTICK_LOAD (SYSTEM_CLOCK/1000000UL)
#define SYSTICK_DELAY_CALIB (SYSTICK_LOAD >> 1)

#define DELAY_US(us) \
    do { \
         uint32_t start = SysTick->VAL; \
         uint32_t ticks = (us * SYSTICK_LOAD)-SYSTICK_DELAY_CALIB;  \
         while((start - SysTick->VAL) < ticks); \
    } while (0)

#define DELAY_MS(ms) \
    do { \
        for (uint32_t i = 0; i < ms; ++i) { \
            DELAY_US(1000); \
        } \
    } while (0)

void systick_configure();

#endif // DELAY_H
Do not follow this link