小熊派学习(1)
进行Hello world程序实现
C语言主程序代码
#include <stdio.h>
#include "ohos_init.h"
void Hello_World(void)
{
printf("Hello World!\r\n");
printf("你好,小熊派开发\r\n");
}
APP_FEATURE_INIT(Hello_World);
相关调用流程代码
static_library("myapp") {
sources = [
"hello_world.c" ]
include_dirs = [
"//utils/native/lite/include"
] }
运行成功截图
点亮led灯操作(注意PPT中存在大括号错误)
#include <stdio.h>
#include <unistd.h>
#include "ohos_init.h"
#include "wifiiot_gpio.h"
#include "wifiiot_gpio_ex.h"
void Led_Sample(void)
{
GpioInit(); //初始化GPIO
IoSetFunc(WIFI_IOT_IO_NAME_GPIO_2, WIFI_IOT_IO_FUNC_GPIO_2_GPIO);//设置GPIO_2的复用功能为普通GPIO
GpioSetDir(WIFI_IOT_IO_NAME_GPIO_2, WIFI_IOT_GPIO_DIR_OUT);//设置GPIO_2为输出模式
GpioSetOutputVal(WIFI_IOT_IO_NAME_GPIO_2,1);//设置GPIO_2输出高电平点亮LED灯
}
APP_FEATURE_INIT(Led_Sample);
static_library("myled") {
sources = [
"led_example.c" ]
include_dirs = [
"//utils/native/lite/include",
"//base/iot_hardware/interfaces/kits/wifiiot_lite" ] }
实现成功效果截图:
编译构建介绍
主要介绍了gn模块的作用,介绍代码入口和注册入口,算是代码整个编译的流程。本部分比较难理解,牵涉到一些编译底层的东西,想直接搞懂确实很难,目前我会用即可。
有问题可以评论,一起讨论。