Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d367f9ebc1a25e9e0ceb444210485e827e8caaa7 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*******************************************************************************
 * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * CONTRIBUTORS:
 * 		Thomas Schuetz, Thomas Jung (initial contribution)
 *
 *******************************************************************************/

/**
 *
 * etTime.c MinGW implementation of etTime
 *
 */

#include "osal/etTime.h"

#include <sys/time.h>

void getTimeFromTarget(etTime *t){
	struct timeval currentTime;
	gettimeofday(&currentTime, NULL);
	t->sec = currentTime.tv_sec;
	t->nSec = currentTime.tv_usec*1000;
}


/* TODO: remove old API functions
uint64 getTargetTimeUs(void){
	struct timeval currentTime;
	gettimeofday(&currentTime, NULL);

	return currentTime.tv_sec * 1000000L + currentTime.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