Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1035293828aeaf102e6aea1420da7e4e80150f76 (plain) (blame)
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
28
29
30
31
32
33
#include "platform/etTimer.h"

#include <sys/time.h>

#include "etGlobalFlags.h"

void etTimer_init(void){
}

uint64 getTargetTimeUs(void){
	struct timeval time;
	gettimeofday(&time, NULL);

	return time.tv_sec * 1000000L + time.tv_usec;
}

etBool etTimer_executeNeeded(void){

	static uint64 lastTime = 0L;

	uint64 currentTime = getTargetTimeUs();

	uint64 timestep = 1000000L/FREQUENCY;

	if (currentTime >= lastTime +  timestep) {
		lastTime = currentTime;
		return TRUE;
	}
	else {
		return FALSE;
	}
}

Back to the top