HP85 GPIB Disk Emulator  1.0
HP85GPIBDiskEmulator
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
timer.h
Go to the documentation of this file.
1 
25 #ifndef __TIMER_H__
26 #define __TIMER_H__
27 
29 #define MAX_TIMER_CNT 8
30 
32 typedef uint16_t clockid_t;
33 
35 typedef struct
36 {
37  void (*user_timer_handler)(void); // user task
38  uint8_t timer; // user task enabled ?
39 } TIMERS;
40 
42 #ifndef SYSTEM_TASK_HZ
43 #error #define SYSTEM_TASK_HZ 1000L
44 #endif
45 
47 #define SYSTEM_TASK_TIC_NS ( 1000000000L / SYSTEM_TASK_HZ )
48 #define SYSTEM_TASK_TIC_US ( 1000000L / SYSTEM_TASK_HZ )
50 
52 #define CLOCK_HZ SYSTEM_TASK_HZ
53 #define CLOCK_TIC_NS SYSTEM_TASK_TIC_NS
55 #define CLOCK_TIC_US SYSTEM_TASK_TIC_US
57 
58 /* timer.c */
59 MEMSPACE int set_timers ( void (*handler )(void ), int timer );
60 MEMSPACE int kill_timer ( int timer );
61 MEMSPACE void delete_all_timers ( void );
62 MEMSPACE void subtract_timespec ( ts_t *a , ts_t *b );
63 MEMSPACE char *ts_to_str ( ts_t *val );
64 MEMSPACE void display_ts ( ts_t *val );
65 MEMSPACE void clock_elapsed_begin ( void );
66 MEMSPACE void clock_elapsed_end ( char *msg );
67 MEMSPACE void clock_clear ( void );
68 MEMSPACE void disable_timers ( void );
69 MEMSPACE void enable_timers ( void );
70 void execute_timers ( void );
71 MEMSPACE void clock_init ( void );
72 void clock_task ( void );
73 MEMSPACE void init_timers ( void );
74 MEMSPACE int clock_getres ( clockid_t clk_id , struct timespec *res );
75 MEMSPACE int clock_settime ( clockid_t clk_id , const struct timespec *ts );
76 
77 extern MEMSPACE int clock_gettime ( clockid_t clk_id , struct timespec *ts );
78 /* timer_hal.c */
79 MEMSPACE void disable_system_task ( void );
80 MEMSPACE void enable_system_task ( void );
81 MEMSPACE void install_timers_isr ( void );
82 #endif // _TIMER_H_
clockid_t
uint16_t clockid_t
type of clockid_t.
Definition: time.h:37
enable_timers
MEMSPACE void enable_timers(void)
Enable timer tasks.
Definition: timer.c:251
TIMERS
user timer struct
Definition: timer.h:35
clock_settime
MEMSPACE int clock_settime(clockid_t clk_id, const struct timespec *ts)
disable_timers
MEMSPACE void disable_timers(void)
Disable all timer tasks.
Definition: timer.c:237
MEMSPACE
#define MEMSPACE
Definition: user_config.h:17
ts_to_str
MEMSPACE char * ts_to_str(ts_t *val)
Definition: timer.c:154
kill_timer
MEMSPACE int kill_timer(int timer)
Delete "Kill" one user timer task.
Definition: timer.c:99
subtract_timespec
MEMSPACE void subtract_timespec(ts_t *a, ts_t *b)
subtract a-= b timespec * structures.
Definition: timer.c:134
clockid_t
uint16_t clockid_t
type of clockid_t.
Definition: timer.h:32
clock_gettime
MEMSPACE int clock_gettime(clockid_t clk_id, struct timespec *ts)
disable_system_task
MEMSPACE void disable_system_task(void)
clock_init
MEMSPACE void clock_init(void)
execute_timers
void execute_timers(void)
Execute all user timers at SYSTEM_HZ rate. Called by system task.
Definition: timer.c:265
display_ts
MEMSPACE void display_ts(ts_t *val)
timespec structure in seconds.nanoseconds.
Definition: timer.c:167
TIMERS::timer
uint8_t timer
Definition: timer.h:38
clock_getres
MEMSPACE int clock_getres(clockid_t clk_id, struct timespec *res)
init_timers
MEMSPACE void init_timers(void)
Setup all timers tasksi and enable interrupts.
Definition: timer.c:299
clock_clear
MEMSPACE void clock_clear(void)
clear time and timezone to 0.
Definition: timer.c:222
install_timers_isr
MEMSPACE void install_timers_isr(void)
timespec
POSIX timespec.
Definition: time.h:85
clock_elapsed_end
MEMSPACE void clock_elapsed_end(char *msg)
Subtract and display time difference from clock_elapesed_begin().
Definition: timer.c:200
clock_task
void clock_task(void)
1000HZ timer task
Definition: timer.c:281
set_timers
MEMSPACE int set_timers(void(*handler)(void), int timer)
enable_system_task
MEMSPACE void enable_system_task(void)
delete_all_timers
MEMSPACE void delete_all_timers(void)
Clear ALL user timer tasks.
Definition: timer.c:116
clock_elapsed_begin
MEMSPACE void clock_elapsed_begin(void)
Store current struct timespec in __clock_elapsed.
Definition: timer.c:184