void Camera_Test(void) { int i; SetSysFclk(FCLK_220M); //设置系统时钟 220M ChangeClockDivider(1, 1); //设置分频 1:2:4 CalcBusClk(); //计算总线频 Uart_Select(0); Uart_Init(0, 115200); Uart_Printf("\nCamera Preview Test\n"); CamReset(); // Initializing camif rCLKCON |= (1<<19); // enable camclk CamPortSet(); ChangeUPllValue(56, 2, 1); // UPLL clock = 96MHz, PLL input 12MHz rCLKDIVN|=(1<<3); // UCLK 48MHz setting for UPLL 96MHz // 0:48MHz, 1:24MHz, 2:16MHz, 3:12MHz... // Camera clock = UPLL/[(CAMCLK_DIV+1)X2] SetCAMClockDivider(CAMCLK24000000); //Set Camera Clock 24MHz s5x532, OV9650 i = Test_OV9650(); if( i ) { Uart_Printf("\nTest is failed!!!\n"); return ; } Uart_Printf("Initializing end...\n"); Test_CamPreview() ; Uart_Printf("\nCamera Preview Test End\n"); rCLKCON &= ~(1<<19); // disable camclk TFT_Init(); SetSysFclk(FCLK_400M); //设置系统时钟 400M ChangeClockDivider(2, 1); //设置分频 1:4:8 CalcBusClk(); //计算总线频 Uart_Select(0); Uart_Init(0, 115200); }
void TargetInit(void) { int i; U8 key; U32 mpll_val=0; #if ADS10 __rt_lib_init(0,0); //for ADS 1.0 #endif i = 2 ; //use 400M! switch ( i ) { case 0: //200 key = 12; mpll_val = (92<<12)|(4<<4)|(1); break; case 1: //300 key = 14; mpll_val = (67<<12)|(1<<4)|(1); break; case 2: //400 key = 14; mpll_val = (92<<12)|(1<<4)|(1); break; case 3: //440!!! key = 14; mpll_val = (102<<12)|(1<<4)|(1); break; default: key = 14; mpll_val = (92<<12)|(1<<4)|(1); break; } //init FCLK=400M ChangeClockDivider(key, 12); ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3); //MMU_EnableICache(); //MMU_EnableDCache(); MMU_DisableICache(); MMU_DisableDCache(); Port_Init(); MMU_Init(); Delay(0); Uart_Init(0,115200); Uart_Select(0); Uart_SendString("Board init complete.\n"); }
void Main(void) { memcpy((unsigned char *)0x0,(unsigned char *)0x30000000,0x1000); SetSysFclk(FCLK_400M); //设置系统时钟 400M ChangeClockDivider(2, 1); //设置分频 1:4:8 CalcBusClk(); //计算总线频 Uart_Select(0); Uart_Init(0, 115200); Test_Nand(); while(1); }
/* *============================================================================================== * 函数名称:TargetInit * 功能描述:初始化目标板,完成以下功能: * 1. 时钟初始化 * 2. mmu初始化 * 3. 串口初始化 * 4. 串口初始化 * 传 参:void * 返 回 值:void *============================================================================================== */ void TargetInit( void ) { U32 i; U8 key; U32 mpllVal = 0; i = 2; /* 使用400MHz主频 */ switch ( i ) { case 0: /* 200MHz */ key = 12; mpllVal = (92 << 12) | (4 << 4) | (1); break; case 1: /* 300MHz */ key = 14; mpllVal = (67 << 12) | (1 << 4) | (1); break; case 2: /* 400MHz */ key = 14; mpllVal = (92 << 12) | (1 << 4) | (1); break; case 3: /* 440MHz */ key = 14; mpllVal = (102 << 12) | (1 << 4) | (1); break; default: /* 默认使用400MHz */ key = 14; mpllVal = (92 << 12) | (1 << 4) | (1); break; } ChangeMPLLValue( (mpllVal >> 12) & 0xff, (mpllVal >> 4) & 0x3f, mpllVal & 3 ); /* 时钟初始化 */ ChangeClockDivider( key, 12 ); MMUDisableICache( ); MMUDisableDCache( ); MMUInit( ); /* MMU初始化 */ PortInit( ); /* 端口初始化 */ UartSelect( 0 ); /* 串口选择 */ UartInit( 0, 115200 ); /* 串口初始化 */ }
void TargetInit(void) { int i; U8 key; U32 mpll_val=0; i = 2 ; //use 400M! switch ( i ) { case 0: //200 key = 12; mpll_val = (92<<12)|(4<<4)|(1); break; case 1: //300 key = 14; mpll_val = (67<<12)|(1<<4)|(1); break; case 2: //400 key = 14; mpll_val = (92<<12)|(1<<4)|(1); break; case 3: //440!!! key = 14; mpll_val = (102<<12)|(1<<4)|(1); break; default: key = 14; mpll_val = (92<<12)|(1<<4)|(1); break; } //init FCLK=400M, so change MPLL first ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3); ChangeClockDivider(key, 12); MMU_DisableICache(); MMU_DisableDCache(); Port_Init(); MMU_Init(); _init_alloc(0x17fe000, 0x17ff000);/*分配堆的起始地址和结束地址,4k的空间*/ Delay(0); Uart_Init(0,115200); Uart_Select(0); Uart_SendString("Board init complete.\n"); }
/******************************************************************** // 语法格式 : void Main(void) // 功能描述 : DMA操作实验主程序 // 实现功能: // 实现DMA方式内存到内存的拷贝动作,修改DMA设置 // 并比较其工作效率,实验包括:DMA0-DMA3 // 入口参数 : 无 // 出口参数 : 无 *********************************************************************/ void Main(void) { memcpy((U8 *)0x0,(U8 *)0x30000000,0x1000); SetSysFclk(FCLK_400M); //设置系统时钟 400M ChangeClockDivider(2,1); //设置分频 1:4:8 CalcBusClk(); //计算总线频 Uart_Select(0); Uart_Init(0,115200); Uart_Printf("\n---DMA操作实验主程序---\n"); Test_DMA(); Uart_Printf("\nDMA测试结束\n"); while(1); }
//==================================================== // 语法格式:void Main(void) // 功能描述: 主函数 // 入口参数: 无 // 出口参数: 无 //==================================================== void Main(void) { memcpy((unsigned char *)0x0,(unsigned char *)0x30000000,0x1000); SetSysFclk(FCLK_400M); //设置系统时钟 400M ChangeClockDivider(2, 1); //设置分频 1:4:8 CalcBusClk(); //计算总线频 Uart_Select(0); Uart_Init(0, 115200); //设置端口 波特率115200 无数据流检测 数据位= 8位 Select_Device(IrDA); IrDA_Port_Set(); Uart_Printf("\2440 IrDA Test start\n"); while(1) { Test_IrDA_Tx(); } }
void ChangeDVSLevel(SYSTEM_ACTIVE_LEVEL NewLevel) { if(!g_bDVSEN) { return; } if (g_CurrentLevel == NewLevel) { // There is no need to change return; } else { #ifdef ENABLE_VOLTAGE_CONTROL if(g_CurrentLevel > NewLevel) // Clock Speed of New Level is Slower, Voltage of New Level is Lower { PMIC_VoltageSet(SETVOLTAGE_ARM, VoltageARM(NewLevel), 100); PMIC_VoltageSet(SETVOLTAGE_INTERNAL, VoltageInternal(NewLevel), 100); } #endif ChangeClockDivider(NewLevel); #ifdef ENABLE_VOLTAGE_CONTROL if(g_CurrentLevel < NewLevel) // Clock Speed of New Level is Faster, Voltage of New Level is Higher { PMIC_VoltageSet(SETVOLTAGE_ARM, VoltageARM(NewLevel), 100); PMIC_VoltageSet(SETVOLTAGE_INTERNAL, VoltageInternal(NewLevel), 100); } #endif OALMSG(OAL_POWER && OAL_FUNC, (L"[DVS] System Level Changed [%d -> %d]\r\n", g_CurrentLevel, NewLevel)); // Update System Level Variable g_CurrentLevel = NewLevel; } }
void Dvs_Test(void) { volatile int i, n; Uart_Printf("Dvs test.\n"); rGPGCON = (rGPGCON & ~(3<<22)) | (1<<22); // set GPG11 output for idle state. rBANKSIZE = (rBANKSIZE & ~(3<<4)) | (0<<4) | (1<<7); //SCKE_EN, SCLK_EN = disable. Uart_Printf("Change core speed to 266MHz.\n"); #if FIN==12000000 ChangeClockDivider(13, 12); // 1:3:6 #if CPU2440A==1 ChangeMPllValue(127,2,1); // 406MHz #else // 2440X ChangeMPllValue(127,2,0); // 406MHz #endif #else // 16.9344Mhz ChangeClockDivider(13, 12); #if CPU2440A==1 ChangeMPllValue(110,3,1); // 400MHz #else // 2440X ChangeMPllValue(110,3,0); // 400MHz #endif #endif Calc_Clock(1); UPDATE_REFRESH(Hclk); Uart_Init(Pclk, 115200); Uart_Printf("Check Clkout0:FCLK, Clkout1:HCLK.\n"); // Clkout0: FCLK. Clk0_Enable(2); // Clkout1: HCLK. Clk1_Enable(3); #if ADS10==TRUE srand(0); #endif Led_Display(0); // clear all leds. Timer_Setting(); Set_Lcd_Tft_16Bit_240320_Dvs(); Uart_Printf("Tcnt, Vcnt, Idle_flag.\n"); Uart_Printf("%8d,%8d,%1d\n", Timer_cnt0, Vcount, Idle_flag); while(1) { //Uart_Printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); Uart_Printf("%8d,%8d,%1d\n", Timer_cnt0, Vcount, Idle_flag); for(i=0; i<1024*32; i+=4) { //*(U32 *)(XADDR+i) = i; //*(U32 *)(XADDR+i); } if(Uart_GetKey()==ESC_KEY) break; } rINTMSK = BIT_ALLMSK; }
void TargetInit(void) { int i; U8 key; U32 mpll_val=0; #if ADS10 //_rt_lib_init(0,0); //for ADS 1.0 #endif i = 2 ; //use 400M! switch ( i ) { case 0: //200 key = 12; mpll_val = (92<<12)|(4<<4)|(1); break; case 1: //300 key = 14; mpll_val = (67<<12)|(1<<4)|(1); break; case 2: //400 key = 14; mpll_val = (92<<12)|(1<<4)|(1); break; case 3: //440!!! key = 14; mpll_val = (102<<12)|(1<<4)|(1); break; default: key = 14; mpll_val = (92<<12)|(1<<4)|(1); break; } //init FCLK=400M, so change MPLL first ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3); ChangeClockDivider(key, 12); //MMU_EnableICache(); //MMU_EnableDCache(); MMU_DisableICache(); MMU_DisableDCache(); Port_Init(); MMU_Init(); Touch_init(); Delay(0); Uart_Init(0,115200); Uart_Select(1); //Uart_SendString("hello,FriendlyARM\n"); /*若使用printf语句,将使目标代码增加很多*/ // Uart_Printf("hello,qq2440, printf\n"); rGPBCON = 0x00555555; rGPBDAT = 0x0000; // rGPBDAT = 0x07ff; rGPFDAT = 0x00; rGPFDAT = 0x00; // Delay(0); }
void CpuSpeedFunc1(void) { int i,j; i=0; LED_DISPLAY(0x3); //The following code should not use the stack memory. // because the stack memory is not DCache-locked. // It's should be checked using disassembly code. // chage refresh count. rREFRESH = (rREFRESH & ~0x3ff) | 200; // Set clock frequency. ChangeClockDivider(1,1); // 1:2:4 //ChangeMPllValue(0xa1,0x3,0x1); // FCLK=202.8MHz, refersh:473 //ChangeMPllValue(0x66,0x1,0x1); // FCLK=220MHz // ChangeMPllValue(0x69,0x1,0x1); // FCLK=226MHz ChangeMPllValue(0x96,0x2,0x1); // FCLK=237MHz, refresh:200 // Set clock out pad. #if WHICH_CPU==5410 //rGPDCON = (rGPDCON & ~(3<<30)) | (2<<30); // GPD15 = CLKOUT. //rMISCCR = (rMISCCR & ~(7<<8)) | (2<<8); // CLKOUT = FCLK #else //2410 rGPHCON = (rGPHCON & ~(3<<20)) | (2<<20); // GPH10 = CLKOUT1. rMISCCR = (rMISCCR & ~(7<<8)) | (2<<8); // CLKOUT1 = FCLK #endif // Start signal, Just for notification. #if 0 rPWRSAV |= 1<<2; // SDRAM1 self refresh. #endif LED_DISPLAY(0x4); for(i=0;i<9000000;i++); for(i=0;i<9000000;i++); while(1) { for(i=0;i<0x100;i+=4) *(volatile U32 *)(TEST_STADDR+i)=0x12345678*i+i; // Write data. for(i=0;i<0x100;i+=4) { if(*(volatile U32 *)(TEST_STADDR+i)!=0x12345678*i+i) // Error { // Display LED x101 and stop. //rGPDDAT=rGPDDAT&~(0xf<<8)|(0x0<<8); //rGPDDAT=rGPDDAT&~(0xf<<8)|(0x2<<8); LED_DISPLAY(0x5); while(1); } *(volatile U32 *)(TEST_STADDR+i)=0x0; // Clear memory. } //rGPDDAT=rGPDDAT&~(0xf<<8)|(0xf<<8); LED_DISPLAY(0xf); i=0; i++; i=i*0x12345678; // i=1. if(i==0x12345678) //rGPDDAT=rGPDDAT&~(0xf<<8)|(0x0<<8); LED_DISPLAY(0x0); else //rGPDDAT=rGPDDAT&~(0xf<<8)|(0x9<<8); LED_DISPLAY(0x3); } }
void MeasurePowerConsumption(void) { int i,j; volatile int a,b,c; Uart_Printf("[ Measure the power consumption of S3C2410 ]\n"); Uart_Printf("FCLK is changed to %5.1lfMhz.\n",TMP_FCLK/1000000.); MMU_Init(); ChangeClockDivider(1,1); // 1:2:4 // ChangeClockDivider(0,1); // 1:1:2 #if TMP_FCLK==266000000 ChangeMPllValue(125,4,0); // TMP_FCLK=237000000Hz Uart_Init(266000000/4,115200); #endif #if TMP_FCLK==237000000 ChangeMPllValue(150,2,1); // TMP_FCLK=237000000Hz Uart_Init(237000000/4,115200); #endif #if TMP_FCLK==226000000 ChangeMPllValue(105,1,1); // TMP_FCLK=226000000Hz Uart_Init(226000000/4,115200); #endif #if TMP_FCLK==214500000 ChangeMPllValue(135,2,1); // TMP_FCLK=214500000Hz Uart_Init(214500000/4,115200); #endif #if TMP_FCLK==202800000 ChangeMPllValue(161,3,1); // TMP_FCLK=202800000Hz Uart_Init(202800000/4,115200); #endif #if TMP_FCLK==180000000 ChangeMPllValue(82,1,1); // TMP_FCLK=180000000Hz Uart_Init(180000000/4,115200); #endif #if TMP_FCLK==152000000 ChangeMPllValue(68,1,1); // TMP_FCLK=152000000Hz Uart_Init(152000000/4,115200); #endif #if TMP_FCLK==135000000 ChangeMPllValue(82,2,1); // FCLK=135000000Hz Uart_Init(135000000/4,115200); #endif #if TMP_FCLK==101250000 ChangeMPllValue(127,2,2); // TMP_FCLK=101250000Hz Uart_Init(101250000/2,115200); #endif #if TMP_FCLK==50700000 ChangeMPllValue(161,3,3); // TMP_FCLK=50700000Hz Uart_Init(50700000/4,115200); #endif rGPHCON = rGPHCON&~(3<<18|3<<20)|(1<<18|1<<20); //GPH9:CLKOUT0->OUT,GPH10:CLKOUT1->OUT #if 0 rGPHCON = rGPHCON&~(3<<18)|(2<<18); //CLKOUT0 rMISCCR = rMISCCR&~(7<<4)|(4<<4); //PCLK=45Mhz @FCLK=180Mhz #endif #if UNUSED_BLCOK_ON==0 rCLKCON=rCLKCON&~(1<<18|1<<16|1<<12|1<<11|1<<9|1<<4); //SPI,IIC,UART1,2,SDI,NFC #endif #if DMA2_ON==1 StartDmaMem2Mem(); #endif PWR_StartTimer(); Uart_Printf("TFT-LCD 240x320 16bit is running.\n"); Lcd_PowerEnable(0,1); PWR_Lcd_Tft_16Bit_240320_On(); PWR_StartIIS(); #if CPU_WORK==QUICK_SORT Uart_Printf("CPU JOB : quick sort of 65536 intteger data.\n"); //qsort; for(i=0; i<NUM_SORT_DATA; i++)dim2[i]=i; i=0; while(1) { qsort(dim2,NUM_SORT_DATA,sizeof(int),compare1); qsort(dim2,NUM_SORT_DATA,sizeof(int),compare2); Uart_Printf(","); } #else Uart_Printf("CPU JOB : Dhrystone 2.1 code.\n"); while(1) { dhrystone21(); Uart_Printf("."); } #endif Uart_Printf("End of the Measurement\n"); }