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); } /**