ZYNQ连载07-PIN设备
1. 简述
RT-Thread PIN设备
这里参看RT-Thread提供的PIN设备管理接口,简单封装了几个接口函数。
文章来源地址https://www.toymoban.com/news/detail-717241.html
2. 实现
#include "include/drv_gpio.h"
#define LOG_TAG "drv_gpio"
static XGpioPs xgpiops;
void rt_pin_mode(rt_base_t pin, rt_uint8_t mode)
{
XGpioPs_Config *xgpiops_config;
xgpiops_config = XGpioPs_LookupConfig(XPAR_XGPIOPS_0_DEVICE_ID);
if (XST_SUCCESS != XGpioPs_CfgInitialize(&xgpiops, xgpiops_config, xgpiops_config->BaseAddr))
log_e("XGpioPs_CfgInitialize fail");
switch (mode)
{
case PIN_MODE_OUTPUT:
XGpioPs_SetDirectionPin(&xgpiops, pin, 1);
XGpioPs_SetOutputEnablePin(&xgpiops, pin, 1);
break;
case PIN_MODE_INPUT:
XGpioPs_SetDirectionPin(&xgpiops, pin, 0);
break;
default:
log_e("XGpioPs_SetDirectionPin fail");
break;
}
}
void rt_pin_write(rt_base_t pin, rt_uint8_t value)
{
XGpioPs_WritePin(&xgpiops, pin, value);
}
rt_int8_t rt_pin_read(rt_base_t pin)
{
return (rt_int8_t)XGpioPs_ReadPin(&xgpiops, pin);
}
文章来源:https://www.toymoban.com/news/detail-717241.html
到了这里,关于ZYNQ连载07-PIN设备的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!