XilinxProcessorIPLib/drivers/axicdma/examples/xaxicdma_example_simple_poll.c
static int DoSimplePollTransfer(XAxiCdma *InstancePtr, int Length, int Retries)
{
	int Index;
	u8  *SrcPtr;
	u8  *DestPtr;
	int Status;

	/* Initialize the source buffer bytes with a pattern and the
	 * the destination buffer bytes to zero
	 */
	SrcPtr = (u8 *)SrcBuffer;
	DestPtr = (u8 *)DestBuffer;
	for (Index = 0; Index < BUFFER_BYTESIZE; Index++) {
		SrcPtr[Index] = Index & 0xFF;
		DestPtr[Index] = 0;
	}

	/* Flush the SrcBuffer before the DMA transfer, in case the Data Cache
	 * is enabled
	 */
	Xil_DCacheFlushRange((UINTPTR)&SrcBuffer, Length);
	Xil_DCacheFlushRange((UINTPTR)&DestBuffer, Length);

	/* Try to start the DMA transfer
	 */
	while (Retries) {
		Retries -= 1;

		Status = XAxiCdma_SimpleTransfer(InstancePtr, (UINTPTR)SrcBuffer,
			(UINTPTR)DestBuffer, Length, NULL, NULL);
		if (Status == XST_SUCCESS) {
			break;
		}
	}

	/* Return failure if failed to submit the transfer
	 */
	if (!Retries) {
		xdbg_printf(XDBG_DEBUG_ERROR,
			    "Failed to submit the transfer with %d\r\n", Status);
		return XST_FAILURE;
	}

	/* Wait until the DMA transfer is done
	 */
	while (XAxiCdma_IsBusy(InstancePtr)) {
		/* Wait */
	}

	/* If the hardware has errors, this example fails
	 * This is a poll example, no interrupt handler is involved.
	 * Therefore, error conditions are not cleared by the driver.
	 */
	Error = XAxiCdma_GetError(InstancePtr);
	if (Error != 0x0) {
		int TimeOut = RESET_LOOP_COUNT;

		/* Need to reset the hardware to restore to the correct state
		 */
		XAxiCdma_Reset(InstancePtr);

		while (TimeOut) {
			if (XAxiCdma_ResetIsDone(InstancePtr)) {
				break;
			}
			TimeOut -= 1;
		}

		/* Reset has failed, print a message to notify the user
		 */
		xdbg_printf(XDBG_DEBUG_ERROR, "Reset done failed\r\n");
		return XST_FAILURE;
	}

	/* Transfer completes successfully, check data
	 */
	Status = CheckData(SrcPtr, DestPtr, Length);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	return XST_SUCCESS;
}
/*****************************************************************************/
/*
* This function does one simple transfer in polled mode
*
* @param	InstancePtr is a pointer to the XAxiCdma instance
* @param	Length is the transfer length
* @param	Retries is how many times to retry on submission
*
* @return
*		- XST_SUCCESS if transfer is successful
*		- XST_FAILURE if either the transfer fails or the data has
*		  error
*
* @note		None
*
******************************************************************************/
This function does one simple transfer in polled mode
This function does one simple transfer in polled mode
static int DoSimplePollTransfer(XAxiCdma *InstancePtr, int Length, int Retries)
{
	int Index;
	u8  *SrcPtr;
	u8  *DestPtr;
	int Status;
	SrcPtr = (u8 *)SrcBuffer;
	DestPtr = (u8 *)DestBuffer;
	for (Index = 0; Index < BUFFER_BYTESIZE; Index++) {
		SrcPtr[Index] = Index & 0xFF;
		DestPtr[Index] = 0;
	}
	Xil_DCacheFlushRange((UINTPTR)&SrcBuffer, Length);
	Xil_DCacheFlushRange((UINTPTR)&DestBuffer, Length);
	while (Retries) {
		Retries -= 1;
		Status = XAxiCdma_SimpleTransfer(InstancePtr, (UINTPTR)SrcBuffer,
			(UINTPTR)DestBuffer, Length, NULL, NULL);
		if (Status == XST_SUCCESS) {
			break;
		}
	}
	if (!Retries) {
		xdbg_printf(XDBG_DEBUG_ERROR,
			    "Failed to submit the transfer with %d\r\n", Status);
		return XST_FAILURE;
	}
	while (XAxiCdma_IsBusy(InstancePtr)) {
	}
	Error = XAxiCdma_GetError(InstancePtr);
	if (Error != 0x0) {
		int TimeOut = RESET_LOOP_COUNT;
		XAxiCdma_Reset(InstancePtr);
		while (TimeOut) {
			if (XAxiCdma_ResetIsDone(InstancePtr)) {
				break;
			}
			TimeOut -= 1;
		}
		xdbg_printf(XDBG_DEBUG_ERROR, "Reset done failed\r\n");
		return XST_FAILURE;
	}
	Status = CheckData(SrcPtr, DestPtr, Length);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	return XST_SUCCESS;
}
static int DoSimplePollTransfer ( XAxiCdma * InstancePtr , int Length , int Retries ) { int Index ; u8 * SrcPtr ; u8 * DestPtr ; int Status ; SrcPtr = ( u8 * ) SrcBuffer ; DestPtr = ( u8 * ) DestBuffer ; for ( Index = 0 ; Index < BUFFER_BYTESIZE ; Index ++ ) { SrcPtr [ Index ] = Index & 0xFF ; DestPtr [ Index ] = 0 ; } Xil_DCacheFlushRange ( ( UINTPTR ) & SrcBuffer , Length ) ; Xil_DCacheFlushRange ( ( UINTPTR ) & DestBuffer , Length ) ; while ( Retries ) { Retries -= 1 ; Status = XAxiCdma_SimpleTransfer ( InstancePtr , ( UINTPTR ) SrcBuffer , ( UINTPTR ) DestBuffer , Length , NULL , NULL ) ; if ( Status == XST_SUCCESS ) { break ; } } if ( ! Retries ) { xdbg_printf ( XDBG_DEBUG_ERROR , " \r \n " , Status ) ; return XST_FAILURE ; } while ( XAxiCdma_IsBusy ( InstancePtr ) ) { } Error = XAxiCdma_GetError ( InstancePtr ) ; if ( Error != 0x0 ) { int TimeOut = RESET_LOOP_COUNT ; XAxiCdma_Reset ( InstancePtr ) ; while ( TimeOut ) { if ( XAxiCdma_ResetIsDone ( InstancePtr ) ) { break ; } TimeOut -= 1 ; } xdbg_printf ( XDBG_DEBUG_ERROR , " \r \n " ) ; return XST_FAILURE ; } Status = CheckData ( SrcPtr , DestPtr , Length ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } return XST_SUCCESS ; }
This function does one simple transfer in polled mode
This function does one simple transfer in polled mode
/* Initialize the source buffer bytes with a pattern and the
	 * the destination buffer bytes to zero
	 */ /* Flush the SrcBuffer before the DMA transfer, in case the Data Cache
	 * is enabled
	 */ /* Try to start the DMA transfer
	 */ /* Return failure if failed to submit the transfer
	 */ /* Wait until the DMA transfer is done
	 */ /* Wait */ /* If the hardware has errors, this example fails
	 * This is a poll example, no interrupt handler is involved.
	 * Therefore, error conditions are not cleared by the driver.
	 */ /* Need to reset the hardware to restore to the correct state
		 */ /* Reset has failed, print a message to notify the user
		 */ /* Transfer completes successfully, check data
	 */