打印
[RISC-V MCU 应用开发]

【RISC-V MCU CH32V103测评】+uart测试

[复制链接]
303|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
dami|  楼主 | 2020-11-21 11:49 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 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: &quot;Microsoft Yahei&quot;, 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: &quot;Microsoft Yahei&quot;, Hei, Tahoma, SimHei, sans-serif; font-weight: 700; background-color: rgb(239, 245, 249);">volatile </span>UARTRECEBUF rece_buf;

4,编译。下载。测试。完成。




       

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

61

主题

1042

帖子

5

粉丝