diff --git a/Inc/uart.h b/Inc/uart.h index 1ce91c0..050fe26 100644 --- a/Inc/uart.h +++ b/Inc/uart.h @@ -12,6 +12,5 @@ typedef enum { } uart_printf_port_t; void rs485_init(void); -// void uart_set_printf_port(uart_printf_port_t port); #endif // UART_H diff --git a/Src/gd32e23x_it.c b/Src/gd32e23x_it.c index 3bcff34..01293ab 100644 --- a/Src/gd32e23x_it.c +++ b/Src/gd32e23x_it.c @@ -103,4 +103,12 @@ void USART0_IRQHandler(void) { uint8_t data = usart_data_receive(USART0); uart_rx_put(data); } + /* 处理 USART0 中断 + ** USART_INT_FLAG_RBNE 读缓冲区非空中断标志 + ** 即:当 USART0 的接收缓冲区有数据时,触发该中断 + ** 该中断为只读中断,不需要手动清除 + ** + ** + ** + */ } \ No newline at end of file diff --git a/Src/main.c b/Src/main.c index 1316d4c..ef560be 100644 --- a/Src/main.c +++ b/Src/main.c @@ -37,15 +37,6 @@ OF SUCH DAMAGE. #include "uart.h" #include "led.h" #include -#include "board_config.h" -#include "uart_ring_buffer.h" -#include "command.h" - -void uart_puts(const char *s) { - while (*s) { - usart_data_transmit(RS485_PHY, (uint8_t)*s++); - } -} /*! \brief main function diff --git a/Src/uart.c b/Src/uart.c index 76a4325..6d699c9 100644 --- a/Src/uart.c +++ b/Src/uart.c @@ -70,32 +70,3 @@ void rs485_init(void) { #endif // RS485_MAX13487 } - -// static uart_printf_port_t g_printf_port = UART_PRINTF_USART0; - -// void uart_set_printf_port(uart_printf_port_t port) { -// g_printf_port = port; -// } - -// // printf 重定向,支持多串口 -// int __io_putchar(int ch) { -// switch (g_printf_port) { -// case UART_PRINTF_USART0: -// while (usart_flag_get(USART0, USART_FLAG_TBE) == RESET) {} -// usart_data_transmit(USART0, (uint8_t)ch); -// break; -// case UART_PRINTF_USART1: -// while (usart_flag_get(USART1, USART_FLAG_TBE) == RESET) {} -// usart_data_transmit(USART1, (uint8_t)ch); -// break; -// case UART_PRINTF_BOTH: -// while (usart_flag_get(USART0, USART_FLAG_TBE) == RESET) {} -// usart_data_transmit(USART0, (uint8_t)ch); -// while (usart_flag_get(USART1, USART_FLAG_TBE) == RESET) {} -// usart_data_transmit(USART1, (uint8_t)ch); -// break; -// default: -// break; -// } -// return ch; -// }