lib/sw_services/xilisf/src/xilisf_write.c
static int BufferWrite(XIsf *InstancePtr, u8 BufferNum, const u8 *WritePtr,
			u32 ByteOffset, u32 NumBytes)
{
	int Status = (int)XST_FAILURE;

	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(BufferNum != 0);
	Xil_AssertNonvoid(WritePtr != NULL);
	Xil_AssertNonvoid(ByteOffset != 0);
	Xil_AssertNonvoid(NumBytes != 0);

#if (XPAR_XISF_FLASH_FAMILY == ATMEL)
	u16 Index;

	/*
	 * Check buffer number is valid or not.
	 */
	if ((BufferNum == XISF_PAGE_BUFFER1) ||
		(BufferNum == XISF_PAGE_BUFFER2)) {
		if ((InstancePtr->DeviceCode  == XISF_ATMEL_DEV_AT45DB011D) &&
			(BufferNum != XISF_PAGE_BUFFER1))
			return (int)XST_FAILURE;
	} else
		return (int)XST_FAILURE;

	if (WritePtr == NULL)
		return (int)XST_FAILURE;

	if (ByteOffset > InstancePtr->BytesPerPage)
		return (int)XST_FAILURE;

	if ((NumBytes <= 0) ||
			(NumBytes > InstancePtr->BytesPerPage))
		return (int)XST_FAILURE;


	if (BufferNum == XISF_PAGE_BUFFER1)
		InstancePtr->WriteBufPtr[BYTE1] = XISF_CMD_BUFFER1_WRITE;
	else
		InstancePtr->WriteBufPtr[BYTE1] = XISF_CMD_BUFFER2_WRITE;

	InstancePtr->WriteBufPtr[BYTE2] = (u8) (0x00);
	InstancePtr->WriteBufPtr[BYTE3] =
			(u8) (ByteOffset >> XISF_ADDR_SHIFT8);
	InstancePtr->WriteBufPtr[BYTE4] = (u8) ByteOffset;


	for (Index = 4; Index < NumBytes + XISF_CMD_SEND_EXTRA_BYTES; Index++)
		InstancePtr->WriteBufPtr[Index] = *WritePtr++;

	/*
	 * Initiate the Transfer.
	 */
	Status = XIsf_Transfer(InstancePtr, InstancePtr->WriteBufPtr, NULL,
				(NumBytes + XISF_CMD_SEND_EXTRA_BYTES));
	if (Status != (int)XST_SUCCESS)
		return (int)XST_FAILURE;
#endif /* (XPAR_XISF_FLASH_FAMILY == ATMEL) */

	return Status;
}
/*****************************************************************************/
/**
 *
 * This function writes data to the specified SRAM buffer of the Serial Flash.
 *
 * @param	InstancePtr is a pointer to the XIsf instance.
 * @param	BufferNum specifies the internal SRAM Buffer of the Serial
 *		Flash. The valid values are XISF_PAGE_BUFFER1 or
 *		XISF_PAGE_BUFFER2. XISF_PAGE_BUFFER2 is not valid in case of
 *		Atmel AT45DB011D Serial Flash as it contains a single buffer.
 * @param	WritePtr is the pointer to the data to be written to the
 *		Serial Flash SRAM Buffer.
 * @param	ByteOffset is the byte offset in the buffer from where the
 *		data is to be written.
 * @param	NumBytes is the number of bytes to be written to the Buffer.
 *
 * @return	XST_SUCCESS if successful else XST_FAILURE.
 *
 * @note
 *		- A minimum of one byte and a maximum of one SRAM buffer can be
 *		written using this function.
 *		- This operation is only supported for Atmel Serial Flash.
 *
 ******************************************************************************/
This function writes data to the specified SRAM buffer of the Serial Flash.
@param       InstancePtr is a pointer to the XIsf instance.
@param       BufferNum specifies the internal SRAM Buffer of the Serial
Flash. The valid values are XISF_PAGE_BUFFER1 or
XISF_PAGE_BUFFER2. XISF_PAGE_BUFFER2 is not valid in case of
Atmel AT45DB011D Serial Flash as it contains a single buffer.
@param       WritePtr is the pointer to the data to be written to the
Serial Flash SRAM Buffer.
@param       ByteOffset is the byte offset in the buffer from where the
data is to be written.
@param       NumBytes is the number of bytes to be written to the Buffer.



