【务必拉取】修复ui发送使用临时变量buffer的问题,增加了DMAbuffer防止裁判系统接收溢出

This commit is contained in:
NeoZng 2023-04-24 07:11:19 +08:00
parent 7a95d3c451
commit 1c384d5193
4 changed files with 35 additions and 28 deletions

View File

@ -50,15 +50,14 @@
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */
/* USER CODE END Variables */
osThreadId defaultTaskHandle;
osThreadId insTaskHandle;
osThreadId ledTaskHandle;
osThreadId robotTaskHandle;
osThreadId motorTaskHandle;
osThreadId daemonTaskHandle;
osThreadId uiTaskHandle;
/* USER CODE END Variables */
osThreadId defaultTaskHandle;
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */
@ -73,13 +72,13 @@ void StartROBOTTASK(void const *argument);
void StartUITASK(void const *argument);
/* USER CODE END FunctionPrototypes */
void StartDefaultTask(void const *argument);
void StartDefaultTask(void const * argument);
extern void MX_USB_DEVICE_Init(void);
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
/* GetIdleTaskMemory prototype (linked to static allocation support) */
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize);
void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize );
/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */
static StaticTask_t xIdleTaskTCBBuffer;
@ -95,12 +94,11 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackTyp
/* USER CODE END GET_IDLE_TASK_MEMORY */
/**
* @brief FreeRTOS initialization
* @param None
* @retval None
*/
void MX_FREERTOS_Init(void)
{
* @brief FreeRTOS initialization
* @param None
* @retval None
*/
void MX_FREERTOS_Init(void) {
/* USER CODE BEGIN Init */
/* USER CODE END Init */
@ -144,6 +142,7 @@ void MX_FREERTOS_Init(void)
defaultTaskHandle = osThreadCreate(osThread(uitask), NULL);
/* USER CODE END RTOS_THREADS */
}
/* USER CODE BEGIN Header_StartDefaultTask */
@ -153,16 +152,12 @@ void MX_FREERTOS_Init(void)
* @retval None
*/
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void const *argument)
void StartDefaultTask(void const * argument)
{
/* init code for USB_DEVICE */
MX_USB_DEVICE_Init();
/* USER CODE BEGIN StartDefaultTask */
/* Infinite loop */
// for (;;)
// {
// osDelay(1);
// }
vTaskDelete( NULL );
/* USER CODE END StartDefaultTask */
}
@ -173,7 +168,7 @@ void StartINSTASK(void const *argument)
while (1)
{
// 1kHz
INS_Task();
INS_Task();
osDelay(1);
}
}
@ -204,7 +199,7 @@ void StartROBOTTASK(void const *argument)
{
// 200Hz
RobotTask();
osDelay(5);
osDelay(5);
}
}

View File

