首页 > 代码库 > zedboard 流水灯
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!.\r\n"); } return XST_SUCCESS; }
zedboard 流水灯
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。