SquidgeOS/src/kernel/timer.h

30 lines
No EOL
684 B
C

#ifndef TIMER_H
#define TIMER_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 const uint64_t tick_delta;
// Initialize timer (1ms ticks)
void timer_init();
// Increment the system tick counter
void timer_tick();
// Get current time in milliseconds
uint64_t timer_get_ms();
// Delay for 'ms' milliseconds (blocking)
void delay_ms(uint64_t ms);
// Sleep for 'ms' milliseconds (non-blocking, if possible)
void sleep_ms(uint64_t ms);
#endif