Files
Sakimi-UAV/modules/zephyr-spl06/README.md
T
Misaki af5987b37b first
2026-10-27 00:34:27 +08:00

59 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# zephyr-spl06 — SPL06-001 / DPS310 气压计驱动(Zephyr 模块)
标准 Zephyr out-of-tree 模块:自定义 binding + Kconfig + 驱动实现。
SPL06-001(歌尔)与 DPS310(Infineon)为同一颗 die,寄存器/系数/补偿公式
一致,本模块一份驱动同时支持两者,补偿公式按 datasheet 4.9 节在软件实现。
## 目录结构
zephyr-spl06/
├── zephyr/module.yml
├── CMakeLists.txt / Kconfig
├── dts/bindings/sensor/misaki,spl06.yaml # SPL06-001 binding
└── drivers/sensor/spl06/
├── Kconfig # CONFIG_SPL06
├── CMakeLists.txt
└── spl06.c
## 接入步骤
1. 构建时传 `-DZEPHYR_EXTRA_MODULES=/path/to/zephyr-spl06`
(或在 west.yml manifest 里加仓库后 `west update`)。
2. 板级 dts 加节点。SPL06-001 用本模块 binding(地址由 SDO 电平决定,
本板 0x77):
&i2c1 {
spl06: spl06@77 {
compatible = "misaki,spl06";
reg = <0x77>;
press-osr = <16>;
temp-osr = <16>;
};
};
DPS310 用上游 binding(地址 SDO 下拉为 0x76):
&i2c2 {
dps310: dps310@76 {
compatible = "infineon,dps310";
reg = <0x76>;
};
};
3. prj.conf 追加 `CONFIG_SPL06=y`。**DPS310 节点必须 `CONFIG_DPS310=n`**,
否则上游 DPS310 驱动与本驱动会为同一节点各自定义设备,链接报重复符号。
## 关键设计点
- 后台连续测量(气压/温度默认 16x 过采样、32Hz,对齐 Betaflight),
fetch 时轮询 PRS_RDY + TMP_RDY 后 burst read 6 字节(气压 24bit +
温度 24bit)。结果读走后 RDY 位自动清零,保证读到同一轮的新数据。
- 上电后软复位并等 COEF_RDY + SENSOR_RDY(最长 40ms)再读校准系数,
否则补偿输出天文数字;系数按 Betaflight 做法分块(每块 9 字节)读取。
- OSR > 8 时结果寄存器必须右移 6 位(CFG_REG 的 P_SHIFT/T_SHIFT),
缩放因子 k 用移位版;k 与移位配置必须配对,混用即输出天文数字。
- 温度源(TMP_CFG bit7):SPL06-001 强制用 MEMS 元件温度源;DPS310
运行时跟随 COEF_SRCE 标志位(Betaflight 行为)。
- 应用层:sensor_sample_fetch() + sensor_channel_get()
(SENSOR_CHAN_PRESS / SENSOR_CHAN_AMBIENT_TEMP),
压力单位 kPa(val1.val2 合成),温度单位 °C。