XilinxProcessorIPLib/drivers/ospipsv/examples/xospipsv_flash_non_blocking_read_example.c
int FlashLinearWrite(XOspiPsv *OspiPsvPtr, u32 Address, u32 ByteCount,
				u8 *WriteBfrPtr)
{
	u8 Status;

	FlashMsg.Opcode = WRITE_ENABLE_CMD;
	FlashMsg.Addrsize = 0;
	FlashMsg.Addrvalid = 0;
	FlashMsg.TxBfrPtr = NULL;
	FlashMsg.RxBfrPtr = NULL;
	FlashMsg.ByteCount = 0;
	FlashMsg.Flags = XOSPIPSV_MSG_FLAG_TX;
	FlashMsg.IsDDROpCode = 0;
	FlashMsg.Proto = 0;
	FlashMsg.Dummy = 0;
	if (OspiPsvPtr->SdrDdrMode == XOSPIPSV_EDGE_MODE_DDR_PHY) {
		FlashMsg.Proto = XOSPIPSV_WRITE_8_0_0;
	}

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

	Status = XOspiPsv_PollTransfer(OspiPsvPtr, &FlashMsg);
	if (Status != XST_SUCCESS)
		return XST_FAILURE;

	FlashMsg.Opcode = (u8)(Flash_Config_Table[FCTIndex].WriteCmd >> 8);
	FlashMsg.Addrvalid = 1;
	FlashMsg.TxBfrPtr = WriteBfrPtr;
	FlashMsg.RxBfrPtr = NULL;
	FlashMsg.ByteCount = ByteCount;
	FlashMsg.Flags = XOSPIPSV_MSG_FLAG_TX;
	FlashMsg.Addrsize = 4;
	FlashMsg.Addr = Address;
	FlashMsg.Proto = XOspiPsv_Get_Proto(OspiPsvPtr, 0);
	FlashMsg.Dummy = 0;
	if (OspiPsvPtr->SdrDdrMode == XOSPIPSV_EDGE_MODE_DDR_PHY) {
		FlashMsg.Proto = XOSPIPSV_WRITE_8_8_8;
	}
	FlashMsg.IsDDROpCode = 0;
	if (OspiPsvPtr->DualByteOpcodeEn != 0U)
		FlashMsg.ExtendedOpcode = (u8)(~FlashMsg.Opcode);

	Status = XOspiPsv_PollTransfer(OspiPsvPtr, &FlashMsg);
	if (Status != XST_SUCCESS)
		return XST_FAILURE;

	return 0;
}
/*****************************************************************************/
/**
*
* This function writes to the  serial Flash connected to the OSPIPSV interface.
* All the data put into the buffer must be in the same page of the device with
* page boundaries being on 256 byte boundaries. This can be used when controller
* is in Linear mode.
*
* @param	OspiPsvPtr is a pointer to the OSPIPSV driver component to use.
* @param	Address contains the address to write data to in the Flash.
* @param	ByteCount contains the number of bytes to write.
* @param	WriteBfrPtr is Pointer to the write buffer
*		(which is to be transmitted)
*
* @return	XST_SUCCESS if successful, else XST_FAILURE.
*
* @note		None.
*
******************************************************************************/
This function writes to the  serial Flash connected to the OSPIPSV interface.
All the data put into the buffer must be in the same page of the device with
page boundaries being on 256 byte boundaries. This can be used when controller
is in Linear mode.
This function writes to the serial Flash connected to the OSPIPSV interface . All the data put into the buffer must be in the same page of the device with page boundaries being on 256 byte boundaries . This can be used when controller is in Linear mode .
int FlashLinearWrite(XOspiPsv *OspiPsvPtr, u32 Address, u32 ByteCount,
				u8 *WriteBfrPtr)
{
	u8 Status;
	FlashMsg.Opcode = WRITE_ENABLE_CMD;
	FlashMsg.Addrsize = 0;
	FlashMsg.Addrvalid = 0;
	FlashMsg.TxBfrPtr = NULL;
	FlashMsg.RxBfrPtr = NULL;
	FlashMsg.ByteCount = 0;
	FlashMsg.Flags = XOSPIPSV_MSG_FLAG_TX;
	FlashMsg.IsDDROpCode = 0;
	FlashMsg.Proto = 0;
	FlashMsg.Dummy = 0;
	if (OspiPsvPtr->SdrDdrMode == XOSPIPSV_EDGE_MODE_DDR_PHY) {
		FlashMsg.Proto = XOSPIPSV_WRITE_8_0_0;
	}
	if (OspiPsvPtr->DualByteOpcodeEn != 0U)
		FlashMsg.ExtendedOpcode = (u8)(~FlashMsg.Opcode);
	Status = XOspiPsv_PollTransfer(OspiPsvPtr, &FlashMsg);
	if (Status != XST_SUCCESS)
		return XST_FAILURE;
	FlashMsg.Opcode = (u8)(Flash_Config_Table[FCTIndex].WriteCmd >> 8);
	FlashMsg.Addrvalid = 1;
	FlashMsg.TxBfrPtr = WriteBfrPtr;
	FlashMsg.RxBfrPtr = NULL;
	FlashMsg.ByteCount = ByteCount;
	FlashMsg.Flags = XOSPIPSV_MSG_FLAG_TX;
	FlashMsg.Addrsize = 4;
	FlashMsg.Addr = Address;
	FlashMsg.Proto = XOspiPsv_Get_Proto(OspiPsvPtr, 0);
	FlashMsg.Dummy = 0;
	if (OspiPsvPtr->SdrDdrMode == XOSPIPSV_EDGE_MODE_DDR_PHY) {
		FlashMsg.Proto = XOSPIPSV_WRITE_8_8_8;
	}
	FlashMsg.IsDDROpCode = 0;
	if (OspiPsvPtr->DualByteOpcodeEn != 0U)
		FlashMsg.ExtendedOpcode = (u8)(~FlashMsg.Opcode);
	Status = XOspiPsv_PollTransfer(OspiPsvPtr, &FlashMsg);
	if (Status != XST_SUCCESS)
		return XST_FAILURE;
	return 0;
}
int FlashLinearWrite ( XOspiPsv * OspiPsvPtr , u32 Address , u32 ByteCount , u8 * WriteBfrPtr ) { u8 Status ; FlashMsg . Opcode = WRITE_ENABLE_CMD ; FlashMsg . Addrsize = 0 ; FlashMsg . Addrvalid = 0 ; FlashMsg . TxBfrPtr = NULL ; FlashMsg . RxBfrPtr = NULL ; FlashMsg . ByteCount = 0 ; FlashMsg . Flags = XOSPIPSV_MSG_FLAG_TX ; FlashMsg . IsDDROpCode = 0 ; FlashMsg . Proto = 0 ; FlashMsg . Dummy = 0 ; if ( OspiPsvPtr -> SdrDdrMode == XOSPIPSV_EDGE_MODE_DDR_PHY ) { FlashMsg . Proto = XOSPIPSV_WRITE_8_0_0 ; } if ( OspiPsvPtr -> DualByteOpcodeEn != 0U ) FlashMsg . ExtendedOpcode = ( u8 ) ( ~ FlashMsg . Opcode ) ; Status = XOspiPsv_PollTransfer ( OspiPsvPtr , & FlashMsg ) ; if ( Status != XST_SUCCESS ) return XST_FAILURE ; FlashMsg . Opcode = ( u8 ) ( Flash_Config_Table [ FCTIndex ] . WriteCmd >> 8 ) ; FlashMsg . Addrvalid = 1 ; FlashMsg . TxBfrPtr = WriteBfrPtr ; FlashMsg . RxBfrPtr = NULL ; FlashMsg . ByteCount = ByteCount ; FlashMsg . Flags = XOSPIPSV_MSG_FLAG_TX ; FlashMsg . Addrsize = 4 ; FlashMsg . Addr = Address ; FlashMsg . Proto = XOspiPsv_Get_Proto ( OspiPsvPtr , 0 ) ; FlashMsg . Dummy = 0 ; if ( OspiPsvPtr -> SdrDdrMode == XOSPIPSV_EDGE_MODE_DDR_PHY ) { FlashMsg . Proto = XOSPIPSV_WRITE_8_8_8 ; } FlashMsg . IsDDROpCode = 0 ; if ( OspiPsvPtr -> DualByteOpcodeEn != 0U ) FlashMsg . ExtendedOpcode = ( u8 ) ( ~ FlashMsg . Opcode ) ; Status = XOspiPsv_PollTransfer ( OspiPsvPtr , & FlashMsg ) ; if ( Status != XST_SUCCESS ) return XST_FAILURE ; return 0 ; }
This function writes to the  serial Flash connected to the OSPIPSV interface.
This function writes to the serial Flash connected to the OSPIPSV interface .