• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
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 <stdio.h>
17 #include <unistd.h>
18 #include "ohos_init.h"
19 #include "cmsis_os2.h"
20 #include "iot_watchdog.h"
21 #include "app_demo_multi_sample.h"
22 
23 #define TASK_STACK  (1024 * 4)
24 #define INTERRUPT_TASK_PRIO (26)
25 #define TRAFFIC_TASK_PRIO   (25)
KeyInterruptScan(const char * arg)26 void KeyInterruptScan(const char *arg)
27 {
28     (void)arg;
29     AppMultiSampleDemo();
30 }
31 
TrafficLightDemo(const char * arg)32 void TrafficLightDemo(const char *arg)
33 {
34     if (StartHotspot() != 0) {
35         printf("start ap failed\r\n");
36     }
37     printf("start ap success\r\n");
38     void *link_platform = HistreamingOpen();
39     TrafficLightFunc();
40     printf("traffic light open ok\r\n");
41 }
42 
InterruptTask(void)43 static void InterruptTask(void)
44 {
45     osThreadAttr_t attr;
46 
47     attr.name = "Interrupt";
48     attr.attr_bits = 0U;
49     attr.cb_mem = NULL;
50     attr.cb_size = 0U;
51     attr.stack_mem = NULL;
52     attr.stack_size = TASK_STACK;
53     attr.priority = INTERRUPT_TASK_PRIO;
54 
55     if (osThreadNew((osThreadFunc_t)KeyInterruptScan, NULL, &attr) == NULL) {
56         printf("[TrafficLight] Failed to create TrafficLightDemo!\n");
57     }
58 }
59 
60 SYS_RUN(InterruptTask);
61 
StartTask(void)62 static void StartTask(void)
63 {
64     osThreadAttr_t attr;
65     IoTWatchDogDisable();
66 
67     attr.name = "TrafficLightDemo";
68     attr.attr_bits = 0U;
69     attr.cb_mem = NULL;
70     attr.cb_size = 0U;
71     attr.stack_mem = NULL;
72     attr.stack_size = TASK_STACK;
73     attr.priority = osPriorityNormal;
74 
75     if (osThreadNew((osThreadFunc_t)TrafficLightDemo, NULL, &attr) == NULL) {
76         printf("[TrafficLight] Failed to create TrafficLightDemo!\n");
77     }
78 }
79 
80 SYS_RUN(StartTask);
81