文件
phonerail/firmware/host/CMakeLists.txt
T
zhou yang和Claude Opus 5.5 c37c08aa43 固件 A16:风扇闭环接进任务体 + NTC / TACH 真实采样(已上板)
- 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]>
2026-09-27 13:31:32 +08:00

99 行
3.6 KiB
CMake
原始文件 Blame 文件历史

此文件含有模棱两可的 Unicode 字符
此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。
# PhoneRail 宿主机构建 —— 不依赖 ESP-IDF,用来跑单元测试(CTest)。
#
# bash host/test.sh 配置 + 编译 + ctest
#
# 与 IDF 目标共享的源码只有 ../main 里的与硬件无关部分。
# 新增一个既要上板又要被测的 .c,必须同时加进:
# ../main/CMakeLists.txt 的 SRCS 和 下面的 PHONERAIL_CORE_SRCS
# HAL 里新增一路实现则要同时加进:
# ../components/phonerail_hal/CMakeLists.txt 的 SRCS(esp 那份)
# 和下面的 PHONERAIL_HAL_SIM_SRCS(sim 那份)
# 新增一个器件驱动则是:
# ../components/drv/CMakeLists.txt 的 SRCS 和 下面的 PHONERAIL_DRV_SRCS
cmake_minimum_required(VERSION 3.16)
project(phonerail_host C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
add_compile_options(-Wall -Wextra -Werror)
set(FW_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..)
# ---- 被测代码 -------------------------------------------------------------
set(PHONERAIL_CORE_SRCS
${FW_ROOT}/main/version.c
${FW_ROOT}/main/rail.c
${FW_ROOT}/main/rail_cfg.c
${FW_ROOT}/main/i2cbus.c
${FW_ROOT}/main/slot.c
${FW_ROOT}/main/sched.c
${FW_ROOT}/main/tasks.c
${FW_ROOT}/main/t_safety.c
${FW_ROOT}/main/t_actuator.c
${FW_ROOT}/main/t_thermal.c
${FW_ROOT}/main/evlog.c
${FW_ROOT}/main/cmd_json.c
${FW_ROOT}/main/cmd.c
${FW_ROOT}/main/cmd_exec.c
${FW_ROOT}/main/cmd_report.c
${FW_ROOT}/main/ulink.c
${FW_ROOT}/main/cmd_net.c
${FW_ROOT}/main/netcfg.c
${FW_ROOT}/main/mlink.c
${FW_ROOT}/main/bringup.c
${FW_ROOT}/main/ntc.c
)
# HAL:接口在 include/,宿主机链 sim/ 的实现(esp/ 那份只有 IDF 目标编)。
set(PHONERAIL_HAL_DIR ${FW_ROOT}/components/phonerail_hal)
set(PHONERAIL_HAL_SIM_SRCS
${PHONERAIL_HAL_DIR}/hal_err.c
${PHONERAIL_HAL_DIR}/hal_i2c_acct.c
${PHONERAIL_HAL_DIR}/sim/hal_lock_sim.c
${PHONERAIL_HAL_DIR}/sim/sim_hal.c
${PHONERAIL_HAL_DIR}/sim/hal_i2c_sim.c
${PHONERAIL_HAL_DIR}/sim/hal_gpio_sim.c
${PHONERAIL_HAL_DIR}/sim/sim_sr595.c
${PHONERAIL_HAL_DIR}/sim/sim_pca9555.c
${PHONERAIL_HAL_DIR}/sim/hal_pwm_sim.c
${PHONERAIL_HAL_DIR}/sim/hal_time_sim.c
${PHONERAIL_HAL_DIR}/sim/hal_store_sim.c
)
# 器件驱动:与平台无关(只经 hal_i2c_*),两个目标编的是同一份源码。
set(PHONERAIL_DRV_DIR ${FW_ROOT}/components/drv)
set(PHONERAIL_DRV_SRCS
${PHONERAIL_DRV_DIR}/ina226.c
${PHONERAIL_DRV_DIR}/dac63204.c
${PHONERAIL_DRV_DIR}/sr595.c
${PHONERAIL_DRV_DIR}/pca9555.c
${PHONERAIL_DRV_DIR}/tca9548a.c
${PHONERAIL_DRV_DIR}/ch224a.c
)
add_library(phonerail_core STATIC
${PHONERAIL_CORE_SRCS} ${PHONERAIL_HAL_SIM_SRCS} ${PHONERAIL_DRV_SRCS})
target_include_directories(phonerail_core PUBLIC
${FW_ROOT}/main
${PHONERAIL_HAL_DIR}/include
${PHONERAIL_HAL_DIR}/sim
${PHONERAIL_DRV_DIR}/include)
# ---- 测试框架 Unity(从 ESP-IDF v5.4 原样复制到 third_party/,与上板测试同一套)
add_library(unity STATIC ${FW_ROOT}/third_party/unity/unity.c)
target_include_directories(unity PUBLIC ${FW_ROOT}/third_party/unity)
target_compile_definitions(unity PUBLIC UNITY_OUTPUT_COLOR)
# 第三方源码不吃本工程的 -Werror
target_compile_options(unity PRIVATE -w)
# ---- 测试用例:test/test_*.c 一个文件一个可执行 + 一条 ctest ---------------
enable_testing()
file(GLOB PHONERAIL_TESTS ${FW_ROOT}/test/test_*.c)
foreach(test_src ${PHONERAIL_TESTS})
get_filename_component(test_name ${test_src} NAME_WE)
add_executable(${test_name} ${test_src})
target_link_libraries(${test_name} PRIVATE phonerail_core unity)
add_test(NAME ${test_name} COMMAND ${test_name})
endforeach()