Files
JBao_Temp_Humi_Fan_FW/apps/usr_periph/bsp_aht20.h
T
wuchuyuan e324ebd99b 精简 usr_app 架构:去掉关机/休眠死代码,按键复用 key.c 状态机,ISR 重活统一延后到任务上下文
Type-C 长供电、上电即工作、无软关机,删除 app_boot/app_power 及 DP0 开关相关逻辑,
去掉空占位 app_fan_run 和无效的 usr_timer_pick_mode/rearm(数码管 4ms 扫描已 priority=1,
系统本来就不会进低功耗)。按键 5s 配对 / 12s OTA 改走 key.c 长按分级,去掉自计时与 1~5s 死区。
新增 app_defer,NVM/配对/OTA 只在 ISR 置位、在 500ms 任务上下文落地,避免再在 usr_timer 里写 flash。
规格书与注释同步精简。
2026-08-31 17:57:52 +08:00

44 lines
1.8 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.3IO 分离:AHT20 独占 PC4(SCL)/PC5(SDA),无总线共享锁,
* 恢复一次完成采集;含 SCL 高电平假 STOP 修复与 0x71 校准检查
*
* @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__ */