1 /* 2 * Copyright (c) 2021 GOODIX. 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 16 #include "ohos_init.h" 17 #include "cmsis_os2.h" 18 19 20 #define HELLO_TASK_STACK_SIZE 4096 21 #define HELLO_TASK_PRIO 25 22 static int index = 0; 23 #define MS_1000 1000 24 HelloTask(const char * arg)25static void *HelloTask(const char *arg) 26 { 27 (void)arg; 28 29 while (1) { 30 printf("hello world! index=%d\r\n", index++); 31 osDelay(MS_1000); 32 } 33 } 34 HelloTaskEntry(void)35void HelloTaskEntry(void) 36 { 37 osThreadAttr_t attr; 38 39 attr.name = "HelloTask"; 40 attr.attr_bits = 0U; 41 attr.cb_mem = NULL; 42 attr.cb_size = 0U; 43 attr.stack_mem = NULL; 44 attr.stack_size = HELLO_TASK_STACK_SIZE; 45 attr.priority = HELLO_TASK_PRIO; 46 47 if (osThreadNew((osThreadFunc_t)HelloTask, NULL, &attr) == NULL) { 48 printf("[HelloDemo] Falied to create HelloTask!\n"); 49 } 50 } 51 52 SYS_RUN(HelloTaskEntry); 53