ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
Data Structures | Macros | Typedefs | Functions
timer.h File Reference

timer functions More...

Go to the source code of this file.

Data Structures

struct  TIMERS
 user timer struct More...
 

Macros

#define MAX_TIMER_CNT   8
 Number of user timer tasks. More...
 
#define SYSTEM_TASK_TIC_NS   ( 1000000000L / SYSTEM_TASK_HZ )
 System task in HZ. More...
 
#define SYSTEM_TASK_TIC_US   ( 1000000L / SYSTEM_TASK_HZ )
 System task in Microseconds. More...
 
#define CLOCK_HZ   SYSTEM_TASK_HZ
 Clock task in HZ defined as System task. More...
 
#define CLOCK_TIC_NS   SYSTEM_TASK_TIC_NS
 Clock task in Nanoseconds defined as System Task. More...
 
#define CLOCK_TIC_US   SYSTEM_TASK_TIC_US
 CLock task in Microseconds defined as System Task. More...
 

Typedefs

typedef uint16_t clockid_t
 type of clockid_t. More...
 

Functions

MEMSPACE int set_timers (void(*handler)(void), int timer)
 Install a user timer task. More...
 
MEMSPACE int kill_timer (int timer)
 Delete "Kill" one user timer task. More...
 
MEMSPACE void delete_all_timers (void)
 Clear ALL user timer tasks. More...
 
MEMSPACE void subtract_timespec (ts_t *a, ts_t *b)
 subtract a-= b timespec * structures. More...
 
MEMSPACE char * ts_to_str (ts_t *val)
 
MEMSPACE void display_ts (ts_t *val)
 timespec structure in seconds.nanoseconds. More...
 
MEMSPACE void clock_elapsed_begin (void)
 Store current struct timespec in __clock_elapsed. More...
 
MEMSPACE void clock_elapsed_end (char *msg)
 Subtract and display time difference from clock_elapesed_begin(). More...
 
MEMSPACE void clock_clear (void)
 clear time and timezone to 0. More...
 
MEMSPACE void disable_timers (void)
 Disable all timer tasks. More...
 
MEMSPACE void enable_timers (void)
 Enable timer tasks. More...
 
void execute_timers (void)
 Execute all user timers at SYSTEM_HZ rate. Called by system task. More...
 
MEMSPACE void clock_init (void)
 
void clock_task (void)
 1000HZ timer task More...
 
MEMSPACE void init_timers (void)
 Setup all timers tasksi and enable interrupts. More...
 
MEMSPACE int clock_getres (clockid_t clk_id, struct timespec *res)
 Read clock time resolution into struct timepec *ts - POSIX function. More...
 
MEMSPACE int clock_settime (clockid_t clk_id, const struct timespec *ts)
 Set system clock using seconds and nonoseconds - POSIX function. More...
 
MEMSPACE int clock_gettime (clockid_t clk_id, struct timespec *ts)
 Generic clock_gettime() function WITHOUT high resolution. More...
 
MEMSPACE void disable_system_task (void)
 
MEMSPACE void enable_system_task (void)
 
MEMSPACE void install_timers_isr (void)
 

Detailed Description

timer functions

Copyright © 2015 Mike Gore, GPL License
You are free to use this code under the terms of GPL
please retain a copy of this notice in any code you use it in.

This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file timer.h.

Macro Definition Documentation

#define CLOCK_HZ   SYSTEM_TASK_HZ

Clock task in HZ defined as System task.

Definition at line 52 of file timer.h.

#define CLOCK_TIC_NS   SYSTEM_TASK_TIC_NS

Clock task in Nanoseconds defined as System Task.

Definition at line 54 of file timer.h.

#define CLOCK_TIC_US   SYSTEM_TASK_TIC_US

CLock task in Microseconds defined as System Task.

Definition at line 56 of file timer.h.

#define MAX_TIMER_CNT   8

Number of user timer tasks.

Definition at line 29 of file timer.h.

Referenced by delete_all_timers(), execute_timers(), kill_timer(), and set_timers().

#define SYSTEM_TASK_TIC_NS   ( 1000000000L / SYSTEM_TASK_HZ )

System task in HZ.

System task in Nanoseconds.

Definition at line 47 of file timer.h.

Referenced by clock_getres().

#define SYSTEM_TASK_TIC_US   ( 1000000L / SYSTEM_TASK_HZ )

System task in Microseconds.

Definition at line 49 of file timer.h.

Typedef Documentation

type of clockid_t.

Definition at line 32 of file timer.h.

Function Documentation

MEMSPACE void clock_clear ( void  )

clear time and timezone to 0.

See also
clock_settime().
settimezone().
Returns
void.

