From 1a8f1fa2033868eb63a45dec2e5abaa879b85743 Mon Sep 17 00:00:00 2001 From: yelvlab Date: Tue, 31 Dec 2024 21:53:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9cmakelist=E4=B8=AD=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=96=87=E4=BB=B6=E5=90=8D=E7=9A=84=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E3=80=82=20=E6=B7=BB=E5=8A=A0=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=9A=84usart=E7=9A=84=E6=8E=A5=E6=94=B6=E4=B8=AD?= =?UTF-8?q?=E6=96=AD=E5=92=8C=E8=B6=85=E6=97=B6=E4=B8=AD=E6=96=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 11 ++++++----- README.md | 2 +- src/gd32e23x_it.c | 11 ++++++++++- src/main.c | 1 + src/usart.c | 4 ++++ 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ed06994..562c8b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.28) include(cmake/toolchain.cmake) +set(PROJECT_NAME "gd32e23x_template") project(gd32e23x_template) set(VERSION_MAJOR 0) @@ -39,11 +40,11 @@ set(TARGET_C_SRC ${CMAKE_SOURCE_DIR}/src/fwdgt.c ) -add_executable(gd32e23x_template ${TARGET_C_SRC}) +add_executable(${PROJECT_NAME} ${TARGET_C_SRC}) -target_link_libraries(gd32e23x_template GD32E23X_SDK) -target_include_directories(gd32e23x_template PUBLIC inc) +target_link_libraries(${PROJECT_NAME} GD32E23X_SDK) +target_include_directories(${PROJECT_NAME} PUBLIC inc) # Generate .bin and .hex -generate_binary_file(gd32e23x_template) -generate_hex_file(gd32e23x_template) +generate_binary_file(${PROJECT_NAME}) +generate_hex_file(${PROJECT_NAME}) diff --git a/README.md b/README.md index 1a1fe8a..3870b0d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ### 版本号 默认版本号为`0.0.1`,在`CMakeLists.txt`中修改`PROJECT_VERSION`即可。 ### 项目名称 -默认项目名称为`gd32e23x_template`,在`CMakeLists.txt`中修改`PROJECT_NAME`即可。请先修改项目名称再配置编译环境。 +默认项目名称为`gd32e23x_template`,在`CMakeLists.txt`中修改`set(PROJECT_NAME "gd32e23x_template")`即可。请先修改项目名称再配置编译环境。 ### 软件IIC与硬件IIC 本项目中提供了软件IIC与硬件IIC的驱动,但是默认使用硬件IIC,如果需要使用软件IIC,请在`board_config.h`中取消注释`// #define SOFTWARE_IIC`(line 8)。 ### 编译选项 diff --git a/src/gd32e23x_it.c b/src/gd32e23x_it.c index 4dc5453..9c2009d 100644 --- a/src/gd32e23x_it.c +++ b/src/gd32e23x_it.c @@ -120,4 +120,13 @@ void TIMER16_IRQHandler(void) } led_status = !led_status; } -} \ No newline at end of file +} + +/*! + \brief this function handles USART0 interrupt request + \param[in] none + \param[out] none + \retval none +*/ +void USART0_IRQHandler(void) { +} diff --git a/src/main.c b/src/main.c index c6b5403..26cb9fd 100644 --- a/src/main.c +++ b/src/main.c @@ -14,6 +14,7 @@ */ int main(void) { + setbuf(stdout, NULL); /* configure systick */ systick_config(); /* configure USART */ diff --git a/src/usart.c b/src/usart.c index 25e1a4e..4416f9e 100644 --- a/src/usart.c +++ b/src/usart.c @@ -28,6 +28,10 @@ void usart_config(void) usart_transmit_config(USART_PHY, USART_TRANSMIT_ENABLE); usart_enable(USART_PHY); + + nvic_irq_enable(USART0_IRQn, 0); + usart_interrupt_enable(USART_PHY, USART_INT_RBNE); + usart_interrupt_enable(USART_PHY, USART_INT_IDLE); } /**