1.新建一个一个工作空间文件夹
![图片.png](//file.elecfans.com/web2/M00/7E/BE/poYBAGOHDgaAN6XlAACsmmHQfTw295.png)
2.创建一个工程
2.1
![图片.png](//file.elecfans.com/web2/M00/7E/BE/poYBAGOHDk6AOSYAAACU2kkw8ls035.png)
2.2
![图片.png](//file.elecfans.com/web2/M00/7F/4A/pYYBAGOHDpeABgpPAACJUS_2UqI684.png)
2.3 选择 FSP 库版本、板子型号、设备(MCU)型号、编程语言、编译器
![图片.png](//file.elecfans.com/web2/M00/7F/4A/pYYBAGOHDxKAYMksAAEgRZ5cNfk099.png)
![图片.png](//file.elecfans.com/web2/M00/7F/4B/pYYBAGOHD3SAXm87AADb3nC9FKE878.png)
![图片.png](//file.elecfans.com/web2/M00/7E/BF/poYBAGOHD56AW46-AAEhGTJM33Q872.png)
2.4
![图片.png](//file.elecfans.com/web2/M00/7F/4B/pYYBAGOHD-eACt82AAE8iZiHLOI752.png)
2.5
![图片.png](//file.elecfans.com/web2/M00/7F/4B/pYYBAGOHD_KALUuvAAB4Ccb2Od0177.png)
2.6
![图片.png](//file.elecfans.com/web2/M00/7E/BF/poYBAGOHECmAHflrAAChxNekqeU894.png)
2.7
![图片.png](//file.elecfans.com/web2/M00/7F/4B/pYYBAGOHEHSAU5C0AAJkto3yr14042.png)
2.8 代码生成
![图片.png](//file.elecfans.com/web2/M00/7F/4B/pYYBAGOHEJeAJ98RAAKIKtqrlFI542.png)
2.9 代码生成结果
![图片.png](//file.elecfans.com/web2/M00/7F/4B/pYYBAGOHELmAblexAAFPFwtzNos111.png)
2.10 通过MDK 打卡RASC配置软件
![图片.png](//file.elecfans.com/web2/M00/7E/BF/poYBAGOHERyADJVRAAH2eO9-N14001.png)
2.11
![图片.png](//file.elecfans.com/web2/M00/7F/4C/pYYBAGOHEaGAFqsnAATQckW-Kbw049.png)
LED硬件信息
3.1 LED
![图片.png](//file.elecfans.com/web2/M00/7F/4D/pYYBAGOHFMSAb8j5AACOKMgaIlw785.png)
3.2 RASC 配置gpio
![图片.png](//file.elecfans.com/web2/M00/7E/C1/poYBAGOHFVaATiOCAAKNvj5xDUA866.png)
![图片.png](//file.elecfans.com/web2/M00/7E/C1/poYBAGOHFWaASZuqAAF4C9xGFYA861.png)
![图片.png](//file.elecfans.com/web2/M00/7E/C1/poYBAGOHFXqAMkPqAAHnXNulcTY690.png)
属性说明:
![图片.png](//file.elecfans.com/web2/M00/7F/4D/pYYBAGOHFdmAGUYuAAICIAse1YE578.png)
生成代码
![图片.png](//file.elecfans.com/web2/M00/7F/4D/pYYBAGOHFf-ARBwaAAKLznbTMGo934.png)
软件编写
软件入口函数
void hal_entry(void)
led 闪烁函数
void hal_entry(void)
{
R_IOPORT_Open (&g_ioport_ctrl, g_ioport.p_cfg);
while(1)
{
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_LOW);
R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_HIGH);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_LOW);
R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_HIGH);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_15, BSP_IO_LEVEL_LOW);
R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_15, BSP_IO_LEVEL_HIGH);
}
#if BSP_TZ_SECURE_BUILD
R_BSP_NonSecureEnter();
#endif
}
系统延时函数
可选的时间单位
```c
typedef enum
{
BSP_DELAY_UNITS_SECONDS = 1000000, ///< Requested delay amount is in seconds
BSP_DELAY_UNITS_MILLISECONDS = 1000, ///< Requested delay amount is in milliseconds
BSP_DELAY_UNITS_MICROSECONDS = 1 ///< Requested delay amount is in microseconds
} bsp_delay_units_t;
gpio相关的函数
fsp_err_t R_IOPORT_Open(ioport_ctrl_t * const p_ctrl, const ioport_cfg_t * p_cfg);
fsp_err_t R_IOPORT_Close(ioport_ctrl_t * const p_ctrl);
fsp_err_t R_IOPORT_PinsCfg(ioport_ctrl_t * const p_ctrl, const ioport_cfg_t * p_cfg);
fsp_err_t R_IOPORT_PinCfg(ioport_ctrl_t * const p_ctrl, bsp_io_port_pin_t pin, uint32_t cfg);
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);
fsp_err_t R_IOPORT_PinEventOutputWrite(ioport_ctrl_t * const p_ctrl, bsp_io_port_pin_t pin, bsp_io_level_t pin_value);
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);
fsp_err_t R_IOPORT_PinWrite(ioport_ctrl_t * const p_ctrl, bsp_io_port_pin_t pin, bsp_io_level_t level);
fsp_err_t R_IOPORT_PortDirectionSet(ioport_ctrl_t * const p_ctrl,
bsp_io_port_t port,
ioport_size_t direction_values,
ioport_size_t mask);
fsp_err_t R_IOPORT_PortEventInputRead(ioport_ctrl_t * const p_ctrl, bsp_io_port_t port, ioport_size_t * event_data);
fsp_err_t R_IOPORT_PortEventOutputWrite(ioport_ctrl_t * const p_ctrl,
bsp_io_port_t port,
ioport_size_t event_data,
ioport_size_t mask_value);
fsp_err_t R_IOPORT_PortRead(ioport_ctrl_t * const p_ctrl, bsp_io_port_t port, ioport_size_t * p_port_value);
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);
审核编辑 黄昊宇