systick 1.0
SysTick software timer library
Loading...
Searching...
No Matches
systick

Version: 1.0 Release Build License GPLv3

SysTick Utils

Ask DeepWiki

This utility can be used to initiate a software timer for system delays or non-blocking code execution. An example howto use this library inside a project (with an avr0) can be found here.

The library works with unsigned int which is 16 bit wide on an avr(0) plattform. So a maximum tick sequence of ~16000 can be counted!

File Structure

File Structure

utils/
└── systick/
├── systick.c
└── systick.h

The library is completely patform independent and can be usesd across a wide range of c-compilers.

Downloads

The library can be downloaded (zip or tar), cloned or used as submodule in a project.

Type File Description
Library zip / tar SysTick library for counting ticks of a timer over an ISR

Using with git clone

mkdir -p ./utils/
git clone https://github.com/0x007E/utils-systick.git ./utils
mv ./utils/utils-systick ./utils/systick

Using as git submodule

git submodule add https://github.com/0x007E/utils-systick.git ./utils/systick

Programming

#include "../lib/utils/systick/systick.h"
SYSTICK_Timer systick_timer;
ISR(...)
{
}
void systick_timer_wait_ms(unsigned int ms)
{
// If necessary calculate the ticks
// e.g.:
// Timer interrupts every us:
// ms *= 1000;
}
// If the timer ticks fast enough, the systick_timer_wait_us() can be implemented
void systick_timer_wait_us(unsigned int us)
{
}
int main(void)
{
// Defining of a timer that interrupts every ms or us!
// ...
// Wait a second blocking
while(1)
{
// Execute every second non-blocking
if (systick_timer_elapsed(&systick_timer))
{
// ...
systick_timer_set(&systick_timer, 1000UL);
}
// Return how much time remaining
unsigned int remaining = systick_timer_remaining(&systick_timer);
// Cancel a timer
systick_timer_cancel(&systick_timer);
}
}
SYSTICK_Timer_Status systick_timer_elapsed(SYSTICK_Timer *timer)
Checks whether a SysTick software timer has expired.
Definition systick.c:118
unsigned int systick_timer_remaining(SYSTICK_Timer *timer)
Returns the remaining time before a SysTick timer expires.
Definition systick.c:142
void systick_timer_cancel(SYSTICK_Timer *timer)
Cancels a running SysTick software timer.
Definition systick.c:189
void systick_timer_set(SYSTICK_Timer *timer, unsigned int delay_ticks)
Sets and starts a SysTick software timer.
Definition systick.c:97
void systick_init(void)
Initializes the SysTick timer module.
Definition systick.c:35
void systick_tick(void)
Increments the SysTick timer tick counter.
Definition systick.c:61
void systick_timer_wait(unsigned int ticks)
Blocks execution for a specified number of SysTick ticks.
Definition systick.c:168
struct SYSTICK_Timer_t SYSTICK_Timer
Alias for struct SYSTICK_Timer_t representing a SysTick software timer.
Definition systick.h:61
void systick_timer_wait_ms(unsigned int ms)
void systick_timer_wait_us(unsigned int us)

R. GAECHTER