@note
- A minimum of one byte and a maximum of one SRAM buffer can be
written using this function.
- This operation is only supported for Atmel Serial Flash.
This function writes data to the specified SRAM buffer of the Serial Flash . @param InstancePtr is a pointer to the XIsf instance . @param BufferNum specifies the internal SRAM Buffer of the Serial Flash . The valid values are XISF_PAGE_BUFFER1 or XISF_PAGE_BUFFER2 . XISF_PAGE_BUFFER2 is not valid in case of Atmel AT45DB011D Serial Flash as it contains a single buffer . @param WritePtr is the pointer to the data to be written to the Serial Flash SRAM Buffer . @param ByteOffset is the byte offset in the buffer from where the data is to be written . @param NumBytes is the number of bytes to be written to the Buffer . @note - A minimum of one byte and a maximum of one SRAM buffer can be written using this function . - This operation is only supported for Atmel Serial Flash .
static int BufferWrite(XIsf *InstancePtr, u8 BufferNum, const u8 *WritePtr,
			u32 ByteOffset, u32 NumBytes)
{
	int Status = (int)XST_FAILURE;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(BufferNum != 0);
	Xil_AssertNonvoid(WritePtr != NULL);
	Xil_AssertNonvoid(ByteOffset != 0);
	Xil_AssertNonvoid(NumBytes != 0);
#if (XPAR_XISF_FLASH_FAMILY == ATMEL)
	u16 Index;
	if ((BufferNum == XISF_PAGE_BUFFER1) ||
		(BufferNum == XISF_PAGE_BUFFER2)) {
		if ((InstancePtr->DeviceCode  == XISF_ATMEL_DEV_AT45DB011D) &&
			(BufferNum != XISF_PAGE_BUFFER1))
			return (int)XST_FAILURE;
	} else
		return (int)XST_FAILURE;
	if (WritePtr == NULL)
		return (int)XST_FAILURE;
	if (ByteOffset > InstancePtr->BytesPerPage)
		return (int)XST_FAILURE;
	if ((NumBytes <= 0) ||
			(NumBytes > InstancePtr->BytesPerPage))
		return (int)XST_FAILURE;
	if (BufferNum == XISF_PAGE_BUFFER1)
		InstancePtr->WriteBufPtr[BYTE1] = XISF_CMD_BUFFER1_WRITE;
	else
		InstancePtr->WriteBufPtr[BYTE1] = XISF_CMD_BUFFER2_WRITE;
	InstancePtr->WriteBufPtr[BYTE2] = (u8) (0x00);
	InstancePtr->WriteBufPtr[BYTE3] =
			(u8) (ByteOffset >> XISF_ADDR_SHIFT8);
	InstancePtr->WriteBufPtr[BYTE4] = (u8) ByteOffset;
	for (Index = 4; Index < NumBytes + XISF_CMD_SEND_EXTRA_BYTES; Index++)
		InstancePtr->WriteBufPtr[Index] = *WritePtr++;
	Status = XIsf_Transfer(InstancePtr, InstancePtr->WriteBufPtr, NULL,
				(NumBytes + XISF_CMD_SEND_EXTRA_BYTES));
	if (Status != (int)XST_SUCCESS)
		return (int)XST_FAILURE;
#endif 
	return Status;
}
static int BufferWrite ( XIsf * InstancePtr , u8 BufferNum , const u8 * WritePtr , u32 ByteOffset , u32 NumBytes ) { int Status = ( int ) XST_FAILURE ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( BufferNum != 0 ) ; Xil_AssertNonvoid ( WritePtr != NULL ) ; Xil_AssertNonvoid ( ByteOffset != 0 ) ; Xil_AssertNonvoid ( NumBytes != 0 ) ; #if ( XPAR_XISF_FLASH_FAMILY == ATMEL ) u16 Index ; if ( ( BufferNum == XISF_PAGE_BUFFER1 ) || ( BufferNum == XISF_PAGE_BUFFER2 ) ) { if ( ( InstancePtr -> DeviceCode == XISF_ATMEL_DEV_AT45DB011D ) && ( BufferNum != XISF_PAGE_BUFFER1 ) ) return ( int ) XST_FAILURE ; } else return ( int ) XST_FAILURE ; if ( WritePtr == NULL ) return ( int ) XST_FAILURE ; if ( ByteOffset > InstancePtr -> BytesPerPage ) return ( int ) XST_FAILURE ; if ( ( NumBytes <= 0 ) || ( NumBytes > InstancePtr -> BytesPerPage ) ) return ( int ) XST_FAILURE ; if ( BufferNum == XISF_PAGE_BUFFER1 ) InstancePtr -> WriteBufPtr [ BYTE1 ] = XISF_CMD_BUFFER1_WRITE ; else InstancePtr -> WriteBufPtr [ BYTE1 ] = XISF_CMD_BUFFER2_WRITE ; InstancePtr -> WriteBufPtr [ BYTE2 ] = ( u8 ) ( 0x00 ) ; InstancePtr -> WriteBufPtr [ BYTE3 ] = ( u8 ) ( ByteOffset >> XISF_ADDR_SHIFT8 ) ; InstancePtr -> WriteBufPtr [ BYTE4 ] = ( u8 ) ByteOffset ; for ( Index = 4 ; Index < NumBytes + XISF_CMD_SEND_EXTRA_BYTES ; Index ++ ) InstancePtr -> WriteBufPtr [ Index ] = * WritePtr ++ ; Status = XIsf_Transfer ( InstancePtr , InstancePtr -> WriteBufPtr , NULL , ( NumBytes + XISF_CMD_SEND_EXTRA_BYTES ) ) ; if ( Status != ( int ) XST_SUCCESS ) return ( int ) XST_FAILURE ; #endif return Status ; }
This function writes data to the specified SRAM buffer of the Serial Flash.
This function writes data to the specified SRAM buffer of the Serial Flash .
/*
	 * Check buffer number is valid or not.
	 */ /*
	 * Initiate the Transfer.
	 */ /* (XPAR_XISF_FLASH_FAMILY == ATMEL) */