ca13734bf0
Add kernel (Cortex-M0/M3/M4, Tricore, S32K, RISC-V ports), drivers, middleware (CAN stack, diagnostics, safety), applications, board support, build/test tooling, and documentation.
44 lines
1.0 KiB
C
44 lines
1.0 KiB
C
/**
|
|
* @file timer.h
|
|
* @brief Software timer management
|
|
*/
|
|
|
|
#ifndef TIMER_H
|
|
#define TIMER_H
|
|
|
|
#include "kernel.h"
|
|
|
|
/* Timer Types */
|
|
typedef enum {
|
|
TIMER_ONE_SHOT = 0,
|
|
TIMER_PERIODIC = 1
|
|
} TimerType_t;
|
|
|
|
/* Timer Callback */
|
|
typedef void (*TimerCallback_t)(void* parameters);
|
|
|
|
/* Timer Control Block */
|
|
typedef struct {
|
|
char name[16];
|
|
TimerType_t type;
|
|
TickType_t period_ticks;
|
|
TickType_t expiry_time;
|
|
TimerCallback_t callback;
|
|
void* parameters;
|
|
bool is_active;
|
|
struct Timer* next;
|
|
} Timer_t;
|
|
|
|
/* Timer Functions */
|
|
KernelStatus_t timer_create(Timer_t* timer, const char* name, TimerType_t type,
|
|
TickType_t period, TimerCallback_t callback,
|
|
void* parameters);
|
|
KernelStatus_t timer_start(Timer_t* timer);
|
|
KernelStatus_t timer_stop(Timer_t* timer);
|
|
KernelStatus_t timer_reset(Timer_t* timer);
|
|
KernelStatus_t timer_delete(Timer_t* timer);
|
|
bool timer_is_active(Timer_t* timer);
|
|
void timer_process_expired(void);
|
|
|
|
#endif /* TIMER_H */
|