feat(CAN): 实现多节点CAN总线通信与节点ID管理功能

- 添加CAN调试宏定义,支持条件编译调试信息输出
- 实现节点ID相关功能,包括构建CAN ID、消息过滤、获取/设置节点ID
- 支持Flash存储节点ID,提供加载和保存功能
- 实现节点ID设置和查询命令处理
- 更新CANFD发送函数使用节点ID构建发送ID
- 添加消息过滤逻辑,只处理目标节点的消息
- 重构DMA中断服务程序,优化数据传输处理
- 替换printf为调试宏,便于生产环境控制调试输出
This commit is contained in:
cbb
2026-03-15 02:38:50 +08:00
parent 2b93a4537c
commit 9f56ab394e
10 changed files with 751 additions and 461 deletions
+17 -9
View File
@@ -1,25 +1,33 @@
#include "adc.h"
#include "config.h"
#include <cstdio>
// TEST 调试宏定义
#if TEST_DEBUG
#define TEST_DEBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define TEST_DEBUG_PRINT(fmt, ...) ((void)0)
#endif
constexpr int status_print = 0;
extern sampler sampler;
void test_1111() {
// 初始化CAN回环测试
// 初始化 CAN 回环测试
// can_loopback_init();
// can_config();
if (status_print) {
/* value print */
printf(" the temperature data is %2.2f degrees Celsius\r\n",
TEST_DEBUG_PRINT(" the temperature data is %2.2f degrees Celsius\r\n",
sampler.get_mcu_temp());
printf(" the drv_temperature data is %2.2f degrees Celsius\r\n",
TEST_DEBUG_PRINT(" the drv_temperature data is %2.2f degrees Celsius\r\n",
sampler.get_drv_temp());
printf(" the U current data is %2.2f mA\r\n", sampler.get_current('U'));
printf(" the V current data is %2.2f mA\r\n", sampler.get_current('V'));
printf(" the W current data is %2.2f mA\r\n", sampler.get_current('W'));
printf(" the VBUS is %2.2f V\r\n", sampler.get_vbus_voltage());
// printf(" the angle is %2.2f\r\n", tle5012b_read());
TEST_DEBUG_PRINT(" the U current data is %2.2f mA\r\n", sampler.get_current('U'));
TEST_DEBUG_PRINT(" the V current data is %2.2f mA\r\n", sampler.get_current('V'));
TEST_DEBUG_PRINT(" the W current data is %2.2f mA\r\n", sampler.get_current('W'));
TEST_DEBUG_PRINT(" the VBUS is %2.2f V\r\n", sampler.get_vbus_voltage());
// TEST_DEBUG_PRINT(" the angle is %2.2f\r\n", tle5012b_read());
printf("\n----------------------------------------------------\n");
TEST_DEBUG_PRINT("\n----------------------------------------------------\n");
}
// can_loopback_test();
}