查看: 625|回复: 1

【瑞萨RA4系列开发板体验】使用 RASC 生成 Keil 工程+点亮LED

[复制链接]

116

主题

133

帖子

3768

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3768
发表于 2023-2-7 16:18:08 | 显示全部楼层 |阅读模式
【瑞萨RA4系列开发板体验】使用 RASC 生成 Keil 工程+点亮LED
作者:jf_92517703


1.新建一个工空间文件夹作

2.创建一个工程
2.1

2.2

2.3 选择 FSP 库版本、板子型号、设备(MCU)型号、编程语言、编译器



2.4

2.5

2.6

2.7

2.8 代码生成

2.9 代码生成结果

2.10 通过MDK 打卡RASC配置软件

2.11

LED硬件信息
3.1 LED

3.2 RASC 配置gpio



属性说明:

生成代码

软件编写
软件入口函数
  1. void hal_entry(void)
复制代码
led 闪烁函数
  1. void hal_entry(void)
  2. {
  3.     /* TODO: add your own code here */
  4.         //初始化io
  5.         R_IOPORT_Open (&g_ioport_ctrl, g_ioport.p_cfg);
  6.         //
  7.         while(1)
  8.         {
  9.                 R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_LOW);
  10.                 R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS); //延时 100毫秒
  11.                 R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_HIGH);
  12.                 R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_LOW);
  13.                 R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS); //延时 100毫秒
  14.                 R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_HIGH);
  15.                 R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_15, BSP_IO_LEVEL_LOW);
  16.                 R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS); //延时 100毫秒
  17.                 R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_15, BSP_IO_LEVEL_HIGH);
  18.         }
  19. #if BSP_TZ_SECURE_BUILD
  20.     /* Enter non-secure code */
  21.     R_BSP_NonSecureEnter();
  22. #endif
  23. }
复制代码
系统延时函数
  1. /*


  2. void R_BSP_SoftwareDelay (uint32_t delay, bsp_delay_units_t units)
  3. delay:时间数量
  4. units:时间单位
  5. */
复制代码
可选的时间单位
  1. ```c

  2. typedef enum
  3. {
  4.     BSP_DELAY_UNITS_SECONDS      = 1000000, ///< Requested delay amount is in seconds
  5.     BSP_DELAY_UNITS_MILLISECONDS = 1000,    ///< Requested delay amount is in milliseconds
  6.     BSP_DELAY_UNITS_MICROSECONDS = 1        ///< Requested delay amount is in microseconds
  7. } bsp_delay_units_t;
复制代码
gpio相关函数
  1. fsp_err_t R_IOPORT_Open(ioport_ctrl_t * const p_ctrl, const ioport_cfg_t * p_cfg);
  2. fsp_err_t R_IOPORT_Close(ioport_ctrl_t * const p_ctrl);
  3. fsp_err_t R_IOPORT_PinsCfg(ioport_ctrl_t * const p_ctrl, const ioport_cfg_t * p_cfg);
  4. fsp_err_t R_IOPORT_PinCfg(ioport_ctrl_t * const p_ctrl, bsp_io_port_pin_t pin, uint32_t cfg);
  5. fsp_err_t R_IOPORT_PinEventInputRead(ioport_ctrl_t * const p_ctrl, bsp_io_port_pin_t pin, bsp_io_level_t * p_pin_event);
  6. fsp_err_t R_IOPORT_PinEventOutputWrite(ioport_ctrl_t * const p_ctrl, bsp_io_port_pin_t pin, bsp_io_level_t pin_value);
  7. fsp_err_t R_IOPORT_PinRead(ioport_ctrl_t * const p_ctrl, bsp_io_port_pin_t pin, bsp_io_level_t * p_pin_value);
  8. fsp_err_t R_IOPORT_PinWrite(ioport_ctrl_t * const p_ctrl, bsp_io_port_pin_t pin, bsp_io_level_t level);
  9. fsp_err_t R_IOPORT_PortDirectionSet(ioport_ctrl_t * const p_ctrl,
  10.                                     bsp_io_port_t         port,
  11.                                     ioport_size_t         direction_values,
  12.                                     ioport_size_t         mask);
  13. fsp_err_t R_IOPORT_PortEventInputRead(ioport_ctrl_t * const p_ctrl, bsp_io_port_t port, ioport_size_t * event_data);
  14. fsp_err_t R_IOPORT_PortEventOutputWrite(ioport_ctrl_t * const p_ctrl,
  15.                                         bsp_io_port_t         port,
  16.                                         ioport_size_t         event_data,
  17.                                         ioport_size_t         mask_value);
  18. fsp_err_t R_IOPORT_PortRead(ioport_ctrl_t * const p_ctrl, bsp_io_port_t port, ioport_size_t * p_port_value);
  19. fsp_err_t R_IOPORT_PortWrite(ioport_ctrl_t * const p_ctrl, bsp_io_port_t port, ioport_size_t value, ioport_size_t mask);
复制代码


回复

使用道具 举报

3

主题

195

帖子

1206

积分

金牌会员

Rank: 6Rank: 6

积分
1206
发表于 2023-3-14 11:01:27 | 显示全部楼层

不错,学习一下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

用户排行榜

RA助手

主题: 116帖子:133精华:0

RA_Lance

主题: 92帖子:132精华:9

lugl

主题: 38帖子:126精华:0

xujiwei263

主题: 16帖子:73精华:0

books咦

主题: 11帖子:11精华:2

Juggernaut

主题: 9帖子:95精华:0
快速回复 返回顶部 返回列表