generated from hulk/gd32e23x_template
for debug
This commit is contained in:
parent
11cf546438
commit
c11db2c9bf
@ -2,7 +2,7 @@
|
|||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
|
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
|
||||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 4K
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
|
||||||
}
|
}
|
||||||
|
|
||||||
ENTRY(Reset_Handler)
|
ENTRY(Reset_Handler)
|
||||||
|
@ -163,15 +163,15 @@ void USART1_IRQHandler(void) {
|
|||||||
// static uint8_t rx_buffer[RX_BUFFER_SIZE];
|
// static uint8_t rx_buffer[RX_BUFFER_SIZE];
|
||||||
|
|
||||||
if (RESET != usart_interrupt_flag_get(USART_PHY, USART_INT_FLAG_RBNE)) {
|
if (RESET != usart_interrupt_flag_get(USART_PHY, USART_INT_FLAG_RBNE)) {
|
||||||
usart_interrupt_flag_clear(USART_PHY, USART_INT_FLAG_RBNE);
|
// usart_interrupt_flag_clear(USART_PHY, USART_INT_FLAG_RBNE);
|
||||||
uint8_t received_data = (uint8_t) usart_data_receive(USART_PHY);
|
uint8_t received_data = (uint8_t) usart_data_receive(USART_PHY);
|
||||||
|
|
||||||
printf("%c", received_data);
|
// printf("%c", received_data);
|
||||||
// // 将接收到的数据存储到缓冲区
|
// 将接收到的数据存储到缓冲区
|
||||||
// if (rx_index < RX_BUFFER_SIZE - 1) {
|
// if (rx_index < RX_BUFFER_SIZE - 1) {
|
||||||
// rx_buffer[rx_index++] = received_data;
|
// rx_buffer[rx_index++] = received_data;
|
||||||
// }
|
// }
|
||||||
// store_char(received_data, &rx_buffer);
|
store_char(received_data, &rx_buffer);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_IDLE)) {
|
// if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_IDLE)) {
|
||||||
|
@ -18,8 +18,19 @@ static char *strchr_pointer = NULL;
|
|||||||
|
|
||||||
static packet_state_t packet_state = PS_LEN;
|
static packet_state_t packet_state = PS_LEN;
|
||||||
|
|
||||||
|
// bool code_seen(char code) {
|
||||||
|
// // strchr_pointer = strchr(cmd_buffer[buf_index_r], code);
|
||||||
|
// return (strchr_pointer != NULL); //Return True if a character was found
|
||||||
|
// }
|
||||||
|
|
||||||
bool code_seen(char code) {
|
bool code_seen(char code) {
|
||||||
strchr_pointer = strchr(cmd_buffer[buf_index_r], code);
|
strchr_pointer = NULL;
|
||||||
|
for (int i = 0; cmd_buffer[buf_index_r][i] != '\0'; i++) {
|
||||||
|
if (cmd_buffer[buf_index_r][i] == code) {
|
||||||
|
strchr_pointer = &cmd_buffer[buf_index_r][i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return (strchr_pointer != NULL); // Return True if a character was found
|
return (strchr_pointer != NULL); // Return True if a character was found
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,6 +160,7 @@ void start_communication(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (buf_length) {
|
if (buf_length) {
|
||||||
|
printf("DONE!\r\n");
|
||||||
prcess_command();
|
prcess_command();
|
||||||
buf_length--;
|
buf_length--;
|
||||||
buf_index_r = (buf_index_r + 1) % BUF_SIZE;
|
buf_index_r = (buf_index_r + 1) % BUF_SIZE;
|
||||||
@ -206,6 +218,8 @@ void get_command(void) {
|
|||||||
buf_index_w = (buf_index_w + 1) % BUF_SIZE;
|
buf_index_w = (buf_index_w + 1) % BUF_SIZE;
|
||||||
buf_length++;
|
buf_length++;
|
||||||
serial_count = 0;
|
serial_count = 0;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user