资源简介
使用NucleiStudio打开工程, 代码实现了GD32VF103串口0的发送, printf支持, 接收中断, DMA等, 具体参考我的博客: GD32VF103_串口发送_printf_接收中断_DMA
代码片段和文件信息
/*!
\file main.c
\brief running led
\version 2019-6-5 V1.0.0 firmware for GD32VF103
*/
/*
Copyright (c) 2019 GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms with or without modification
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS“
AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT
INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING BUT
NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE DATA OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY
WHETHER IN CONTRACT STRICT LIABILITY OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#include “gd32vf103.h“
#include “systick.h“
#include
void uart0_config(uint32_t baudrate) {
rcu_periph_clock_enable(RCU_GPIOA); //enable GPIO clock PA9/PA10
rcu_periph_clock_enable(RCU_USART0); //enable USART clock
gpio_init(GPIOA GPIO_MODE_AF_PP GPIO_OSPEED_50MHZ GPIO_PIN_9); //PA9--TX0
gpio_init(GPIOA GPIO_MODE_IN_FLOATING GPIO_OSPEED_50MHZ GPIO_PIN_10); //PA10--RX0
//USART0: 115200-8-1-N
usart_deinit(USART0);
usart_baudrate_set(USART0 baudrate);
usart_word_length_set(USART0 USART_WL_8BIT);
usart_stop_bit_set(USART0 USART_STB_1BIT);
usart_parity_config(USART0 USART_PM_NONE);
usart_hardware_flow_rts_config(USART0 USART_RTS_DISABLE);
usart_hardware_flow_cts_config(USART0 USART_CTS_DISABLE);
usart_receive_config(USART0 USART_RECEIVE_ENABLE);
usart_transmit_config(USART0 USART_TRANSMIT_ENABLE);
usart_enable(USART0);
}
void usart0_transmit_arr(uint8_t arr[] uint32_t length) {
for(uint32_t i=0; i usart_data_transmit(USART0 arr[i]);
while (usart_flag_get(USART0 USART_FLAG_TBE)== RESET);
}
}
/* retarget the C library printf function to the USART */
int _put_char(int ch)
{
usart_data_transmit(USART0 (uint8_t)ch );
while ( usart_flag_
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-10-30 21:42 gd32vf_usart_test0\
文件 36235 2019-10-30 21:28 gd32vf_usart_test0\.cproject
文件 846 2019-10-30 21:27 gd32vf_usart_test0\.project
目录 0 2019-10-30 21:27 gd32vf_usart_test0\.settings\
文件 2245 2019-10-30 21:27 gd32vf_usart_test0\.settings\language.settings.xm
目录 0 2019-10-30 21:27 gd32vf_usart_test0\Application\
文件 2445 2019-10-30 21:27 gd32vf_usart_test0\Application\gd32vf103_libopt.h
文件 7361 2019-10-30 22:56 gd32vf_usart_test0\Application\main.c
文件 1825 2019-10-30 21:27 gd32vf_usart_test0\Application\main.h
文件 2295 2019-10-30 21:27 gd32vf_usart_test0\Application\systick.c
文件 1839 2019-10-30 21:27 gd32vf_usart_test0\Application\systick.h
目录 0 2019-10-30 23:00 gd32vf_usart_test0\Debug\
目录 0 2019-10-30 23:00 gd32vf_usart_test0\Debug\Application\
文件 1492 2019-10-30 22:56 gd32vf_usart_test0\Debug\Application\subdir.mk
文件 212798 2019-10-30 22:56 gd32vf_usart_test0\Debug\gd32vf_usart_test0.map
文件 3199 2019-10-30 22:56 gd32vf_usart_test0\Debug\makefile
文件 239 2019-10-30 21:42 gd32vf_usart_test0\Debug\ob
目录 0 2019-10-30 23:00 gd32vf_usart_test0\Debug\Peripherals\
目录 0 2019-10-30 23:00 gd32vf_usart_test0\Debug\Peripherals\Source\
文件 3874 2019-10-30 22:56 gd32vf_usart_test0\Debug\Peripherals\Source\subdir.mk
文件 1449 2019-10-30 22:56 gd32vf_usart_test0\Debug\Peripherals\subdir.mk
目录 0 2019-10-30 21:42 gd32vf_usart_test0\Debug\RISCV\
目录 0 2019-10-30 23:00 gd32vf_usart_test0\Debug\RISCV\drivers\
文件 1438 2019-10-30 22:56 gd32vf_usart_test0\Debug\RISCV\drivers\subdir.mk
目录 0 2019-10-30 23:00 gd32vf_usart_test0\Debug\RISCV\env_Eclipse\
文件 2830 2019-10-30 22:56 gd32vf_usart_test0\Debug\RISCV\env_Eclipse\subdir.mk
目录 0 2019-10-30 23:00 gd32vf_usart_test0\Debug\RISCV\stubs\
文件 2009 2019-10-30 22:56 gd32vf_usart_test0\Debug\RISCV\stubs\subdir.mk
文件 771 2019-10-30 22:56 gd32vf_usart_test0\Debug\sources.mk
目录 0 2019-10-30 23:00 gd32vf_usart_test0\Debug\Utilities\
目录 0 2019-10-30 23:00 gd32vf_usart_test0\Debug\Utilities\LCD_common\
............此处省略91个文件信息
- 上一篇:Sublime风格的IDEA配置文件
- 下一篇:DDOS压力测试工具
相关资源
- STM8L15x的USART调试实验串口调试_含中断
- 安装risc-V的rocket的环境,零基础
- STM32 USART1 USART2 UASRT3 UART4 UART5串口通信
- STM32 多串口DMA传输透传带DEBUG输出代码
- STM32F103的三串口DMA读取例程
- ESP8266_NONOS_SDK-2.2.0
- STM32F103C8T6+MPU6050六轴传感器
- stm32L151c8t6 USART1例程
- stm32f103vet6_usart1_AHT10.zip
- STM32F103C8T6的串口1和串口3收发实验
- stm32 USART接收总线空闲中断--USART_IT_
- PIC18F25K80串口自发自收
- STM32上移植FreeRTOSDemo
- RN8209X_LN_STM32F103_USART3.zip
- STM32 USART例程源代码
- STM32串口通信 USART1(printf+USER_printf)
- STM32 UART DMA 收发数据
- 基于STM32F105RB设计的串口转双路CAN程序
- stm32+USART协议RS485 iap Bootloader源码 ke
- STM32 USART1 收发数据
- stm32 最完整的串口通讯代码
评论
共有 条评论