XilinxProcessorIPLib/drivers/qspips/examples/xqspips_g128_flash_example.c
void DieErase(XQspiPs *QspiPtr, u8 *WriteBfrPtr)
{
	u8 WriteEnableCmd = { WRITE_ENABLE_CMD };
	u8 DieCnt;
	u8 ReadFlagSRCmd[] = { READ_FLAG_STATUS_CMD, 0 };
	u8 FlagStatus[2];

	for(DieCnt = 0; DieCnt < Flash_Config_Table[FCTIndex].NumDie; DieCnt++) {
		/*
		 * Select bank - the lower of the 2 banks in each die
		 * This is specific to Micron flash
		 */
		SendBankSelect(QspiPtr, WriteBfrPtr, DieCnt*2);

		/*
		 * Send the write enable command to the SEEPOM so that it can be
		 * written to, this needs to be sent as a separate transfer
		 * before the write
		 */
		XQspiPs_PolledTransfer(QspiPtr, &WriteEnableCmd, NULL,
				  sizeof(WriteEnableCmd));

		/*
		 * Setup the write command with the specified address and data
		 * for the Flash
		 */
		/*
		 * This ensures 3B address is sent to flash even with address
		 * greater than 128Mb.
		 * The address is the start address of die - MSB bits will be
		 * derived from bank select by the flash
		 */
		WriteBfrPtr[COMMAND_OFFSET]   = DIE_ERASE_CMD;
		WriteBfrPtr[ADDRESS_1_OFFSET] = 0x00;
		WriteBfrPtr[ADDRESS_2_OFFSET] = 0x00;
		WriteBfrPtr[ADDRESS_3_OFFSET] = 0x00;

		/*
		 * Send the sector erase command and address; no receive buffer
		 * is specified since there is nothing to receive
		 */
		XQspiPs_PolledTransfer(QspiPtr, WriteBfrPtr, NULL,
				DIE_ERASE_SIZE);

		/*
		 * Wait for the sector erase command to the Flash to be completed
		 */
		while (1) {
			/*
			 * Poll the status register of the device to determine
			 * when it completes, by sending a read status command
			 * and receiving the status byte
			 */
			XQspiPs_PolledTransfer(QspiPtr, ReadFlagSRCmd, FlagStatus,
					sizeof(ReadFlagSRCmd));

			/*
			 * If the status indicates the write is done, then stop
			 * waiting, if a value of 0xFF in the status byte is
			 * read from the device and this loop never exits, the
			 * device slave select is possibly incorrect such that
			 * the device status is not being read
			 */
			if ((FlagStatus[1] & 0x80) == 0x80) {
				break;
			}
		}

	}
}
/*****************************************************************************/
/**
*
* This functions performs a die erase operation on all the die in
* the flash device. This function uses the die erase command for
* Micron 512Mbit and 1Gbit
*
* @param	QspiPtr is a pointer to the QSPI driver component to use.
* @param	WriteBfrPtr is the pointer to command+address to be sent
*
* @return	None
*
* @note		None.
*
******************************************************************************/
This functions performs a die erase operation on all the die in
the flash device. This function uses the die erase command for
Micron 512Mbit and 1Gbit
This functions performs a die erase operation on all the die in the flash device . This function uses the die erase command for Micron 512Mbit and 1Gbit
void DieErase(XQspiPs *QspiPtr, u8 *WriteBfrPtr)
{
	u8 WriteEnableCmd = { WRITE_ENABLE_CMD };
	u8 DieCnt;
	u8 ReadFlagSRCmd[] = { READ_FLAG_STATUS_CMD, 0 };
	u8 FlagStatus[2];
	for(DieCnt = 0; DieCnt < Flash_Config_Table[FCTIndex].NumDie; DieCnt++) {
		SendBankSelect(QspiPtr, WriteBfrPtr, DieCnt*2);
		XQspiPs_PolledTransfer(QspiPtr, &WriteEnableCmd, NULL,
				  sizeof(WriteEnableCmd));
		WriteBfrPtr[COMMAND_OFFSET]   = DIE_ERASE_CMD;
		WriteBfrPtr[ADDRESS_1_OFFSET] = 0x00;
		WriteBfrPtr[ADDRESS_2_OFFSET] = 0x00;
		WriteBfrPtr[ADDRESS_3_OFFSET] = 0x00;
		XQspiPs_PolledTransfer(QspiPtr, WriteBfrPtr, NULL,
				DIE_ERASE_SIZE);
		while (1) {
			XQspiPs_PolledTransfer(QspiPtr, ReadFlagSRCmd, FlagStatus,
					sizeof(ReadFlagSRCmd));
			if ((FlagStatus[1] & 0x80) == 0x80) {
				break;
			}
		}
	}
}
void DieErase ( XQspiPs * QspiPtr , u8 * WriteBfrPtr ) { u8 WriteEnableCmd = { WRITE_ENABLE_CMD } ; u8 DieCnt ; u8 ReadFlagSRCmd [ ] = { READ_FLAG_STATUS_CMD , 0 } ; u8 FlagStatus [ 2 ] ; for ( DieCnt = 0 ; DieCnt < Flash_Config_Table [ FCTIndex ] . NumDie ; DieCnt ++ ) { SendBankSelect ( QspiPtr , WriteBfrPtr , DieCnt * 2 ) ; XQspiPs_PolledTransfer ( QspiPtr , & WriteEnableCmd , NULL , sizeof ( WriteEnableCmd ) ) ; WriteBfrPtr [ COMMAND_OFFSET ] = DIE_ERASE_CMD ; WriteBfrPtr [ ADDRESS_1_OFFSET ] = 0x00 ; WriteBfrPtr [ ADDRESS_2_OFFSET ] = 0x00 ; WriteBfrPtr [ ADDRESS_3_OFFSET ] = 0x00 ; XQspiPs_PolledTransfer ( QspiPtr , WriteBfrPtr , NULL , DIE_ERASE_SIZE ) ; while ( 1 ) { XQspiPs_PolledTransfer ( QspiPtr , ReadFlagSRCmd , FlagStatus , sizeof ( ReadFlagSRCmd ) ) ; if ( ( FlagStatus [ 1 ] & 0x80 ) == 0x80 ) { break ; } } } }
This functions performs a die erase operation on all the die in
the flash device.
This functions performs a die erase operation on all the die in the flash device .
/*
		 * Select bank - the lower of the 2 banks in each die
		 * This is specific to Micron flash
		 */ /*
		 * Send the write enable command to the SEEPOM so that it can be
		 * written to, this needs to be sent as a separate transfer
		 * before the write
		 */ /*
		 * Setup the write command with the specified address and data
		 * for the Flash
		 */ /*
		 * This ensures 3B address is sent to flash even with address
		 * greater than 128Mb.
		 * The address is the start address of die - MSB bits will be
		 * derived from bank select by the flash
		 */ /*
		 * Send the sector erase command and address; no receive buffer
		 * is specified since there is nothing to receive
		 */ /*
		 * Wait for the sector erase command to the Flash to be completed
		 */ /*
			 * Poll the status register of the device to determine
			 * when it completes, by sending a read status command
			 * and receiving the status byte
			 */ /*
			 * If the status indicates the write is done, then stop
			 * waiting, if a value of 0xFF in the status byte is
			 * read from the device and this loop never exits, the
			 * device slave select is possibly incorrect such that
			 * the device status is not being read
			 */