~ruther/uni-mam-arm

uni-mam-arm/arm03/include/delay.h -rw-r--r-- 635 bytes
f80d4fd6 — Rutherther chore(arm07): add few image upload commands 3 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
#ifndef DELAY_H
#define DELAY_H

// TODO: define system clock well
#define SYSTEM_CLOCK    ((uint32_t)48000000UL)

#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