-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.c
62 lines (49 loc) · 889 Bytes
/
main.c
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
#include<ucos_ii.h>
#include<stdint.h>
#include<time.h>
#include<host.h>
#include<cpu.h>
#define STK_LEN (2048)
OS_STK task1_stk[STK_LEN];
OS_STK task2_stk[STK_LEN];
OS_STK start_stk[STK_LEN];
void task1(void *args)
{
int cnt=0;
for(;;)
{
cnt++;
printf("task1 is runing... %d\n",cnt);
OSTimeDly(10);
}
}
void task2(void *args)
{
int cnt=0;
for(;;)
{
cnt++;
printf("task2 is runing... %d\n",cnt);
OSTimeDly(11);
}
}
void start_task(void *args)
{
printf("start all task...\n");
next_timecmp();
enable_time_int();
enable_global_int();
OSTaskCreate(task1,NULL,&task1_stk[STK_LEN-1],13);
OSTaskCreate(task2,NULL,&task2_stk[STK_LEN-1],12);
OSTaskDel(OS_PRIO_SELF);
for(;;){}
}
int main(void)
{
printf("init...\n");
OSInit();
OSTaskCreate(start_task,NULL,&start_stk[STK_LEN-1],10);
printf("create start task success \r\n");
OSStart();
while(1){}
}