refactor(FOC): 添加Doxygen文档注释并优化SVPWM算法性能
添加了完整的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文档生成。
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
# 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-238` `FOC_Controller::calibrate_cogging_tick` risk=high
|
||||
- 27 `device/Can.cpp:1076-1300` `CAN_transmiter::communication_check` risk=high
|
||||
- 17 `main.cpp:120-205` `do_task` risk=high
|
||||
- 15 `Algorithm/FOC.cpp:392-490` `FOC_Controller::setSVPWM_PhaseVoltage` risk=medium
|
||||
- 12 `sys/flash.cpp:308-383` `FlashEEPROM::writeFloat` risk=medium
|
||||
- 12 `sys/health.cpp:35-94` `ThermalController::update` risk=medium
|
||||
- 11 `device/Can.cpp:597-665` `can_loopback_test` risk=medium
|
||||
- 10 `device/Can.cpp:1448-1504` `CAN_transmiter::CANFD_AsyncSend` risk=low
|
||||
- 10 `sys/flash.cpp:90-161` `FlashEEPROM::read_saved_system_config` risk=low
|
||||
- 10 `sys/flash.cpp:237-300` `FlashEEPROM::write` risk=low
|
||||
- 10 `sys/flash.cpp:657-717` `FlashEEPROM::writeNodeId` risk=low
|
||||
- 10 `sys/flash.cpp:928-1030` `move_app_data` risk=low
|
||||
- 9 `device/Can.cpp:534-589` `canfd_loopback_test` risk=low
|
||||
- 9 `sys/flash.cpp:413-482` `FlashEEPROM::save_system_config` risk=low
|
||||
- 9 `sys/flash.cpp:792-879` `OTA_SET` risk=low
|
||||
- 9 `sys/health.cpp:113-149` `power_manage` risk=low
|
||||
- 8 `device/ADC.cpp:194-219` `sampler::get_current` risk=low
|
||||
- 8 `sys/flash.cpp:724-776` `FlashEEPROM::writeCRC` risk=low
|
||||
- 8 `sys/systick.cpp:244-298` `app_prepare_deep_sleep` risk=low
|
||||
- 7 `device/Timer.cpp:134-184` `TIMER2_IRQHandler` risk=low
|
||||
|
||||
## Warning 明细
|
||||
- [AUTO-CTRL-002] `device/Can.cpp:1124` continue 需避免或说明偏离
|
||||
- `continue;`
|
||||
- [AUTO-CTRL-002] `device/Can.cpp:1194` continue 需避免或说明偏离
|
||||
- `continue;`
|
||||
- [AUTO-CTRL-002] `device/Can.cpp:1199` continue 需避免或说明偏离
|
||||
- `continue;`
|
||||
- [AUTO-CTRL-002] `main.cpp:80` continue 需避免或说明偏离
|
||||
- `continue;`
|
||||
- [AUTO-CTRL-002] `sys/flash.cpp:693` continue 需避免或说明偏离
|
||||
- `continue;`
|
||||
- [AUTO-CTRL-002] `sys/systick.cpp:264` continue 需避免或说明偏离
|
||||
- `continue;`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:100` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:161` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("",`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:195` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:198` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("", angle_deg, cogging_table[i]);`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:203` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:206` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("", angle_deg, cogging_table_rev[i]);`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:211` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:212` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:214` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `if (i % 8 == 0) printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:215` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("", cogging_table[i]);`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:216` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `if (i < COGGING_TABLE_SIZE - 1) printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:217` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `if (i % 8 == 7 || i == COGGING_TABLE_SIZE - 1) printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:220` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:223` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:224` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:226` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `if (i % 8 == 0) printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:227` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("", cogging_table_rev[i]);`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:228` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `if (i < COGGING_TABLE_SIZE - 1) printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:229` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `if (i % 8 == 7 || i == COGGING_TABLE_SIZE - 1) printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:232` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("");`
|
||||
- [AUTO-FUNC-002] `Algorithm/FOC.cpp:234` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("");`
|
||||
- [AUTO-FUNC-002] `device/Can.cpp:30` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `#define CAN_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)`
|
||||
- [AUTO-FUNC-002] `device/ang_sensor.cpp:22` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `#define ANG_SENS_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)`
|
||||
- [AUTO-FUNC-002] `device/motor.cpp:38` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `printf("");`
|
||||
- [AUTO-FUNC-002] `main.cpp:22` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `#define MAIN_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)`
|
||||
- [AUTO-FUNC-002] `sys/flash.cpp:22` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `#define EEP_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)`
|
||||
- [AUTO-FUNC-002] `sys/flash.cpp:31` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `#define OTA_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)`
|
||||
- [AUTO-FUNC-002] `sys/initial.cpp:23` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `#define OTA_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)`
|
||||
- [AUTO-FUNC-002] `sys/initial.cpp:32` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `#define EEP_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)`
|
||||
- [AUTO-FUNC-002] `sys/initial.cpp:129` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `snprintf(buffer, bufSize, "", version.major, version.minor,`
|
||||
- [AUTO-FUNC-002] `sys/systick.cpp:47` printf/格式化输出需确认调试隔离和实时性影响
|
||||
- `#define SLEEP_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)`
|
||||
- [AUTO-MET-001] `Algorithm/FOC.cpp:75` 圈复杂度 33 超过建议阈值 15
|
||||
- `FOC_Controller::calibrate_cogging_tick`
|
||||
- [AUTO-MET-001] `device/Can.cpp:1076` 圈复杂度 27 超过建议阈值 15
|
||||
- `CAN_transmiter::communication_check`
|
||||
- [AUTO-MET-001] `main.cpp:120` 圈复杂度 17 超过建议阈值 15
|
||||
- `do_task`
|
||||
|
||||
## 输出文件
|
||||
- `report.md`: 本摘要
|
||||
- `findings.csv`: 规则命中明细
|
||||
- `metrics.csv`: 函数复杂度
|
||||
- `files.csv`: 文件范围与行数/hash
|
||||
Reference in New Issue
Block a user