STM32F10x library
cmt.h
1 #ifndef MAT_CMT_H
2 #define MAT_CMT_H
3 
4 #include <inttypes.h>
5 
6 #define CMT_MAXTASKS 5
7 
9 struct cmt_task
10 {
11  uint32_t sp;
12  uint32_t tp;
13  uint32_t d;
14  uint32_t minsp;
15 };
16 
18 struct cmt_mutex
19 {
20  uint8_t ot;
21  uint8_t ac;
22 };
23 
24 void cmt_delay_ticks(uint32_t d);
25 uint8_t cmt_setup_task(void (*task_proc)(void), uint32_t task_sp);
26 void cmt_tick(void);
27 uint32_t cmt_minsp(uint8_t task_num);
28 
29 uint8_t cmt_try_acquire(struct cmt_mutex* m);
30 void cmt_acquire(struct cmt_mutex* m);
31 void cmt_release(struct cmt_mutex* m);
32 #endif
void cmt_tick(void)
Call within a timer interrupt.
Definition: cmt.c:100
Definition: cmt.h:18
uint8_t ac
Definition: cmt.h:21
void cmt_release(struct cmt_mutex *m)
Releases mutex.
Definition: cmt.c:161
void cmt_acquire(struct cmt_mutex *m)
Waits until mutex acquired.
Definition: cmt.c:150
uint8_t ot
Definition: cmt.h:20
uint32_t sp
Definition: cmt.h:11
Definition: cmt.h:9
uint8_t cmt_setup_task(void(*task_proc)(void), uint32_t task_sp)
Add task to switching logic.
Definition: cmt.c:80
uint32_t tp
Definition: cmt.h:12
uint32_t cmt_minsp(uint8_t task_num)
Returns the task's minimal detected stack pointer.
Definition: cmt.c:123
void cmt_delay_ticks(uint32_t d)
Delay d ticks.
Definition: cmt.c:44
uint8_t cmt_try_acquire(struct cmt_mutex *m)
Tries to acquire mutex.
Definition: cmt.c:136
uint32_t d
Definition: cmt.h:13
uint32_t minsp
Definition: cmt.h:14