当前位置:网站首页>Openharmony quick start
Openharmony quick start
2022-07-27 00:27:00 【INSIGNER】
To write Helloworld
Create folder
stay [git clone In the directory ]bearpi-hm_nano\applications\BearPi\BearPi-HM_Nano\sample Create under directory my_app Folder .( Remember the name of the folder and use it later )
To write HelloWorld
In the my_app Under the folder , To write hello_world.c( Remember to use ) file , There is no need to create src Folder .
#include <stdio.h>
// Imported this h The file comes with the project , The interior defines APP_FEATURE_INIT
#include "ohos_init.h"
void HelloWorld(void)
{
printf("Hello World\r\n");
}
//harmony Start the recovery interface
APP_FEATURE_INIT(HelloWorld);
To write BUILD.gn
This BUILD.gn The file name must be capitalized , Otherwise it will go wrong .
This document is placed in my_app Under the folder
// Specify the compilation result of the business module , For static library files libmyapp.a, The developer shall fill in according to the actual situation .
static_library("myapp") {
sources=[
// You just created ,hello_world.c Pay attention to the name always
"hello_world.c"
]
include_dirs=[
// Just at hello_world.c The include file
// Symbol // Represents the root path of the project
"//utils/native/lite/include"
]
}
gn File cannot be annotated , The notes here are just for convenience of explanation
Modify the module compilation build file BUILD.gn
[git clone In the directory ]bearpi-hm_nano\applications\BearPi\BearPi-HM_Nano\sample In the catalog BUILD.gn file
import("//build/lite/config/component/lite_component.gni")
lite_component("app") {
features = [
//.......... Omit ........
#"Zx_Developer:zx_develop_sample" ## Not involved in building , Contribute demo structure to developers , among Zx by Z1,Z2...Z100
#"Z1_hi3861_uart_ylc:uart_hi3861",
#"Z2_hi3861_flash_ylc:flash_example",
// Add this line of command at the end ,my_app It was created in the beginning my_app file ,myapp It was just in BUILD.gn As defined in static_library After the name .
"my_app:myapp",
]
}
gn File cannot be annotated , The notes here are just for convenience of explanation
Then compile the file and burn ,
Burning or Hi3861_wifiiot_app_allinone.bin file .
After burning, you can mobaxterm see Hello World
Lighten up led The lamp
The steps are similar to the above , So it's abbreviated
- stay
sampleCreate under directorymy_lebFolder - establish
leb_example.cfile
#include "ohos_init.h"
#include "wifiiot_gpio.h"
#include "wifiiot_gpio_ex.h"
void led_example(void)
{
GpioInit();
IoSetFunc(WIFI_IOT_IO_NAME_GPIO_2, WIFI_IOT_IO_FUNC_GPIO_2_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);
- stay
my_lebCreateBUILD.gnfile
static_library("myleb") {
sources=[
"led_example.c"
]
include_dirs=[
"//utils/native/lite/include",
// Store here wifiiot_gpio.h and wifiiot_gpio_ex.h
"//base/iot_hardware/interfaces/kits/wifiiot_lite"
]
}
gn File cannot be annotated , The notes here are just for convenience of explanation
4. Modify the module to compile the build file BUILD.gn
stay features Add... In the last line
"my_leb:myleb"
Notice the comma in front , Separate from the previous line .
- Bake and record to the development board
success ,led The light will flash continuously - modify led_example.c When adding led Code for flashing light
#include <stdio.h>
#include <unistd.h>
#include "ohos_init.h"
#include "wifiiot_gpio.h"
#include "wifiiot_gpio_ex.h"
void led_example(void)
{
GpioInit();
IoSetFunc(WIFI_IOT_IO_NAME_GPIO_2, WIFI_IOT_IO_FUNC_GPIO_2_GPIO);
GpioSetDir(WIFI_IOT_IO_NAME_GPIO_2, WIFI_IOT_GPIO_DIR_OUT);
// control led The flicker of the lamp
for (int i = 0; i < 10; i++)
{
// Set up WIFI_IOT_IO_NAME_GPIO_2,1 Indicates that the light is on
GpioSetOutputVal(WIFI_IOT_IO_NAME_GPIO_2, 1);
usleep(1000000);
// 0 It means that the light is off
GpioSetOutputVal(WIFI_IOT_IO_NAME_GPIO_2, 0);
usleep(1000000);
}
GpioSetOutputVal(WIFI_IOT_IO_NAME_GPIO_2, 1);
}
APP_FEATURE_INIT(led_example);
- Burn code
After success led The light flashes slowly 10 Time
openharmony Introduction to compilation and construction
ninja It's a ratio. Makefile More efficient compilation and construction tools .Google Development .
When we run on the command line python build.py BearPi-HM_Nano On command ,ninja It's activated
This BearPi-HM_Nano Actually, it comes from the project directory list/product/ Under folder BearPi-HM_Nano.json
边栏推荐
- C and pointer Chapter 18 runtime environment 18.7 problems
- 12_决策树(Decision tree)
- 深度学习调参技巧
- 在pycharm中部署yolov5报错问题
- 蒙着头配置deeplabcut 1
- Leetcode topic - array
- 1、 Kubernetes basic concept + environment installation (build cross server public network environment)
- Apple TV HD with the first generation Siri remote is listed as obsolete
- 4. Talk about the famous Zhang Zhengyou calibration method
- 2022-07-17:1, 2, 3... N-1, N, n+1, n+2... In this sequence, only one number has repetition (n). This sequence is unordered. Find the repeated number n. This sequence is ordered. Find the repeated numb
猜你喜欢

数据库:MySQL基础+CRUD基本操作

Chapter 7 course summary

4. Talk about the famous Zhang Zhengyou calibration method

RESNET paper interpretation and code implementation (pytorch)

Anaconda = > pycharm=> CUDA=> cudnn=> pytorch environment configuration

Drawing warehouse-2 (function image)

Relationship between limit, continuity, partial derivative and total differential of multivariate function (learning notes)

Leetcode - hash table

Recent answers - column

Complete backpack and 01 Backpack
随机推荐
Blue Bridge Cup brush question notes (word analysis)
Shang school software testing (1) software testing curriculum system, advantages, learning suggestions, understanding software, software testing and defects, software testing process, debugging and te
Topological sorting (learning notes) introduction + judge whether there is a ring
UNET notes
Request attribute in crawler
解析网页的完整回顾
Double. isNaN(double var)
Midge paper reading notes
在pycharm中部署yolov5报错问题
Codeforces D. two divisors (number theory, linear sieve)
PTA 7-4 small generation (DFS)
Machine learning model -- lightgbm
三层架构 模拟
6_梯度下降法(Gradient Descent)
Resolve Microsoft 365 and Visio conflicts
Training team lpoj round10 e Jumping Frog
Mysql database complex operations: Database Constraints, query / connect table operations
Search engine hijacking of black hat SEO
94. Middle order traversal of binary tree
Arcgis和Cass实现断面展高程点