问题:使用vivado进行zedboard开发,制作一个简单的流水灯程序以说明软硬件协同设计的方法、开发流程等。
正文:
本文将分为三个部分:
1. 使用Vivado IDE创建一个工程,并构建一个Zynq嵌入式处理系统
2. 在上述基础上,将完成后的硬件导入到SDK中进行软件设计。
3. 最后下载到ZedBoard上进行调试。
/*
* Marquee.c
*
* Created on: 2014-7-3
* Author: ZhouQiang
*/
#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_1_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)
{
volatile int Delay;
u32 LedBit;
u32 LedLoop;
int Status;
/*
* Initialize the GPIO driver so that it's ready to use,
* specify the device ID that is 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 LED is 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 LED is visible
for (Delay = 0; Delay < LED_DELAY; Delay++);
}
}
return XST_SUCCESS;
}
int main(void)
{//Application start
/* loop forever*/
int cnt=0;
while(1)
{
u32 status;
status = GpioMarquee (GPIO_DEVICE_ID,GPIO_BITWIDTH);
if (status == 0)
{
printf("%d:SUCESS!.\r\n",cnt++);
if(cnt>=1000)
cnt=0;
}
else
printf("FAILED.\r\n");
}
return XST_SUCCESS;
}