10a7ce71fSopenharmony_ci/* 20a7ce71fSopenharmony_ci * Copyright (C) 2022 HiHope Open Source Organization . 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 * 140a7ce71fSopenharmony_ci * limitations under the License. 150a7ce71fSopenharmony_ci */ 160a7ce71fSopenharmony_ci 170a7ce71fSopenharmony_ci#include <stdio.h> 180a7ce71fSopenharmony_ci 190a7ce71fSopenharmony_ci#include <unistd.h> 200a7ce71fSopenharmony_ci 210a7ce71fSopenharmony_ci#include "cmsis_os2.h" 220a7ce71fSopenharmony_ci#include "ohos_init.h" 230a7ce71fSopenharmony_ci#include "wifiiot_gpio.h" 240a7ce71fSopenharmony_ci#include "wifiiot_gpio_ex.h" 250a7ce71fSopenharmony_ci 260a7ce71fSopenharmony_ci#define LED_TASK_STACK_SIZE 1024 270a7ce71fSopenharmony_ci#define LED_TASK_PRIO 25 280a7ce71fSopenharmony_ci#define NUM 1 290a7ce71fSopenharmony_ci#define OS_DELAY 50 300a7ce71fSopenharmony_ci 310a7ce71fSopenharmony_cistatic int* GpioTask(const char* arg) 320a7ce71fSopenharmony_ci{ 330a7ce71fSopenharmony_ci (void)arg; 340a7ce71fSopenharmony_ci 350a7ce71fSopenharmony_ci GpioInit(); 360a7ce71fSopenharmony_ci IoSetFunc(WIFI_IOT_IO_NAME_GPIO_9, WIFI_IOT_IO_FUNC_GPIO_9_GPIO); 370a7ce71fSopenharmony_ci GpioSetDir(WIFI_IOT_IO_NAME_GPIO_9, WIFI_IOT_GPIO_DIR_OUT); 380a7ce71fSopenharmony_ci 390a7ce71fSopenharmony_ci while (NUM) { 400a7ce71fSopenharmony_ci printf("LED_SPARK! \n"); 410a7ce71fSopenharmony_ci GpioSetOutputVal(WIFI_IOT_IO_NAME_GPIO_9, WIFI_IOT_GPIO_VALUE0); 420a7ce71fSopenharmony_ci osDelay(OS_DELAY); 430a7ce71fSopenharmony_ci GpioSetOutputVal(WIFI_IOT_IO_NAME_GPIO_9, WIFI_IOT_GPIO_VALUE1); 440a7ce71fSopenharmony_ci osDelay(OS_DELAY); 450a7ce71fSopenharmony_ci } 460a7ce71fSopenharmony_ci return NULL; 470a7ce71fSopenharmony_ci} 480a7ce71fSopenharmony_ci 490a7ce71fSopenharmony_cistatic void GpioExampleEntry(void) 500a7ce71fSopenharmony_ci{ 510a7ce71fSopenharmony_ci osThreadAttr_t attr; 520a7ce71fSopenharmony_ci 530a7ce71fSopenharmony_ci attr.name = "GpioTask"; 540a7ce71fSopenharmony_ci attr.attr_bits = 0U; 550a7ce71fSopenharmony_ci attr.cb_mem = NULL; 560a7ce71fSopenharmony_ci attr.cb_size = 0U; 570a7ce71fSopenharmony_ci attr.stack_mem = NULL; 580a7ce71fSopenharmony_ci attr.stack_size = LED_TASK_STACK_SIZE; 590a7ce71fSopenharmony_ci attr.priority = LED_TASK_PRIO; 600a7ce71fSopenharmony_ci 610a7ce71fSopenharmony_ci if (osThreadNew((osThreadFunc_t)GpioTask, NULL, &attr) == NULL) { 620a7ce71fSopenharmony_ci printf("[GpioExample] Failed to create GpioTask!\n"); 630a7ce71fSopenharmony_ci } 640a7ce71fSopenharmony_ci} 650a7ce71fSopenharmony_ci 660a7ce71fSopenharmony_ciSYS_RUN(GpioExampleEntry); // if test add it 67