7
fsp_err_t R_IOPORT_PortRead (
ioport_ctrl_t *const p_ctrl,
bsp_io_port_t port,
ioport_size_t * p_port_value )
//说明:Reads the value on an IO port. Implements ioport_api_t::portRead.The specified port will be read, and the levels for all the pins will be returned. Each bit in the returned value corresponds to a pin on the port. For example, bit 7 corresponds to pin 7, bit 6 to pin 6, and so on.
R_IOPORT_PortRead(&g_ioport_ctrl, BSP_IO_PORT_00, &p_port_value_port_15);
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 )
//说明:Reads the level on a pin. Implements ioport_api_t::pinRead.
bsp_io_level_t p_port_value_port_151;
R_IOPORT_PinRead(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_15, &p_port_value_port_151);
ioport_size_t p_port_value_port_15;
bsp_io_level_t p_port_value_port_151;
/*******************************************************************************************************************//**
* main() is generated by the RA Configuration editor and is used to generate threads if an RTOS is used. This function
* is called by main() when no RTOS is used.
**********************************************************************************************************************/
void hal_entry(void)
{
/* TODO: add your own code here */
while(1)
{
R_IOPORT_PortRead(&g_ioport_ctrl, BSP_IO_PORT_00, &p_port_value_port_15);
if(p_port_value_port_15 & 0x8000)
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_04, BSP_IO_LEVEL_LOW);
else
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_04, BSP_IO_LEVEL_HIGH);
R_IOPORT_PinRead(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_15, &p_port_value_port_151);
if(p_port_value_port_151)
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_04, BSP_IO_LEVEL_LOW);
else
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_04, BSP_IO_LEVEL_HIGH);
}
#if BSP_TZ_SECURE_BUILD
/* Enter non-secure code */
R_BSP_NonSecureEnter();
#endif
}
视频教学在B站官方账号,欢迎观看B站教学视频~
原文标题:瑞萨e2studio----GPIO输入检测
文章出处:【微信公众号:RA生态工作室】欢迎添加关注!文章转载请注明出处。
全部0条评论
快来发表一下你的评论吧 !