diff --git a/inc/board_config.h b/inc/board_config.h index 9d9797b..5e5024f 100644 --- a/inc/board_config.h +++ b/inc/board_config.h @@ -48,6 +48,7 @@ #define USART_RX_PIN GPIO_PIN_3 #define USART_PHY USART1 #define USART_PHY_BAUDRATE 115200U +#define USART_PHY_IRQ USART1_IRQn #define RS485_EN_PORT GPIOA #define RS485_EN_PIN GPIO_PIN_4 diff --git a/src/fwdgt.c b/src/fwdgt.c index 996e6f5..4beebce 100644 --- a/src/fwdgt.c +++ b/src/fwdgt.c @@ -15,7 +15,7 @@ void watchdog_init(void) { rcu_osci_stab_wait(RCU_IRC40K); /* Configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */ - fwdgt_config(6250, FWDGT_PSC_DIV64); // Set timeout to 1 seconds (625 / 0.625 KHz) + fwdgt_config(625, FWDGT_PSC_DIV64); // Set timeout to 1 seconds (625 / 0.625 KHz) /* Enable FWDGT */ fwdgt_enable(); diff --git a/src/gd32e23x_it.c b/src/gd32e23x_it.c index 324a900..b82e933 100644 --- a/src/gd32e23x_it.c +++ b/src/gd32e23x_it.c @@ -159,18 +159,19 @@ void EXTI0_1_IRQHandler(void) { } void USART1_IRQHandler(void) { - static uint8_t rx_index = 0; - static uint8_t rx_buffer[RX_BUFFER_SIZE]; + // static uint8_t rx_index = 0; + // static uint8_t rx_buffer[RX_BUFFER_SIZE]; - if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_RBNE)) { - usart_interrupt_flag_clear(USART0, USART_INT_FLAG_RBNE); - uint8_t received_data = (uint8_t) usart_data_receive(USART0); + if (RESET != usart_interrupt_flag_get(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); + printf("%c", received_data); // // 将接收到的数据存储到缓冲区 // if (rx_index < RX_BUFFER_SIZE - 1) { // 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)) { diff --git a/src/usart.c b/src/usart.c index be620c0..cbaca3b 100644 --- a/src/usart.c +++ b/src/usart.c @@ -31,7 +31,7 @@ void usart_config(void) usart_baudrate_set(USART_PHY, 115200U); usart_receive_config(USART_PHY, USART_RECEIVE_ENABLE); usart_transmit_config(USART_PHY, USART_TRANSMIT_ENABLE); - nvic_irq_enable(USART1_IRQn, 0); + nvic_irq_enable(USART_PHY_IRQ, 0); usart_interrupt_enable(USART_PHY, USART_INT_RBNE); // usart_interrupt_enable(USART_PHY, USART_INT_IDLE); usart_enable(USART_PHY);