跳转到内容

SensorPressure::XGZP6847D API

文档完整
符号
29
已记录
29
类型
2
继承关系
1
源码分支
main
继承关系总览

继承图尚未加载。

全部继承关系

共 2 个类型

类型目录
类

XGZP6847DDevice

查看源码

XGZP6847D 数字压力传感器驱动。 https://cfsensor.com/product/xgzp6847d/ 官方产品页: https://cfsensor.com/wp-content/uploads/2026/04/XGZP6847D-Pressure-Sensor-V3.0.pdf V3.0 datasheet: https://www.scribd.com/document/891923775/XGZP6847D-Pressure-Sensor-V2-2025-05-04-21-28-42 V2.8 检索页: 旧版协议/量程换算参考资料: 当前实现使用的是旧版协议里的 K 表换算: pressure_pa = signExtend24(raw_pressure) / K -100~100 kPa -> pressure_range_kpa = 100 -> K = 64 量程 -100~300 kPa -> pressure_range_kpa = 300 -> K = 16 量程 这里的 pressure_range_kpa 不是总量程跨度,而是 max(abs(Pmin), abs(Pmax))。 例如: onTrigger() onRead() 该设备需要先写命令触发一次联合转换,再等待芯片完成内部测量,最后读取 压力和温度原始值并更新缓存。因此它重写了、conversionMs() 和三个状态机钩子。

继承关系

基类
  • I2CDevice公开

构造与析构

1

XGZP6847DDevice

函数公开
        XGZP6847DDevice::XGZP6847DDevice (float pressure_range_kpa, uint8_t address_7bit=DefaultAddress)
      

构造压力传感器设备对象 pressure_range_kpa 旧版 K 表使用的等效量程,单位 kPa; 取 max(abs(Pmin), abs(Pmax)),不是 Pmax - Pmin address_7bit 设备的 7 位 I2C 地址

pressure/XGZP6847D/XGZP6847DDevice.hpp:55

成员函数

11

calcK

函数私有静态
        int32_t XGZP6847DDevice::calcK (float pressure_range_kpa)
      

根据量程计算压力换算系数 pressure_range_kpa 旧版 K 表使用的等效量程,单位 kPa; 取 max(abs(Pmin), abs(Pmax)),不是 Pmax - Pmin 对应的压力换算系数

pressure/XGZP6847D/XGZP6847DDevice.hpp:139

conversionMs

函数受保护const
        uint32_t XGZP6847DDevice::conversionMs () const override
      

获取芯片一次联合转换的最大等待时间 转换时间上限,单位毫秒

pressure/XGZP6847D/XGZP6847DDevice.hpp:107

init

函数公开
        bool XGZP6847DDevice::init (I2CBusDMA &bus, uint32_t timeout_ms) override
      

通过最小寄存器读操作确认设备在线 bus 当前设备所在的 I2C 总线 timeout_ms 单次事务超时时间,单位毫秒 初始化探活是否成功

pressure/XGZP6847D/XGZP6847DDevice.hpp:80

onRead

函数受保护
        bool XGZP6847DDevice::onRead (I2CBusDMA &bus, uint32_t now_ms, uint32_t timeout_ms) override
      

读取原始数据并更新缓存 bus 当前设备所在的 I2C 总线 now_ms 当前时间戳,单位毫秒 timeout_ms 单次事务超时时间,单位毫秒 读取并解析是否成功

pressure/XGZP6847D/XGZP6847DDevice.hpp:119

onTrigger

函数受保护
        bool XGZP6847DDevice::onTrigger (I2CBusDMA &bus, uint32_t timeout_ms) override
      

发送一次联合转换命令 bus 当前设备所在的 I2C 总线 timeout_ms 单次事务超时时间,单位毫秒 触发采样是否成功

pressure/XGZP6847D/XGZP6847DDevice.hpp:101

signExtend24

函数私有静态
        int32_t XGZP6847DDevice::signExtend24 (const uint8_t data[3])
      

将 24 位补码原始压力扩展为 32 位有符号整数 data 指向 3 字节原始压力数据 符号扩展后的 32 位压力原始值

pressure/XGZP6847D/XGZP6847DDevice.hpp:146

成员变量

9

嵌套类型

1
结构体

XGZP6847DDevice::Sample

查看源码

保存最近一次成功更新后的传感器样本

成员变量

4

其他公开符号

文件

2