XilinxProcessorIPLib/drivers/spi/examples/xspi_intel_flash_example.c
int SpiIntelFlashRead(XSpi *SpiPtr, u32 Addr, u32 ByteCount)
{
	int Status;

	/*
	 * Prepare the WriteBuffer.
	 */
	WriteBuffer[BYTE1] = INTEL_COMMAND_RANDOM_READ;
	WriteBuffer[BYTE2] = (u8) (Addr >> 16);
	WriteBuffer[BYTE3] = (u8) (Addr >> 8);
	WriteBuffer[BYTE4] = (u8) Addr;

	/*
	 * Initiate the Transfer.
	 */
	TransferInProgress = TRUE;
	Status = XSpi_Transfer( SpiPtr, WriteBuffer, ReadBuffer,
				(ByteCount + INTEL_READ_WRITE_EXTRA_BYTES));
	if(Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Wait till the Transfer is complete and check if there are any errors
	 * in the transaction..
	 */
	while(TransferInProgress);
	if(ErrorCount != 0) {
		ErrorCount = 0;
		return XST_FAILURE;
	}

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function reads the data from the Intel Serial Flash Memory
*
* @param	SpiPtr is a pointer to the instance of the Spi device.
* @param	Addr is the starting address in the Flash Memory from which the
*		data is to be read.
* @param	ByteCount is the number of bytes to be read.
*
* @return	XST_SUCCESS if successful else XST_FAILURE.
*
* @note		None.
*
******************************************************************************/
This function reads the data from the Intel Serial Flash Memory
This function reads the data from the Intel Serial Flash Memory
int SpiIntelFlashRead(XSpi *SpiPtr, u32 Addr, u32 ByteCount)
{
	int Status;
	WriteBuffer[BYTE1] = INTEL_COMMAND_RANDOM_READ;
	WriteBuffer[BYTE2] = (u8) (Addr >> 16);
	WriteBuffer[BYTE3] = (u8) (Addr >> 8);
	WriteBuffer[BYTE4] = (u8) Addr;
	TransferInProgress = TRUE;
	Status = XSpi_Transfer( SpiPtr, WriteBuffer, ReadBuffer,
				(ByteCount + INTEL_READ_WRITE_EXTRA_BYTES));
	if(Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	while(TransferInProgress);
	if(ErrorCount != 0) {
		ErrorCount = 0;
		return XST_FAILURE;
	}
	return XST_SUCCESS;
}
int SpiIntelFlashRead ( XSpi * SpiPtr , u32 Addr , u32 ByteCount ) { int Status ; WriteBuffer [ BYTE1 ] = INTEL_COMMAND_RANDOM_READ ; WriteBuffer [ BYTE2 ] = ( u8 ) ( Addr >> 16 ) ; WriteBuffer [ BYTE3 ] = ( u8 ) ( Addr >> 8 ) ; WriteBuffer [ BYTE4 ] = ( u8 ) Addr ; TransferInProgress = TRUE ; Status = XSpi_Transfer ( SpiPtr , WriteBuffer , ReadBuffer , ( ByteCount + INTEL_READ_WRITE_EXTRA_BYTES ) ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } while ( TransferInProgress ) ; if ( ErrorCount != 0 ) { ErrorCount = 0 ; return XST_FAILURE ; } return XST_SUCCESS ; }
This function reads the data from the Intel Serial Flash Memory
This function reads the data from the Intel Serial Flash Memory
/*
	 * Prepare the WriteBuffer.
	 */ /*
	 * Initiate the Transfer.
	 */ /*
	 * Wait till the Transfer is complete and check if there are any errors
	 * in the transaction..
	 */