- ntc.{h,c}(宿主机可测):分压端 mV → Ω → NCP18XH103F03RB 的 R-T 表插值;
开路 / 短路 / 表外一律「读不到」(t_thermal 因此满速)
- thermal_esp.{h,c}(仅 IDF):ADC1 oneshot + 曲线校准读两路 NTC;两个 PCNT 单元数 TACH 边沿
- app_main:task_thermal 任务体、t_thermal_init 放在上电恢复之前、status 带热管理快照
- test_ntc.c 4 例;全工程 429 例全绿;版本 0.1.0-a16
- 板 B:两路 NTC 38.2 / 34.0 °C;风扇两路 rpm 0 报停转(拉满电流不涨,疑未插风扇,待确认)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
24 行
975 B
C
24 行
975 B
C
/* `t_thermal` 的两个回调在 ESP32-S3 上的实现(A16)。**只进 IDF 目标。**
|
|
温度:ADC1 oneshot + 曲线拟合校准 → mV → `ntc_mc_from_mv()`;
|
|
TACH:两个 PCNT 单元数上升沿(累计计数,uint32 回绕安全)。 */
|
|
#ifndef THERMAL_ESP_H
|
|
#define THERMAL_ESP_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include "hal_err.h"
|
|
|
|
/* 起 ADC 与 PCNT。失败不 abort:温度读不到 t_thermal 会满速(§10.10),
|
|
TACH 读不到就不判停转 —— 两者都是降级,不是固件写错了。
|
|
返回第一个错误码;已经起来的那一半照常可用。 */
|
|
hal_err_t thermal_esp_init(void);
|
|
|
|
bool thermal_esp_temp(void *ctx, int idx, int32_t *milli_c); /* therm_temp_fn */
|
|
bool thermal_esp_tach(void *ctx, int idx, uint32_t *edges); /* therm_tach_fn */
|
|
|
|
/* 最近一次读到的两路原始毫伏(调试 / 标定用;读失败是 −1)。 */
|
|
int32_t thermal_esp_last_mv(int idx);
|
|
|
|
#endif /* THERMAL_ESP_H */
|