|
px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
|
Driver to initalise TMRx so that a periodic system clock tick interrupt is generated.
File(s):
px_sysclk_init() configures TMRx to expire every 1/PX_SYSCLK_TICKS_PER_SEC second and generate an interrupt during which a clock tick counter is incremented. px_sysclk_get_tick_count() must be called to fetch a copy of the clock tick counter in an interrupt safe way (atomically).
A periodic timeout function can also be called by the system clock timer interrupt, for example a software RTC can be implemented by calling an RTC update function once a second. The period is specified in 'px_sysclk_cfg.h' with PX_SYSCLK_TIMEOUT_PERIOD_TICKS and the function to call with.
See px_systmr.h : Polled software timers which builds on px_sysclk.h : System Clock using a TMRx peripheral to provide multiple software timers. Example:
Macros | |
| #define | PX_SYSCLK_CFG_TICKS_PER_SEC 100ul |
| The number of system clock ticks per second. More... | |
| #define | PX_SYSCLK_CFG_USE_TMRX 2 |
| Specify which TMR peripheral must be used. More... | |
| #define | PX_SYSCLK_CFG_TMR_PRESCALER 1024 |
| Specify TMR Prescaler. More... | |
| #define | PX_SYSCLK_CFG_TIMEOUT_PERIOD_TICKS PX_SYSCLK_CFG_TICKS_PER_SEC |
| Specify periodic timeout (in sysclk ticks) More... | |
Typedefs | |
| typedef uint16_t | px_sysclk_ticks_t |
| Size definition of the tick counter. More... | |
Functions | |
| void | px_sysclk_init (void) |
| Start system clock (one clock tick every 1/PX_SYSCLK_TICKS_PER_SEC seconds). More... | |
| bool | px_sysclk_disable (void) |
| Disable system clock. More... | |
| void | px_sysclk_enable (void) |
| Enable system clock. More... | |
| px_sysclk_ticks_t | px_sysclk_get_tick_count (void) |
| Return number of ticks since system clock started. More... | |
| #define PX_SYSCLK_CFG_TICKS_PER_SEC 100ul |
The number of system clock ticks per second.
Definition at line 35 of file px_sysclk_cfg_template.h.
| #define PX_SYSCLK_CFG_USE_TMRX 2 |
Specify which TMR peripheral must be used.
Definition at line 38 of file px_sysclk_cfg_template.h.
| #define PX_SYSCLK_CFG_TMR_PRESCALER 1024 |
Specify TMR Prescaler.
Definition at line 41 of file px_sysclk_cfg_template.h.
| #define PX_SYSCLK_CFG_TIMEOUT_PERIOD_TICKS PX_SYSCLK_CFG_TICKS_PER_SEC |
Specify periodic timeout (in sysclk ticks)
Definition at line 44 of file px_sysclk_cfg_template.h.
| typedef uint16_t px_sysclk_ticks_t |
Size definition of the tick counter.
Definition at line 73 of file px_sysclk.h.
| void px_sysclk_init | ( | void | ) |
Start system clock (one clock tick every 1/PX_SYSCLK_TICKS_PER_SEC seconds).
Start system clock (one clock tick every 1/PX_SYSCLK_TICKS_PER_SEC seconds).
Definition at line 79 of file px_sysclk.c.
| bool px_sysclk_disable | ( | void | ) |
Disable system clock.
Definition at line 185 of file px_sysclk.c.
| void px_sysclk_enable | ( | void | ) |
Enable system clock.
Definition at line 194 of file px_sysclk.c.
| px_sysclk_ticks_t px_sysclk_get_tick_count | ( | void | ) |
Return number of ticks since system clock started.
Definition at line 97 of file px_sysclk.c.