Пример #1
0
/*******************************************************************************
Func:读取页面内容
Date:2014-7-27
Note:返回状态
*******************************************************************************/
TQFS_Error TQFS_ReadPageContext(TQFS_Open_File *Open_File,uint8 *rBuffer,uint16 Length)
{
	File_Infor TempFile;
	int OviLenth;
	uint16 Offset=0;
  OviLenth=(Open_File->OffsetCursor+Length);
	OviLenth-=NAND_PAGE_SIZE;//写不下的长度
	if(OviLenth>=0)//当前页不够
	{
		Nand_ReadPage(Nand_Infor.FileStartPage+Open_File->PageCursor,&rBuffer[Offset],Open_File->OffsetCursor+NAND_SPARE_SIZE,Length-OviLenth);
		Offset=Length-OviLenth;
		Open_File->OffsetCursor=0;
		Read_FileInfor(Open_File->PageCursor,&TempFile);
		if(TempFile.NextPageAddr==0xffffffff)return TE_NoNextPage;
		else{
			Open_File->PageCursor=TempFile.NextPageAddr;
			Length=OviLenth;
		}			
	}
		Nand_ReadPage(Nand_Infor.FileStartPage+Open_File->PageCursor,&rBuffer[Offset],Open_File->OffsetCursor+NAND_SPARE_SIZE,Length);
		Open_File->OffsetCursor+=Length;
	if(OviLenth>=0)return TE_NewPage;
	else return TE_CurrentPage;
}
Пример #2
0
/******************************************************************************
 * @brief  Main function
 * Main is called from _program_start, see assembly startup file
 *****************************************************************************/
int main(void)
{
    uint32_t i,j;
    uint16_t column;
    uint8_t page;
    uint8_t plane;
    uint16_t block;

    uint8_t status;

    /* Initialize chip */
    CHIP_Init();

    SystemCoreClockUpdate();


    /* Setup SysTick Timer for 1 msec interrupts  */
//   if (SysTick_Config(SystemCoreClock / 1000)) while (1) ;

    /* Enable clock for GPIO */
    CMU_ClockEnable(cmuClock_GPIO, true);




//    GPIO_PinModeSet(LED_PORT, LED_PIN0, gpioModePushPull, 0 );
//    GPIO_PinModeSet(LED_PORT, LED_PIN1, gpioModePushPull, 0 );
//    GPIO_PinModeSet(LED_PORT, LED_PIN2, gpioModePushPull, 0 );
//    GPIO_PinModeSet(LED_PORT, LED_PIN3, gpioModePushPull, 0 );


    Nand_InitPins();

    /*
        while (1)
        {
            GPIO_PortOutSetVal(LED_PORT, 0xf, 0xf);
            Delay_ms(1000);
            GPIO_PortOutSetVal(LED_PORT, 0x0, 0xf);
            Delay_ms(1000);
        }
    */

    Nand_Reset();
//    Delay_ms(500);

    page = 1;
    while (page--)
    {
        Nand_GetID(&nandID);
    }

    column = 0;
    page   = 0;
    plane  = 0;
    block  = 24;

    for (i = 0; i < PHYSICAL_PAGE_SIZE; i++)
    {
        dataBuf[i] = i & 0xFF;
    }

//    status = Nand_EraseBlock(page, plane, block);

//    if (status & 0x1) //if fail, you shall not pass here.
//    {
//        while(1);
//    }

//    status = Nand_ProgramPage(column, page, plane, block, dataBuf);

//    if (status & 0x1) //if fail, you shall not pass here.
//    {
//        while(1);
//    }

//   Delay_ms(1500);

    for (i = 0; i < PHYSICAL_PAGE_SIZE; i++)
    {
        dataBuf[i] = 0x0;
    }

    Nand_ReadPage(column, page, plane, block, dataBuf);

//dammy bad block scan
//cannot find any bad blocks???? is it possible???
    /*
       column = PAGE_SIZE;
       for (plane = 0; plane < PLANE_IN_DIE; plane++)
       {
           for (block = 0; block < PLANE_SIZE_BLOCKS; block++)
           {
               Nand_ReadPage(column, 0, plane, block, dataBuf); // check first page
               if (dataBuf[0] != 0xFF) while(1);
               Nand_ReadPage(column, (BLOCK_SIZE_PAGES -1), plane, block, dataBuf); //check last page
               if (dataBuf[0] != 0xFF) while(1);
           }
       }
    */
}