XilinxProcessorIPLib/drivers/ospipsv/examples/xospipsv_flash_intr_example.c
int FlashReadID(XOspiPsv *OspiPsvPtr)
{
	int Status;
	int ReadIdBytes = 8;
	u32 ReadId = 0;

	/*
	 * Read ID
	 */
	FlashMsg.Opcode = READ_ID;
	FlashMsg.Addrsize = 0;
	FlashMsg.Addrvalid = 0;
	FlashMsg.TxBfrPtr = NULL;
	FlashMsg.RxBfrPtr = ReadBfrPtr;
	FlashMsg.ByteCount = ReadIdBytes;
	FlashMsg.Flags = XOSPIPSV_MSG_FLAG_RX;
	FlashMsg.Dummy = OspiPsvPtr->Extra_DummyCycle;
	FlashMsg.IsDDROpCode = 0;
	FlashMsg.Proto = 0;
	if (OspiPsvPtr->SdrDdrMode == XOSPIPSV_EDGE_MODE_DDR_PHY) {
		FlashMsg.Dummy += 8;
		FlashMsg.Proto = XOSPIPSV_READ_8_0_8;
	}

	if (OspiPsvPtr->DualByteOpcodeEn != 0U)
		FlashMsg.ExtendedOpcode = (u8)(~FlashMsg.Opcode);

	TransferInProgress = TRUE;
	Error = 0;
	Status = XOspiPsv_IntrTransfer(OspiPsvPtr, &FlashMsg);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	while(TransferInProgress);
	if (Error) {
		return XST_FAILURE;
	}


	xil_printf("FlashID = ");
	while(ReadIdBytes >= 0 ) {
		xil_printf("0x%x ", ReadBfrPtr[FlashMsg.ByteCount - ReadIdBytes]);
		ReadIdBytes--;
	}
	xil_printf("\n\r");

	OspiPsvPtr->DeviceIdData = ((ReadBfrPtr[3] << 24) | (ReadBfrPtr[2] << 16) |
		(ReadBfrPtr[1] << 8) | ReadBfrPtr[0]);
	ReadId = ((ReadBfrPtr[0] << 16) | (ReadBfrPtr[1] << 8) | ReadBfrPtr[2]);

	FlashMake = ReadBfrPtr[0];

	if (FlashMake == MACRONIX_OCTAL_ID_BYTE0)
		FSRFlag = 0;
	else
		FSRFlag = 1;

	Status = CalculateFCTIndex(ReadId, &FCTIndex);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* Reads the flash ID and identifies the flash in FCT table.
*
* @param	OspiPsvPtr is a pointer to the OSPIPSV driver component to use.
*
* @return	XST_SUCCESS if successful, else XST_FAILURE.
*
* @note		None.
*
*****************************************************************************/
Reads the flash ID and identifies the flash in FCT table.
Reads the flash ID and identifies the flash in FCT table .
int FlashReadID(XOspiPsv *OspiPsvPtr)
{
	int Status;
	int ReadIdBytes = 8;
	u32 ReadId = 0;
	FlashMsg.Opcode = READ_ID;
	FlashMsg.Addrsize = 0;
	FlashMsg.Addrvalid = 0;
	FlashMsg.TxBfrPtr = NULL;
	FlashMsg.RxBfrPtr = ReadBfrPtr;
	FlashMsg.ByteCount = ReadIdBytes;
	FlashMsg.Flags = XOSPIPSV_MSG_FLAG_RX;
	FlashMsg.Dummy = OspiPsvPtr->Extra_DummyCycle;
	FlashMsg.IsDDROpCode = 0;
	FlashMsg.Proto = 0;
	if (OspiPsvPtr->SdrDdrMode == XOSPIPSV_EDGE_MODE_DDR_PHY) {
		FlashMsg.Dummy += 8;
		FlashMsg.Proto = XOSPIPSV_READ_8_0_8;
	}
	if (OspiPsvPtr->DualByteOpcodeEn != 0U)
		FlashMsg.ExtendedOpcode = (u8)(~FlashMsg.Opcode);
	TransferInProgress = TRUE;
	Error = 0;
	Status = XOspiPsv_IntrTransfer(OspiPsvPtr, &FlashMsg);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	while(TransferInProgress);
	if (Error) {
		return XST_FAILURE;
	}
	xil_printf("FlashID = ");
	while(ReadIdBytes >= 0 ) {
		xil_printf("0x%x ", ReadBfrPtr[FlashMsg.ByteCount - ReadIdBytes]);
		ReadIdBytes--;
	}
	xil_printf("\n\r");
	OspiPsvPtr->DeviceIdData = ((ReadBfrPtr[3] << 24) | (ReadBfrPtr[2] << 16) |
		(ReadBfrPtr[1] << 8) | ReadBfrPtr[0]);
	ReadId = ((ReadBfrPtr[0] << 16) | (ReadBfrPtr[1] << 8) | ReadBfrPtr[2]);
	FlashMake = ReadBfrPtr[0];
	if (FlashMake == MACRONIX_OCTAL_ID_BYTE0)
		FSRFlag = 0;
	else
		FSRFlag = 1;
	Status = CalculateFCTIndex(ReadId, &FCTIndex);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	return XST_SUCCESS;
}
int FlashReadID ( XOspiPsv * OspiPsvPtr ) { int Status ; int ReadIdBytes = 8 ; u32 ReadId = 0 ; FlashMsg . Opcode = READ_ID ; FlashMsg . Addrsize = 0 ; FlashMsg . Addrvalid = 0 ; FlashMsg . TxBfrPtr = NULL ; FlashMsg . RxBfrPtr = ReadBfrPtr ; FlashMsg . ByteCount = ReadIdBytes ; FlashMsg . Flags = XOSPIPSV_MSG_FLAG_RX ; FlashMsg . Dummy = OspiPsvPtr -> Extra_DummyCycle ; FlashMsg . IsDDROpCode = 0 ; FlashMsg . Proto = 0 ; if ( OspiPsvPtr -> SdrDdrMode == XOSPIPSV_EDGE_MODE_DDR_PHY ) { FlashMsg . Dummy += 8 ; FlashMsg . Proto = XOSPIPSV_READ_8_0_8 ; } if ( OspiPsvPtr -> DualByteOpcodeEn != 0U ) FlashMsg . ExtendedOpcode = ( u8 ) ( ~ FlashMsg . Opcode ) ; TransferInProgress = TRUE ; Error = 0 ; Status = XOspiPsv_IntrTransfer ( OspiPsvPtr , & FlashMsg ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } while ( TransferInProgress ) ; if ( Error ) { return XST_FAILURE ; } xil_printf ( " " ) ; while ( ReadIdBytes >= 0 ) { xil_printf ( " " , ReadBfrPtr [ FlashMsg . ByteCount - ReadIdBytes ] ) ; ReadIdBytes -- ; } xil_printf ( " \n \r " ) ; OspiPsvPtr -> DeviceIdData = ( ( ReadBfrPtr [ 3 ] << 24 ) | ( ReadBfrPtr [ 2 ] << 16 ) | ( ReadBfrPtr [ 1 ] << 8 ) | ReadBfrPtr [ 0 ] ) ; ReadId = ( ( ReadBfrPtr [ 0 ] << 16 ) | ( ReadBfrPtr [ 1 ] << 8 ) | ReadBfrPtr [ 2 ] ) ; FlashMake = ReadBfrPtr [ 0 ] ; if ( FlashMake == MACRONIX_OCTAL_ID_BYTE0 ) FSRFlag = 0 ; else FSRFlag = 1 ; Status = CalculateFCTIndex ( ReadId , & FCTIndex ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } return XST_SUCCESS ; }
Reads the flash ID and identifies the flash in FCT table.
Reads the flash ID and identifies the flash in FCT table .
/*
	 * Read ID
	 */