/*
* MD.C
*
* Created on:2015 Year July 16
* Author:administrator
*/
/*
* LEDWC.C
*
* Created on:2015 Year July 16
* Author:administrator
*/
#include "xparameters.h"/* Peripheral Parameters */
#include "xgpio.h"/* GPIO data struct and APIs */
#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 10000000/* 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)
{
Volatileint
int Delay;
int Delay;
U32 Ledbit;
U32 Ledloop;
int Status;
/*
* Initialize the GPIO driver so it's ready for use,
* Specify the device ID that's generated in xparameters.h
*/
Status = Xgpio_initialize (&gpiooutput, DeviceId);
if (Status! = xst_success) {
return xst_failure;
}
Set the direction for all signals to be outputs
Xgpio_setdatadirection (&gpiooutput, Led_channel, 0x0);
Set the GPIO outputs to low
Xgpio_discretewrite (&gpiooutput, Led_channel, 0x0);
for (ledbit = 0x0; Ledbit < Gpiowidth; ledbit++) {
for (ledloop = 0; Ledloop < Led_max_blink; ledloop++) {
Set the GPIO Output to high
Xgpio_discretewrite (&gpiooutput, Led_channel,
1 << ledbit);
Wait a small amount of time so the LEDs are visible
for (Delay = 0; Delay < Led_delay; delay++);
Clear the GPIO Output
Xgpio_discreteclear (&gpiooutput, Led_channel,
1 << ledbit);
Wait a small amount of time so the LEDs are visible
for (Delay = 0; Delay < Led_delay; delay++);
}
}
return xst_success;
}
Main (void)//The int in front of main is removed.
{//application Start
/* Loop forever*/
while (1) {
U32 status;
Status = Gpiomarquee (Gpio_device_id,gpio_bitwidth);
if (status = = 0)
printf ("sucess!. \ r \ n ");
else printf ("failed.\r\n");
}
return xst_success;
}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Zedboard Do running Lights code