添加了完整的Doxygen文档注释到FOC算法模块的所有函数、类和变量,提升了代码可读性和维护性。同时优化了SVPWM算法实现,将atan2f替换为符号法扇区判断,显著提升计算效率(约15周期vs atan2f 300周期),并改进了arm_sin_cos_f32替代sqrtf提高性能。 feat(FOC): 统一电气角度计算避免重复运算 重构代码以统一电气角度计算,在各个控制循环中只计算一次电气角度并传递给需要的函数,避免了多次重复的fmodf运算和角度归一化操作,提升了实时控制性能。 refactor(Filter): 改进α-β观测器角度处理精度 修改角度卡尔曼滤波器在归一化角度空间[0,360)内工作,避免大累积角度的浮点精度损失问题,确保静止状态下不会产生虚假速度,同时保持与下游代码的兼容性。 refactor: 为算法模块添加完整文档注释 为所有算法模块(FOC、Filter、pid、thermal)添加了详细的Doxygen文档注释,包括函数说明、参数描述、返回值说明等,便于代码理解和API文档生成。
7.7 KiB
7.7 KiB
ROBOT_V2 APP 业务代码汽车电子静态测试包
范围
- 根目录:
/workzone/ROBOT_V2/APP/Robot_V2 - 包含:
Algorithm/,device/,sys/,main.cpp,main.h - 排除:
RTE/第三方 GD32 库、工程生成文件、临时目录 - 方式: 只读扫描,不修改代码
工具环境限制
- 当前环境未安装 QAC / Polyspace / Coverity / PC-lint / cppcheck / 交叉编译器。
- 本报告为汽车电子规则初筛和评审入口,不等同正式 MISRA/AUTOSAR 合规报告。
总览
- 扫描文件数: 29
- 总行数: 8159
- 非空代码行估算: 4272
- error: 0
- warning: 40
- info: 513
规则命中统计
- AUTO-ARRAY-001: 251
- AUTO-ASM-001: 10
- AUTO-CAST-001: 223
- AUTO-CTRL-002: 6
- AUTO-FUNC-002: 31
- AUTO-MACRO-001: 29
- AUTO-MET-001: 3
高优先级结论
- 未发现动态内存、goto、高风险 C 字符串/输入函数等硬性高风险项。
- 复杂度超过 15 的函数需要人工评审或后续单元测试加强。
continue、调试输出、关中断/开中断属于偏离说明候选。
Top 圈复杂度
- 33
Algorithm/FOC.cpp:75-238FOC_Controller::calibrate_cogging_tickrisk=high - 27
device/Can.cpp:1076-1300CAN_transmiter::communication_checkrisk=high - 17
main.cpp:120-205do_taskrisk=high - 15
Algorithm/FOC.cpp:392-490FOC_Controller::setSVPWM_PhaseVoltagerisk=medium - 12
sys/flash.cpp:308-383FlashEEPROM::writeFloatrisk=medium - 12
sys/health.cpp:35-94ThermalController::updaterisk=medium - 11
device/Can.cpp:597-665can_loopback_testrisk=medium - 10
device/Can.cpp:1448-1504CAN_transmiter::CANFD_AsyncSendrisk=low - 10
sys/flash.cpp:90-161FlashEEPROM::read_saved_system_configrisk=low - 10
sys/flash.cpp:237-300FlashEEPROM::writerisk=low - 10
sys/flash.cpp:657-717FlashEEPROM::writeNodeIdrisk=low - 10
sys/flash.cpp:928-1030move_app_datarisk=low - 9
device/Can.cpp:534-589canfd_loopback_testrisk=low - 9
sys/flash.cpp:413-482FlashEEPROM::save_system_configrisk=low - 9
sys/flash.cpp:792-879OTA_SETrisk=low - 9
sys/health.cpp:113-149power_managerisk=low - 8
device/ADC.cpp:194-219sampler::get_currentrisk=low - 8
sys/flash.cpp:724-776FlashEEPROM::writeCRCrisk=low - 8
sys/systick.cpp:244-298app_prepare_deep_sleeprisk=low - 7
device/Timer.cpp:134-184TIMER2_IRQHandlerrisk=low
Warning 明细
- [AUTO-CTRL-002]
device/Can.cpp:1124continue 需避免或说明偏离continue;
- [AUTO-CTRL-002]
device/Can.cpp:1194continue 需避免或说明偏离continue;
- [AUTO-CTRL-002]
device/Can.cpp:1199continue 需避免或说明偏离continue;
- [AUTO-CTRL-002]
main.cpp:80continue 需避免或说明偏离continue;
- [AUTO-CTRL-002]
sys/flash.cpp:693continue 需避免或说明偏离continue;
- [AUTO-CTRL-002]
sys/systick.cpp:264continue 需避免或说明偏离continue;
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:100printf/格式化输出需确认调试隔离和实时性影响printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:161printf/格式化输出需确认调试隔离和实时性影响printf("",
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:195printf/格式化输出需确认调试隔离和实时性影响printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:198printf/格式化输出需确认调试隔离和实时性影响printf("", angle_deg, cogging_table[i]);
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:203printf/格式化输出需确认调试隔离和实时性影响printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:206printf/格式化输出需确认调试隔离和实时性影响printf("", angle_deg, cogging_table_rev[i]);
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:211printf/格式化输出需确认调试隔离和实时性影响printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:212printf/格式化输出需确认调试隔离和实时性影响printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:214printf/格式化输出需确认调试隔离和实时性影响if (i % 8 == 0) printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:215printf/格式化输出需确认调试隔离和实时性影响printf("", cogging_table[i]);
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:216printf/格式化输出需确认调试隔离和实时性影响if (i < COGGING_TABLE_SIZE - 1) printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:217printf/格式化输出需确认调试隔离和实时性影响if (i % 8 == 7 || i == COGGING_TABLE_SIZE - 1) printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:220printf/格式化输出需确认调试隔离和实时性影响printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:223printf/格式化输出需确认调试隔离和实时性影响printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:224printf/格式化输出需确认调试隔离和实时性影响printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:226printf/格式化输出需确认调试隔离和实时性影响if (i % 8 == 0) printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:227printf/格式化输出需确认调试隔离和实时性影响printf("", cogging_table_rev[i]);
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:228printf/格式化输出需确认调试隔离和实时性影响if (i < COGGING_TABLE_SIZE - 1) printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:229printf/格式化输出需确认调试隔离和实时性影响if (i % 8 == 7 || i == COGGING_TABLE_SIZE - 1) printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:232printf/格式化输出需确认调试隔离和实时性影响printf("");
- [AUTO-FUNC-002]
Algorithm/FOC.cpp:234printf/格式化输出需确认调试隔离和实时性影响printf("");
- [AUTO-FUNC-002]
device/Can.cpp:30printf/格式化输出需确认调试隔离和实时性影响#define CAN_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)
- [AUTO-FUNC-002]
device/ang_sensor.cpp:22printf/格式化输出需确认调试隔离和实时性影响#define ANG_SENS_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)
- [AUTO-FUNC-002]
device/motor.cpp:38printf/格式化输出需确认调试隔离和实时性影响printf("");
- [AUTO-FUNC-002]
main.cpp:22printf/格式化输出需确认调试隔离和实时性影响#define MAIN_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)
- [AUTO-FUNC-002]
sys/flash.cpp:22printf/格式化输出需确认调试隔离和实时性影响#define EEP_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)
- [AUTO-FUNC-002]
sys/flash.cpp:31printf/格式化输出需确认调试隔离和实时性影响#define OTA_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)
- [AUTO-FUNC-002]
sys/initial.cpp:23printf/格式化输出需确认调试隔离和实时性影响#define OTA_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)
- [AUTO-FUNC-002]
sys/initial.cpp:32printf/格式化输出需确认调试隔离和实时性影响#define EEP_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)
- [AUTO-FUNC-002]
sys/initial.cpp:129printf/格式化输出需确认调试隔离和实时性影响snprintf(buffer, bufSize, "", version.major, version.minor,
- [AUTO-FUNC-002]
sys/systick.cpp:47printf/格式化输出需确认调试隔离和实时性影响#define SLEEP_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)
- [AUTO-MET-001]
Algorithm/FOC.cpp:75圈复杂度 33 超过建议阈值 15FOC_Controller::calibrate_cogging_tick
- [AUTO-MET-001]
device/Can.cpp:1076圈复杂度 27 超过建议阈值 15CAN_transmiter::communication_check
- [AUTO-MET-001]
main.cpp:120圈复杂度 17 超过建议阈值 15do_task
输出文件
report.md: 本摘要findings.csv: 规则命中明细metrics.csv: 函数复杂度files.csv: 文件范围与行数/hash