⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flash_psd4256g_test.c

📁 ADSP 地层驱动
💻 C
字号:
///////////////////////////////////////////////////////////////
//
// main.c
//
// Analog Devices, Inc. - 2006
//
//
// Change Log
//
//		1.00.0
//			- initial release
//
// Perform POST test for ADSP-BF533 EZ-KIT Lite containing the 
// STMicroelectronics PSD4256G flash device.
//
///////////////////////////////////////////////////////////////

/*===== I n c l u d e s  =====*/

#include <services/services.h>
#include <drivers/adi_dev.h>		// device manager includes
#include <stdlib.h>
#include "adi_psd4256g.h"		// flash-PSD4256G includes
#include "util.h" 				// library struct includes
#include "Errors.h"				// error type includes

#define FLASH_SECTOR_39 			39			// number of sectors in the flash device
#define FLASH_START_ADDR			0x20000000
#define FLASH_SECTOR_39_OFFSET		0x00288000	// block size 0x8000

#define FLASH_SECTOR				FLASH_SECTOR_39
#define FLASH_SECTOR_OFFSET			FLASH_SECTOR_39_OFFSET


/*********************************************************************
*
*	Function:	main
*
*********************************************************************/

int TEST_FLASH(void)
{
	int i;
	unsigned int iPassed = 0;
	unsigned int iResult;				// result
	ADI_DEV_1D_BUFFER FlashBuff1D;		// write buffer pointer
	unsigned short sVal = 0;
	unsigned int nSector = 0;

	COMMAND_STRUCT pCmdBuffer;

	// setup the external bus control
	*pEBIU_AMGCTL = 0xFF;



	// erase the second to last sector
	// (the last sector on the BF533 )
	pCmdBuffer.SEraseSect.nSectorNum = FLASH_SECTOR;
	pCmdBuffer.SEraseSect.ulFlashStartAddr = FLASH_START_ADDR;

	// Erase the flash
	iResult = adi_dev_Control(DevHandlePSD4256G, CNTRL_ERASE_SECT, &pCmdBuffer );
	if(ADI_DEV_RESULT_SUCCESS == iResult)
	{
		// initialize our buffer
		FlashBuff1D.Data = &sVal;

		for( i = 0; i < 0xFFFF; i+=2 )
		{
			unsigned long ulOffset = FLASH_SECTOR_OFFSET + i;
			FlashBuff1D.pAdditionalInfo = (void *)&ulOffset;
			FlashBuff1D.pNext = NULL;
			sVal = i;

			// write to the flash
			iResult = adi_dev_Write(DevHandlePSD4256G, ADI_DEV_1D, (ADI_DEV_BUFFER *)&FlashBuff1D);
			if(ADI_DEV_RESULT_SUCCESS == iResult)
			{
				iPassed = 1;
				sVal = 0;

				// Read back the values from sector
				// set the parameters needed to do a read

				// read from the flash
				iResult = adi_dev_Read(DevHandlePSD4256G, ADI_DEV_1D, (ADI_DEV_BUFFER *)&FlashBuff1D);
				if(ADI_DEV_RESULT_SUCCESS == iResult)
				{
					if( i != sVal )
					{
						iPassed = 0;
						break;
					}
				}
			}//end adi_pdd_Write() -- if(ADI_DEV_RESULT_SUCCESS == iResult)
		}// end for( i = 0; i < 0xFFFF; i+=2 )
	}//end adi_pdd_Control() -- if(ADI_DEV_RESULT_SUCCESS == iResult)


	return iPassed;
}


/*********************************************************************
*
*	Function:	main
*
*********************************************************************/
#ifdef _STANDALONE_ // use this to run standalone tests
int main(void)
{
	int iStatus;

	asm("nop;");

	while(1)
	{
		iStatus = TEST_FLASH();
		if( 0 == iStatus )
		{
			asm("emuexcpt;");
		}
	}

}
#endif //#ifdef _STANDALONE_ // use this to run standalone tests

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -