- 云台(ROBOT_TYPE_GIMBAL)与底盘(ROBOT_TYPE_CHASSIS)完整固件源码 - 新增根级 .gitignore,排除 Keil MDK-ARM 构建产物(.o/.d/.crf/.axf/.lnp/.map/.htm/.sct/.dep/.iex/.lst 等) 与 *.uvguix.* / DebugConfig/(与机器绑定的 UI 布局) - core.autocrlf=false,避免固件源码在检出时被改动换行符
83 lines
3.3 KiB
C
83 lines
3.3 KiB
C
/* =============================================================================
|
|
* debug_task.c - USB 虚拟串口(CDC)诊断输出(仅诊断用,稳定后可整组移除)
|
|
* 每 500ms 一行状态:各芯片实测 ID/DR16 帧计数/USART 空闲中断计数/任务循环
|
|
* 计数等;板子插电脑出现虚拟 COM 口,串口助手打开即可(波特率随意)。
|
|
* 字段含义见重构说明与编译指南.md 的诊断章节
|
|
* ========================================================================== */
|
|
#include "debug_task.h"
|
|
#include "app_tasks.h"
|
|
#include "cmsis_os.h"
|
|
#include "FreeRTOS.h"
|
|
#include "task.h"
|
|
#include "usb_device.h"
|
|
#include "usbd_cdc_if.h"
|
|
#include "usart.h"
|
|
#include "bsp_can.h"
|
|
#include "bsp_usart.h"
|
|
#include <stdio.h>
|
|
#include "dr16.h"
|
|
#include "referee.h"
|
|
#include "c_comm.h"
|
|
#if defined(ROBOT_TYPE_GIMBAL)
|
|
#include "bmi088.h"
|
|
#include "ist8310.h"
|
|
#include "ins.h"
|
|
#include "attitude.h"
|
|
#include "gimbal.h"
|
|
#elif defined(ROBOT_TYPE_CHASSIS)
|
|
#include "chassis.h"
|
|
#include "bmi088.h"
|
|
#include "ins.h"
|
|
#include "robot_typedef.h"
|
|
#endif
|
|
|
|
/* debug_task:USB 虚拟串口(CDC)诊断输出,每 500ms 一行
|
|
* 板子插上电脑会出现虚拟 COM 口,用串口助手打开即可看到(波特率随意)
|
|
* 输出为纯整数,用于远程定位传感器/通讯初始化问题 */
|
|
|
|
/* 各模块导出的诊断变量(定义在 imu_task.c / can_task.c) */
|
|
extern volatile uint32_t dbg_imu_loop;
|
|
extern volatile uint32_t dbg_can_loop;
|
|
|
|
void debug_task(void const * argument)
|
|
{
|
|
char line[128];
|
|
|
|
for (;;)
|
|
{
|
|
int len = 0;
|
|
#if defined(ROBOT_TYPE_GIMBAL)
|
|
len = snprintf(line, sizeof(line),
|
|
"app=%u can=%u imu=%u acc=%02X gyro=%02X bmi=%u ist=%u who=%02X "
|
|
"cvg=%u ys=%d yaw=%.1f u3g=%02X i3=%u l3=%u d16=%u ref=%u/%u mot=%u\r\n",
|
|
app_ready, dbg_can_loop, dbg_imu_loop,
|
|
bmi088_last_acc_id, bmi088_last_gyro_id, bmi088_online,
|
|
ist8310_online, ist8310_last_who,
|
|
INS.ConvergeFlag,
|
|
(int)gimbal_yaw_sign(), att_deg_yaw,
|
|
(unsigned)(huart3.gState), dbg_usart3_idle, dbg_usart3_last_len,
|
|
dr16_frame_count,
|
|
referee.link_status, (unsigned)(HAL_GetTick() - referee.last_update_tick),
|
|
gimbal_motor_offline());
|
|
#elif defined(ROBOT_TYPE_CHASSIS)
|
|
len = snprintf(line, sizeof(line),
|
|
"app=%u can=%u imu=%u acc=%02X gyro=%02X cvg=%u "
|
|
"ctoc=%u/%u att=%u/%d mot=%u md=%u err=%.1f fw=%d spin=%u lim=%u\r\n",
|
|
app_ready, dbg_can_loop, dbg_imu_loop,
|
|
bmi088_last_acc_id, bmi088_last_gyro_id,
|
|
INS.ConvergeFlag,
|
|
ctoc_remote.status,
|
|
(unsigned)(ctoc_remote.last_tick ? HAL_GetTick() - ctoc_remote.last_tick : 0),
|
|
ctoc_att_fresh(), (int)ctoc_gimbal_yaw,
|
|
chassis_motor_offline(),
|
|
cmd_robot.chassis_mode,
|
|
dbg_follow_err_deg, (int)dbg_follow_out,
|
|
ctoc_remote.spin_flag, referee.chassis_power_limit);
|
|
#endif
|
|
if (len > 0)
|
|
CDC_Transmit_FS((uint8_t *)line, (uint16_t)len);
|
|
|
|
osDelay(500);
|
|
}
|
|
}
|