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

ref: 9cb6ab52fc2b86956e5f74a8630a3aaf79411f29 stm32h747i-disco-usb-image-viewer/include/delay.h -rw-r--r-- 809 bytes
9cb6ab52 — Rutherther feat: vos0, system clock at 480 MHz 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
28
29
30
31
32
33
34
#ifndef DELAY_H
#define DELAY_H

#include <stdint.h>

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

/* #define SYSTICK_CALIB 0x3E8 */
// Underflow every 1 us
#define SYSTICK_LOAD (SYSTEM_CLOCK/1000UL-1)
#define SYSTICK_DELAY_CALIB (SYSTICK_LOAD >> 1)

extern uint32_t us_ticks;

#define DELAY_US(us) \
    do { \
      for (int i = 0; i < 500000; i++); \
         /* uint32_t start = us_ticks; \ */ \
         /* while((us_ticks - start) < us); \ */ \
    } while (0)

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

void systick_configure();

#endif // DELAY_H
Do not follow this link