Hi3861 OpenHarmony嵌入式应用入门--hello world

devtools/2024/9/22 19:08:55/

这篇文章我们开始根据自己的开发板编写测试例程,通过编写例程来更好的学习。

目的:使用开发板上电后周期性打印“hello world”

我们需要创建自己的开发板工程目录,这里大部分时候会参考hqyj开发板的目录,但是我们会从0开始,这样能够更好的了解我们的工程中有哪些是我们自己的,哪些是鸿蒙sdk的。

修改D:\DevEcoProjects\test\src\applications\sample\wifi-iot\app\BUILD.gn文件

# Copyright (c) 2020 Huawei Device 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 = [
#        "startup","//vendor/rtplay/rt_hi3861/demo:demo",]
}

在D:\DevEcoProjects\test\src\vendor创建文件夹rtplay,里面创建rt_hi3861,编写config文件,复制D:\DevEcoProjects\test\src\vendor\hqyj\fs_hi3861\config.json文件为 D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\config.json,并修改里面的开发板信息。

{"product_name": "rt_hi3861","ohos_version": "OpenHarmony 1.0","device_company": "rtplay","board": "rtplay_hi3861","kernel_type": "liteos_m","kernel_version": "","subsystems": [{"subsystem": "applications","components": [{ "component": "wifi_iot_sample_app", "features":[] }]},{"subsystem": "iot_hardware","components": [{ "component": "iot_controller", "features":[] }]},{"subsystem": "hiviewdfx","components": [{ "component": "hilog_lite", "features":[] }]},{"subsystem": "distributed_schedule","components": [{ "component": "samgr_lite", "features":[] }]},{"subsystem": "security","components": [{ "component": "hichainsdk", "features":[] },{ "component": "deviceauth_lite", "features":[] },{ "component": "huks", "features":["disable_huks_binary = false","disable_authenticate = false","huks_use_lite_storage = true","huks_use_hardware_root_key = true","huks_config_file = \"hks_config_lite.h\"","huks_mbedtls_path = \"//device/hisilicon/hispark_pegasus/sdk_liteos/third_party/mbedtls/include/\""]}]},{"subsystem": "startup","components": [{ "component": "bootstrap_lite", "features":[] },{ "component": "syspara_lite", "features":["enable_ohos_startup_syspara_lite_use_thirdparty_mbedtls = false"]}]},{"subsystem": "communication","components": [{ "component": "wifi_lite", "features":[] },{ "component": "softbus_lite", "features":[] },{ "component": "wifi_aware", "features":[]}]},{"subsystem": "update","components": [{ "component": "ota_lite", "features":[] }]},{"subsystem": "iot","components": [{ "component": "iot_link", "features":[] }]},{"subsystem": "utils","components": [{ "component": "file", "features":[] },{ "component": "kv_store", "features":[] },{ "component": "os_dump", "features":[] }]},{"subsystem": "vendor","components": [{ "component": "hi3861_sdk", "target": "//device/hisilicon/hispark_pegasus/sdk_liteos:wifiiot_sdk", "features":[] }]}],"third_party_dir": "//device/hisilicon/hispark_pegasus/sdk_liteos/third_party","product_adapter_dir": "//vendor/hisilicon/hispark_pegasus/hals"}

创建D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\BUILD.gn文件

# Copyright (c) 2023 Beijing HuaQing YuanJian Education 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("demo") {features = ["base_00_hellowrold:base_helloworld_example",]
}

创建D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\base_00_helloworld文件夹

文件夹中创建D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\base_00_helloworld\base_helloworld_example.c文件D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\base_00_helloworld\BUILD.gn文件

