AVR library
cmt.h
1 #ifndef MAT_CMT_H
2 #define MAT_CMT_H
3 
4 #include <inttypes.h>
5 
6 #define CMT_MAXTASKS 2
7 
8 struct cmt_task
9 {
10  uint16_t sp;
11  uint16_t tp;
12  uint16_t d;
13  uint16_t minsp;
14 };
15 
16 struct cmt_mutex
17 {
18  uint8_t ot;
19  uint8_t ac;
20 };
21 
22 void cmt_delay_ticks(uint16_t d);
23 uint8_t cmt_setup_task(void (*task_proc)(void), uint16_t task_sp);
24 void cmt_tick(uint8_t ms);
25 uint16_t cmt_minsp(uint8_t task_num);
26 
27 uint8_t cmt_try_acquire(struct cmt_mutex* m);
28 void cmt_acquire(struct cmt_mutex* m);
29 void cmt_release(struct cmt_mutex* m);
30 
31 #endif
Definition: cmt.h:16
uint8_t ac
Definition: cmt.h:19
uint16_t sp
Definition: cmt.h:10
uint16_t tp
Definition: cmt.h:11
uint8_t ot
Definition: cmt.h:18
void cmt_tick(uint8_t ms)
Call within a timer interrupt.
Definition: cmt.c:142
uint16_t d
Definition: cmt.h:12
Definition: cmt.h:8
uint16_t minsp
Definition: cmt.h:13
void cmt_delay_ticks(uint16_t d)
Delay d ticks.
Definition: cmt.c:46
uint8_t cmt_setup_task(void(*task_proc)(void), uint16_t task_sp)
Add task to switching logic.
Definition: cmt.c:122