Zedboard Do running Lights code

Source: Internet
Author: User

/*
* 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.