# Copyright (c) 2023 Beijing HuaQing YuanJian Education 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. static_library("base_led_example") {sources = ["base_helloworld_example.c",]include_dirs = ["//utils/native/lite/include","//kernel/liteos_m/kal/cmsis","//base/iot_hardware/peripheral/interfaces/kits","//vendor/hqyj/fs_hi3861/common/bsp/include"]
}
/** Copyright (c) 2023 Beijing HuaQing YuanJian Education 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.*/#include <stdio.h>
#include <unistd.h>#include "cmsis_os2.h"
#include "ohos_init.h"osThreadId_t Task1_ID = 0;    //  任务1 ID
#define TASK_STACK_SIZE 1024
#define TASK_DELAY_TIME (1000 * 1000)/*** @description: 任务1* @param {*}* @return {*}*/
void Task1(void)
{printf("enter Task 1.......\r\n");while (1) {printf("hello world\r\n");usleep(TASK_DELAY_TIME);                      // 1s sleep}
}/*** @description: 初始化并创建任务* @param {*}* @return {*}*/
static void base_helloworld_demo(void)
{printf("[demo] Enter base_led_demo()!\r\n");osThreadAttr_t taskOptions;taskOptions.name = "Task1";                // 任务的名字taskOptions.attr_bits = 0;                 // 属性位taskOptions.cb_mem = NULL;                 // 堆空间地址taskOptions.cb_size = 0;                   // 堆空间大小taskOptions.stack_mem = NULL;              // 栈空间地址taskOptions.stack_size = TASK_STACK_SIZE;  // 栈空间大小 单位:字节taskOptions.priority = osPriorityNormal;   // 任务的优先级:wqTask1_ID = osThreadNew((osThreadFunc_t)Task1, NULL, &taskOptions);  // 创建任务1if (Task1_ID != NULL) {printf("ID = %d, Create Task1_ID is OK!\r\n", Task1_ID);}
}
SYS_RUN(base_helloworld_demo);

目录结构

│  config.json
│
├─common
│  └─bsp
│      ├─include
│      └─src
├─demo
│  │  BUILD.gn
│  │
│  └─base_00_helloworld
│         base_helloworld_example.c
│         BUILD.gn
└─doc│  HarmonyOS开发板实验指导书 v2.1.pdf│  华清远见 FS_Hi3861开发指导.md│  华清远见 FS_Hi3861新手入门手册.md│├─board│      FS-Hi3861-V4.2.pdf│      FS-Hi3861QDB-V3.2.pdf│      hi-12f_kit_v1.1.0A7E6BCB9%A6-20211025.pdf│      hi-12f_v1.1.2-A7E6BCB9%A6-20211202.pdf│      nodemcu-hi-07s_12f-kit_v1.1-20210913.pdf│      RTplay2.01_2024-06-14.pdf│└─figures

使用build

不出意外会出现如下

下载程序,具体流程详见烧写博文

间隔1秒打印hello world。


http://www.ppmy.cn/devtools/52298.html

相关文章

硬核新品!M4E EDU民航考培一体无人机

天途上新啦&#xff01; 应我国民用无人机首项强制性国家标准《民用无人驾驶航空器系统安全要求》&#xff0c;天途对现有小型无人机训练机的飞控、电池、感知避障和电子围栏等软硬件全面升级设计&#xff0c;严格按国标GB42590-2023规范生产。 M4E EDU四轴多旋翼无人机是天途…

深度学习训练——batch_size参数设置过大反而训练更耗时的原因分析

&#x1f4aa; 专业从事且热爱图像处理&#xff0c;图像处理专栏更新如下&#x1f447;&#xff1a; &#x1f4dd;《图像去噪》 &#x1f4dd;《超分辨率重建》 &#x1f4dd;《语义分割》 &#x1f4dd;《风格迁移》 &#x1f4dd;《目标检测》 &#x1f4dd;《暗光增强》 &a…

策略模式(设计模式)

使用策略模式重构 if/else 策略设计模式是一种允许在运行时选择算法的行为。这种模式 ● 定义了一系列算法 ● 封装每种算法 ● 使算法在该系列内可互换。 下面是策略设计模式的架构&#xff0c;客户端将在其中与上下文进行通信。上下文将包含对策略对象的引用&#xff0c;这反…

samba共享服务-多用户挂载smb共享

1、服务端部署&#xff0c;在system1上执行&#xff1a; 1.1安装软件包并确保服务开机启动 [rootsystem1 ~]# yum install samba samba‐client ‐y [rootsystem1 ~]# systemctl enable smb.service nmb.service 1.2设定防火墙 [rootsystem1 ~]# firewall‐cmd ‐‐perman…

大模型泡沫退去,谁能活到下半场?

前言 从今年3月开始&#xff0c;国内企业纷纷下场大模型&#xff0c;铆足劲秀肌肉&#xff0c;如今转向垂直行业淘金&#xff0c;试图争霸行业大模型。我们的心态也逐渐从看乐子&#xff0c;到严肃讨论。 在人工智能的世界&#xff0c;我们经历了众多的概念游戏&#xff0c;在…

低代码开发应用:国企数字化转型的思考与探索

引言 在当今数字化浪潮席卷全球的背景下&#xff0c;国有企业作为国家经济发展的重要支柱&#xff0c;面临着数字化转型的迫切需求。数字化转型不仅能够提升国企的运营效率和创新能力&#xff0c;还能帮助其更好地适应市场竞争和满足客户需求。然而&#xff0c;国企在数字化转型…

Novartis诺华制药社招综合能力性格动机问卷入职测评笔试题库答案及包过助攻

【华东同舟求职】由资深各行业从业者建立的一站式人才服务网络平台&#xff0c;现阶段目标是“提升全市场各行业岗位信息的流动性和透明度”。我们接受众多行业机构的直接委托发布&#xff0c;并尽力通过各种方法搜寻高价值岗位信息。事实上&#xff0c;我们以发现不为人知的优…

江苏哪些行业需要服务器托管?

服务器托管顾名思义就是用户委托具有完善设备的机房、良好网络和丰富运营经验的服务商管理其计算机系统&#xff0c;使企业的服务器能够更加安全、稳定和高效的运行&#xff0c;那在江苏都有哪些行业需要服务器托管服务呢&#xff1f;本文就来大概介绍一下。 首先让我们来一起了…