File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -55,12 +55,12 @@ void SysTick_Handler(void) {
55
55
}
56
56
57
57
void tick_init () {
58
- uint32_t ticks_per_ms = 16000000 / 1000 ;
58
+ uint32_t ticks_per_ms = SystemCoreClock / 1000 ;
59
59
SysTick_Config (ticks_per_ms ); // interrupt is enabled
60
60
}
61
61
62
62
void tick_delay (uint32_t us ) {
63
- uint32_t ticks_per_us = 16000000 / 1000 / 1000 ;
63
+ uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000 ;
64
64
uint32_t us_between_ticks = SysTick -> VAL / ticks_per_us ;
65
65
uint64_t start_ms = ticks_ms ;
66
66
while (us > 1000 ) {
@@ -74,12 +74,12 @@ void tick_delay(uint32_t us) {
74
74
75
75
// us counts down!
76
76
void current_tick (uint64_t * ms , uint32_t * us_until_ms ) {
77
- uint32_t ticks_per_us = 16000000 / 1000 / 1000 ;
77
+ uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000 ;
78
78
* ms = ticks_ms ;
79
79
* us_until_ms = SysTick -> VAL / ticks_per_us ;
80
80
}
81
81
82
82
void wait_until (uint64_t ms , uint32_t us_until_ms ) {
83
- uint32_t ticks_per_us = 16000000 / 1000 / 1000 ;
83
+ uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000 ;
84
84
while (ticks_ms <= ms && SysTick -> VAL / ticks_per_us >= us_until_ms ) {}
85
85
}
You can’t perform that action at this time.
0 commit comments