mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
use memmove to improve recive buff
This commit is contained in:
parent
1a3cbcb7eb
commit
56b8bf4fd2
@ -16,7 +16,7 @@
|
||||
<TargetCommonOption>
|
||||
<Device>STM32G030C8Tx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32G0xx_DFP.1.2.0</PackID>
|
||||
<PackID>Keil.STM32G0xx_DFP.1.3.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000-0x20001FFF) IROM(0x8000000-0x800FFFF) CLOCK(8000000) CPUTYPE("Cortex-M0+") TZ</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
|
@ -405,13 +405,17 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef* huart) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* recive next char, avoid recive buff overflow */
|
||||
if (pika_uart->rxBuffOffset + 2 < RX_BUFF_LENGTH) {
|
||||
pika_uart->rxBuffOffset++;
|
||||
pika_uart->rxBuff[pika_uart->rxBuffOffset] = 0;
|
||||
/* avoid recive buff overflow */
|
||||
if (pika_uart->rxBuffOffset + 2 > RX_BUFF_LENGTH) {
|
||||
memmove(pika_uart->rxBuff, pika_uart->rxBuff + 1, RX_BUFF_LENGTH);
|
||||
UART_Start_Receive_IT(
|
||||
huart, (uint8_t*)(pika_uart->rxBuff + pika_uart->rxBuffOffset), 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* recive next char */
|
||||
pika_uart->rxBuffOffset++;
|
||||
pika_uart->rxBuff[pika_uart->rxBuffOffset] = 0;
|
||||
UART_Start_Receive_IT(
|
||||
huart, (uint8_t*)(pika_uart->rxBuff + pika_uart->rxBuffOffset), 1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user