[RISC-V MCU 应用开发] 【RISC-V MCU CH32V103测评】+uart测试

[复制链接]
 楼主| 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就出现在工程中。
  1. #ifndef __LED_H
  2. #define __LED_H
  3.     #include "ch32v10x_conf.h"
  4.     void LED_Init(void);  //初始化
  5. #endif
  1. #include "led.h"
  2. void LED_Init(void)
  1. *
  2. * uart.h
  3. *
  4. *  Created on: Nov 19, 2020
  5. *      Author: zxw
  6. */
  7. #include "ch32v10x_conf.h"
  8. #ifndef USER_UART_H_
  9. #define USER_UART_H_
  10. <font color="#ff0000">typedef struct</font>
  1. /*
  2. * uart.c
  3. *
  4. *  Created on: Nov 19, 2020
  5. *      Author: zxw
  6. */
  7. #include "uart.h"
  8. <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;
  9. void USART2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));

  10. /*******************************************************************************
  11. * Function Name  : USARTx_CFG
  12. * Description    : Initializes the USART2  peripheral.
  13. * Input          : None
  14. * Return         : None
  15. *******************************************************************************/
  16. void USARTx_CFG(void)

3,在main中调用相应函数。
  1. /********************************** (C) COPYRIGHT *******************************
  2. * File Name          : main.c
  3. * Author             : WCH
  4. * Version            : V1.0.0
  5. * Date               : 2020/04/30
  6. * Description        : Main program body.
  7. *******************************************************************************/

  8. /*
  9. *@Note
  10. 串口打印调试例程:
  11. USART1_Tx(PA9)。
  12. 本例程演示使用 USART1(PA9) 作打印调试口输出。

  13. */
  14. #include "ch32v10x_conf.h"
  15. #include "debug.h"
  16. #include "uart.h"
  17. #include "led.h"
  18. #include "debug.h"


  19. /* Global typedef */

  20. /* Global define */

  21. /* Global Variable */
  22. 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,编译。下载。测试。完成。
4.PNG

6.PNG

    微信图片_20201121125919.jpg    
您需要登录后才可以回帖 登录 | 注册

本版积分规则

66

主题

1077

帖子

6

粉丝
快速回复 在线客服 返回列表 返回顶部

66

主题

1077

帖子

6

粉丝
快速回复 在线客服 返回列表 返回顶部