Files
JBao_Temp_Humi_Fan_FW/apps/usr_periph/bsp_aht20.h
T
wuchuyuan 5cc7e9dbd6 接入温湿度风扇产品固件(仲裁/条件/定时/显示),并补齐规格书与外设驱动
新增 usr_app 产品逻辑:手动>定时>条件仲裁、条件控温湿、定时任务、数码管显示、
按键/LED、风扇档位、NVM 掉电恢复、配对与开关机,上电按规格恢复上次状态。
新增 usr_periph:AHT20、CT1642、板级引脚与硬件封装;见宝协议 cond_config
改为 7 字节编解码,并接入产品 DP。
补充《温湿度风扇_固件需求规格书》,工程加入对应源文件。
.gitignore 忽略 WorkBuddy/Cursor 本地会话
2026-08-31 15:17:27 +08:00

49 lines
2.1 KiB
C
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.
/******************************************************************************
* @file bsp_aht20.h
* @brief CBR3 AHT20 温湿度传感器:软件 I2C + 测量 + CRC8
* @author cyWu <1917507415@qq.com>
* @date 2026.08.29
* @version V1.0.3
* @history
* - V1.0.0, 2026.08.29, cyWu, 首次发布
* - V1.0.1, 2026.08.29, cyWu, 修复 SCL 高电平期间推挽输出 SDA 导致的假 STOP
* - V1.0.2, 2026.08.29, cyWu, 回退诊断代码,保留时序修复/上拉/总线恢复/0x71 校准
* - V1.0.3, 2026.08.29, cyWu, IO 分离:AHT20 独占 PC4(SCL)/PC5(SDA),删除
* bsp_bus 共线锁与 measure_start/finish 拆分锁,恢复一次完成采集
*
* @note I2C 7 位地址 0x38(写 0x70 / 读 0x71)。测量命令 0xAC 0x33 0x00
* 等 ≥80ms 后读 7 字节:Status + 20bit 湿度 + 20bit 温度 + CRC8。
* CRC8 多项式 0x31,初值 0xFF,覆盖前 6 字节。
* PC4=SCL(推挽)/ PC5=SDA(开漏+内部上拉),与 CT1642 的 PG0/PG1
* 完全独立,无总线竞争(2026-08-29 改板分离)。
******************************************************************************/
#ifndef __BSP_AHT20_H__
#define __BSP_AHT20_H__
#include <stdint.h>
/**
* @brief 初始化:配置 PC4/PC5(上拉+die+ 软件 I2C 总线复位 + 0x71 校准检查
* @return 无
*/
void bsp_aht20_init(void);
/**
* @brief 发起一次测量:发 0xAC 0x33 0x00
* @note 调用后必须等 ≥80ms 再 bsp_aht20_measure_finish。
* 等待期间 I2C 总线空闲(AHT20 内部测量),CT1642 显示不受影响。
* @return 0=命令已发出,非 0=失败(未初始化/通讯失败)
*/
int8_t bsp_aht20_measure_start(void);
/**
* @brief 读取测量结果:读 7 字节 + CRC8 校验 + 换算
* @param temp_x10 输出温度 ×10(如 25.3℃ → 253
* @param humi_pct 输出湿度 0~100 整数 %
* @return 0=成功,非 0=失败(CRC 错/时序错,本次采样视为失败)
*/
int8_t bsp_aht20_measure_finish(int16_t *temp_x10, uint8_t *humi_pct);
#endif /* __BSP_AHT20_H__ */