diff --git a/kernel/driver/uart/uart.c b/kernel/driver/uart/uart.c index 2001d28b..c7d4450f 100644 --- a/kernel/driver/uart/uart.c +++ b/kernel/driver/uart/uart.c @@ -83,6 +83,25 @@ uchar uart_read(uint32_t port) { while (serial_received(port) == 0) pause(); - + return io_in8(port); +} + +/** + * @brief 通过串口发送整个字符串 + * + * @param port 串口端口 + * @param str 字符串 + */ +void uart_send_str(uint32_t port, const char *str) +{ + if ((unlikely(str == NULL))) + return; + while (1) + { + if (unlikely(*str == '\0')) + return; + uart_send(port, *str); + ++str; + } } \ No newline at end of file diff --git a/kernel/driver/uart/uart.h b/kernel/driver/uart/uart.h index c5442bd5..8a011685 100644 --- a/kernel/driver/uart/uart.h +++ b/kernel/driver/uart/uart.h @@ -61,4 +61,12 @@ void uart_send(uint32_t port, char c); * @param port 端口号 * @return uchar 接收到的数据 */ -uchar uart_read(uint32_t port); \ No newline at end of file +uchar uart_read(uint32_t port); + +/** + * @brief 通过串口发送整个字符串 + * + * @param port 串口端口 + * @param str 字符串 + */ +void uart_send_str(uint32_t port, const char *str); \ No newline at end of file