This commit is contained in:
wu58430 2023-12-05 09:38:21 +08:00
parent 8bc96bdc7c
commit b3aa07bd45
2 changed files with 9 additions and 5 deletions

View file

@ -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();

View file

@ -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;
}