mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-24 03:27:45 +08:00
添加了大量调试log,新增了dwt计时宏,增加了USB软件复位防止主控复位后上位机无法连接usb
This commit is contained in:
@@ -10,11 +10,13 @@
|
||||
*/
|
||||
#include "master_process.h"
|
||||
#include "seasky_protocol.h"
|
||||
#include "daemon.h"
|
||||
#include "bsp_log.h"
|
||||
#include "robot_def.h"
|
||||
|
||||
static Vision_Recv_s recv_data;
|
||||
static Vision_Send_s send_data;
|
||||
static DaemonInstance *vision_daemon_instance;
|
||||
|
||||
void VisionSetFlag(Enemy_Color_e enemy_color, Work_Mode_e work_mode, Bullet_Speed_e bullet_speed)
|
||||
{
|
||||
@@ -30,13 +32,26 @@ void VisionSetAltitude(float yaw, float pitch, float roll)
|
||||
send_data.roll = roll;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 离线回调函数,将在daemon.c中被daemon task调用
|
||||
* @attention 由于HAL库的设计问题,串口开启DMA接收之后同时发送有概率出现__HAL_LOCK()导致的死锁,使得无法
|
||||
* 进入接收中断.通过daemon判断数据更新,重新调用服务启动函数以解决此问题.
|
||||
*
|
||||
* @param id vision_usart_instance的地址,此处没用.
|
||||
*/
|
||||
static void VisionOfflineCallback(void *id)
|
||||
{
|
||||
#ifdef VISION_USE_UART
|
||||
USARTServiceInit(vision_usart_instance);
|
||||
#endif // !VISION_USE_UART
|
||||
LOGWARNING("[vision] vision offline, restart communication.");
|
||||
}
|
||||
|
||||
#ifdef VISION_USE_UART
|
||||
|
||||
#include "bsp_usart.h"
|
||||
#include "daemon.h"
|
||||
|
||||
static USARTInstance *vision_usart_instance;
|
||||
static DaemonInstance *vision_daemon_instance;
|
||||
|
||||
/**
|
||||
* @brief 接收解包回调函数,将在bsp_usart.c中被usart rx callback调用
|
||||
@@ -51,21 +66,8 @@ static void DecodeVision()
|
||||
// TODO: code to resolve flag_register;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 离线回调函数,将在daemon.c中被daemon task调用
|
||||
* @attention 由于HAL库的设计问题,串口开启DMA接收之后同时发送有概率出现__HAL_LOCK()导致的死锁,使得无法
|
||||
* 进入接收中断.通过daemon判断数据更新,重新调用服务启动函数以解决此问题.
|
||||
*
|
||||
* @param id vision_usart_instance的地址,此处没用.
|
||||
*/
|
||||
static void VisionOfflineCallback(void *id)
|
||||
{
|
||||
USARTServiceInit(vision_usart_instance);
|
||||
}
|
||||
|
||||
Vision_Recv_s *VisionInit(UART_HandleTypeDef *_handle)
|
||||
{
|
||||
#ifdef VISION_USE_UART
|
||||
USART_Init_Config_s conf;
|
||||
conf.module_callback = DecodeVision;
|
||||
conf.recv_buff_size = VISION_RECV_SIZE;
|
||||
@@ -79,7 +81,6 @@ Vision_Recv_s *VisionInit(UART_HandleTypeDef *_handle)
|
||||
.reload_count = 10,
|
||||
};
|
||||
vision_daemon_instance = DaemonRegister(&daemon_conf);
|
||||
#endif // VISION_USE_UART
|
||||
|
||||
return &recv_data;
|
||||
}
|
||||
@@ -125,9 +126,17 @@ static void DecodeVision(uint16_t recv_len)
|
||||
Vision_Recv_s *VisionInit(UART_HandleTypeDef *_handle)
|
||||
{
|
||||
UNUSED(_handle); // 仅为了消除警告
|
||||
USB_Init_Config_s conf = {0};
|
||||
conf.rx_cbk = DecodeVision;
|
||||
USB_Init_Config_s conf = {.rx_cbk = DecodeVision};
|
||||
vis_recv_buff = USBInit(conf);
|
||||
|
||||
// 为master process注册daemon,用于判断视觉通信是否离线
|
||||
Daemon_Init_Config_s daemon_conf = {
|
||||
.callback = VisionOfflineCallback, // 离线时调用的回调函数,会重启串口接收
|
||||
.owner_id = NULL,
|
||||
.reload_count = 5, // 50ms
|
||||
};
|
||||
vision_daemon_instance = DaemonRegister(&daemon_conf);
|
||||
|
||||
return &recv_data;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user