GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Vanderhell/microtimer: microtimer is a lightweight C99 software timer manager for embedded systems, designed for deterministic timing in main-loop or SysTick-driven firmware without dynamic memory allocation.

BranchesTags
Open more actions menu

Latest commit

 

History

16 Commits
16 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
cmake
cmake
 
 
docs
docs
 
 
include
include
 
 
src
src
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CMakeLists.txt
CMakeLists.txt
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 

Repository files navigation

microtimer

CI License: MIT C Standard

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.

Support Scope

  • C99 and C11 consumers
  • C++ header consumption
  • GCC, Clang, and MSVC builds
  • Main-loop usage
  • ISR-owned usage with strict limits
  • External synchronization around shared access
  • ARM Cortex-M compile-only verification
  • CMake find_package() and add_subdirectory() consumers

Quick Start

#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();
        }
    }
}

Key Contracts

  • Clock units are milliseconds on an unsigned 32-bit modulo counter.
  • Natural uint32_t wraparound is supported if the clock is not reset while timers are active.
  • mtimer_tick() fires each running timer at most once per successful call.
  • Missed periodic intervals are skipped without callback bursts; phase is retained when only one interval is due.
  • Timer names are optional and caller-owned. Non-NULL names must remain valid, immutable, and unique per manager.
  • Timer IDs are slot indexes. Destroying a timer invalidates its ID, and later creates may reuse that slot.
  • Same-manager mutation during callbacks returns MTIMER_ERR_BUSY.

Build

CMake

cmake -S . -B build -DMICROTIMER_BUILD_TESTS=ON
cmake --build build
ctest --test-dir build --output-on-failure

Make

make

Caller-provided CC, CPPFLAGS, CFLAGS, and LDFLAGS are honored by the Makefiles.

Documentation

  • API reference
  • Cookbook
  • Design notes
  • Issues and troubleshooting
  • Porting guide
  • Verification status
  • Contributing
  • Security reporting
  • Changelog

Releases are tag-driven through .github/workflows/release.yml and are only published from pushed v* tags.

About

microtimer is a lightweight C99 software timer manager for embedded systems, designed for deterministic timing in main-loop or SysTick-driven firmware without dynamic memory allocation.

Topics

bare-metalc99embeddedembedded-cfirmwarelibrarymicrocontrollerreal-timesoftware-timertimer

Resources

Readme
MIT license

Contributing

Contributing

Security policy

Security policy
Activity

Stars

0 stars

Watchers

0 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.