文件
phonerail/firmware/host/CMakeLists.txt
T
zhou yang和Claude Opus 5.5 c85eec53e6 固件 A15:启动顺序 + 降级矩阵(bringup.{h,c},已上板)
- 启动序列从 app_main.c 拆进 main/bringup.{h,c},宿主机可测:
  bringup_devices()(§10.9 第 1~4 步)→ 起 t_safety → bringup_power_restore()(第 5~6 步)
- 六片 INA226 写 Config/Calibration(之前没做,电流恒 0);输入侧 0x43 登记对调接
- 按「意图」逐路上电、错开 100 ms、每路等 PG 500 ms,等不到关回去并记 LOG_EV_PG_TIMEOUT(17)
- 意图只由 power 命令改(cmd_env_t.intent → NVS phonerail/rail_want)
- §10.10 逐行降级:INA/DAC/PCA9555/mux/PRSNT#/CH224A;mux 失联时不碰主干
- BOOT 事件 arg = 复位原因;HUB_RST# 仍只在上电复位时脉冲
- rail_volt_init() 一片失败不再放弃另一片;CH224A 主干 / 通道 5 两处都找
- sim:sim_gpio_rise_us / sim_gpio_set_hook,sim_gpio_drive 可在配置前调
- test_bringup.c 24 例 + test_cmd 意图 1 例,共 425 例全绿;版本 0.1.0-a15
- rack:事件表加 17 PG_TIMEOUT(已部署)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-27 13:24:17 +08:00

98 行
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
)
# 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()