generated from hulk/gd32e23x_template
完成协议解析与错误报告,并在vofa上创建好各个测试预设
This commit is contained in:
@@ -129,21 +129,14 @@ void USART0_IRQHandler(void) {
|
||||
if (rx_index < RX_BUFFER_SIZE - 1) {
|
||||
rx_buffer[rx_index++] = received_data;
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否接收到换行符,表示指令结束
|
||||
if (received_data == '\n') {
|
||||
if (calculate_crc(rx_buffer, rx_index - 2) == rx_buffer[rx_index - 2]) {
|
||||
// printf("CRC check success\r\n");
|
||||
// rx_buffer[rx_index] = '\0'; // 添加字符串结束符
|
||||
process_command(rx_buffer, rx_index); // 处理指令
|
||||
rx_index = 0; // 重置缓冲区索引
|
||||
} else {
|
||||
// printf("CRC check failed\r\n");
|
||||
printf("%c%c%c%c\r\n", 0xB5, 0xF2, 0x00, 0xF2);
|
||||
rx_index = 0; // 重置缓冲区索引
|
||||
return;
|
||||
}
|
||||
if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_IDLE)) {
|
||||
usart_interrupt_flag_clear(USART0, USART_INT_FLAG_IDLE);
|
||||
|
||||
}
|
||||
process_command(rx_buffer, rx_index); // 处理指令
|
||||
|
||||
rx_index = 0; // 重置缓冲区索引
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user