• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "task_sample.h"
16 #include "los_config.h"
17 #include "los_interrupt.h"
18 #include "los_task.h"
19 #include "los_tick.h"
20 
sample_task_entry1(void)21 void sample_task_entry1(void) {
22     while (1) {
23         printf("%s: sample_task_entry1 runing\r\n", __func__);
24         LOS_TaskDelay(1000);
25     }
26 }
27 
sample_task_entry2(void)28 void sample_task_entry2(void) {
29     while (1) {
30         printf("%s: sample_task_entry2 runing\r\n", __func__);
31         LOS_TaskDelay(1000);
32     }
33 }
34 
create_task(void)35 void create_task(void) {
36     UINT32 ret;
37     TSK_INIT_PARAM_S sample_task1 = {0};
38     TSK_INIT_PARAM_S sample_task2 = {0};
39     UINT32 sample_taskid1;
40     UINT32 sample_taskid2;
41 
42     sample_task1.pfnTaskEntry = (TSK_ENTRY_FUNC)sample_task_entry1;
43     sample_task1.uwStackSize = 0x1000;
44     sample_task1.pcName = "sample_task_entry1";
45     sample_task1.usTaskPrio = 6; /* Os task priority is 6 */
46     ret = LOS_TaskCreate(&sample_task1, &sample_task1);
47     if (ret != LOS_OK) {
48         printf("%s: sample task1 create failed!\r\n", __func__);
49     }
50 
51     sample_task2.pfnTaskEntry = (TSK_ENTRY_FUNC)sample_task_entry2;
52     sample_task2.uwStackSize = 0x1000;
53     sample_task2.pcName = "sample_task_entry2";
54     sample_task2.usTaskPrio = 6; /* Os task priority is 6 */
55     ret = LOS_TaskCreate(&sample_task2, &sample_task2);
56     if (ret != LOS_OK) {
57         printf("%s: sample task2 create failed!\r\n", __func__);
58     }
59 
60     printf("%s: sample tasks create ok.\r\n", __func__);
61 }
62 
63