1 /*
2 Copyright (C) 2024 HiHope Open Source Organization .
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 <stdio.h>
16 #include <unistd.h>
17
18 #include "ohos_init.h"
19 #include "cmsis_os2.h"
20
rtosv2_delay_main(void * arg)21 void rtosv2_delay_main(void *arg)
22 {
23 (void) arg;
24
25 printf("[Delay Test] Current system tick: %d.\r\n", osKernelGetTickCount());
26 osStatus_t status = osDelay(100);
27 printf("[Delay Test] osDelay, status: %d.\r\n", status);
28 printf("[Delay Test] Current system tick: %d.\r\n", osKernelGetTickCount());
29
30 uint32_t tick = osKernelGetTickCount();
31 tick += 100;
32 status = osDelayUntil(tick);
33 printf("[Delay Test] osDelayUntil, status: %d.\r\n", status);
34 printf("[Delay Test] Current system tick: %d.\r\n", osKernelGetTickCount());
35 }
36
DelayTestTask(void)37 static void DelayTestTask(void)
38 {
39 osThreadAttr_t attr;
40
41 attr.name = "rtosv2_delay_main";
42 attr.attr_bits = 0U;
43 attr.cb_mem = NULL;
44 attr.cb_size = 0U;
45 attr.stack_mem = NULL;
46 attr.stack_size = 0x1000;
47 attr.priority = osPriorityNormal;
48
49 if (osThreadNew((osThreadFunc_t) rtosv2_delay_main, NULL, &attr) == NULL) {
50 printf("[DelayTestTask] Falied to create rtosv2_delay_main!\n");
51 }
52 }
53
54 APP_FEATURE_INIT(DelayTestTask);