| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
microtimer is a fixed-capacity software timer manager for C99 projects.
It targets serialized access to one manager from one execution context by default. It does not provide heap allocation, hidden locks, persistence, or general ISR/thread safety.
#include "mtimer.h"
static uint32_t app_clock_ms(void) { return platform_millis(); }
static void blink_cb(uint8_t id, void *ctx)
{
(void)id;
*(volatile int *)ctx = 1;
}
int main(void)
{
mtimer_t tm;
volatile int blink_due = 0;
int timer_id;
if (mtimer_init(&tm, app_clock_ms) != MTIMER_OK) {
return 1;
}
timer_id = mtimer_create(&tm, "blink", 500u, MTIMER_PERIODIC, blink_cb, (void *)&blink_due);
if (timer_id < 0) {
return 1;
}
if (mtimer_start(&tm, (uint8_t)timer_id) != MTIMER_OK) {
return 1;
}
for (;;) {
int tick_rc = mtimer_tick(&tm);
if (tick_rc < 0) {
return 1;
}
if (blink_due) {
blink_due = 0;
toggle_led();
}
}
}cmake -S . -B build -DMICROTIMER_BUILD_TESTS=ON
cmake --build build
ctest --test-dir build --output-on-failuremakeCaller-provided CC, CPPFLAGS, CFLAGS, and LDFLAGS are honored by the Makefiles.
Releases are tag-driven through .github/workflows/release.yml and are only published from pushed v* tags.
| Back | FazBrowse Home | New Git URL |