diff --git a/Src/freertos.c b/Src/freertos.c index 1ff4a6b..ad89d1e 100644 --- a/Src/freertos.c +++ b/Src/freertos.c @@ -125,7 +125,7 @@ void StartDefaultTask(void const *argument) /* init code for USB_DEVICE */ MX_USB_DEVICE_Init(); // 默认usb启动任务的位置 /* USER CODE BEGIN StartDefaultTask */ - vTaskDelete(NULL); // 避免空置和切换占用cpu + osThreadTerminate(NULL); // 避免空置和切换占用cpu /* USER CODE END StartDefaultTask */ } diff --git a/bsp/can/bsp_can.c b/bsp/can/bsp_can.c index 992cde4..5f2b890 100644 --- a/bsp/can/bsp_can.c +++ b/bsp/can/bsp_can.c @@ -150,19 +150,21 @@ static void CANFIFOxCallback(CAN_HandleTypeDef *_hcan, uint32_t fifox) { static CAN_RxHeaderTypeDef rxconf; // 同上 uint8_t can_rx_buff[8]; - - HAL_CAN_GetRxMessage(_hcan, fifox, &rxconf, can_rx_buff); // 从FIFO中获取数据 - for (size_t i = 0; i < idx; ++i) - { // 两者相等说明这是要找的实例 - if (_hcan == can_instance[i]->can_handle && rxconf.StdId == can_instance[i]->rx_id) - { - if (can_instance[i]->can_module_callback != NULL) // 回调函数不为空就调用 + while (HAL_CAN_GetRxFifoFillLevel(_hcan, fifox)) // FIFO不为空,有可能在其他中断时有多帧数据进入 + { + HAL_CAN_GetRxMessage(_hcan, fifox, &rxconf, can_rx_buff); // 从FIFO中获取数据 + for (size_t i = 0; i < idx; ++i) + { // 两者相等说明这是要找的实例 + if (_hcan == can_instance[i]->can_handle && rxconf.StdId == can_instance[i]->rx_id) { - can_instance[i]->rx_len = rxconf.DLC; // 保存接收到的数据长度 - memcpy(can_instance[i]->rx_buff, can_rx_buff, rxconf.DLC); // 消息拷贝到对应实例 - can_instance[i]->can_module_callback(can_instance[i]); // 触发回调进行数据解析和处理 + if (can_instance[i]->can_module_callback != NULL) // 回调函数不为空就调用 + { + can_instance[i]->rx_len = rxconf.DLC; // 保存接收到的数据长度 + memcpy(can_instance[i]->rx_buff, can_rx_buff, rxconf.DLC); // 消息拷贝到对应实例 + can_instance[i]->can_module_callback(can_instance[i]); // 触发回调进行数据解析和处理 + } + return; } - return; } } } diff --git a/modules/referee/rm_referee.c b/modules/referee/rm_referee.c index d76c6cf..2743d7d 100644 --- a/modules/referee/rm_referee.c +++ b/modules/referee/rm_referee.c @@ -16,6 +16,7 @@ #include "task.h" #include "daemon.h" #include "bsp_log.h" +#include "cmsis_os.h" #define RE_RX_BUFFER_SIZE 255u // 裁判系统接收缓冲区大小 @@ -143,7 +144,6 @@ referee_info_t *RefereeInit(UART_HandleTypeDef *referee_usart_handle) */ void RefereeSend(uint8_t *send, uint16_t tx_len) { - static TickType_t xLastWakeTime; USARTSend(referee_usart_instance, send, tx_len, USART_TRANSFER_DMA); - vTaskDelayUntil(&xLastWakeTime, 120); // 裁判系统接收ui数据和多机通信最大支持频率为10Hz + osDelay(115); }