10a7ce71fSopenharmony_ci/* 20a7ce71fSopenharmony_ci * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 30a7ce71fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 40a7ce71fSopenharmony_ci * you may not use this file except in compliance with the License. 50a7ce71fSopenharmony_ci * You may obtain a copy of the License at 60a7ce71fSopenharmony_ci * 70a7ce71fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 80a7ce71fSopenharmony_ci * 90a7ce71fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 100a7ce71fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 110a7ce71fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 120a7ce71fSopenharmony_ci * See the License for the specific language governing permissions and 130a7ce71fSopenharmony_ci * limitations under the License. 140a7ce71fSopenharmony_ci */ 150a7ce71fSopenharmony_ci 160a7ce71fSopenharmony_ci#include <stdio.h> 170a7ce71fSopenharmony_ci#include <unistd.h> 180a7ce71fSopenharmony_ci#include "ohos_init.h" 190a7ce71fSopenharmony_ci#include "cmsis_os2.h" 200a7ce71fSopenharmony_ci#include "iot_watchdog.h" 210a7ce71fSopenharmony_ci#include "app_demo_multi_sample.h" 220a7ce71fSopenharmony_ci 230a7ce71fSopenharmony_ci#define TASK_STACK (1024 * 4) 240a7ce71fSopenharmony_ci#define INTERRUPT_TASK_PRIO (26) 250a7ce71fSopenharmony_ci#define TRAFFIC_TASK_PRIO (25) 260a7ce71fSopenharmony_civoid KeyInterruptScan(const char *arg) 270a7ce71fSopenharmony_ci{ 280a7ce71fSopenharmony_ci (void)arg; 290a7ce71fSopenharmony_ci AppMultiSampleDemo(); 300a7ce71fSopenharmony_ci} 310a7ce71fSopenharmony_ci 320a7ce71fSopenharmony_civoid TrafficLightDemo(const char *arg) 330a7ce71fSopenharmony_ci{ 340a7ce71fSopenharmony_ci if (StartHotspot() != 0) { 350a7ce71fSopenharmony_ci printf("start ap failed\r\n"); 360a7ce71fSopenharmony_ci } 370a7ce71fSopenharmony_ci printf("start ap success\r\n"); 380a7ce71fSopenharmony_ci void *link_platform = HistreamingOpen(); 390a7ce71fSopenharmony_ci TrafficLightFunc(); 400a7ce71fSopenharmony_ci printf("traffic light open ok\r\n"); 410a7ce71fSopenharmony_ci} 420a7ce71fSopenharmony_ci 430a7ce71fSopenharmony_cistatic void InterruptTask(void) 440a7ce71fSopenharmony_ci{ 450a7ce71fSopenharmony_ci osThreadAttr_t attr; 460a7ce71fSopenharmony_ci 470a7ce71fSopenharmony_ci attr.name = "Interrupt"; 480a7ce71fSopenharmony_ci attr.attr_bits = 0U; 490a7ce71fSopenharmony_ci attr.cb_mem = NULL; 500a7ce71fSopenharmony_ci attr.cb_size = 0U; 510a7ce71fSopenharmony_ci attr.stack_mem = NULL; 520a7ce71fSopenharmony_ci attr.stack_size = TASK_STACK; 530a7ce71fSopenharmony_ci attr.priority = INTERRUPT_TASK_PRIO; 540a7ce71fSopenharmony_ci 550a7ce71fSopenharmony_ci if (osThreadNew((osThreadFunc_t)KeyInterruptScan, NULL, &attr) == NULL) { 560a7ce71fSopenharmony_ci printf("[TrafficLight] Failed to create TrafficLightDemo!\n"); 570a7ce71fSopenharmony_ci } 580a7ce71fSopenharmony_ci} 590a7ce71fSopenharmony_ci 600a7ce71fSopenharmony_ciSYS_RUN(InterruptTask); 610a7ce71fSopenharmony_ci 620a7ce71fSopenharmony_cistatic void StartTask(void) 630a7ce71fSopenharmony_ci{ 640a7ce71fSopenharmony_ci osThreadAttr_t attr; 650a7ce71fSopenharmony_ci IoTWatchDogDisable(); 660a7ce71fSopenharmony_ci 670a7ce71fSopenharmony_ci attr.name = "TrafficLightDemo"; 680a7ce71fSopenharmony_ci attr.attr_bits = 0U; 690a7ce71fSopenharmony_ci attr.cb_mem = NULL; 700a7ce71fSopenharmony_ci attr.cb_size = 0U; 710a7ce71fSopenharmony_ci attr.stack_mem = NULL; 720a7ce71fSopenharmony_ci attr.stack_size = TASK_STACK; 730a7ce71fSopenharmony_ci attr.priority = osPriorityNormal; 740a7ce71fSopenharmony_ci 750a7ce71fSopenharmony_ci if (osThreadNew((osThreadFunc_t)TrafficLightDemo, NULL, &attr) == NULL) { 760a7ce71fSopenharmony_ci printf("[TrafficLight] Failed to create TrafficLightDemo!\n"); 770a7ce71fSopenharmony_ci } 780a7ce71fSopenharmony_ci} 790a7ce71fSopenharmony_ci 800a7ce71fSopenharmony_ciSYS_RUN(StartTask); 81