lib/sw_services/xilisf/src/xilisf_write.c
static int BufferToFlashWriteWithErase(XIsf *InstancePtr, u8 BufferNum,
					u32 Address)
{
	int Status = (int)XST_FAILURE;

	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(BufferNum != 0);
	Xil_AssertNonvoid(Address != 0);

#if (XPAR_XISF_FLASH_FAMILY == ATMEL)
	/*
	 * Check whether the 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 (BufferNum == XISF_PAGE_BUFFER1) {
		/*
		 * Buffer 1 to Page Program With Erase.
		 */
		InstancePtr->WriteBufPtr[BYTE1] =
				XISF_CMD_ERASE_BUF1TOPAGE_WRITE;
	} else {
		/*
		 * Buffer 2 to Page Program With Erase.
		 */
		InstancePtr->WriteBufPtr[BYTE1] =
			XISF_CMD_ERASE_BUF2TOPAGE_WRITE;
	}
	InstancePtr->WriteBufPtr[BYTE2] = (u8) (Address >> XISF_ADDR_SHIFT16);
	InstancePtr->WriteBufPtr[BYTE3] = (u8) (Address >> XISF_ADDR_SHIFT8);
	InstancePtr->WriteBufPtr[BYTE4] = (u8) (XISF_DUMMYBYTE);

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

	return Status;
}
/*****************************************************************************/
/**
 *
 * This function first erases a page and then writes data from the specified
 * internal SRAM buffer to the specified locations in the Serial Flash.
 *
 * @param	InstancePtr is a pointer to the XIsf instance.
 * @param	BufferNum specifies the internal SRAM Buffer, from which the
 *		data needs to be written to the Serial Flash. The valid values
 *		are XISF_PAGE_BUFFER1 or XISF_PAGE_BUFFER2. XISF_PAGE_BUFFER2
 *		is not valid in the case of Atmel AT45DB011D Serial Flash as it
 *		contains a single buffer.
 * @param	Address is the starting address in the Serial Flash where
 *		the data has to be written. Byte address in this address is
 *		ignored	as an entire Page is transferred using this API.
 *
 * @return	XST_SUCCESS if successful else XST_FAILURE.
 *
 * @note
 *		- A minimum of one Page and a maximum of one Page can be
 *		written using this function.
 *		- This operation is only supported for Atmel Serial Flash.
 *
 ******************************************************************************/
This function first erases a page and then writes data from the specified
internal SRAM buffer to the specified locations in the Serial Flash.

@param       InstancePtr is a pointer to the XIsf instance.
@param       BufferNum specifies the internal SRAM Buffer, from which the
data needs to be written to the Serial Flash. The valid values
are XISF_PAGE_BUFFER1 or XISF_PAGE_BUFFER2. XISF_PAGE_BUFFER2
is not valid in the case of Atmel AT45DB011D Serial Flash as it
contains a single buffer.
@param       Address is the starting address in the Serial Flash where
the data has to be written. Byte address in this address is
ignored as an entire Page is transferred using this API.



@note
- A minimum of one Page and a maximum of one Page can be
written using this function.
- This operation is only supported for Atmel Serial Flash.
This function first erases a page and then writes data from the specified internal SRAM buffer to the specified locations in the Serial Flash . @param InstancePtr is a pointer to the XIsf instance . @param BufferNum specifies the internal SRAM Buffer from which the data needs to be written to the Serial Flash . The valid values are XISF_PAGE_BUFFER1 or XISF_PAGE_BUFFER2 . XISF_PAGE_BUFFER2 is not valid in the case of Atmel AT45DB011D Serial Flash as it contains a single buffer . @param Address is the starting address in the Serial Flash where the data has to be written . Byte address in this address is ignored as an entire Page is transferred using this API . @note - A minimum of one Page and a maximum of one Page can be written using this function . - This operation is only supported for Atmel Serial Flash .
static int BufferToFlashWriteWithErase(XIsf *InstancePtr, u8 BufferNum,
					u32 Address)
{
	int Status = (int)XST_FAILURE;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(BufferNum != 0);
	Xil_AssertNonvoid(Address != 0);
#if (XPAR_XISF_FLASH_FAMILY == ATMEL)
	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 (BufferNum == XISF_PAGE_BUFFER1) {
		InstancePtr->WriteBufPtr[BYTE1] =
				XISF_CMD_ERASE_BUF1TOPAGE_WRITE;
	} else {
		InstancePtr->WriteBufPtr[BYTE1] =
			XISF_CMD_ERASE_BUF2TOPAGE_WRITE;
	}
	InstancePtr->WriteBufPtr[BYTE2] = (u8) (Address >> XISF_ADDR_SHIFT16);
	InstancePtr->WriteBufPtr[BYTE3] = (u8) (Address >> XISF_ADDR_SHIFT8);
	InstancePtr->WriteBufPtr[BYTE4] = (u8) (XISF_DUMMYBYTE);
	Status = XIsf_Transfer(InstancePtr, InstancePtr->WriteBufPtr, NULL,
				XISF_CMD_SEND_EXTRA_BYTES);
	if (Status != (int)XST_SUCCESS)
		return (int)XST_FAILURE;
#endif 
	return Status;
}
static int BufferToFlashWriteWithErase ( XIsf * InstancePtr , u8 BufferNum , u32 Address ) { int Status = ( int ) XST_FAILURE ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( BufferNum != 0 ) ; Xil_AssertNonvoid ( Address != 0 ) ; #if ( XPAR_XISF_FLASH_FAMILY == ATMEL ) 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 ( BufferNum == XISF_PAGE_BUFFER1 ) { InstancePtr -> WriteBufPtr [ BYTE1 ] = XISF_CMD_ERASE_BUF1TOPAGE_WRITE ; } else { InstancePtr -> WriteBufPtr [ BYTE1 ] = XISF_CMD_ERASE_BUF2TOPAGE_WRITE ; } InstancePtr -> WriteBufPtr [ BYTE2 ] = ( u8 ) ( Address >> XISF_ADDR_SHIFT16 ) ; InstancePtr -> WriteBufPtr [ BYTE3 ] = ( u8 ) ( Address >> XISF_ADDR_SHIFT8 ) ; InstancePtr -> WriteBufPtr [ BYTE4 ] = ( u8 ) ( XISF_DUMMYBYTE ) ; Status = XIsf_Transfer ( InstancePtr , InstancePtr -> WriteBufPtr , NULL , XISF_CMD_SEND_EXTRA_BYTES ) ; if ( Status != ( int ) XST_SUCCESS ) return ( int ) XST_FAILURE ; #endif return Status ; }
This function first erases a page and then writes data from the specified
 internal SRAM buffer to the specified locations in the Serial Flash.
This function first erases a page and then writes data from the specified internal SRAM buffer to the specified locations in the Serial Flash .
/*
	 * Check whether the buffer number is valid or not.
	 */ /*
		 * Buffer 1 to Page Program With Erase.
		 */ /*
		 * Buffer 2 to Page Program With Erase.
		 */ /*
	 * Initiate the Transfer.
	 */ /* (XPAR_XISF_FLASH_FAMILY == ATMEL) */