summaryrefslogtreecommitdiff
path: root/globals.c
blob: d63aa2ed486f536bcc19dbdfb09c40d156d4de68 (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
28
29
30
31
32
33
34
35
36
#include "globals.h"
#include <time.h>
#include <sys/time.h>


GlobalStruct globals = {
	.Flags.do_check_settings = 1,
	.DefaultFlags.do_check_settings = 1,

	.Registers.last_rise_time_relay_setting = 99,

	.Registers.last_relay_driver_settings[0] = -1,
	.Registers.last_relay_driver_settings[1] = -1,
	.Registers.last_relay_driver_settings[2] = -1,

	.Registers.gpib_buffer[0] = 0
};


long sec_timer (void)
{
	return (long)time(NULL);
}


unsigned long long ms_timer (void)
{
	struct timeval tv;
	gettimeofday(&tv, NULL);

	unsigned long long millisecondsSinceEpoch =
	        (unsigned long long)(tv.tv_sec) * 1000 +
	        (unsigned long long)(tv.tv_usec) / 1000;

	return millisecondsSinceEpoch;
}