Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
1dbe058f
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1dbe058f
编写于
3月 18, 2022
作者:
O
openharmony_ci
提交者:
Gitee
3月 18, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2172 修改为纯净版
Merge pull request !2172 from liyan/master
上级
e505524c
d01fb8e8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
195 deletion
+44
-195
zh-cn/device-dev/driver/driver-peripherals-sensor-des.md
zh-cn/device-dev/driver/driver-peripherals-sensor-des.md
+44
-195
未找到文件。
zh-cn/device-dev/driver/driver-peripherals-sensor-des.md
浏览文件 @
1dbe058f
...
...
@@ -70,207 +70,56 @@ Sensor驱动模型对外开放的API接口能力如下:
-
提供同一类型Sensor器件驱动归一接口, 寄存器配置解析操作接口,总线访问抽象接口,平台抽象接口。
-
提供开发者实现的能力接口:依赖HDF驱动框架的HCS(HDF Configuration Source)配置管理,根据同类型Sensor差异化配置,实现Sensor器件参数序列化配置和器件部分操作接口,简化Sensor器件驱动开发。
Sensor驱动模型对外开放的API接口能力的具体实现参考
[
表1
](
#table203963834718
)
:
**表 1**
Sensor驱动模型对外API接口功能介绍
<a
name=
"table203963834718"
></a>
<table><thead
align=
"left"
><tr
id=
"row173964834716"
><th
class=
"cellrowborder"
valign=
"top"
width=
"8.260000000000002%"
id=
"mcps1.2.4.1.1"
><p
id=
"p17401913133218"
><a
name=
"p17401913133218"
></a><a
name=
"p17401913133218"
></a>
功能分类
</p>
</th>
<th
class=
"cellrowborder"
valign=
"top"
width=
"45.4%"
id=
"mcps1.2.4.1.2"
><p
id=
"p20921103144918"
><a
name=
"p20921103144918"
></a><a
name=
"p20921103144918"
></a>
接口名
</p>
</th>
<th
class=
"cellrowborder"
valign=
"top"
width=
"46.339999999999996%"
id=
"mcps1.2.4.1.3"
><p
id=
"p109216317495"
><a
name=
"p109216317495"
></a><a
name=
"p109216317495"
></a>
功能描述
</p>
</th>
</tr>
</thead>
<tbody><tr
id=
"row4397198154712"
><td
class=
"cellrowborder"
valign=
"top"
width=
"8.260000000000002%"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p8437193673211"
><a
name=
"p8437193673211"
></a><a
name=
"p8437193673211"
></a>
查询操作
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"45.4%"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p11001322173912"
><a
name=
"p11001322173912"
></a><a
name=
"p11001322173912"
></a>
int32_t
<strong
id=
"b935414557240"
><a
name=
"b935414557240"
></a><a
name=
"b935414557240"
></a>
GetAllSensors
</strong>
(struct SensorInformation
**
sensorInfo, int32_t
*
count)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"46.339999999999996%"
headers=
"mcps1.2.4.1.3 "
><p
id=
"p199227318499"
><a
name=
"p199227318499"
></a><a
name=
"p199227318499"
></a>
获取系统中注册的所有传感器信息,一组完整传感器信息包括传感器名字、设备厂商、固件版本号、硬件版本号、传感器类型编号、传感器标识、最大量程、精度、功耗。
</p>
</td>
</tr>
<tr
id=
"row1839716854716"
><td
class=
"cellrowborder"
rowspan=
"5"
valign=
"top"
width=
"8.260000000000002%"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p06071477324"
><a
name=
"p06071477324"
></a><a
name=
"p06071477324"
></a>
配置操作
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"45.4%"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p38874252376"
><a
name=
"p38874252376"
></a><a
name=
"p38874252376"
></a>
int32_t
<strong
id=
"b199602219271"
><a
name=
"b199602219271"
></a><a
name=
"b199602219271"
></a>
Enable
</strong>
(int32_t sensorId)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"46.339999999999996%"
headers=
"mcps1.2.4.1.3 "
><p
id=
"p5922331114916"
><a
name=
"p5922331114916"
></a><a
name=
"p5922331114916"
></a>
使能指定传感器设备,只有数据订阅者使能传感器后,才能获取订阅的传感器数据。
</p>
</td>
</tr>
<tr
id=
"row6397138134713"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p6923143184914"
><a
name=
"p6923143184914"
></a><a
name=
"p6923143184914"
></a>
int32_t
<strong
id=
"b84601875330"
><a
name=
"b84601875330"
></a><a
name=
"b84601875330"
></a>
Disable
</strong>
(int32_t sensorId)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p139231531184912"
><a
name=
"p139231531184912"
></a><a
name=
"p139231531184912"
></a>
去使能指定传感器设备。
</p>
</td>
</tr>
<tr
id=
"row43981283476"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p992473112496"
><a
name=
"p992473112496"
></a><a
name=
"p992473112496"
></a>
int32_t
<strong
id=
"b16691194511438"
><a
name=
"b16691194511438"
></a><a
name=
"b16691194511438"
></a>
SetBatch
</strong>
(iint32_t sensorId, int64_t samplingInterval, int64_t reportInterval)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p14924203134910"
><a
name=
"p14924203134910"
></a><a
name=
"p14924203134910"
></a>
设置指定传感器的数据采样间隔和数据上报间隔。
</p>
</td>
</tr>
<tr
id=
"row439813812472"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p170411511281"
><a
name=
"p170411511281"
></a><a
name=
"p170411511281"
></a>
int32_t
<strong
id=
"b170414153284"
><a
name=
"b170414153284"
></a><a
name=
"b170414153284"
></a>
SetMode
</strong>
(int32_t sensorId, int32_t mode)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p107051159281"
><a
name=
"p107051159281"
></a><a
name=
"p107051159281"
></a>
设置指定传感器的工作模式,不同的工作模式,上报数据方式不同。
</p>
</td>
</tr>
<tr
id=
"row123998813470"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p492513120494"
><a
name=
"p492513120494"
></a><a
name=
"p492513120494"
></a>
int32_t
<strong
id=
"b7501191019330"
><a
name=
"b7501191019330"
></a><a
name=
"b7501191019330"
></a>
SetOption
</strong>
(int32_t sensorId, uint32_t option)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p5926031124914"
><a
name=
"p5926031124914"
></a><a
name=
"p5926031124914"
></a>
设置指定传感器量程,精度等可选配置。
</p>
</td>
</tr>
<tr
id=
"row939914814478"
><td
class=
"cellrowborder"
rowspan=
"2"
valign=
"top"
width=
"8.260000000000002%"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p1039815743211"
><a
name=
"p1039815743211"
></a><a
name=
"p1039815743211"
></a>
数据订阅操作
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"45.4%"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p11530101054411"
><a
name=
"p11530101054411"
></a><a
name=
"p11530101054411"
></a>
int32_t
<strong
id=
"b0569161217334"
><a
name=
"b0569161217334"
></a><a
name=
"b0569161217334"
></a>
Register
</strong>
(int32_t groupId, RecordDataCallback cb);
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"46.339999999999996%"
headers=
"mcps1.2.4.1.3 "
><p
id=
"p892633118493"
><a
name=
"p892633118493"
></a><a
name=
"p892633118493"
></a>
订阅者根据不同groupId注册传感器数据回调函数,系统会将获取到的传感器数据上报给订阅者。
</p>
</td>
</tr>
<tr
id=
"row10716713314"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p196491214133110"
><a
name=
"p196491214133110"
></a><a
name=
"p196491214133110"
></a>
int32_t
<strong
id=
"b13758151483317"
><a
name=
"b13758151483317"
></a><a
name=
"b13758151483317"
></a>
Unregister
</strong>
(int32_t groupId, RecordDataCallback cb)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p5817133119"
><a
name=
"p5817133119"
></a><a
name=
"p5817133119"
></a>
订阅者根据groupId和回调函数注销对应订阅者的传感器数据回调函数。
</p>
</td>
</tr>
</tbody>
</table>
Sensor驱动模型对驱动开发者开放的功能接口,驱动开发者无需实现,直接使用,参考
[
表2
](
#table1156812588320
)
:
Sensor驱动模型对外开放的API接口能力的具体实现参考
[
表1
](
#PinCntlrMethod成员的回调函数功能说明
)
:
**表 1**
PinCntlrMethod成员的回调函数功能说明
| 接口名 | 功能描述 |
| ----- | -------- |
| int32_t GetAllSensors(struct SensorInformation
**
sensorInfo, int32_t
*
count) | 获取系统中注册的所有传感器信息,一组完整传感器信息包括传感器名字、设备厂商、固件版本号、硬件版本号、传感器类型编号、传感器标识、最大量程、精度、功耗。 |
| int32_t Enable(int32_t sensorId) | 使能指定传感器设备,只有数据订阅者使能传感器后,才能获取订阅的传感器数据。 |
| int32_t Disable(int32_t sensorId) | 去使能指定传感器设备。 |
| int32_t SetBatch(iint32_t sensorId, int64_t samplingInterval, int64_t reportInterval) | 设置指定传感器的数据采样间隔和数据上报间隔。 |
| int32_t SetMode(int32_t sensorId, int32_t mode) | 设置指定传感器的工作模式,不同的工作模式,上报数据方式不同。 |
| int32_t SetOption(int32_t sensorId, uint32_t option) | 设置指定传感器量程,精度等可选配置。 |
| int32_t Register(int32_t groupId, RecordDataCallback cb) | 订阅者根据不同groupId注册传感器数据回调函数,系统会将获取到的传感器数据上报给订阅者。 |
| int32_t Unregister(int32_t groupId, RecordDataCallback cb) | 订阅者根据groupId和回调函数注销对应订阅者的传感器数据回调函数。 |
Sensor驱动模型对驱动开发者开放的功能接口,驱动开发者无需实现,直接使用,参考
[
表2
](
#Sensor驱动模型对驱动开发者开放的功能接口列表
)
:
**表2**
Sensor驱动模型对驱动开发者开放的功能接口列表
<a
name=
"table1156812588320"
></a>
<table><thead
align=
"left"
><tr
id=
"row756817584327"
><th
class=
"cellrowborder"
valign=
"top"
width=
"8.550855085508552%"
id=
"mcps1.2.4.1.1"
><p
id=
"p7568125873219"
><a
name=
"p7568125873219"
></a><a
name=
"p7568125873219"
></a>
功能分类
</p>
</th>
<th
class=
"cellrowborder"
valign=
"top"
width=
"45.53455345534553%"
id=
"mcps1.2.4.1.2"
><p
id=
"p1756812582328"
><a
name=
"p1756812582328"
></a><a
name=
"p1756812582328"
></a>
接口名
</p>
</th>
<th
class=
"cellrowborder"
valign=
"top"
width=
"45.91459145914592%"
id=
"mcps1.2.4.1.3"
><p
id=
"p35681558183210"
><a
name=
"p35681558183210"
></a><a
name=
"p35681558183210"
></a>
功能描述
</p>
</th>
</tr>
</thead>
<tbody><tr
id=
"row756875811329"
><td
class=
"cellrowborder"
rowspan=
"3"
valign=
"top"
width=
"8.550855085508552%"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p5974193991911"
><a
name=
"p5974193991911"
></a><a
name=
"p5974193991911"
></a>
设备管理操作接口
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"45.53455345534553%"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p18569158173210"
><a
name=
"p18569158173210"
></a><a
name=
"p18569158173210"
></a>
int32_t
<strong
id=
"b4994112595516"
><a
name=
"b4994112595516"
></a><a
name=
"b4994112595516"
></a>
AddSensorDevice
</strong>
(const struct SensorDeviceInfo
*
deviceInfo)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"45.91459145914592%"
headers=
"mcps1.2.4.1.3 "
><p
id=
"p356935816328"
><a
name=
"p356935816328"
></a><a
name=
"p356935816328"
></a>
添加当前类型的传感器设备到传感器设备管理。
</p>
</td>
</tr>
<tr
id=
"row195691858113219"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p1156945883215"
><a
name=
"p1156945883215"
></a><a
name=
"p1156945883215"
></a>
int32_t
<strong
id=
"b1736762975518"
><a
name=
"b1736762975518"
></a><a
name=
"b1736762975518"
></a>
DeleteSensorDevice
</strong>
(const struct SensorBasicInfo
*
sensorBaseInfo)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p2569145833214"
><a
name=
"p2569145833214"
></a><a
name=
"p2569145833214"
></a>
删除传感器设备管理里指定的传感器设备。
</p>
</td>
</tr>
<tr
id=
"row15699589321"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p6569105811328"
><a
name=
"p6569105811328"
></a><a
name=
"p6569105811328"
></a>
int32_t
<strong
id=
"b1174510321555"
><a
name=
"b1174510321555"
></a><a
name=
"b1174510321555"
></a>
ReportSensorEvent
</strong>
(const struct SensorReportEvent
*
events)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p15691858193220"
><a
name=
"p15691858193220"
></a><a
name=
"p15691858193220"
></a>
上报指定类型传感器的数据到用户侧。
</p>
</td>
</tr>
<tr
id=
"row17569145814329"
><td
class=
"cellrowborder"
rowspan=
"2"
valign=
"top"
width=
"8.550855085508552%"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p10589113932619"
><a
name=
"p10589113932619"
></a><a
name=
"p10589113932619"
></a>
Sensor抽象总线
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"45.53455345534553%"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p145705585322"
><a
name=
"p145705585322"
></a><a
name=
"p145705585322"
></a>
int32_t
<strong
id=
"b15560203515558"
><a
name=
"b15560203515558"
></a><a
name=
"b15560203515558"
></a>
ReadSensor
</strong>
(struct SensorBusCfg
*busCfg, uint16_t regAddr, uint8_t *
data, uint16_t dataLen)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"45.91459145914592%"
headers=
"mcps1.2.4.1.3 "
><p
id=
"p1657018586322"
><a
name=
"p1657018586322"
></a><a
name=
"p1657018586322"
></a>
按照配置的总线方式,读取传感器寄存器配置数据。
</p>
</td>
</tr>
<tr
id=
"row28712021112011"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p38722218200"
><a
name=
"p38722218200"
></a><a
name=
"p38722218200"
></a>
int32_t
<strong
id=
"b573774595514"
><a
name=
"b573774595514"
></a><a
name=
"b573774595514"
></a>
WriteSensor
</strong>
(struct SensorBusCfg
*busCfg, uint8_t *
writeData, uint16_t len)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p6872112112201"
><a
name=
"p6872112112201"
></a><a
name=
"p6872112112201"
></a>
按照配置的总线方式,将传感器配置数据写入寄存器。
</p>
</td>
</tr>
<tr
id=
"row19401042245"
><td
class=
"cellrowborder"
valign=
"top"
width=
"8.550855085508552%"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p694020492417"
><a
name=
"p694020492417"
></a><a
name=
"p694020492417"
></a>
通用配置操作接口
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"45.53455345534553%"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p1794064142418"
><a
name=
"p1794064142418"
></a><a
name=
"p1794064142418"
></a>
int32_t
<strong
id=
"b1740939195611"
><a
name=
"b1740939195611"
></a><a
name=
"b1740939195611"
></a>
SetSensorRegCfgArray
</strong>
(struct SensorBusCfg
*busCfg, const struct SensorRegCfgGroupNode *
group);
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"45.91459145914592%"
headers=
"mcps1.2.4.1.3 "
><p
id=
"p49409417249"
><a
name=
"p49409417249"
></a><a
name=
"p49409417249"
></a>
根据传感器总线类型信息,下发寄存器分组配置。
</p>
</td>
</tr>
<tr
id=
"row1494015418246"
><td
class=
"cellrowborder"
rowspan=
"5"
valign=
"top"
width=
"8.550855085508552%"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p185291624202618"
><a
name=
"p185291624202618"
></a><a
name=
"p185291624202618"
></a>
配置解析操作接口
</p>
<p
id=
"p978482418524"
><a
name=
"p978482418524"
></a><a
name=
"p978482418524"
></a></p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"45.53455345534553%"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p994194132410"
><a
name=
"p994194132410"
></a><a
name=
"p994194132410"
></a>
int32_t
<strong
id=
"b109631149171514"
><a
name=
"b109631149171514"
></a><a
name=
"b109631149171514"
></a>
GetSensorBaseConfigData
</strong>
(const struct DeviceResourceNode
*node, struct SensorCfgData *
config)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"45.91459145914592%"
headers=
"mcps1.2.4.1.3 "
><p
id=
"p79411640248"
><a
name=
"p79411640248"
></a><a
name=
"p79411640248"
></a>
根据传感器设备HCS资源配置,获取传感器信息,总线配置信息,属性配置等基本配置信息,并初始化对应的基本配置数据结构体。
</p>
</td>
</tr>
<tr
id=
"row1171817565518"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p7718165615113"
><a
name=
"p7718165615113"
></a><a
name=
"p7718165615113"
></a>
int32_t
<strong
id=
"b14392155271515"
><a
name=
"b14392155271515"
></a><a
name=
"b14392155271515"
></a>
ParseSensorRegConfig
</strong>
(struct SensorCfgData
*
config)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p171885685120"
><a
name=
"p171885685120"
></a><a
name=
"p171885685120"
></a>
根据传感器设备HCS资源配置,解析寄存器分组信息,并初始化配置数据结构体。
</p>
</td>
</tr>
<tr
id=
"row394144192414"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p99411144241"
><a
name=
"p99411144241"
></a><a
name=
"p99411144241"
></a>
void
<strong
id=
"b1322165619152"
><a
name=
"b1322165619152"
></a><a
name=
"b1322165619152"
></a>
ReleaseSensorAllRegConfig
</strong>
(struct SensorCfgData
*
config)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p17941154152419"
><a
name=
"p17941154152419"
></a><a
name=
"p17941154152419"
></a>
释放传感器配置数据结构体里分配的资源。
</p>
</td>
</tr>
<tr
id=
"row10589154102611"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p4557141217521"
><a
name=
"p4557141217521"
></a><a
name=
"p4557141217521"
></a>
int32_t
<strong
id=
"b1206195914157"
><a
name=
"b1206195914157"
></a><a
name=
"b1206195914157"
></a>
GetSensorBusHandle
</strong>
(struct SensorBusCfg
*
busCfg)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p953821245219"
><a
name=
"p953821245219"
></a><a
name=
"p953821245219"
></a>
获取传感器总线句柄信息。
</p>
</td>
</tr>
<tr
id=
"row6784142455212"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p478492410522"
><a
name=
"p478492410522"
></a><a
name=
"p478492410522"
></a>
int32_t
<strong
id=
"b9443344101610"
><a
name=
"b9443344101610"
></a><a
name=
"b9443344101610"
></a>
ReleaseSensorBusHandle
</strong>
(struct SensorBusCfg
*
busCfg)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p1878422485212"
><a
name=
"p1878422485212"
></a><a
name=
"p1878422485212"
></a>
释放传感器句柄信息。
</p>
</td>
</tr>
</tbody>
</table>
Sensor驱动模型要求驱动开发者实现的接口功能,参考
[
表3
](
#table1083014911336
)
:
| 接口名 | 功能描述 |
| ----- | -------- |
| int32_t AddSensorDevice(const struct SensorDeviceInfo
*
deviceInfo) | 添加当前类型的传感器设备到传感器设备管理。 |
| int32_t DeleteSensorDevice(const struct SensorBasicInfo
*
sensorBaseInfo) | 删除传感器设备管理里指定的传感器设备。 |
| int32_t ReportSensorEvent(const struct SensorReportEvent
*
events) | 上报指定类型传感器的数据到用户侧。 |
| int32_t ReadSensor(struct SensorBusCfg
*busCfg, uint16_t regAddr, uint8_t *
data, uint16_t dataLen) | 按照配置的总线方式,读取传感器寄存器配置数据。 |
| int32_t WriteSensor(struct SensorBusCfg
*busCfg, uint8_t *
writeData, uint16_t len) | 按照配置的总线方式,将传感器配置数据写入寄存器。 |
| int32_t SetSensorRegCfgArray(struct SensorBusCfg
*busCfg, const struct SensorRegCfgGroupNode *
group); | 根据传感器总线类型信息,下发寄存器分组配置。 |
| int32_t GetSensorBaseConfigData(const struct DeviceResourceNode
*node, struct SensorCfgData *
config) | 根据传感器设备HCS资源配置,获取传感器信息,总线配置信息,属性配置等基本配置信息,并初始化对应的基本配置数据结构体。 |
| int32_t ParseSensorRegConfig(struct SensorCfgData
*
config) | 根据传感器设备HCS资源配置,解析寄存器分组信息,并初始化配置数据结构体。 |
| void ReleaseSensorAllRegConfig(struct SensorCfgData
*
config) | 释放传感器配置数据结构体里分配的资源。 |
| int32_t GetSensorBusHandle(struct SensorBusCfg
*
busCfg) | 获取传感器总线句柄信息。 |
| int32_t ReleaseSensorBusHandle(struct SensorBusCfg
*
busCfg) | 释放传感器句柄信息。 |
**表 3**
Sensor驱动模型要求驱动开发者实现的接口列表
<a
name=
"table1083014911336"
></a>
<table><thead
align=
"left"
><tr
id=
"row208301997332"
><th
class=
"cellrowborder"
valign=
"top"
width=
"8.41084108410841%"
id=
"mcps1.2.4.1.1"
><p
id=
"p1777364318152"
><a
name=
"p1777364318152"
></a><a
name=
"p1777364318152"
></a>
功能分类
</p>
</th>
<th
class=
"cellrowborder"
valign=
"top"
width=
"45.77457745774577%"
id=
"mcps1.2.4.1.2"
><p
id=
"p5773174317157"
><a
name=
"p5773174317157"
></a><a
name=
"p5773174317157"
></a>
接口名
</p>
</th>
<th
class=
"cellrowborder"
valign=
"top"
width=
"45.81458145814582%"
id=
"mcps1.2.4.1.3"
><p
id=
"p1777319437155"
><a
name=
"p1777319437155"
></a><a
name=
"p1777319437155"
></a>
功能描述
</p>
</th>
</tr>
</thead>
<tbody><tr
id=
"row1880425111572"
><td
class=
"cellrowborder"
rowspan=
"8"
valign=
"top"
width=
"8.41084108410841%"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p598171454520"
><a
name=
"p598171454520"
></a><a
name=
"p598171454520"
></a>
基本功能操作
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"45.77457745774577%"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p880485195711"
><a
name=
"p880485195711"
></a><a
name=
"p880485195711"
></a>
int32_t
<strong
id=
"b16497123107"
><a
name=
"b16497123107"
></a><a
name=
"b16497123107"
></a>
init
</strong>
(void)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
width=
"45.81458145814582%"
headers=
"mcps1.2.4.1.3 "
><p
id=
"p1480465165710"
><a
name=
"p1480465165710"
></a><a
name=
"p1480465165710"
></a>
传感器设备探测成功后,需要对传感器设备初始化配置。
</p>
</td>
</tr>
<tr
id=
"row178311493339"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p208318963320"
><a
name=
"p208318963320"
></a><a
name=
"p208318963320"
></a>
int32_t
<strong
id=
"b189921571402"
><a
name=
"b189921571402"
></a><a
name=
"b189921571402"
></a>
Enable
</strong>
(void)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p68310953312"
><a
name=
"p68310953312"
></a><a
name=
"p68310953312"
></a>
根据当前传感器设备的HCS配置,下发传感器设备使能操作组的寄存器配置。
</p>
</td>
</tr>
<tr
id=
"row0831129153318"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p0831169183314"
><a
name=
"p0831169183314"
></a><a
name=
"p0831169183314"
></a>
int32_t
<strong
id=
"b13541291106"
><a
name=
"b13541291106"
></a><a
name=
"b13541291106"
></a>
Disable
</strong>
(void)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p138314912336"
><a
name=
"p138314912336"
></a><a
name=
"p138314912336"
></a>
根据当前传感器设备的HCS配置,下发传感器设备去使能操作组的寄存器配置。
</p>
</td>
</tr>
<tr
id=
"row178311093334"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p583118920338"
><a
name=
"p583118920338"
></a><a
name=
"p583118920338"
></a>
int32_t
<strong
id=
"b111117118017"
><a
name=
"b111117118017"
></a><a
name=
"b111117118017"
></a>
SetBatch
</strong>
(int64_t samplingInterval, int64_t reportInterval)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p08311903315"
><a
name=
"p08311903315"
></a><a
name=
"p08311903315"
></a>
根据数据采样率和数据上报间隔,配置当前传感器设备的数据上报线程处理时间。
</p>
</td>
</tr>
<tr
id=
"row1356419421422"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p9565174218421"
><a
name=
"p9565174218421"
></a><a
name=
"p9565174218421"
></a>
int32_t
<strong
id=
"b13702551143412"
><a
name=
"b13702551143412"
></a><a
name=
"b13702551143412"
></a>
SetMode
</strong>
(int32_t mode)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p356524224213"
><a
name=
"p356524224213"
></a><a
name=
"p356524224213"
></a>
配置当前传感器设备数据上报方式。
</p>
</td>
</tr>
<tr
id=
"row12565104264215"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p17565104210429"
><a
name=
"p17565104210429"
></a><a
name=
"p17565104210429"
></a>
int32_t
<strong
id=
"b96811512011"
><a
name=
"b96811512011"
></a><a
name=
"b96811512011"
></a>
SetOption
</strong>
(uint32_t option)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p4565104214213"
><a
name=
"p4565104214213"
></a><a
name=
"p4565104214213"
></a>
根据可选配置、下发量程和精度等寄存器配置。
</p>
</td>
</tr>
<tr
id=
"row380240111218"
><td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.1 "
><p
id=
"p1181184016120"
><a
name=
"p1181184016120"
></a><a
name=
"p1181184016120"
></a>
void
<strong
id=
"b1613451717016"
><a
name=
"b1613451717016"
></a><a
name=
"b1613451717016"
></a>
ReadSensorData
</strong>
(void)
</p>
</td>
<td
class=
"cellrowborder"
valign=
"top"
headers=
"mcps1.2.4.1.2 "
><p
id=
"p7815401121"
><a
name=
"p7815401121"
></a><a
name=
"p7815401121"
></a>
实现传感器的数据读取函数。
</p>
</td>
</tr>
</tbody>
</table>
Sensor驱动模型要求驱动开发者实现的接口功能,参考
[
表3
](
#Sensor驱动模型要求驱动开发者实现的接口列表
)
:
**表 3**
Sensor驱动模型要求驱动开发者实现的接口列表
| 接口名 | 功能描述 |
| ----- | -------- |
| int32_t init(void) | 传感器设备探测成功后,需要对传感器设备初始化配置。 |
| int32_t Enable(void) | 根据当前传感器设备的HCS配置,下发传感器设备使能操作组的寄存器配置。 |
| int32_t Disable(void) | 根据当前传感器设备的HCS配置,下发传感器设备去使能操作组的寄存器配置。 |
| int32_t SetBatch(int64_t samplingInterval, int64_t reportInterval) | 根据数据采样率和数据上报间隔,配置当前传感器设备的数据上报线程处理时间。 |
| int32_t SetMode(int32_t mode) | 配置当前传感器设备数据上报方式。 |
| int32_t SetOption(uint32_t option) | 根据可选配置、下发量程和精度等寄存器配置。 |
| void ReadSensorData(void) | 实现传感器的数据读取函数。 |
接口实现参考
[
开发步骤
](
#section7893102915819
)
章节。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录