timer: Refactor tick_delta to use hardware-specific clock frequency
This commit is contained in:
parent
5f09049765
commit
40333f1a37
2 changed files with 8 additions and 1 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
#include "drivers/uart.h"
|
#include "drivers/uart.h"
|
||||||
|
|
||||||
_Atomic uint64_t sys_ticks = 0;
|
_Atomic uint64_t sys_ticks = 0;
|
||||||
const uint64_t tick_delta = 1000;
|
const uint64_t tick_delta = TICKS_PER_MS;
|
||||||
|
|
||||||
void timer_init() {
|
void timer_init() {
|
||||||
timer_tick();
|
timer_tick();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,13 @@
|
||||||
#define TIMER_H
|
#define TIMER_H
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/* Define your clock frequency here based on your hardware */
|
||||||
|
/* Example: 12.5 MHz for QEMU virt machine */
|
||||||
|
#define CLOCK_FREQ_HZ 12500000
|
||||||
|
|
||||||
|
/* Calculate ticks per millisecond */
|
||||||
|
#define TICKS_PER_MS (CLOCK_FREQ_HZ / 1000)
|
||||||
|
|
||||||
extern _Atomic uint64_t sys_ticks;
|
extern _Atomic uint64_t sys_ticks;
|
||||||
extern const uint64_t tick_delta;
|
extern const uint64_t tick_delta;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue