本帖最后由 dami 于 2020-12-12 11:28 编辑
【RISC-V MCU CH32V103测评】+uart测试
1,在生成一个工程。
2,在工程目录user里面加入led.h和 led.c uart.h uart.c文件。按F5 Reflash就出现在工程中。- #ifndef __LED_H
- #define __LED_H
- #include "ch32v10x_conf.h"
- void LED_Init(void); //初始化
- #endif
- #include "led.h"
- void LED_Init(void)
- *
- * uart.h
- *
- * Created on: Nov 19, 2020
- * Author: zxw
- */
- #include "ch32v10x_conf.h"
- #ifndef USER_UART_H_
- #define USER_UART_H_
- <font color="#ff0000">typedef struct</font>
- /*
- * uart.c
- *
- * Created on: Nov 19, 2020
- * Author: zxw
- */
- #include "uart.h"
- <span style="font-family: "Microsoft Yahei", Hei, Tahoma, SimHei, sans-serif; font-weight: 700; background-color: rgb(239, 245, 249);">volatile </span>UARTRECEBUF rece_buf;
- void USART2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
- /*******************************************************************************
- * Function Name : USARTx_CFG
- * Description : Initializes the USART2 peripheral.
- * Input : None
- * Return : None
- *******************************************************************************/
- void USARTx_CFG(void)
3,在main中调用相应函数。
- /********************************** (C) COPYRIGHT *******************************
- * File Name : main.c
- * Author : WCH
- * Version : V1.0.0
- * Date : 2020/04/30
- * Description : Main program body.
- *******************************************************************************/
- /*
- *@Note
- 串口打印调试例程:
- USART1_Tx(PA9)。
- 本例程演示使用 USART1(PA9) 作打印调试口输出。
- */
- #include "ch32v10x_conf.h"
- #include "debug.h"
- #include "uart.h"
- #include "led.h"
- #include "debug.h"
- /* Global typedef */
- /* Global define */
- /* Global Variable */
- extern <span style="font-family: "Microsoft Yahei", Hei, Tahoma, SimHei, sans-serif; font-weight: 700; background-color: rgb(239, 245, 249);">volatile </span>UARTRECEBUF rece_buf;
4,编译。下载。测试。完成。
|