資源簡介
使用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壓力測試工具
評論
共有 條評論