@ -274,7 +274,10 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
hdma_usart6_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_usart6_rx.Init.Mode = DMA_NORMAL;
hdma_usart6_rx.Init.Priority = DMA_PRIORITY_HIGH;
hdma_usart6_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
hdma_usart6_rx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
hdma_usart6_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
hdma_usart6_rx.Init.MemBurst = DMA_MBURST_SINGLE;
hdma_usart6_rx.Init.PeriphBurst = DMA_PBURST_SINGLE;
if (HAL_DMA_Init(&hdma_usart6_rx) != HAL_OK)
{
Error_Handler();
@ -292,7 +295,10 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
hdma_usart6_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_usart6_tx.Init.Mode = DMA_NORMAL;
hdma_usart6_tx.Init.Priority = DMA_PRIORITY_HIGH;
hdma_usart6_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
hdma_usart6_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
hdma_usart6_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
hdma_usart6_tx.Init.MemBurst = DMA_MBURST_SINGLE;
hdma_usart6_tx.Init.PeriphBurst = DMA_PBURST_SINGLE;
if (HAL_DMA_Init(&hdma_usart6_tx) != HAL_OK)
{
Error_Handler();

View File

@ -148,25 +148,31 @@ Dma.USART3_RX.7.PeriphInc=DMA_PINC_DISABLE
Dma.USART3_RX.7.Priority=DMA_PRIORITY_LOW
Dma.USART3_RX.7.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
Dma.USART6_RX.0.Direction=DMA_PERIPH_TO_MEMORY
Dma.USART6_RX.0.FIFOMode=DMA_FIFOMODE_DISABLE
Dma.USART6_RX.0.FIFOMode=DMA_FIFOMODE_ENABLE
Dma.USART6_RX.0.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL
Dma.USART6_RX.0.Instance=DMA2_Stream2
Dma.USART6_RX.0.MemBurst=DMA_MBURST_SINGLE
Dma.USART6_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
Dma.USART6_RX.0.MemInc=DMA_MINC_ENABLE
Dma.USART6_RX.0.Mode=DMA_NORMAL
Dma.USART6_RX.0.PeriphBurst=DMA_PBURST_SINGLE
Dma.USART6_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
Dma.USART6_RX.0.PeriphInc=DMA_PINC_DISABLE
Dma.USART6_RX.0.Priority=DMA_PRIORITY_HIGH
Dma.USART6_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
Dma.USART6_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
Dma.USART6_TX.1.Direction=DMA_MEMORY_TO_PERIPH
Dma.USART6_TX.1.FIFOMode=DMA_FIFOMODE_DISABLE
Dma.USART6_TX.1.FIFOMode=DMA_FIFOMODE_ENABLE
Dma.USART6_TX.1.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL
Dma.USART6_TX.1.Instance=DMA2_Stream6
Dma.USART6_TX.1.MemBurst=DMA_MBURST_SINGLE
Dma.USART6_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE
Dma.USART6_TX.1.MemInc=DMA_MINC_ENABLE
Dma.USART6_TX.1.Mode=DMA_NORMAL
Dma.USART6_TX.1.PeriphBurst=DMA_PBURST_SINGLE
Dma.USART6_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
Dma.USART6_TX.1.PeriphInc=DMA_PINC_DISABLE
Dma.USART6_TX.1.Priority=DMA_PRIORITY_HIGH
Dma.USART6_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
Dma.USART6_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
FREERTOS.INCLUDE_vTaskDelayUntil=1
FREERTOS.IPParameters=Tasks01,configENABLE_FPU,configMAX_TASK_NAME_LEN,configUSE_TIMERS,configUSE_POSIX_ERRNO,INCLUDE_vTaskDelayUntil
FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL

View File

@ -22,7 +22,7 @@
*****************************************************************************************/
void UIDelete(referee_id_t *_id, uint8_t Del_Operate, uint8_t Del_Layer)
{
UI_delete_t UI_delete_data;
static UI_delete_t UI_delete_data;
uint8_t temp_datalength = Interactive_Data_LEN_Head + UI_Operate_LEN_Del; // 计算交互数据长度
UI_delete_data.FrameHeader.SOF = REFEREE_SOF;
@ -352,7 +352,7 @@ void UI_ReFresh(referee_id_t *_id, int cnt, ...)
uint8_t temp_datalength = LEN_HEADER + LEN_CMDID + Interactive_Data_LEN_Head + UI_Operate_LEN_PerDraw * cnt + LEN_TAIL; // 计算交互数据长度
uint8_t buffer[temp_datalength]; // 交互数据缓存
static uint8_t buffer[512]; // 交互数据缓存
va_list ap; // 创建一个 va_list 类型变量
va_start(ap, cnt); // 初始化 va_list 变量为一个参数列表
@ -398,7 +398,7 @@ void UI_ReFresh(referee_id_t *_id, int cnt, ...)
/************************************************UI推送字符使更改生效*********************************/
void Char_ReFresh(referee_id_t *_id, String_Data_t string_Data)
{
UI_CharReFresh_t UI_CharReFresh_data;
static UI_CharReFresh_t UI_CharReFresh_data;
uint8_t temp_datalength = Interactive_Data_LEN_Head + UI_Operate_LEN_DrawChar; // 计算交互数据长度