Skip to content

Version 0.2.0 - #18

Merged
ale-giustina merged 13 commits into
masterfrom
dev
Nov 16, 2026
Merged

ale-giustina merged 13 commits into
masterfrom
dev

Conversation

@ale-giustina

Copy link
Copy Markdown
Contributor

Purpose

Prepare the next release (v0.2.0) of libtimebase-sw by merging dev into master.
The main goal is to remove the current_tick parameter from the tasks and watchdogs APIs:
both modules now read the time through a user-provided tick getter. The PR also fixes several
scheduling bugs in the tasks module and extends the watchdogs API.

⚠️ This is a breaking change: nearly every function in the tasks and watchdogs APIs has a new signature.

Overview

Tick getter (breaking)

  • tasks_api_init and watchdogs_api_init_pool now take a uint32_t (*)(void) tick getter
    (task_tick_callback / watchdog_tick_callback) instead of current_tick.
  • current_tick has been removed from *_routine, tasks_api_enable/pause/disable/update_task
    and watchdogs_api_watchdog_start/restart/pet.
  • Any tick source can be used (a timebase_get_tick wrapper, the HAL tick or the RTOS tick).
    The temporal continuity check still applies to the value the getter returns.

Tasks

  • Fix: a callback can now safely enable, pause, disable or update its own task. The task's state
    (next trigger, remaining repeats) is updated before the callback runs.
  • Fix: a long-overdue task no longer runs several times in one burst. Missed executions are
    skipped and counted, and the count can be read with the new tasks_api_get_dropped_task_executions().
  • Fix: a task that was paused after its trigger time had passed now runs immediately when re-enabled,
    instead of having its schedule recomputed incorrectly.
  • Fix: tasks_api_init and tasks_api_routine now report heap insertion failures (TASKS_RC_ERROR).
  • MAX_TASKS was renamed to TASKS_MAX_COUNT and can be overridden at compile time (#ifndef guard).

Watchdogs

  • New watchdogs_api_watchdog_reset() puts a watchdog back in NOT_RUNNING from any state,
    without running its callback.
  • New watchdogs_api_watchdog_feed() signals liveness: a running watchdog is petted, a timed-out
    watchdog is restarted, and a stopped watchdog stays stopped.
  • timeout_callback was renamed to watchdog_timeout_callback.
  • MAX_WATCHDOGS was renamed to WATCHDOGS_MAX_COUNT and can be overridden at compile time.
  • The unused watchdog_module_enabled / task_module_enabled fields were removed from the handlers.

Docs, examples, tests

  • README rewritten for the tick getter model (new "Tick getter" section).
  • Examples updated to the new API.
  • Test suites greatly extended (~1,100 lines for tasks, ~570 for watchdogs), covering self-handling,
    overdue bursts, pause/resume, reset and feed.

Guidance

  1. Start with the public headers to see the new contract:
    include/tasks/tasks.h → include/tasks/tasks-api.h →
    include/watchdogs/watchdogs.h → include/watchdogs/watchdogs-api.h.
  2. src/tasks-api.c, the most delicate part. Focus on tasks_api_routine (state update before
    the callback, overdue-drop loop) and prv_handle_task_transition (resume from paused-and-overdue).
  3. src/watchdogs-api.c: the tick getter integration and the new reset / feed functions.
  4. Tests (test/test_tasks/, test/test_watchdog/), to check the edge cases above are covered.
  5. README.md, examples/, library.json: check that the docs and examples match the new API.

@ale-giustina
ale-giustina requested a review from Bridiro November 16, 2026 14:00

@Bridiro Bridiro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@ale-giustina
ale-giustina merged commit a3873ae into master Nov 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants