From b3aa07bd459ac0a91eb9f2c7eece5ca6bcf3dc15 Mon Sep 17 00:00:00 2001 From: wu58430 Date: Tue, 5 Dec 2023 09:38:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=99=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/app.c | 3 +-- app/uart.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/app.c b/app/app.c index 1b0e13c..d08e5c0 100644 --- a/app/app.c +++ b/app/app.c @@ -1185,8 +1185,7 @@ void APP_TimeSlice10ms(void) if (UART_IsCommandAvailable()) { - char a[2]="OK"; - UART_Send((uint8_t *)&a,2); + __disable_irq(); UART_HandleCommand(); __enable_irq(); diff --git a/app/uart.c b/app/uart.c index 7c904fa..c80456f 100644 --- a/app/uart.c +++ b/app/uart.c @@ -429,18 +429,22 @@ bool UART_IsCommandAvailable(void) uint16_t CRC; uint16_t CommandLength; uint16_t DmaLength = DMA_CH0->ST & 0xFFFU; + char a[2]="OK"; + UART_Send((uint8_t *)&a,2); while (1) { if (gUART_WriteIndex == DmaLength) return false; - + char a[2]="1K"; + UART_Send((uint8_t *)&a,2); while (gUART_WriteIndex != DmaLength && UART_DMA_Buffer[gUART_WriteIndex] != 0xABU) gUART_WriteIndex = DMA_INDEX(gUART_WriteIndex, 1); if (gUART_WriteIndex == DmaLength) return false; - + char a[2]="2K"; + UART_Send((uint8_t *)&a,2); if (gUART_WriteIndex < DmaLength) CommandLength = DmaLength - gUART_WriteIndex; else @@ -510,7 +514,8 @@ bool UART_IsCommandAvailable(void) } CRC = UART_Command.Buffer[Size] | (UART_Command.Buffer[Size + 1] << 8); - + char a[2]="3K"; + UART_Send((uint8_t *)&a,2); return (CRC_Calculate(UART_Command.Buffer, Size) != CRC) ? false : true; }