Add delay_ticks function
This commit is contained in:
parent
7ce8a8b114
commit
1b0f79c818
@ -3,6 +3,12 @@
|
||||
#include <arch/delay.h>
|
||||
#include <arch/timer.h>
|
||||
|
||||
void delay_ticks(uint16_t ticks) {
|
||||
timer_mode_1(-ticks);
|
||||
timer_wait();
|
||||
timer_stop();
|
||||
}
|
||||
|
||||
// One millisecond in ticks is determined as follows:
|
||||
// 9.2 MHz is the clock rate
|
||||
// The timer divider is 12
|
||||
@ -11,8 +17,6 @@
|
||||
// 65536 - 766.667 = 64769.33
|
||||
void delay_ms(int ms) {
|
||||
for (int i = 0; i < ms; i++) {
|
||||
timer_mode_1(64769);
|
||||
timer_wait();
|
||||
timer_stop();
|
||||
delay_ticks(767);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
#ifndef _ARCH_DELAY_H
|
||||
#define _ARCH_DELAY_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void delay_ticks(uint16_t ticks);
|
||||
void delay_ms(int ms);
|
||||
|
||||
#endif // _ARCH_DELAY_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user