PS端MIO EMIO实验

实验内容:控制MIO端口的LED闪烁,闪烁次数16次。
主函数:

int main(void)
{
	int Status;
	u32 InputData;

	printf("GPIO Polled Mode Example Test \r\n");
	Status = GpioPolledExample(GPIO_DEVICE_ID, &InputData);
	if (Status != XST_SUCCESS) {
		printf("GPIO Polled Mode Example Test Failed\r\n");
		return XST_FAILURE;
	}

	printf("Data read from GPIO Input is  0x%x \n\r", (int)InputData);
	printf("Successfully ran GPIO Polled Mode Example Test\r\n");
	return XST_SUCCESS;
}

函数解析:
int GpioPolledExample(u16 DeviceId, u32 *DataRead):

		case XPLAT_ZYNQ:
			Input_Pin = 14;
			Output_Pin = 0;   //控制输出引脚MIO   O  ,即LED的输出
			break;
		}

输出函数:

static int GpioOutputExample(void)
{
	u32 Data;
	volatile int Delay;
	u32 LedLoop;

	/*
	 * Set the direction for the pin to be output and引脚设置为输出
	 * Enable the Output enable for the LED Pin.使能   里面就是在配置寄存器
	 */
	XGpioPs_SetDirectionPin(&Gpio, Output_Pin, 1);      
	XGpioPs_SetOutputEnablePin(&Gpio, Output_Pin, 1); 

	/* Set the GPIO output to be low.   低电平为亮  */  
	XGpioPs_WritePin(&Gpio, Output_Pin, 0x0);

   /*    16次循环   */
	for (LedLoop = 0; LedLoop < LED_MAX_BLINK; LedLoop ++) {


#ifndef __SIM__
		/* Wait a small amount of time so the LED is visible. */
		for (Delay = 0; Delay < LED_DELAY; Delay++);

#endif
		/* Set the GPIO Output to High. */
		XGpioPs_WritePin(&Gpio, Output_Pin, 0x1);

		/*
		 * Read the state of the data and verify. If the data
		 * read back is not the same as the data written then
		 * return FAILURE.
		 */
		Data = XGpioPs_ReadPin(&Gpio, Output_Pin);
		if (Data != 1 ) {
			return XST_FAILURE;
		}

#ifndef __SIM__
		/* Wait a small amount of time so the LED is visible. */
		for (Delay = 0; Delay < LED_DELAY; Delay++);

#endif

		/* Clear the GPIO Output. */
		XGpioPs_WritePin(&Gpio, Output_Pin, 0x0);

		/*
		 * Read the state of the data and verify. If the data
		 * read back is not the same as the data written then
		 * return FAILURE.
		 */
		Data = XGpioPs_ReadPin(&Gpio, Output_Pin);
		if (Data != 0) {
			return XST_FAILURE;
		}
	}
	return XST_SUCCESS;
}


EMIO:

在这里插入图片描述
和PS端的原理差不多,PL端相当于外设的扩展的一部分。需要额外在ZYNQ核上添加,然后经过OUTPUT PRODUCTS 后,顶层文件会有相当的引脚。需要我们对PL端的引脚进行约束。然后SDK 中修改对应的端口地址即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值