-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtask.h
152 lines (109 loc) · 3.43 KB
/
task.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#ifndef TASK_H
#define TASK_H
#include <stdint.h>
#include "taskconfig.h"
#include "task_mem.h"
/*
1,My compiler will garble when typing Chinese, so translate it in English
2,Don't think that writing English is pretending to be force,English is good
*/
typedef unsigned char Task_Id;
typedef unsigned short Task_Event;
typedef unsigned short Task_SysEvent;
#define TASK_VOLE volatile
#define TASK_SYS_EVENT (0x8000U)
#define IS_TASK_EVENT(REG,BIT) ((REG) & (BIT))
#define is_event(arg1,arg2,con) (IS_TASK_EVENT(arg1,arg2) ? (con |= arg2) : (con) )
#define CLEAR_TASK_EVENT(REG,BIT) ((REG) ^= (BIT))
#define task_TEST()
typedef enum timestatus
{
timerror = 0,
timeradd,
timerDelect
}timestatus_t ;
typedef enum
{
mes_sendErr = 0,
mes_sendSucc,
mes_getErr,
mes_getSucc,
mes_initErr,
mes_initSucc,
mes_resError,
mes_resSucc,
mes_null
}taskMessFlag;
typedef enum
{
TASK_ERROR = 0U,
TASK_SUCCESS = !TASK_ERROR
} TASK_ErrorStatus;
typedef struct
{
Task_Id task_id;
Task_Event task_event;
Task_SysEvent task_sysevent;
}task_uhandler_t;
typedef task_uhandler_t task_u;
typedef void(*Task_Function )(void*);
typedef void(*Task_Event_cb )(task_u* arg);
struct task_event_li;
typedef struct taskMan
{
Task_Id task_id;
Task_Event task_event;
Task_SysEvent task_sysevent;
struct task_event_li * task_EventBase;
struct task_event_li* systask_EventBase;
}taskMan_t;
typedef taskMan_t* taskType;
typedef struct task_event_li
{
Task_Event task_event;
Task_Event_cb taskeventprocess;
struct task_event_li* next;
}task_event_l_t;
typedef struct
{
Task_Event cou_event;
taskType task;
}task_handler;
void task_info(void);
void task_time_init(void);
void task_init( void );
/* User use task system related */
/* create task */
taskType task_reg_app(Task_Id taskid);
/* Get the lowest priority of the task */
Task_Id task_get_lowid(void);
/* delete task */
TASK_ErrorStatus task_del_app(taskType* RegTask );
/*task message API */
taskMessFlag task_send_msg(taskType task,Task_Event set_event,void* data);
taskMessFlag task_get_msg(taskType task, void** res);
/* Set time and event api */
uint32_t task_get_time_size(void);
/* Generating common events */
void task_new_genEx(taskType task_type , Task_Event_cb tk_pro_cb ,Task_Event clr_event);
void task_new_sysEx(taskType task_type , Task_Event_cb tk_pro_cb ,Task_Event clr_event );
TASK_ErrorStatus task_set_event(taskType task_type , Task_Event taskEvent);
TASK_ErrorStatus task_cls_ordEx(taskType xtarGet, Task_Event event_flag );
TASK_ErrorStatus task_set_sysex(taskType task_type , Task_SysEvent task_sysevent);
Task_SysEvent task_get_sysEx(taskType task_type);
TASK_ErrorStatus task_cls_sysex(taskType task_type , Task_SysEvent task_sysevent);
//The time unit of parameter three is ms
TASK_ErrorStatus task_start_timer(taskType task_type, Task_Event event_flag, TIME_SAVE_TYPE timeout_value );
void task_stop_timer(taskType task_type,Task_Event des_event);
void task_cls_cnt_time(void);
//Task scheduling related api
void task_update_time( uint32_t updateTime );
void task_run_system(void);
void task_run(void);
#if USE_TASK_HANDLER
task_handler* task_get_handler(void* arg);
void task_des_handler(task_handler* tk_hd);
#endif /* USE_TASK_HANDLER */
/* extern */
extern hpSeBind tkhpHandler;
#endif /* TASK_H */