MAV'RIC
time_keeper.h
1 /*
2  * time_keeper.h
3  *
4  * Provides precise time measurements (emulation version)
5  *
6  * Created: 08/06/2012 17:25:26
7  * Author: Felix Schill
8  */
9 
10 
11 #ifndef TIME_KEEPER_H_
12 #define TIME_KEEPER_H_
13 
14 #include "compiler.h"
15 //#include "ast.h"
16 
17 #define TK_AST_FREQUENCY 1000000 // timer ticks per second (32 bit timer, >1h time-out at 1MHz, >years at 1kHz. We'll go for precision here...)
18 #define AST_PRESCALER_SETTING 5 // log(SOURCE_CLOCK/AST_FREQ)/log(2)-1 . when running from PBA (64Mhz), 5 (1Mhz), or 15 (~1khz, not precisely though).
19 
20 void time_keeper_init(void);
21 
22 
23 double time_keeper_get_time(void); // time in seconds since system start
24 
25 uint32_t time_keeper_get_millis(void); //milliseconds since system start
26 uint32_t time_keeper_get_micros(void); // microseconds since system start. Will run over after an hour.
27 
28 uint32_t time_keeper_get_time_ticks(void); //raw timer ticks
29 
30 float time_keeper_ticks_to_seconds(uint32_t timer_ticks);
31 
32 #endif /* TIME_KEEPER_H_ */