예제 #1
0
/*---------------------------------------------------------------------------------------------------------*/
int main(void)
{
    uint32_t u32i;
    uint32_t u32NORIDInfo;
    uint8_t u8ReadOutData;

    /* Unlock protected registers */
    SYS_UnlockReg();

    /* Init System, peripheral clock and multi-function I/O */
    SYS_Init();

    /* Lock protected registers */
    SYS_LockReg();

    /* Init UART0 for printf */
    UART0_Init();

    printf("\n\nCPU @ %d Hz\n", SystemCoreClock);
    printf("+---------------------------------+\n");
    printf("|    EBI NOR Flash Sample Code    |\n");
    printf("+---------------------------------+\n\n");

    printf("************************************************************************\n");
    printf("* Please connect W39L040P to M051 Series EBI bus before EBI testing !! *\n");
    printf("************************************************************************\n\n");

    /* Enable EBI function and bus width to 8-bit, MCLK is HCLK/2 */
    EBI->EBICON = (EBI_MCLKDIV_2 << EBI_EBICON_MCLKDIV_Pos) | EBI_EBICON_ExtEN_Msk |
                  (0x3 << EBI_EBICON_ExttALE_Pos) ;
    EBI->EXTIME = 0x03003318;

    /* Initial NOR flash and check ID */
    NOR_Init();
    u32NORIDInfo = NOR_GetID();
    if(u32NORIDInfo == 0xDAB6)
    {
        printf("NOR W39L040P initial OK ! Manufacture ID:0x%X, Device ID:0x%X.\n", (u32NORIDInfo >> 8), (u32NORIDInfo & 0xFF));
    }
예제 #2
0
파일: main.c 프로젝트: lsffrank/switch
/*---------------------------------------------------------------------------------------------------------*/    
int main (void)
{
	uint8_t	u8Item = 0x0;
    uint32_t u32NORIDInfo;
    uint32_t u32i;
    uint8_t u8ReadOutData;

    /* Init System, IP clock and multi-function I/O */
    SYS_Init();     

    /* Init UART0 for printf */
    UART0_Init();

    printf("\n\nCPU @ %dHz\n", SystemCoreClock);

    printf("+------------------------------------+\n");
    printf("|    M05xx EBI Driver Sample Code    |\n");
    printf("+------------------------------------+\n");
	printf("\n");
	
	do {
		printf("*****************************************************************\n");
		printf("* Please connect BS616LV4017 or W39L010 to M051 Series EBI bus  *\n");
		printf("* before EBI testing!!                                          *\n");
		printf("*                                                               *\n");								
		printf("* The testing result will be FAILED, if there is no BS616LV4017 *\n");
		printf("* or W39L010 connecting to M051 sereis EBI bus!                 *\n");
		printf("*****************************************************************\n");
		printf("\n");
		printf("|   >>> Selese item to test <<<    |\n");
		printf("| [0] SRAM  --- BS616LV4017, 16bit |\n");
		printf("| [1] NOR   --- W39L010, 8bit      |\n");
		printf("| [ESC] Exit                       |\n");
		u8Item = getchar();

		printf("\n");
		switch (u8Item)
		{
			case '0':               
                /* Enable EBI function and data width 16-bit, MCLK is HCLK/4 */
                EBI->EBICON = EBI_EBICON_ExtEN_Msk | EBI_EBICON_ExtBW16_Msk | EBI_EBICON_MCLKDIV_4; 

                /* Start SRAM test */
                SRAM_BS616LV4017();

                /* Disable EBI function */
                EBI->EBICON = 0;
				break;
				
			case '1':		
                /* Enable EBI function and data width 8-bit, MCLK is HCLK/4 */
                EBI->EBICON = EBI_EBICON_ExtEN_Msk | EBI_EBICON_MCLKDIV_4; 

                /* Initial NOR flash and check ID */
				NOR_Init();
                u32NORIDInfo = NOR_GetID();
            	if (u32NORIDInfo == 0xDA31)
            	{
            		printf("NOR W39L010 initial OK ! ManufactureID:0x%X, DeviceID:0x%X. \n", (u32NORIDInfo>>8), (u32NORIDInfo&0xFF));
            	}else
            	{
            		printf("NOR W39L010 initial fail ! (ID:0x%X) \n\n", u32NORIDInfo);
            		break;
            	}

            	/* Erase flash */
            	NOR_Erase();	        		
        		for (u32i=0; u32i<EBI_MAX_SIZE; u32i++)
        		{
                    u8ReadOutData = NOR_ReadData(u32i);
        			if (u8ReadOutData != 0xFF)
        			{
        				printf("    >> Chip Erase Fail !! Addr:0x%X, Data:0x%X. \n\n", u32i, u8ReadOutData);
        				break;
        			}
        		}
        		printf("    >> Chip Erase OK !!! \n");

                /* Start to program NOR flash test */
                ProgramContinueDataTest();		

                /* Disable EBI function */
                EBI->EBICON = 0;
				break;
		}