aboutsummaryrefslogtreecommitdiff
path: root/src/sys/timer.c
blob: 548bf1af1645b99ce4e13231b0c601e44a916896 (plain)
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
#include <drivers/uart.h>
#include <globals.h>
#include <graphics/drawer.h>
#include <sys/core.h>
#include <sys/timer.h>
#include <util/mutex.h>
#include <util/status.h>
#include <util/time.h>
#include <symbols.h>

void increase_counter(void)
{
	if (lock_mutex(&exe_cnt_m, SCHED_PID) == 0) {
		unsigned long* counter = (unsigned long*)exe_cnt_m.addr;
		*counter += 1;
		release_mutex(&exe_cnt_m, SCHED_PID);
	}
}

void c_timer(void)
{
	// Reset the counter
	write_cntv_tval(cntfrq/CPS);

	increase_counter();
	status();
}