美文网首页
【小熊派nano鸿蒙OS开发板】点亮LED灯

【小熊派nano鸿蒙OS开发板】点亮LED灯

作者: Geekero | 来源:发表于2021-01-15 17:08 被阅读0次

创建业务代码

$vi led_example.c 
(bearpi) 08:46 luohb@Studynode:~/OHOS/Project/code/applications/BearPi/BearPi-HM_Nano/sample/my_led 
$cat led_example.c 
#include "ohos_init.h"
#include "wifiiot_gpio.h"
#include "wifiiot_gpio_ex.h"

void led_example(void)
{
    GpioInit();
    //设置GPIO管脚复用功能
    IoSetFunc(WIFI_IOT_IO_NAME_GPIO_2, WIFI_IOT_IO_FUNC_GPIO_2_GPIO);
    //设置GPIO方向为输出模式
    GpioSetDir(WIFI_IOT_IO_NAME_GPIO_2, WIFI_IOT_GPIO_DIR_OUT);

    //设置高低电平
    GpioSetOutputVal(WIFI_IOT_IO_NAME_GPIO_2, 1); //高电平
}

//启动函数
APP_FEATURE_INIT(led_example);

编写编译构建文件

(bearpi) 08:57 luohb@Studynode:~/OHOS/Project/code/applications/BearPi/BearPi-HM_Nano/sample/my_led 
$cat BUILD.gn 
static_library("myled"){
    sources = [
        "led_example.c"
    ]
    include_dirs = [
        "//utils/native/lite/include",
        "//base/iot_hardware/interfaces/kits/wifiiot_lite"
    ]
}

添加编译模块、

(bearpi) 08:59 luohb@Studynode:~/OHOS/Project/code/applications/BearPi/BearPi-HM_Nano/sample 
$cat BUILD.gn 
# Copyright (c) 2020 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build/lite/config/component/lite_component.gni")

lite_component("app") {
    features = [
        #"A1_kernal_thread:thread_example",
        #"A2_kernel_timer:timer_example",
        #"A3_kernel_event:event_example",
        #"A4_kernel_mutex:mutex_example",
        #"A5_kernel_semaphore:semaphore_example",
        #"A6_kernel_message:message_example",

        #"B1_basic_led_blink:led_example",
        #"B2_basic_button:button_example",
        #"B3_basic_pwm_led:pwm_example",
        #"B4_basic_adc:adc_example",
        #"B5_basic_i2c_nfc:i2c_example",
        #"B6_basic_uart:uart_example",
        
        #"C1_e53_sf1_mq2:e53_sf1_example",
        #"C2_e53_ia1_temp_humi_pls:e53_ia1_example",
        #"C3_e53_sc1_pls:e53_sc1_example",
        #"C4_e53_sc2_axis:e53_sc2_example",
        #"C5_e53_is1_infrared:e53_is1_example",

        #"D1_iot_wifi_sta:wifi_sta",
        #"D2_iot_wifi_sta_connect:wifi_sta_connect",        
        #"D3_iot_udp_client:udp_client",
        #"D4_iot_tcp_server:tcp_server",
        #"D5_iot_mqtt:iot_mqtt",        
        #"D6_iot_cloud_oc:oc_mqtt",
        #"D7_iot_cloud_onenet:onenet_mqtt",
       
        #"my_app:myapp",
        "my_led:myled",
    ]
}

编译

hpm dist

相关文章

网友评论

      本文标题:【小熊派nano鸿蒙OS开发板】点亮LED灯

      本文链接:https://www.haomeiwen.com/subject/vqzyaktx.html