码迷,mamicode.com
首页 > 数据库 > 详细

zedboard 流水灯

时间:2017-05-14 16:11:38      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:rect   parameter   _id   set   put   cache   param   his   gpio   

#include"xparameters.h"/* Peripheral parameters 外围的參数 */
#include"xgpio.h"/* GPIO data struct and APIs GPIO、结构,应用程序编程接口 */
#include"xil_printf.h"
#include"xil_cache.h"
#define GPIO_BITWIDTH	8	/* This is the width of the GPIO */
#define GPIO_DEVICE_ID  XPAR_AXI_GPIO_0_DEVICE_ID//device id
#define LED_DELAY     40000000/* times delay*/
#define LED_MAX_BLINK	0x1	/* Number of times the LED Blinks */
#define LED_CHANNEL 1/* GPIO channel*/
#define printf xil_printf	/* A smaller footprint printf */
XGpio Gpio; /* The Instance of the GPIO Driver */
XGpio GpioOutput; /* The driver instance for GPIO Device configured as O/P */

int GpioMarquee (u16 DeviceId, u32 GpioWidth)
{
	int Delay;
	u32 LedBit;
	u32 LedLoop;
	int Status;
	 Status = XGpio_Initialize(&GpioOutput, DeviceId);
	if (Status != XST_SUCCESS)  {
		return XST_FAILURE;
	 }
	 XGpio_SetDataDirection(&GpioOutput, LED_CHANNEL, 0x0);//输出模式
	 XGpio_DiscreteWrite(&GpioOutput, LED_CHANNEL, 0x0);
	for (LedBit = 0x0; LedBit < GpioWidth; LedBit++)  {
			XGpio_DiscreteWrite(&GpioOutput, LED_CHANNEL,
						1 << LedBit);
			for (Delay = 0; Delay < LED_DELAY; Delay++);
			XGpio_DiscreteClear(&GpioOutput, LED_CHANNEL,
						1 << LedBit);
	 }
	for (LedBit = 0x07; LedBit >= 0x01; LedBit--)  {
				XGpio_DiscreteWrite(&GpioOutput, LED_CHANNEL,
							1 << LedBit);
				for (Delay = 0; Delay < LED_DELAY; Delay++);
				XGpio_DiscreteClear(&GpioOutput, LED_CHANNEL,
							1 << LedBit);
		 }
	for (LedBit = 0x0; LedBit < GpioWidth; LedBit++)  {
		        LedBit++;
				XGpio_DiscreteWrite(&GpioOutput, LED_CHANNEL,
							1 << LedBit);
				for (Delay = 0; Delay < LED_DELAY; Delay++);
				XGpio_DiscreteClear(&GpioOutput, LED_CHANNEL,
							1 << LedBit);
		 }
	return XST_SUCCESS;
}
 main(void)
{
	while(1){
		u32 status;
		status = GpioMarquee (GPIO_DEVICE_ID,GPIO_BITWIDTH);
			printf("SUCESS!.\r\n");
	}
	return XST_SUCCESS;
}










zedboard 流水灯

标签:rect   parameter   _id   set   put   cache   param   his   gpio   

原文地址:http://www.cnblogs.com/liguangsunls/p/6852673.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!