zoukankan      html  css  js  c++  java
  • zedboard 流水灯

    #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!.
    ");
    	}
    	return XST_SUCCESS;
    }
    
    
    
    
    
    
    
    
    
    

  • 相关阅读:
    判断pc端或移动端并跳转
    拖动验证码插件
    angularjs 简易模态框
    angularjs 设置全局变量的3种方法
    摄影之HDR
    CentOS上使用yum安装Apache
    CentOs6.5中安装和配置vsftp简明教程
    python 安装easy_install和pip
    linux mysql 操作命令
    .net源码分析
  • 原文地址:https://www.cnblogs.com/liguangsunls/p/6852673.html
Copyright © 2011-2022 走看看