ZDMA_v1_0: Added examples to ZDMA driver.
Signed-off-by: VNSL Durga <vnsldurg@xilinx.com>
This commit is contained in:
parent
08aea016bb
commit
16795cbacf
7 changed files with 1896 additions and 0 deletions
32
XilinxProcessorIPLib/drivers/zdma/examples/index.html
Executable file
32
XilinxProcessorIPLib/drivers/zdma/examples/index.html
Executable file
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Driver example applications</title>
|
||||
<link rel="stylesheet" type="text/css" href="../help.css">
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<h1> Example Applications for the driver ccm_v5_0 </h1>
|
||||
<HR>
|
||||
<ul>
|
||||
<li>xzdma_selftest_example.c <a href="xzdma_selftest_example.c">(source)</a> </li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>xzdma_writeonlymode_example.c <a href="xzdma_writeonlymode_example.c">(source)</a> </li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>xzdma_writeonlymode_example.c <a href="xzdma_writeonlymode_example.c">(source)</a> </li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>xzdma_simple_example.c <a href="xzdma_simple_example.c">(source)</a> </li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>xzdma_linear_example.c <a href="xzdma_linear_example.c">(source)</a> </li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>xzdma_linkedlist_example.c <a href="xzdma_linkedlist_example.c">(source)</a> </li>
|
||||
</ul>
|
||||
<p><font face="Times New Roman" color="#800000">Copyright <20> 1995-2014 Xilinx, Inc. All rights reserved.</font></p>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,375 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xzdma_linear_example.c
|
||||
*
|
||||
* This file contains the example using XZDma driver to do data transfer in
|
||||
* Linear mode on ZDMA device.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- -----------------------------------------------------
|
||||
* 1.0 vns 2/27/15 First release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xzdma.h"
|
||||
#include "xparameters.h"
|
||||
#include "xscugic.h"
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
int XZDma_LinearExample(u16 DeviceId);
|
||||
static int SetupInterruptSystem(XScuGic *IntcInstancePtr,
|
||||
XZDma *InstancePtr, u16 IntrId);
|
||||
static void DoneHandler(void *CallBackRef);
|
||||
static void ErrorHandler(void *CallBackRef, u32 Mask);
|
||||
|
||||
/************************** Constant Definitions ******************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#define ZDMA_DEVICE_ID XPAR_XZDMA_0_DEVICE_ID /* ZDMA device Id */
|
||||
#define ZDMA_INTC_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID
|
||||
/**< SCUGIC Device ID */
|
||||
#define ZDMA_INTR_DEVICE_ID XPAR_XADMAPS_0_INTR/**< ZDMA Interrupt Id */
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
XZDma ZDma; /**<Instance of the ZDMA Device */
|
||||
XScuGic Intc; /**< XIntc Instance */
|
||||
u32 DstBuf[256] __attribute__ ((aligned (64))); /**< Destination buffer */
|
||||
u32 SrcBuf[256] __attribute__ ((aligned (64))); /**< Source buffer */
|
||||
u32 Dst1Buf[400] __attribute__ ((aligned (64)));/**< Destination buffer */
|
||||
u32 Src1Buf[400] __attribute__ ((aligned (64)));/**< Source buffer */
|
||||
u32 AlloMem[200] __attribute__ ((aligned (64)));
|
||||
/**< memory allocated for descriptors */
|
||||
u8 Done = 0; /**< Variable for Done interrupt */
|
||||
u8 Pause = 0; /**< Variable for Pause interrupt */
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function to call the example.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
int Status;
|
||||
|
||||
/* Run the Linear example */
|
||||
Status = XZDma_LinearExample((u16)ZDMA_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
xil_printf("ZDMA Example Failed\r\n");
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
xil_printf("Successfully ran ZDMA Linear mode Example\r\n");
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function does a test of the data transfer in linear mode on the ZDMA
|
||||
* driver.
|
||||
*
|
||||
* @param DeviceId is the XPAR_<ZDMA Instance>_DEVICE_ID value from
|
||||
* xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XZDma_LinearExample(u16 DeviceId)
|
||||
{
|
||||
int Status;
|
||||
XZDma_Config *Config;
|
||||
XZDma_DataConfig Configure; /**< Configuration values */
|
||||
XZDma_Transfer Data[2];
|
||||
u32 Value;
|
||||
u32 Index;
|
||||
|
||||
/*
|
||||
* Initialize the ZDMA driver so that it's ready to use.
|
||||
* Look up the configuration in the config table,
|
||||
* then initialize it.
|
||||
*/
|
||||
Config = XZDma_LookupConfig(DeviceId);
|
||||
if (NULL == Config) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XZDma_CfgInitialize(&ZDma, Config, Config->BaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
/*
|
||||
* Performs the self-test to check hardware build.
|
||||
*/
|
||||
Status = XZDma_SelfTest(&ZDma);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/* Filling the buffers for data transfer */
|
||||
Value = 0x1230;
|
||||
for (Index = 0; Index < 5; Index++) {
|
||||
SrcBuf[Index] = Value++;
|
||||
}
|
||||
Value = 0x002345F;
|
||||
for (Index = 0; Index < 5; Index++) {
|
||||
Src1Buf[Index] = Value++;
|
||||
}
|
||||
|
||||
/* ZDMA has set in simple transfer of Normal mode */
|
||||
Status = XZDma_SetMode(&ZDma, TRUE, XZDMA_NORMAL_MODE);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/* Allocated memory starting address should be 64 bit aligned */
|
||||
XZDma_CreateBDList(&ZDma, XZDMA_LINEAR, (UINTPTR)AlloMem, 256);
|
||||
|
||||
/* Interrupt call back has been set */
|
||||
XZDma_SetCallBack(&ZDma, XZDMA_HANDLER_DONE,
|
||||
(void *)DoneHandler, &ZDma);
|
||||
XZDma_SetCallBack(&ZDma, XZDMA_HANDLER_ERROR,
|
||||
(void *)ErrorHandler, &ZDma);
|
||||
/*
|
||||
* Connect to the interrupt controller.
|
||||
*/
|
||||
Status = SetupInterruptSystem(&Intc, &(ZDma),
|
||||
ZDMA_INTR_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/* Configuration settings */
|
||||
XZDma_GetChDataConfig(&ZDma, &Configure);
|
||||
Configure.OverFetch = 0;
|
||||
Configure.SrcIssue = 0x1F;
|
||||
Configure.SrcBurstType = XZDMA_INCR_BURST;
|
||||
Configure.SrcBurstLen = 0xF;
|
||||
Configure.DstBurstType = XZDMA_INCR_BURST;
|
||||
Configure.DstBurstLen = 0xF;
|
||||
XZDma_SetChDataConfig(&ZDma, &Configure);
|
||||
|
||||
/* Enable required interrupts */
|
||||
XZDma_EnableIntr(&ZDma, (XZDMA_IXR_DMA_DONE_MASK |
|
||||
XZDMA_IXR_DMA_PAUSE_MASK));
|
||||
|
||||
/* Filling the data transfer elements */
|
||||
Data[0].SrcAddr = (UINTPTR)SrcBuf;
|
||||
Data[0].Size = 1000;
|
||||
Data[0].DstAddr = (UINTPTR)DstBuf;
|
||||
Data[0].SrcCoherent = 0;
|
||||
Data[0].DstCoherent = 0;
|
||||
Data[0].Pause = 1;
|
||||
|
||||
Data[1].SrcAddr = (UINTPTR)Src1Buf;
|
||||
Data[1].Size = 1200;
|
||||
Data[1].DstAddr = (UINTPTR)Dst1Buf;
|
||||
Data[1].SrcCoherent = 0;
|
||||
Data[1].DstCoherent = 0;
|
||||
Data[1].Pause = 0;
|
||||
/*
|
||||
* Invalidating destination address and flushing
|
||||
* source address in cache before the start of DMA data transfer.
|
||||
*/
|
||||
Xil_DCacheFlushRange((INTPTR)Data[0].SrcAddr, Data[0].Size);
|
||||
Xil_DCacheInvalidateRange((INTPTR)Data[0].DstAddr, Data[0].Size);
|
||||
Xil_DCacheFlushRange((INTPTR)Data[1].SrcAddr, Data[1].Size);
|
||||
Xil_DCacheInvalidateRange((INTPTR)Data[1].DstAddr, Data[1].Size);
|
||||
|
||||
XZDma_Start(&ZDma, Data, 2); /* Initiates the data transfer */
|
||||
|
||||
/* wait until pause interrupt is generated and has been resumed */
|
||||
while (Pause == 0);
|
||||
|
||||
/* Resuming the ZDMA core */
|
||||
XZDma_Resume(&ZDma);
|
||||
|
||||
while (Done == 0); /* Wait till DMA done interrupt generated */
|
||||
|
||||
/* Validating the data transfer */
|
||||
for (Index = 0; Index < 250; Index++) {
|
||||
if (SrcBuf[Index] != DstBuf[Index]) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
}
|
||||
for (Index = 0; Index < 300; Index++) {
|
||||
if (Src1Buf[Index] != Dst1Buf[Index]) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function sets up the interrupt system so interrupts can occur for the
|
||||
* ZDMA. This function is application-specific. The user should modify this
|
||||
* function to fit the application.
|
||||
*
|
||||
* @param IntcInstancePtr is a pointer to the instance of the INTC.
|
||||
* @param InstancePtr contains a pointer to the instance of the ZDMA
|
||||
* driver which is going to be connected to the interrupt
|
||||
* controller.
|
||||
* @param IntrId is the interrupt Id and is typically
|
||||
* XPAR_<ZDMA_instance>_INTR value from xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful
|
||||
* - XST_FAILURE if failed
|
||||
*
|
||||
* @note None.
|
||||
|
||||
*
|
||||
****************************************************************************/
|
||||
static int SetupInterruptSystem(XScuGic *IntcInstancePtr,
|
||||
XZDma *InstancePtr, u16 IntrId)
|
||||
{
|
||||
int Status;
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
XScuGic_Config *IntcConfig; /* Config for interrupt controller */
|
||||
|
||||
/*
|
||||
* Initialize the interrupt controller driver
|
||||
*/
|
||||
IntcConfig = XScuGic_LookupConfig(ZDMA_INTC_DEVICE_ID);
|
||||
if (NULL == IntcConfig) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XScuGic_CfgInitialize(IntcInstancePtr, IntcConfig,
|
||||
IntcConfig->CpuBaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Connect the interrupt controller interrupt handler to the
|
||||
* hardware interrupt handling logic in the processor.
|
||||
*/
|
||||
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
|
||||
(Xil_ExceptionHandler) XScuGic_InterruptHandler,
|
||||
IntcInstancePtr);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Connect a device driver handler that will be called when an
|
||||
* interrupt for the device occurs, the device driver handler
|
||||
* performs the specific interrupt processing for the device
|
||||
*/
|
||||
Status = XScuGic_Connect(IntcInstancePtr, IntrId,
|
||||
(Xil_ExceptionHandler) XZDma_IntrHandler,
|
||||
(void *) InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the interrupt for the device
|
||||
*/
|
||||
XScuGic_Enable(IntcInstancePtr, IntrId);
|
||||
|
||||
|
||||
/*
|
||||
* Enable interrupts
|
||||
*/
|
||||
Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);
|
||||
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This static function handles ZDMA Done interrupts.
|
||||
*
|
||||
* @param CallBackRef is the callback reference passed from the interrupt
|
||||
* handler, which in our case is a pointer to the driver instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
static void DoneHandler(void *CallBackRef)
|
||||
{
|
||||
Done = 1;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This static function handles ZDMA pause interrupts.
|
||||
*
|
||||
* @param CallBackRef is the callback reference passed from the interrupt
|
||||
* handler, which in our case is a pointer to the driver instance.
|
||||
* @param Event specifies which interrupts were occurred.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
static void ErrorHandler(void *CallBackRef, u32 Mask)
|
||||
{
|
||||
Pause = 1;
|
||||
}
|
|
@ -0,0 +1,353 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xzdma_linkedlist_example.c
|
||||
*
|
||||
* This file contains the example using XZDma driver to do data transfer in
|
||||
* Linked list mode on ZDMA device.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- -----------------------------------------------------
|
||||
* 1.0 vns 2/27/15 First release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xzdma.h"
|
||||
#include "xparameters.h"
|
||||
#include "xscugic.h"
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
int XZDma_LinkedListExample(u16 DeviceId);
|
||||
static int SetupInterruptSystem(XScuGic *IntcInstancePtr,
|
||||
XZDma *InstancePtr, u16 IntrId);
|
||||
static void DoneHandler(void *CallBackRef);
|
||||
|
||||
/************************** Constant Definitions ******************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#define ZDMA_DEVICE_ID XPAR_XZDMA_0_DEVICE_ID /* ZDMA device Id */
|
||||
#define ZDMA_INTC_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID
|
||||
/**< SCUGIC Device ID */
|
||||
#define ZDMA_INTR_DEVICE_ID XPAR_XADMAPS_0_INTR /**< ZDMA Interrupt Id */
|
||||
#define TESTDATA1 0xABCD1230 /**< Test data */
|
||||
#define TESTDATA2 0x00005000 /**< Test data */
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
XZDma ZDma; /**<Instance of the ZDMA Device */
|
||||
XScuGic Intc; /**< XIntc Instance */
|
||||
|
||||
u32 SrcBuf[256] __attribute__ ((aligned (64)));
|
||||
u32 DstBuf[256] __attribute__ ((aligned (64)));
|
||||
|
||||
u32 *Src1Buf = (u32 *)0x500000;
|
||||
u32 *Dst1Buf = (u32 *)0x800000;
|
||||
|
||||
u32 AlloMem[200] __attribute__ ((aligned (64)));
|
||||
u8 Done = 0;
|
||||
u8 Pause = 0;
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function to call the example.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
int Status;
|
||||
|
||||
/* Run the Linked list example */
|
||||
Status = XZDma_LinkedListExample((u16)ZDMA_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
xil_printf("ZDMA Example Failed\r\n");
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
xil_printf("Successfully ran ZDMA Linked list Example\r\n");
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function does a test of the data transfer in linked mode on the ZDMA
|
||||
* driver.
|
||||
*
|
||||
* @param DeviceId is the XPAR_<ZDMA Instance>_DEVICE_ID value from
|
||||
* xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XZDma_LinkedListExample(u16 DeviceId)
|
||||
{
|
||||
int Status;
|
||||
XZDma_Config *Config;
|
||||
XZDma_DataConfig Configur; /**< Configuration values */
|
||||
XZDma_Transfer Data[2];
|
||||
u32 Value;
|
||||
u32 Index;
|
||||
/*
|
||||
* Initialize the ZDMA driver so that it's ready to use.
|
||||
* Look up the configuration in the config table,
|
||||
* then initialize it.
|
||||
*/
|
||||
Config = XZDma_LookupConfig(DeviceId);
|
||||
if (NULL == Config) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XZDma_CfgInitialize(&ZDma, Config, Config->BaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Performs the self-test to check hardware build.
|
||||
*/
|
||||
Status = XZDma_SelfTest(&ZDma);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
/* Filling the buffers for data transfer */
|
||||
Value = TESTDATA1;
|
||||
for (Index = 0; Index < 250; Index++) {
|
||||
SrcBuf[Index] = Value++;
|
||||
}
|
||||
Value = TESTDATA2;
|
||||
for (Index = 0; Index < 4; Index++) {
|
||||
*(Src1Buf+Index) = Value++;
|
||||
}
|
||||
|
||||
/* ZDMA has set in linked list mode for normal transfer */
|
||||
Status = XZDma_SetMode(&ZDma, TRUE, XZDMA_NORMAL_MODE);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/* Allocated memory starting address should be 64 bit aligned */
|
||||
XZDma_CreateBDList(&ZDma, XZDMA_LINKEDLIST, (UINTPTR)AlloMem, 256);
|
||||
|
||||
/* Interrupt call back has been set */
|
||||
XZDma_SetCallBack(&ZDma, XZDMA_HANDLER_DONE,
|
||||
(void *)DoneHandler, &ZDma);
|
||||
|
||||
/*
|
||||
* Connect to the interrupt controller.
|
||||
*/
|
||||
Status = SetupInterruptSystem(&Intc, &(ZDma),
|
||||
ZDMA_INTR_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
/*
|
||||
* All the configurations are kept as is which was got
|
||||
* through XZDma_GetChDataConfig and only over fetch is disabled
|
||||
*/
|
||||
/* Configuration settings */
|
||||
XZDma_GetChDataConfig(&ZDma, &Configur);
|
||||
Configur.OverFetch = 0;
|
||||
XZDma_SetChDataConfig(&ZDma, &Configur);
|
||||
|
||||
/* Enable required interrupts */
|
||||
XZDma_EnableIntr(&ZDma, XZDMA_IXR_DMA_DONE_MASK);
|
||||
|
||||
/* Filling the data transfer elements */
|
||||
Data[0].SrcAddr = (UINTPTR)SrcBuf;
|
||||
Data[0].Size = 1000;
|
||||
Data[0].DstAddr = (UINTPTR)DstBuf;
|
||||
Data[0].SrcCoherent = 0;
|
||||
Data[0].DstCoherent = 0;
|
||||
Data[0].Pause = 0;
|
||||
|
||||
Data[1].SrcAddr = (UINTPTR)Src1Buf;
|
||||
Data[1].Size = 16;
|
||||
Data[1].DstAddr = (UINTPTR)Dst1Buf;
|
||||
Data[1].SrcCoherent = 0;
|
||||
Data[1].DstCoherent = 0;
|
||||
Data[1].Pause = 0;
|
||||
/*
|
||||
* Invalidating destination address and flushing
|
||||
* source address in cache before initiating the data transfer
|
||||
*/
|
||||
Xil_DCacheFlushRange((INTPTR)Data[0].SrcAddr, Data[0].Size);
|
||||
Xil_DCacheInvalidateRange((INTPTR)Data[0].DstAddr, Data[0].Size);
|
||||
Xil_DCacheFlushRange((INTPTR)Data[1].SrcAddr, Data[1].Size);
|
||||
Xil_DCacheInvalidateRange((INTPTR)Data[1].DstAddr, Data[1].Size);
|
||||
|
||||
XZDma_Start(&ZDma, Data, 2); /* Initiates the data transfer */
|
||||
|
||||
while (Done == 0); /* Wait till DMA done interrupt generated */
|
||||
|
||||
XZDma_DisableIntr(&ZDma, XZDMA_IXR_DMA_DONE_MASK);
|
||||
|
||||
/* Validating the data transfer */
|
||||
for (Index = 0; Index < 250; Index++) {
|
||||
if (SrcBuf[Index] != DstBuf[Index]) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
}
|
||||
for (Index = 0; Index < 4; Index++) {
|
||||
if (Src1Buf[Index] != Dst1Buf[Index]) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function sets up the interrupt system so interrupts can occur for the
|
||||
* ZDMA. This function is application-specific. The user should modify this
|
||||
* function to fit the application.
|
||||
*
|
||||
* @param IntcInstancePtr is a pointer to the instance of the INTC.
|
||||
* @param InstancePtr contains a pointer to the instance of the ZDMA
|
||||
* driver which is going to be connected to the interrupt
|
||||
* controller.
|
||||
* @param IntrId is the interrupt Id and is typically
|
||||
* XPAR_<ZDMA_instance>_INTR value from xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful
|
||||
* - XST_FAILURE if failed
|
||||
*
|
||||
* @note None.
|
||||
|
||||
*
|
||||
****************************************************************************/
|
||||
static int SetupInterruptSystem(XScuGic *IntcInstancePtr,
|
||||
XZDma *InstancePtr, u16 IntrId)
|
||||
{
|
||||
int Status;
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
XScuGic_Config *IntcConfig; /* Config for interrupt controller */
|
||||
|
||||
/*
|
||||
* Initialize the interrupt controller driver
|
||||
*/
|
||||
IntcConfig = XScuGic_LookupConfig(ZDMA_INTC_DEVICE_ID);
|
||||
if (NULL == IntcConfig) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XScuGic_CfgInitialize(IntcInstancePtr, IntcConfig,
|
||||
IntcConfig->CpuBaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Connect the interrupt controller interrupt handler to the
|
||||
* hardware interrupt handling logic in the processor.
|
||||
*/
|
||||
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
|
||||
(Xil_ExceptionHandler) XScuGic_InterruptHandler,
|
||||
IntcInstancePtr);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Connect a device driver handler that will be called when an
|
||||
* interrupt for the device occurs, the device driver handler
|
||||
* performs the specific interrupt processing for the device
|
||||
*/
|
||||
Status = XScuGic_Connect(IntcInstancePtr, IntrId,
|
||||
(Xil_ExceptionHandler) XZDma_IntrHandler,
|
||||
(void *) InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the interrupt for the device
|
||||
*/
|
||||
XScuGic_Enable(IntcInstancePtr, IntrId);
|
||||
|
||||
|
||||
/*
|
||||
* Enable interrupts
|
||||
*/
|
||||
Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);
|
||||
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This static function handles ZDMA Done interrupts.
|
||||
*
|
||||
* @param CallBackRef is the callback reference passed from the interrupt
|
||||
* handler, which in our case is a pointer to the driver instance.
|
||||
* @param Event specifies which interrupts were occurred.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
static void DoneHandler(void *CallBackRef)
|
||||
{
|
||||
|
||||
Done = 1;
|
||||
|
||||
}
|
|
@ -0,0 +1,318 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xzdma_simple_example.c
|
||||
*
|
||||
* This file contains the example using XZDma driver to do simple data read
|
||||
* on ZDMA device.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- ------------------------------------------------------
|
||||
* 1.0 vns 2/27/15 First release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xzdma.h"
|
||||
#include "xparameters.h"
|
||||
#include "xscugic.h"
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
int XZDma_SimpleReadOnlyExample(u16 DeviceId);
|
||||
static int SetupInterruptSystem(XScuGic *IntcInstancePtr,
|
||||
XZDma *InstancePtr, u16 IntrId);
|
||||
static void DoneHandler(void *CallBackRef);
|
||||
|
||||
/************************** Constant Definitions ******************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#define ZDMA_DEVICE_ID XPAR_XZDMA_0_DEVICE_ID /* ZDMA device Id */
|
||||
#define ZDMA_INTC_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID
|
||||
/**< SCUGIC Device ID */
|
||||
#define ZDMA_INTR_DEVICE_ID XPAR_XADMAPS_0_INTR/**< ZDMA Interrupt Id */
|
||||
|
||||
#define SIZE 100 /**< Size of the data to be
|
||||
* transferred */
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
XZDma ZDma; /**<Instance of the ZDMA Device */
|
||||
XScuGic Intc; /**< XIntc Instance */
|
||||
u32 SrcBuf[256]; /**< Source buffer */
|
||||
u8 Done = 0; /**< Done flag */
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function to call the example.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
int Status;
|
||||
|
||||
/* Run the simple read only example */
|
||||
Status = XZDma_SimpleReadOnlyExample((u16)ZDMA_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
xil_printf("ZDMA Example Failed\r\n");
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
xil_printf("Successfully ran ZDMA Read Only Example\r\n");
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function does a test of the data transfer in simple mode of read only
|
||||
* mode on the ZDMA driver.
|
||||
*
|
||||
* @param DeviceId is the XPAR_<ZDMA Instance>_DEVICE_ID value from
|
||||
* xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XZDma_SimpleReadOnlyExample(u16 DeviceId)
|
||||
{
|
||||
int Status;
|
||||
XZDma_Config *Config;
|
||||
XZDma_DataConfig Configur; /**< Configuration values */
|
||||
XZDma_Transfer Data;
|
||||
u32 Value;
|
||||
u32 Index;
|
||||
|
||||
/*
|
||||
* Initialize the ZDMA driver so that it's ready to use.
|
||||
* Look up the configuration in the config table,
|
||||
* then initialize it.
|
||||
*/
|
||||
Config = XZDma_LookupConfig(DeviceId);
|
||||
if (NULL == Config) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XZDma_CfgInitialize(&ZDma, Config, Config->BaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Performs the self-test to check hardware build.
|
||||
*/
|
||||
Status = XZDma_SelfTest(&ZDma);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
/* Filling the buffer for data transfer */
|
||||
Value = 0xABCD1230;
|
||||
for (Index = 0; Index < 256; Index++) {
|
||||
SrcBuf[Index] = Value++;
|
||||
}
|
||||
/*
|
||||
* Flushing source address in cache
|
||||
*/
|
||||
Xil_DCacheFlushRange((INTPTR)SrcBuf, SIZE);
|
||||
|
||||
/* ZDMA has set in simple transfer of Read only mode */
|
||||
Status = XZDma_SetMode(&ZDma, FALSE, XZDMA_RDONLY_MODE);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
(void)XZDma_SetCallBack(&ZDma, XZDMA_HANDLER_DONE,
|
||||
DoneHandler, &ZDma);
|
||||
/*
|
||||
* Connect to the interrupt controller.
|
||||
*/
|
||||
Status = SetupInterruptSystem(&Intc, &(ZDma),
|
||||
ZDMA_INTR_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/* Configuration settings */
|
||||
Configur.OverFetch = 0;
|
||||
Configur.SrcIssue = 0x1F;
|
||||
Configur.SrcBurstType = XZDMA_INCR_BURST;
|
||||
Configur.SrcBurstLen = 0xF;
|
||||
Configur.DstBurstType = XZDMA_INCR_BURST;
|
||||
Configur.DstBurstLen = 0xF;
|
||||
XZDma_SetChDataConfig(&ZDma, &Configur);
|
||||
|
||||
/* Enable required interrupts */
|
||||
XZDma_EnableIntr(&ZDma, XZDMA_IXR_DMA_DONE_MASK);
|
||||
/*
|
||||
* Transfer elements
|
||||
*/
|
||||
Data.DstAddr = 0;
|
||||
Data.DstCoherent = 0;
|
||||
Data.Pause = 0;
|
||||
Data.SrcAddr = (UINTPTR)SrcBuf;
|
||||
Data.SrcCoherent = 0;
|
||||
Data.Size = SIZE; /* Size in bytes */
|
||||
|
||||
XZDma_Start(&ZDma, &Data, 1); /* Initiates the data transfer */
|
||||
/* Wait till DMA Source done interrupt generated */
|
||||
while (Done == 0);
|
||||
|
||||
/*
|
||||
* Validation of read only mode cannot be performed as it will not
|
||||
* store the values
|
||||
*/
|
||||
|
||||
return XST_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function sets up the interrupt system so interrupts can occur for the
|
||||
* ZDMA. This function is application-specific. The user should modify this
|
||||
* function to fit the application.
|
||||
*
|
||||
* @param IntcInstancePtr is a pointer to the instance of the INTC.
|
||||
* @param InstancePtr contains a pointer to the instance of the ZDMA
|
||||
* driver which is going to be connected to the interrupt
|
||||
* controller.
|
||||
* @param IntrId is the interrupt Id and is typically
|
||||
* XPAR_<ZDMA_instance>_INTR value from xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful
|
||||
* - XST_FAILURE if failed
|
||||
*
|
||||
* @note None.
|
||||
|
||||
*
|
||||
****************************************************************************/
|
||||
static int SetupInterruptSystem(XScuGic *IntcInstancePtr,
|
||||
XZDma *InstancePtr, u16 IntrId)
|
||||
{
|
||||
int Status;
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
XScuGic_Config *IntcConfig; /* Config for interrupt controller */
|
||||
|
||||
/*
|
||||
* Initialize the interrupt controller driver
|
||||
*/
|
||||
IntcConfig = XScuGic_LookupConfig(ZDMA_INTC_DEVICE_ID);
|
||||
if (NULL == IntcConfig) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XScuGic_CfgInitialize(IntcInstancePtr, IntcConfig,
|
||||
IntcConfig->CpuBaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Connect the interrupt controller interrupt handler to the
|
||||
* hardware interrupt handling logic in the processor.
|
||||
*/
|
||||
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
|
||||
(Xil_ExceptionHandler) XScuGic_InterruptHandler,
|
||||
IntcInstancePtr);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Connect a device driver handler that will be called when an
|
||||
* interrupt for the device occurs, the device driver handler
|
||||
* performs the specific interrupt processing for the device
|
||||
*/
|
||||
Status = XScuGic_Connect(IntcInstancePtr, IntrId,
|
||||
(Xil_ExceptionHandler) XZDma_IntrHandler,
|
||||
(void *) InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the interrupt for the device
|
||||
*/
|
||||
XScuGic_Enable(IntcInstancePtr, IntrId);
|
||||
|
||||
|
||||
/*
|
||||
* Enable interrupts
|
||||
*/
|
||||
Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);
|
||||
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This static function handles ZDMA Done interrupts.
|
||||
*
|
||||
* @param CallBackRef is the callback reference passed from the interrupt
|
||||
* handler, which in our case is a pointer to the driver instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
static void DoneHandler(void *CallBackRef)
|
||||
{
|
||||
|
||||
Done = 1;
|
||||
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xzdma_selftest_example.c
|
||||
*
|
||||
* This file contains an example using the XZDma driver to do self test
|
||||
* on the device.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- ------------------------------------------------------
|
||||
* 1.0 vns 2/27/15 First release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xzdma.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
int XZDma_SelfTestExample(u16 DeviceId);
|
||||
|
||||
/************************** Constant Definitions ******************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#define ZDMA_DEVICE_ID XPAR_XZDMA_0_DEVICE_ID /* ZDMA device Id */
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
XZDma ZDma; /**<Instance of the ZDMA Device */
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function to call the example.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
int Status;
|
||||
|
||||
/* Run the selftest example */
|
||||
Status = XZDma_SelfTestExample((u16)ZDMA_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
xil_printf("ZDMA Selftest Example Failed\r\n");
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
xil_printf("Successfully ran ZDMA Selftest Example\r\n");
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function does a minimal test on the ZDMA driver.
|
||||
*
|
||||
* @param DeviceId is the XPAR_<ZDMA Instance>_DEVICE_ID value from
|
||||
* xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XZDma_SelfTestExample(u16 DeviceId)
|
||||
{
|
||||
int Status;
|
||||
XZDma_Config *Config;
|
||||
|
||||
/*
|
||||
* Initialize the ZDMA driver so that it's ready to use.
|
||||
* Look up the configuration in the config table,
|
||||
* then initialize it.
|
||||
*/
|
||||
Config = XZDma_LookupConfig(DeviceId);
|
||||
if (NULL == Config) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XZDma_CfgInitialize(&ZDma, Config, Config->BaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Performs the self-test to check hardware build.
|
||||
*/
|
||||
|
||||
Status = XZDma_SelfTest(&ZDma);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,332 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xzdma_simple_example.c
|
||||
*
|
||||
* This file contains the example using XZDma driver to do simple data transfer
|
||||
* in Normal mode on ZDMA device for 1GB data transfer.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- ------------------------------------------------------
|
||||
* 1.0 vns 2/27/15 First release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xzdma.h"
|
||||
#include "xparameters.h"
|
||||
#include "xscugic.h"
|
||||
#include "xil_cache.h"
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
int XZDma_SimpleExample(u16 DeviceId);
|
||||
static int SetupInterruptSystem(XScuGic *IntcInstancePtr,
|
||||
XZDma *InstancePtr, u16 IntrId);
|
||||
static void DoneHandler(void *CallBackRef);
|
||||
|
||||
/************************** Constant Definitions ******************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#define ZDMA_DEVICE_ID XPAR_XZDMA_0_DEVICE_ID /* ZDMA device Id */
|
||||
#define ZDMA_INTC_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID
|
||||
/**< SCUGIC Device ID */
|
||||
#define ZDMA_INTR_DEVICE_ID XPAR_XADMAPS_0_INTR /**< ZDMA Interrupt Id */
|
||||
|
||||
#define SIZE 1000000000 /**< Size of the data to be transferred */
|
||||
#define TESTVALUE 0x1230 /**< For writing into source buffer */
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
XZDma ZDma; /**<Instance of the ZDMA Device */
|
||||
XScuGic Intc; /**< XIntc Instance */
|
||||
|
||||
u32 *DstBuf = (u32 *)0x3C000000; /**< Pointer to destination buffer */
|
||||
u32 *SrcBuf = (u32 *)0x00200000; /**< Pointer to source buffer */
|
||||
|
||||
u8 Done = 0; /**< Done flag */
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function to call the example.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
int Status;
|
||||
|
||||
/* Run the simple example */
|
||||
Status = XZDma_SimpleExample((u16)ZDMA_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
xil_printf("ZDMA Simple Example Failed\r\n");
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
xil_printf("Successfully ran ZDMA Simple Example\r\n");
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function does a test of the data transfer in simple mode of normal mode
|
||||
* on the ZDMA driver.
|
||||
*
|
||||
* @param DeviceId is the XPAR_<ZDMA Instance>_DEVICE_ID value from
|
||||
* xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XZDma_SimpleExample(u16 DeviceId)
|
||||
{
|
||||
int Status;
|
||||
XZDma_Config *Config;
|
||||
XZDma_DataConfig Configure; /**< Configuration values */
|
||||
XZDma_Transfer Data;
|
||||
u32 Index;
|
||||
u32 Value;
|
||||
|
||||
/*
|
||||
* Initialize the ZDMA driver so that it's ready to use.
|
||||
* Look up the configuration in the config table,
|
||||
* then initialize it.
|
||||
*/
|
||||
Config = XZDma_LookupConfig(DeviceId);
|
||||
if (NULL == Config) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XZDma_CfgInitialize(&ZDma, Config, Config->BaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
/*
|
||||
* Performs the self-test to check hardware build.
|
||||
*/
|
||||
Status = XZDma_SelfTest(&ZDma);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/* Filling the buffer for data transfer */
|
||||
Value = TESTVALUE;
|
||||
for (Index = 0; Index < SIZE/4; Index++) {
|
||||
*(SrcBuf +Index) = Value++;
|
||||
}
|
||||
/*
|
||||
* Invalidating destination address and flushing
|
||||
* source address in cache
|
||||
*/
|
||||
Xil_DCacheFlushRange((INTPTR)SrcBuf, SIZE);
|
||||
Xil_DCacheInvalidateRange((INTPTR)DstBuf, SIZE);
|
||||
|
||||
/* ZDMA has set in simple transfer of Normal mode */
|
||||
Status = XZDma_SetMode(&ZDma, FALSE, XZDMA_NORMAL_MODE);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/* Interrupt call back has been set */
|
||||
XZDma_SetCallBack(&ZDma, XZDMA_HANDLER_DONE,
|
||||
(void *)DoneHandler, &ZDma);
|
||||
/*
|
||||
* Connect to the interrupt controller.
|
||||
*/
|
||||
Status = SetupInterruptSystem(&Intc, &(ZDma),
|
||||
ZDMA_INTR_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
/* Enable required interrupts */
|
||||
XZDma_EnableIntr(&ZDma, (XZDMA_IXR_DMA_DONE_MASK));
|
||||
|
||||
/* Configuration settings */
|
||||
Configure.OverFetch = 1;
|
||||
Configure.SrcIssue = 0x1F;
|
||||
Configure.SrcBurstType = XZDMA_INCR_BURST;
|
||||
Configure.SrcBurstLen = 0xF;
|
||||
Configure.DstBurstType = XZDMA_INCR_BURST;
|
||||
Configure.DstBurstLen = 0xF;
|
||||
Configure.SrcCache = 0x2;
|
||||
Configure.DstCache = 0x2;
|
||||
Configure.SrcQos = 0;
|
||||
Configure.DstQos = 0;
|
||||
|
||||
XZDma_SetChDataConfig(&ZDma, &Configure);
|
||||
/*
|
||||
* Transfer elements
|
||||
*/
|
||||
Data.DstAddr = (UINTPTR)DstBuf;
|
||||
Data.DstCoherent = 1;
|
||||
Data.Pause = 0;
|
||||
Data.SrcAddr = (UINTPTR)SrcBuf;
|
||||
Data.SrcCoherent = 1;
|
||||
Data.Size = SIZE; /* Size in bytes */
|
||||
|
||||
XZDma_Start(&ZDma, &Data, 1); /* Initiates the data transfer */
|
||||
|
||||
while (Done == 0); /* Wait till DMA done interrupt generated */
|
||||
|
||||
/* Checking the data transferred */
|
||||
for (Index = 0; Index < SIZE/4; Index++) {
|
||||
if (SrcBuf[Index] != DstBuf[Index]) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function sets up the interrupt system so interrupts can occur for the
|
||||
* ZDMA. This function is application-specific. The user should modify this
|
||||
* function to fit the application.
|
||||
*
|
||||
* @param IntcInstancePtr is a pointer to the instance of the INTC.
|
||||
* @param InstancePtr contains a pointer to the instance of the ZDMA
|
||||
* driver which is going to be connected to the interrupt
|
||||
* controller.
|
||||
* @param IntrId is the interrupt Id and is typically
|
||||
* XPAR_<ZDMA_instance>_INTR value from xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful
|
||||
* - XST_FAILURE if failed
|
||||
*
|
||||
* @note None.
|
||||
|
||||
*
|
||||
****************************************************************************/
|
||||
int SetupInterruptSystem(XScuGic *IntcInstancePtr,
|
||||
XZDma *InstancePtr,
|
||||
u16 IntrId)
|
||||
{
|
||||
int Status;
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
XScuGic_Config *IntcConfig; /* Config for interrupt controller */
|
||||
|
||||
/*
|
||||
* Initialize the interrupt controller driver
|
||||
*/
|
||||
IntcConfig = XScuGic_LookupConfig(ZDMA_INTC_DEVICE_ID);
|
||||
if (NULL == IntcConfig) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XScuGic_CfgInitialize(IntcInstancePtr, IntcConfig,
|
||||
IntcConfig->CpuBaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Connect the interrupt controller interrupt handler to the
|
||||
* hardware interrupt handling logic in the processor.
|
||||
*/
|
||||
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
|
||||
(Xil_ExceptionHandler) XScuGic_InterruptHandler,
|
||||
IntcInstancePtr);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Connect a device driver handler that will be called when an
|
||||
* interrupt for the device occurs, the device driver handler
|
||||
* performs the specific interrupt processing for the device
|
||||
*/
|
||||
Status = XScuGic_Connect(IntcInstancePtr, IntrId,
|
||||
(Xil_ExceptionHandler) XZDma_IntrHandler,
|
||||
(void *) InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the interrupt for the device
|
||||
*/
|
||||
XScuGic_Enable(IntcInstancePtr, IntrId);
|
||||
|
||||
|
||||
/*
|
||||
* Enable interrupts
|
||||
*/
|
||||
Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);
|
||||
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This static function handles ZDMA Done interrupts.
|
||||
*
|
||||
* @param CallBackRef is the callback reference passed from the interrupt
|
||||
* handler, which in our case is a pointer to the driver instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
static void DoneHandler(void *CallBackRef)
|
||||
{
|
||||
Done = 1;
|
||||
|
||||
}
|
|
@ -0,0 +1,339 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xzdma_writeonlymode_example.c
|
||||
*
|
||||
* This file contains the example using XZDma driver to do simple data transfer
|
||||
* in Write only mode on ZDMA device. In this mode data will be predefined
|
||||
* and will be repetitively written into the given address and for given size.
|
||||
* For ADMA only 2 words are repeated and for GDMA 4 words are repeated.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- ------------------------------------------------------
|
||||
* 1.0 vns 2/27/15 First release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xzdma.h"
|
||||
#include "xparameters.h"
|
||||
#include "xscugic.h"
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
int XZDma_WriteOnlyExample(u16 DeviceId);
|
||||
static int SetupInterruptSystem(XScuGic *IntcInstancePtr,
|
||||
XZDma *InstancePtr, u16 IntrId);
|
||||
static void DoneHandler(void *CallBackRef);
|
||||
|
||||
/************************** Constant Definitions ******************************/
|
||||
|
||||
/*
|
||||
* The following constants map to the XPAR parameters created in the
|
||||
* xparameters.h file. They are defined here such that a user can easily
|
||||
* change all the needed parameters in one place.
|
||||
*/
|
||||
#define ZDMA_DEVICE_ID XPAR_XZDMA_0_DEVICE_ID /* ZDMA device Id */
|
||||
#define ZDMA_INTC_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID
|
||||
/**< SCUGIC Device ID */
|
||||
#define ZDMA_INTR_DEVICE_ID XPAR_XADMAPS_0_INTR /**< ZDMA Interrupt Id */
|
||||
|
||||
#define SIZE 1024 /* Size of the data to be written */
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
XZDma ZDma; /**<Instance of the ZDMA Device */
|
||||
XScuGic Intc; /**< XIntc Instance */
|
||||
u32 SrcBuf[4]; /**< Source buffer */
|
||||
u32 DstBuf[300] __attribute__ ((aligned (64))); /**< Destination buffer */
|
||||
u8 Done = 0; /**< Done Flag for interrupt generation */
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function to call the example.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
int Status;
|
||||
|
||||
/* Run the simple write only mode example */
|
||||
Status = XZDma_WriteOnlyExample((u16)ZDMA_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
xil_printf("ZDMA Example Failed\r\n");
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
xil_printf("Successfully ran Write Only mode ZDMA Example\r\n");
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function does a test of the data transfer in simple mode of write only
|
||||
* mode on the ZDMA driver.
|
||||
*
|
||||
* @param DeviceId is the XPAR_<ZDMA Instance>_DEVICE_ID value from
|
||||
* xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if failed.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XZDma_WriteOnlyExample(u16 DeviceId)
|
||||
{
|
||||
int Status;
|
||||
XZDma_Config *Config;
|
||||
XZDma_DataConfig Configur; /**< Configuration values */
|
||||
XZDma_Transfer Data;
|
||||
u32 *Buf = (u32 *)DstBuf;
|
||||
u32 Index;
|
||||
u32 Index1;
|
||||
|
||||
/*
|
||||
* Initialize the ZDMA driver so that it's ready to use.
|
||||
* Look up the configuration in the config table,
|
||||
* then initialize it.
|
||||
*/
|
||||
Config = XZDma_LookupConfig(DeviceId);
|
||||
if (NULL == Config) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
Status = XZDma_CfgInitialize(&ZDma, Config, Config->BaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
/*
|
||||
* Performs the self-test to check hardware build.
|
||||
*/
|
||||
Status = XZDma_SelfTest(&ZDma);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/* ZDMA has set in simple transfer of Normal mode */
|
||||
Status = XZDma_SetMode(&ZDma, FALSE, XZDMA_WRONLY_MODE);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
XZDma_EnableIntr(&ZDma, XZDMA_IXR_DMA_DONE_MASK);
|
||||
/*
|
||||
* Connect to the interrupt controller.
|
||||
*/
|
||||
Status = SetupInterruptSystem(&Intc, &(ZDma),
|
||||
ZDMA_INTR_DEVICE_ID);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
(void)XZDma_SetCallBack(&ZDma,
|
||||
XZDMA_HANDLER_DONE, (void *)(DoneHandler),
|
||||
&ZDma);
|
||||
/* Configuration settings */
|
||||
Configur.OverFetch = 0;
|
||||
Configur.SrcIssue = 0x1F;
|
||||
Configur.SrcBurstType = XZDMA_INCR_BURST;
|
||||
Configur.SrcBurstLen = 0xF;
|
||||
Configur.DstBurstType = XZDMA_INCR_BURST;
|
||||
Configur.DstBurstLen = 0xF;
|
||||
XZDma_SetChDataConfig(&ZDma, &Configur);
|
||||
/*
|
||||
* Transfer elements
|
||||
*/
|
||||
Data.DstAddr = (UINTPTR)DstBuf;
|
||||
Data.DstCoherent = 0;
|
||||
Data.Pause = 0;
|
||||
Data.SrcAddr = (UINTPTR)NULL;
|
||||
Data.SrcCoherent = 0;
|
||||
Data.Size = SIZE; /* Size in bytes */
|
||||
|
||||
if (ZDma.Config.DmaType == 0) { /* For GDMA */
|
||||
SrcBuf[0] = 0x1234;
|
||||
SrcBuf[1] = 0xABCD;
|
||||
SrcBuf[2] = 0x4567;
|
||||
SrcBuf[3] = 0xEF;
|
||||
XZDma_WOData(&ZDma, SrcBuf);
|
||||
}
|
||||
else { /* For ADMA */
|
||||
SrcBuf[0] = 0x1234;
|
||||
SrcBuf[1] = 0xABCD;
|
||||
XZDma_WOData(&ZDma, SrcBuf);
|
||||
}
|
||||
|
||||
Xil_DCacheInvalidateRange((INTPTR)DstBuf, SIZE);
|
||||
|
||||
XZDma_Start(&ZDma, &Data, 1); /* Initiates the data transfer */
|
||||
|
||||
/* Wait till DMA destination done interrupt generated */
|
||||
while (Done == 0);
|
||||
|
||||
/* Validation */
|
||||
if (ZDma.Config.DmaType == 0) { /* For GDMA */
|
||||
for (Index = 0; Index < (SIZE/4)/4; Index++) {
|
||||
for (Index1 = 0; Index1 < 4; Index1++) {
|
||||
if (SrcBuf[Index1] != *Buf++) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else { /* For ADMA */
|
||||
for (Index = 0; Index < (SIZE/4)/2; Index++) {
|
||||
for (Index1 = 0; Index1 < 2; Index1++) {
|
||||
if (SrcBuf[Index1] != *Buf++) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function sets up the interrupt system so interrupts can occur for the
|
||||
* ZDMA. This function is application-specific. The user should modify this
|
||||
* function to fit the application.
|
||||
*
|
||||
* @param IntcInstancePtr is a pointer to the instance of the INTC.
|
||||
* @param InstancePtr contains a pointer to the instance of the ZDMA
|
||||
* driver which is going to be connected to the interrupt
|
||||
* controller.
|
||||
* @param IntrId is the interrupt Id and is typically
|
||||
* XPAR_<ZDMA_instance>_INTR value from xparameters.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful
|
||||
* - XST_FAILURE if failed
|
||||
*
|
||||
* @note None.
|
||||
|
||||
*
|
||||
****************************************************************************/
|
||||
static int SetupInterruptSystem(XScuGic *IntcInstancePtr,
|
||||
XZDma *InstancePtr, u16 IntrId)
|
||||
{
|
||||
int Status;
|
||||
|
||||
#ifndef TESTAPP_GEN
|
||||
XScuGic_Config *IntcConfig; /* Config for interrupt controller */
|
||||
|
||||
/*
|
||||
* Initialize the interrupt controller driver
|
||||
*/
|
||||
IntcConfig = XScuGic_LookupConfig(ZDMA_INTC_DEVICE_ID);
|
||||
if (NULL == IntcConfig) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
Status = XScuGic_CfgInitialize(IntcInstancePtr, IntcConfig,
|
||||
IntcConfig->CpuBaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Connect the interrupt controller interrupt handler to the
|
||||
* hardware interrupt handling logic in the processor.
|
||||
*/
|
||||
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
|
||||
(Xil_ExceptionHandler) XScuGic_InterruptHandler,
|
||||
IntcInstancePtr);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Connect a device driver handler that will be called when an
|
||||
* interrupt for the device occurs, the device driver handler
|
||||
* performs the specific interrupt processing for the device
|
||||
*/
|
||||
Status = XScuGic_Connect(IntcInstancePtr, IntrId,
|
||||
(Xil_ExceptionHandler) XZDma_IntrHandler,
|
||||
(void *) InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the interrupt for the device
|
||||
*/
|
||||
XScuGic_Enable(IntcInstancePtr, IntrId);
|
||||
|
||||
|
||||
/*
|
||||
* Enable interrupts
|
||||
*/
|
||||
Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);
|
||||
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This static function handles ZDMA Done interrupts.
|
||||
*
|
||||
* @param CallBackRef is the callback reference passed from the interrupt
|
||||
* handler, which in our case is a pointer to the driver instance.
|
||||
* @param Event specifies which interrupts were occurred.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
static void DoneHandler(void *CallBackRef)
|
||||
{
|
||||
Done = 1;
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue