- 0.1.5/0.1.6:刷机模式(flash_mode,最多 2 路,60 分钟可加钟)——窗口内顶高按 4450 mV 绝对值判、不断 VBUS - 0.1.7/0.1.8:反灌断 VBUS 阈值放宽到 -300 mA(adb reboot bootloader 过渡实测 -208 mA) - 0.1.9:WiFi 最多存 4 组,连不上轮换;NVS v1 自动迁移并双写(OTA 回滚仍能上网) - 0.1.10:热插拔进来的刀片重新初始化 PCA9555 + INA226(否则 VBUS 常开、电流恒读 0) - 0.1.11:i2cbus 嵌套检测改看本任务持锁(原全局标志让 key 随机回 busy、vbus 随机回 io) - 0.1.12:硬重启先断 VBUS,开机校验通过 60 s 后再接回(否则假重启 / 误判没开机 / 进关机充电) - 0.1.13:这一路被安全判据断电时一并退出刷机模式(事件 21 arg 254) 26 ctest 全绿;新增用例均先在旧代码上确认变红。板 B 已 OTA 到 0.1.13-c5 并实测。 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
101 行
3.7 KiB
CMake
101 行
3.7 KiB
CMake
# 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/chgmode.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
|
||
${FW_ROOT}/main/ota.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()
|