OpenHarmony实战:轻量级系统之外设驱动子系统移植

外设驱动子系统提供OpenHarmony专有的外部设备操作接口。本模块提供设备操作接口有:FLASH, GPIO, I2C, PWM, UART, WATCHDOG等。

OpenHarmony提供了两种驱动适配方式:使用外设驱动子系统、使用HDF驱动框架。由于轻量级系统的资源有限,这里建议使用IOT子系统方式。

移植指导

厂商需要根据OpenHarmony提供的接口定义实现其功能,IOT子系统接口定义的头文件如下:

base/iot_hardware/peripheral/
├── BUILD.gn
└── interfaces
    └── kits
        ├── iot_errno.h
        ├── iot_flash.h
        ├── iot_gpio.h
        ├── iot_i2c.h
        ├── iot_pwm.h
        ├── iot_uart.h
        ├── iot_watchdog.h
        ├── lowpower.h
        └── reset.h

其中“base/iot_hardware/peripheral/BUILD.gn”文件如下:

import("//build/lite/config/subsystem/lite_subsystem.gni")
import("//build/lite/ndk/ndk.gni")
       
lite_subsystem("iothardware") {
  subsystem_components = [
    "$ohos_vendor_adapter_dir/hals/iot_hardware/wifiiot_lite:hal_iothardware",
  ]
}
if (ohos_kernel_type == "liteos_m") {
  ndk_lib("iothardware_ndk") {
    deps = [
      "$ohos_vendor_adapter_dir/hals/iot_hardware/wifiiot_lite:hal_iothardware", #依赖厂商的适配
    ]
    head_files = [ "//base/iot_hardware/peripheral/interfaces/kits" ]
  }
}

从中可以看到厂商适配相关接口的存放目录应为“$ohos_vendor_adapter_dir/hals/iot_hardware/wifiiot_lite”,且该目录下BUILD.gn文件中的目标应为hal_iothardware。

移植实例

  1. 在“config.json”中添加iot_hardware子系统。 路径:“vendor/MyVendorCompany/MyProduct/c

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值