Esempio n. 1
0
uint32_t testNOR(uint32_t startAddress, uint32_t size, uint16_t bufferSize) {
	uint8_t index;
	uint16_t numWord;
	uint16_t check;
	uint8_t startBlock = startAddress / NORFLASH_SECTOR_SIZE;
	uint8_t endBlock = (startAddress + size) / NORFLASH_SECTOR_SIZE;
	NORFLASH_Status status;
	NORFLASH_Id chipId;

	NORFLASH_Init();
//	for (index = startBlock; index <= endBlock; index++) {
//		status = NORFLASH_EraseBlockNum(index);
//	}
//	SerialSendBytes("Start writing.\r\n", 16);
//	for (numWord = 0; numWord < size; numWord++) {
//		NORFLASH_WriteWord(startAddress + numWord, numWord);
//	}
//	SerialSendBytes("Memory written.\r\n", 17);

	char testLine[24] = "Addr:xxxxxxxx :  yyyy \r\n";
	for (numWord = 0; numWord < size; numWord++) {
		check = NORFLASH_ReadWord(startAddress + numWord);
		getHexFromLong(testLine + 5, startAddress + numWord, 8);
		getHexFromLong(testLine + 17, check, 4);
		Delay_ms(1);
		SerialSendBytes(testLine, 24);
	}

	return 0;
}
Esempio n. 2
0
/**************************************************************************//**
 * @brief
 *   Initialize the storage media interface.
 *****************************************************************************/
bool MSDDMEDIA_Init( void )
{
  #if ( MSD_MEDIA != MSD_SDCARD_MEDIA ) && ( MSD_MEDIA != MSD_NORFLASH_MEDIA )
  numSectors = MEDIA_SIZE / 512;
  #endif

  #if ( MSD_MEDIA == MSD_PSRAM_MEDIA )
  storage = (uint8_t*)EBI_BankAddress( EBI_BANK2 );
  storage[0] = 0;   /* To force new "format disk" when host detects disk. */
  #endif

  #if ( MSD_MEDIA == MSD_SDCARD_MEDIA )
  /* Enable SPI access to MicroSD card */
  BSP_PeripheralAccess( BSP_MICROSD, true );
  MICROSD_Init();

  if ( disk_initialize( 0 ) != 0 )
    return false;

  /* Get numSectors from media. */
  if ( disk_ioctl( 0, GET_SECTOR_COUNT, &numSectors ) != RES_OK )
    return false;
  #endif

  #if ( MSD_MEDIA == MSD_FLASH_MEDIA )
  flashStatus.pendingWrite = false;
  MSC_Init();                         /* Unlock and calibrate flash timing  */
  MSC_Deinit();                       /* Lock flash                         */
  #endif

  #if ( MSD_MEDIA == MSD_NORFLASH_MEDIA )
  flashStatus.pendingWrite = false;
  NORFLASH_Init();                    /* Initialize NORFLASH interface      */

  storage       = (uint8_t*)NORFLASH_DeviceInfo()->baseAddress;
  flashPageSize = NORFLASH_DeviceInfo()->sectorSize;
  /* Use external PSRAM as page (flash sector) buffer */
  flashPageBuf  = (uint8_t*)EBI_BankAddress( EBI_BANK2 );
  numSectors    = NORFLASH_DeviceInfo()->deviceSize / 512;
  #endif

  return true;
}