ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
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 
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 
83 #endif // _TIMER_H_
uint8_t timer
Definition: timer.h:38
MEMSPACE int kill_timer(int timer)
Delete "Kill" one user timer task.
Definition: timer.c:100
MEMSPACE char * ts_to_str(ts_t *val)
Definition: timer.c:155
void execute_timers(void)
Execute all user timers at SYSTEM_HZ rate. Called by system task.
Definition: timer.c:261
unsigned short uint16_t
Definition: send.c:18
MEMSPACE void subtract_timespec(ts_t *a, ts_t *b)
subtract a-= b timespec * structures.
Definition: timer.c:135
MEMSPACE void install_timers_isr(void)
MEMSPACE int clock_gettime(clockid_t clk_id, struct timespec *ts)
Generic clock_gettime() function WITHOUT high resolution.
Definition: timer.c:377
uint16_t clockid_t
type of clockid_t.
Definition: time.h:38
MEMSPACE void delete_all_timers(void)
Clear ALL user timer tasks.
Definition: timer.c:117
MEMSPACE void init_timers(void)
Setup all timers tasksi and enable interrupts.
Definition: timer.c:293
MEMSPACE int clock_settime(clockid_t clk_id, const struct timespec *ts)
Set system clock using seconds and nonoseconds - POSIX function.
Definition: timer.c:345
MEMSPACE void clock_elapsed_begin(void)
Store current struct timespec in __clock_elapsed.
Definition: timer.c:184
MEMSPACE int clock_getres(clockid_t clk_id, struct timespec *res)
Read clock time resolution into struct timepec *ts - POSIX function.
Definition: timer.c:329
MEMSPACE void disable_timers(void)
Disable all timer tasks.
Definition: timer.c:235
MEMSPACE void clock_init(void)
void clock_task(void)
1000HZ timer task
Definition: timer.c:276
MEMSPACE int set_timers(void(*handler)(void), int timer)
Install a user timer task.
Definition: timer.c:60
MEMSPACE void clock_elapsed_end(char *msg)
Subtract and display time difference from clock_elapesed_begin().
Definition: timer.c:200
MEMSPACE void enable_system_task(void)
#define MEMSPACE
Definition: cpu.h:25
MEMSPACE void enable_timers(void)
Enable timer tasks.
Definition: timer.c:248
MEMSPACE void display_ts(ts_t *val)
timespec structure in seconds.nanoseconds.
Definition: timer.c:167
user timer struct
Definition: timer.h:35
POSIX timespec.
Definition: time.h:88
MEMSPACE void disable_system_task(void)
uint16_t clockid_t
type of clockid_t.
Definition: timer.h:32
unsigned char uint8_t
Definition: send.c:17
MEMSPACE void clock_clear(void)
clear time and timezone to 0.
Definition: timer.c:221