Definition at line 221 of file timer.c.

Referenced by init_timers().

MEMSPACE void clock_elapsed_begin ( void  )

Store current struct timespec in __clock_elapsed.

See also
clock_gettime() POSIX function.
Returns
void

Definition at line 184 of file timer.c.

MEMSPACE void clock_elapsed_end ( char *  msg)

Subtract and display time difference from clock_elapesed_begin().

  • Notes: Accuracy is a function of timer resolution, CPU overhead and background tasks.
Parameters
[in]msgUser message to proceed Time display.
Returns
void
See also
clock_gettime().
clock_elapesed_begin().

Definition at line 200 of file timer.c.

MEMSPACE int clock_getres ( clockid_t  clk_id,
struct timespec res 
)

Read clock time resolution into struct timepec *ts - POSIX function.

  • Note: We ignore clk_id
    Parameters
    [in]clk_idunused hardware clock index.
    [out]restimespec resolution result.
    Returns
    0 on success.
    -1 on error.

Definition at line 329 of file timer.c.

MEMSPACE int clock_gettime ( clockid_t  clk_id,
struct timespec ts 
)

Generic clock_gettime() function WITHOUT high resolution.

Read clock time into struct timepec *ts - POSIX function.

  • Note: We ignore clk_id, and include low level counter offsets when available.
Parameters
[in]clk_idunused hardware clock index.
[out]tstimespec result.
Returns
0 on success.
-1 on error.

Definition at line 377 of file timer.c.

Referenced by clock_elapsed_begin(), clock_elapsed_end(), display_clock(), gettimeofday(), and time().

MEMSPACE void clock_init ( void  )
MEMSPACE int clock_settime ( clockid_t  clk_id,
const struct timespec ts 
)

Set system clock using seconds and nonoseconds - POSIX function.

Parameters
[in]clk_idHardware timer index used when there are more then one.
  • Note: We ignore clk_id for now.
[in]tsstruct timespec input.
Returns
0.

Definition at line 345 of file timer.c.

Referenced by clock_clear(), clock_set(), initialize_clock(), setdate_r(), and settimeofday().

void clock_task ( void  )

1000HZ timer task

Returns
void

Definition at line 276 of file timer.c.

Referenced by init_timers().

MEMSPACE void delete_all_timers ( void  )

Clear ALL user timer tasks.

Returns
void

Definition at line 117 of file timer.c.

Referenced by init_timers().

MEMSPACE void disable_system_task ( void  )

Referenced by disable_timers().

MEMSPACE void disable_timers ( void  )

Disable all timer tasks.

Returns
void

Definition at line 235 of file timer.c.

MEMSPACE void display_ts ( ts_t val)

timespec structure in seconds.nanoseconds.

Parameters
[in]valtimespec struct we want to display.
Returns
void.

Definition at line 167 of file timer.c.

MEMSPACE void enable_system_task ( void  )

Referenced by enable_timers().

MEMSPACE void enable_timers ( void  )

Enable timer tasks.

Returns
void

Definition at line 248 of file timer.c.

Referenced by init_timers().

void execute_timers ( void  )

Execute all user timers at SYSTEM_HZ rate. Called by system task.

Returns
void

Definition at line 261 of file timer.c.

MEMSPACE void init_timers ( void  )

Setup all timers tasksi and enable interrupts.

See also
clock_task()
: timer_hal.c for hardware dependent interface
Returns
void

See time.c

Definition at line 293 of file timer.c.

Referenced by setup().

MEMSPACE void install_timers_isr ( void  )

Referenced by init_timers().

MEMSPACE int kill_timer ( int  timer)

Delete "Kill" one user timer task.

  • "kill" is a common Linux term for ending a process.
Parameters
[in]timeruser timer task index.
Returns
timer on success.
-1 on error.

Definition at line 100 of file timer.c.

MEMSPACE int set_timers ( void(*)(void)  handler,
int  timer 
)

Install a user timer task.

  • timer argument is unsused, reserved for timer source.
Parameters
[in]handler)function pointer to user task.
[in]timerreserved for systems with additional low level hardware timers.
Returns
timer on success.
-1 on error.

Definition at line 60 of file timer.c.

Referenced by init_timers(), mmc_install_timer(), and ms_init().

MEMSPACE void subtract_timespec ( ts_t a,
ts_t b 
)

subtract a-= b timespec * structures.

Parameters
[in]atimespec struct.
[in]btimespec struct.
Returns
void.

Definition at line 135 of file timer.c.

Referenced by clock_elapsed_end().

MEMSPACE char* ts_to_str ( ts_t val)

Definition at line 155 of file timer.c.

Referenced by clock_elapsed_end(), and display_ts().