首页 > 数据库技术 > 详细

zedboard 流水灯

时间:2015-07-22 18:55:19      阅读:366      评论:0      收藏:0      [点我收藏+]
#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 流水灯

原文:http://blog.csdn.net/kobesdu/article/details/47005743

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!