AKOS  v1.0.0
Documentation
Loading...
Searching...
No Matches
timer.h File Reference

Software timer APIs. More...

#include "list.h"
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for timer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ak_timer_t
 Software timer object type. More...

Typedefs

typedef struct timer_pool timer_pool_t
 Internal timer pool type.
typedef uint8_t timer_id_t
 Timer identifier type.
typedef void(* timer_cb) ()
 Timer callback signature.

Enumerations

enum  timer_type_t { TIMER_ONE_SHOT , TIMER_PERIODIC }
 Timer mode. More...

Functions

void akos_timer_init (void)
 Initialize timer module.
void akos_timer_processing ()
 Timer thread processing loop.
ak_timer_t * akos_timer_create (timer_id_t id, int32_t sig, timer_cb func_cb, uint8_t des_thread_id, uint32_t period, timer_type_t type)
 Create a timer object from timer pool.
void akos_timer_start (ak_timer_t *p_timer, uint32_t tick_to_wait)
 Start a timer.
void akos_timer_reset (ak_timer_t *p_timer)
 Reset a running timer.
void akos_timer_remove (ak_timer_t *p_timer)
 Remove timer from active lists and return to pool.

Detailed Description

Software timer APIs.

Author
Snoopy3921 - AK Foundation
Date
2026/05/08

Definition in file timer.h.

Typedef Documentation

◆ timer_cb

typedef void(* timer_cb) ()

Timer callback signature.

Callback runs in timer-thread context; keep execution short and non-blocking.

Definition at line 37 of file timer.h.

◆ timer_id_t

typedef uint8_t timer_id_t

Timer identifier type.

Definition at line 29 of file timer.h.

◆ timer_pool_t

typedef struct timer_pool timer_pool_t

Internal timer pool type.

Definition at line 27 of file timer.h.

Enumeration Type Documentation

◆ timer_type_t

Timer mode.

Enumerator
TIMER_ONE_SHOT 

Expires once and then stops.

TIMER_PERIODIC 

Reloads using timer.period.

Definition at line 43 of file timer.h.

Function Documentation

◆ akos_timer_create()

ak_timer_t * akos_timer_create ( timer_id_t id,
int32_t sig,
timer_cb func_cb,
uint8_t des_thread_id,
uint32_t period,
timer_type_t type )

Create a timer object from timer pool.

@brief Create timer object from timer pool.
@param id Timer ID.
@param sig Signal posted when timer expires.
@param func_cb Optional callback executed on expiry.
Parameters
des_thread_idDestination thread ID for signal posting.
periodPeriod in ticks for periodic timers.
typeTimer type (one-shot or periodic).
Returns
Created timer pointer, or NULL on failure.
Parameters
idTimer ID.
sigSignal posted on timeout.
func_cbOptional callback run on timeout.
des_thread_idDestination thread ID for signal posting.
periodPeriod in ticks for periodic timer.
typeTimer type.
Returns
Timer pointer, or NULL on failure.

Definition at line 146 of file timer.c.

◆ akos_timer_init()

void akos_timer_init ( void )

Initialize timer module.

Initialize timer module.

Definition at line 234 of file timer.c.

◆ akos_timer_processing()

void akos_timer_processing ( )

Timer thread processing loop.

Timer thread processing loop.

Processes expired timers, executes callbacks/posts signals, then blocks until the next timer event (or a wakeup message).

Definition at line 247 of file timer.c.

◆ akos_timer_remove()

void akos_timer_remove ( ak_timer_t * p_timer)

Remove timer from active lists and return to pool.

Parameters
p_timerTimer pointer.

Remove timer from active lists and return to pool.

Parameters
p_timerTimer object.

Definition at line 211 of file timer.c.

◆ akos_timer_reset()

void akos_timer_reset ( ak_timer_t * p_timer)

Reset a running timer.

Parameters
p_timerTimer pointer.

Reset a running timer.

Parameters
p_timerTimer object.

Definition at line 321 of file timer.c.

◆ akos_timer_start()

void akos_timer_start ( ak_timer_t * p_timer,
uint32_t tick_to_wait )

Start a timer.

Parameters
p_timerTimer pointer.
tick_to_waitInitial delay in ticks.

Start a timer.

Parameters
p_timerTimer object.
tick_to_waitInitial delay in ticks.

Definition at line 306 of file timer.c.