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

📄 mobile_demo.c

📁 s3c24a0固件测试代码 ? ? ? ? ?啊 
💻 C
📖 第 1 页 / 共 3 页
字号:


	dctq_flag = _DCTQ_FLAG;

	switch(dctq_flag){
		case 0x00000010:
			_DCTQ_FLAG = 0x00000011;	
			break;
		case 0x00000020:
			_DCTQ_FLAG = 0x00000021;	
			break;
		case 0x00000030:
			_DCTQ_FLAG = 0x00000031;	
			break;
		case 0x00000040:
			_DCTQ_FLAG = 0x00000041;	
			break;
	}		
    	//printf("{d}");
		//FdStartMe(0,1);
}

void __irq Cam_Demo_MeIsr(void)
{
	U32 me_flag;

    	ClearPending(BIT_ME);	
		//FdStartMc(0,1);		
	me_flag = _ME_FLAG;

	switch(me_flag){
		case 0x00000020:
			_ME_FLAG = 0x00000021;
			break;
		case 0x00000030:
			_ME_FLAG = 0x00000031;
			break;
		case 0x00000040:
			_ME_FLAG = 0x00000041;
			break;
	}			
    	//printf("{e}");

}

void __irq Cam_Demo_McIsr(void)
{

	U32 mc_flag;

    	ClearPending(BIT_MC);	

	mc_flag = _MC_FLAG;

	switch(mc_flag){
		case 0x00000020:
			_MC_FLAG = 0x00000021;
			break;
		case 0x00000030:
			_MC_FLAG = 0x00000031;
			break;
		case 0x00000040:
			_MC_FLAG = 0x00000041;
			break;
	}		
    	//printf("{c}");
}

void __irq Cam_Demo_VlxIsr(void)
{

	rSUBSRCPND |= BIT_SUB_VLX;
    	ClearPending(BIT_VLX_SPI1);	
    	c_vlxDone=TRUE;
    	//printf("{v}");
}

void __irq Cam_Demo_Cam_CodecIsr(void)
{
	U32 camif_flag;
	U32 optime;
	U32 completedFrameIndex;

	ClearPending(BIT_CAMIF_CODEC);

	switch(camCodecStatus) {
		case CAM_STOP_ISSUED:
			_CamCodecStopHw();
			camCodecStatus=CAM_LAST_CAPTURING;
			Uart_Printf("cS1\n");
			break;
		case CAM_LAST_CAPTURING:
			//Uart_Printf("cS2\n");
			camCodecStatus=CAM_STOPPED;
			return;
		case CAM_STARTED:
			//Uart_Printf("cS3\n");
			camif_flag = _CAMIF_FLAG;

			switch(camif_flag){
				case 0x00000000:
					_CAMIF_FLAG = 0x00000010;
				break;
				case 0x00000010:
					_CAMIF_FLAG = 0x00000020;
				break;
				case 0x00000020:
					_CAMIF_FLAG = 0x00000030;
				break;
				case 0x00000030:
					_CAMIF_FLAG = 0x00000040;
				break;
				case 0x00000040:
					_CAMIF_FLAG = 0x00000010;
				break;
				default:
				break;
			}
			break; 
		case CAM_CODEC_SCALER_BYPASS_STATE:
			Uart_Printf("cb\n");
			break;
		default:
			break;
	}
    			
   	//printf("{C}");

	//CamCaptureStart(CAM_CODEC_SCALER_CAPTURE_ENABLE_BIT);

}

//static U32 framecnt;

void __irq Cam_Demo_PostIsr(void)
{

	U32 optime;
	
	U32 post_flag;
	
	rINTMSK |= BIT_LCD_POST;
	rINTSUBMSK=BIT_SUB_DISP_FIFO|BIT_SUB_DISP_FRAME|BIT_SUB_POST;
	   
	rMODE &= ~(1<<6);//Clear Source in POST Processor
	rSUBSRCPND=BIT_SUB_POST; //Clear SUB Interrupt Source Pending.
	ClearPending(BIT_LCD_POST);//Clear Source Pending, Interrupt Pending	   
	
	fpsNum++;

	post_flag = _POSTLCD_FLAG;

	switch(post_flag){
		case 0x00000010:
			_POSTLCD_FLAG = 0x00000011;
		break;
		case 0x00000020:
			_POSTLCD_FLAG = 0x00000021;
		break;
		case 0x00000030:
			_POSTLCD_FLAG = 0x00000031;
		break;
		case 0x00000040:
			_POSTLCD_FLAG = 0x00000000;
			_DCTQ_FLAG = 0x00000000;
		break;
	}				

	rINTSUBMSK &= ~(BIT_SUB_POST); // SUB-INT POST Enable
	rINTMSK &= ~(BIT_LCD_POST); // INT_POST_LCD Enable

	//if( framecnt == 10){
	//	optime=Timer_Stop();
	//	printf("%d fps = %d\n",optime,(1000000*framecnt)/(optime*64));
	//	framecnt = 0;
	//}
		

	
		
    	//Uart_Printf("{P}\n");
}


////////////////////////////////////////////////////////////////////
U32 Timer_PCLK;


void calculate_FPS_WDT(void)
{
    rINTSUBMSK  &= ~(BIT_SUB_WDT | ~BIT_SUB_BATFLT);           
    rINTMSK  &= ~(BIT_WDT_BATFLT); //Watch dog Interrupt service is available
     
    pISR_WDT_BATFLT= (unsigned )fps_WdtIsr;

    rWTCON = 0; // wdt reset & interrupt disable
    rWTCON   = ((Timer_PCLK/1000000-1)<<8) | (3<<3) | (1<<2); //Prescaler=0x2a(42),Clock division 128,Interrupt enable
    rWTDAT   = 7813 ;          
    rWTCNT   = 7813 ;
    rWTCON   = rWTCON | (1<<5);   //Watch-dog timer enable

    // WDT reset enable
    //rWTCON = ((PCLK/1000000-1)<<8) |( 1<<5) | (3<<3) | (1);  
    //rINTSUBMSK  &= (BIT_SUB_WDT | BIT_SUB_BATFLT);
    //rINTMSK |= BIT_WDT_BATFLT;         //WDT Interrupt Mask
}

//---------------------------------------------------------------------
void __irq fps_WdtIsr(void)
{
    	if(rSUBSRCPND & 0x00002000){
		rSUBSRCPND |= BIT_SUB_WDT;
    	}
    	if(rSUBSRCPND & 0x00004000){
		rSUBSRCPND |= BIT_WDT_BATFLT;
    	}
    	ClearPending(BIT_WDT_BATFLT);
       rWTCNT = 7813;
	rWTCNT = 7813;
    	printf("fps = %d\n", fpsNum);
	fpsNum=0;		

}


void mtimer_start(void)
{

    rINTMSK &= ~( BIT_TIMER0);

    pISR_TIMER0 = (int)MTimer0Done;

    //rTCFG0 = rTCFG0 & ~(0xffffff) | 0x000021;         //PCLK =  63MHz , prescaler 0x15= 21 ===>2MHz)
	//printf(" tp = %d\n",Timer_PCLK);
    rTCFG0 = rTCFG0 & ~(0xffffff) |((Timer_PCLK/1000000-1)<<0);
	//printf(" tp = %d   %d\n",Timer_PCLK, rTCFG0);
    //rTCFG0 = rTCFG0 & ~(0xffffff) | 0x000015;         //
    rTCFG1  =rTCFG1 & ~(0xffffff) | 0x000003;         // 16 us

     //Timer input clock frequency = PCLK/(prescaler value+1)/(divider value)
    rTCNTB0 = 0xffff;           
    rTCNTO0 = 0xffff;
    
     // [22:20] [19:16] [15:12] [11:8] [7:4] [3:0]
     //   110     1010   1010    1010   0000  0010
//    rTCON   = 0x6aaa02; //Auto reload (T0=One-shot), Inverter off, Manual update, Dead zone disable, Stop
  
    rTCON   = rTCON & ~(0xffffff) | 0x60000a;         //Auto reload, Inverter off, Manual update, Dead zone disable, Stop  



     // [22:20] [19:16] [15:12] [11:8] [7:4] [3:0]
     //   101     1001   1001    1001   0000  0001      
    rTCON   = rTCON & ~(0xffffff) | 0x500009;         //Auto reload(T0=One-shot),Inverter off,No operation,Dead zone disable,Start


}
U32 mVariable;

U32 mtimer_stop(void)
{
	U32 optime =0;



	rTCON   = rTCON & ~(0xffffff) | 0x60000a;         //Auto reload, Inverter off, Manual update, Dead zone disable, Stop  
	optime = (0xffff-rTCNTO0);
	printf("tcnt post  %d %d\n",rTCNTB0, (0xffff - rTCNTO0)*16);

	ClearPending(BIT_TIMER0);
	rINTMSK |= (BIT_TIMER0);

//		printf("tcnt befoer  %d %d\n",rTCNTB0, rTCNTO0);
//			printf("tcnt befoer  %d %d\n",rTCNTB0, rTCNTO0);
	
    //rTCON   = 0x0;      //One-shot, Inverter off, No operation, Dead zone disable, Stop
	rTCNTB0 = 0xffff;
	rTCNTO0 = 0xffff;	
	mVariable = 0;
		//printf(" cntb0, cnto0 = %d, %d\n", rTCNTB0, rTCNTO0);


	return (optime);	

}
//========================================================
// Timer Interrupt Request 
//========================================================
void __irq MTimer0Done(void)
{

	ClearPending(BIT_TIMER0);
    	mVariable++;    

	//Uart_Printf("variables = %d\n",variable0);
}

void MPEG4_ChangePLL(void)
{
    int i, pdiv, mdiv, sdiv, HCLKdiv, PCLKdiv, fclk;

    Uart_Printf("[Running change test of M/P/S value]\n");

    Timer_PCLK  =0;
    Uart_Printf("Input FCLK vlaue\n");
    fclk=Uart_GetIntNum(); 

    switch(fclk){
		case 220:
			mdiv= 47;
			pdiv = 1;
			sdiv = 0;
			HCLKdiv = 1;
			PCLKdiv = 1;
			break;
		case 222:
			fclk = 220;
			mdiv = 47;
			pdiv = 1;
			sdiv = 0;
			HCLKdiv = 3;
			PCLKdiv = 0;
			break;
		case 202:
			mdiv = 93;
			pdiv = 4;
			sdiv = 0;
			HCLKdiv = 1;
			PCLKdiv = 1;
			break;
		case 192:
			mdiv = 56;
			pdiv = 2;
			sdiv = 0;
			HCLKdiv = 3;
			PCLKdiv = 0;
			break;
		case 180:
			mdiv = 82;
			pdiv = 4;
			sdiv = 0;
			HCLKdiv = 1;
			PCLKdiv = 1;
			break;
		case 118:
			mdiv = 51;
			pdiv = 1;
			sdiv = 1;
			HCLKdiv = 1;
			PCLKdiv = 0;
			break;
		case 158:
			mdiv = 71;
			pdiv = 4;
			sdiv = 0;
			HCLKdiv = 1;
			PCLKdiv = 1;
			break;
		case 147:
			mdiv = 41;
			pdiv = 2;
			sdiv = 0;
			HCLKdiv = 1;
			PCLKdiv = 0;
			break;
		case 170:
			mdiv = 77;
			pdiv = 4;
			sdiv = 0;
			HCLKdiv = 3;
			PCLKdiv = 0;
			break;
		case 135:
			mdiv = 82;
			pdiv = 2;
			sdiv = 1;
			HCLKdiv = 0;
			PCLKdiv = 1;
			break;
		default:
			break;
    	}
    
    Uart_Printf("fclk=%d,Mdiv=%d,Pdiv=%d,Sdiv=%d,HCLKdiv=%d,PCLKdiv=%d\n",fclk*1000000,mdiv,pdiv,sdiv,HCLKdiv,PCLKdiv);
    Uart_Printf("Now change PLL value\n");
    Uart_TxEmpty(0);

    PreChangeSdramParameter();
    if((HCLKdiv==0)&&(PCLKdiv==0))
    {
	ChangeMPllValue(mdiv,pdiv,sdiv);	//Set MPS first
	ChangeClockDivider(0,0);		//And then set divider  
    }
    else
    {
	ChangeClockDivider(HCLKdiv,PCLKdiv); 
	ChangeMPllValue(mdiv,pdiv,sdiv);
    }

    	ChangeSdramParameter( fclk*1000000/(HCLKdiv+1) );
	Uart_Init((fclk*1000000/(HCLKdiv+1))/(PCLKdiv+1),115200); //PCLK, Baud Rate
    	Uart_Printf("FCLK=%dMHz,HCLK=%dMHz,PCLK=%dMHz\n",fclk,(fclk/(HCLKdiv+1)),(fclk/(HCLKdiv+1))/(PCLKdiv+1));
    	Uart_Printf("...I'm running in changed FCLK...\n");
	Timer_PCLK = (fclk*1000000/(HCLKdiv+1))/(PCLKdiv+1);		

	printf("timer_PCLK = %d\n", Timer_PCLK);
    //dhrystone21();
    
 }



void Test_Post_CIF_16(void)
{
	U32 p_time;
	U32 amount;
	U32 OrgSrcWidth, OrgSrcHeight, SrcWidth, SrcHeight, SrcStartX, SrcStartY;
	U32 OrgDstWidth, OrgDstHeight, DstWidth, DstHeight, DstStartX, DstStartY;
	U32 InFrameBuffer, OutFrameBuffer;
	U32 mode;

	OrgSrcWidth=SrcWidth=VGA_XSIZE; //no source offset
	OrgSrcHeight=SrcHeight=VGA_YSIZE; //no source offset
	SrcStartX=SrcStartY=0;
	OrgDstWidth=DstWidth=PQVGA_XSIZE; //no destination offset
	OrgDstHeight=DstHeight=PQVGA_YSIZE; //no destination offset
	DstStartX=DstStartY=0;
	InFrameBuffer=0x12000000;
	OutFrameBuffer=LCDFRAMEBUFFERBG1;
	mode=POST_IN_YCBYCR420|POST_OUT_RGB16B;
	
	//LCD Initialization 
	//LcdBGInit(MODE_PAR_16BIT565_240320|MODE_POST_DISPLAY_16B);	


	PostSetFimv16B(640,480,240,320, 0x11000000,0x12000000);

	pISR_LCD_POST=(unsigned int)Postmpeg;
	rINTMSK &= ~(BIT_LCD_POST);
	rINTSUBMSK &= ~(BIT_SUB_POST);

#if 1
       printf(".......");
	mtimer_start();
	PostStartProcessing(0);

#else
	if(mode&POST_IN_YCBYCR420)
		amount=OrgSrcWidth*OrgSrcHeight*3/2;

	if(mode&POST_OUT_RGB16B)
		amount+=OrgDstWidth*OrgDstHeight*2;
	else if(mode&POST_OUT_RGB24B)
		amount+=OrgDstWidth*OrgDstHeight*4;
	PostStartProcessing(amount, 0);
#endif

	while(!postProcessingDone); //waiting for post-processing done 

	postProcessingDone=0;
	
	LcdEnvidOnOff(1); //LCD Envid On

	rINTSUBMSK |= BIT_SUB_POST;
	rINTMSK |= BIT_LCD_POST; 
	
}


void __irq Postmpeg(void)
{
	U32 p_time = 0;

	rINTSUBMSK=BIT_SUB_DISP_FIFO|BIT_SUB_DISP_FRAME|BIT_SUB_POST;
	   
	rMODE &= ~(1<<6);//Clear Source in POST Processor
	rSUBSRCPND=BIT_SUB_POST; //Clear SUB Interrupt Source Pending.
	ClearPending(BIT_LCD_POST);//Clear Source Pending, Interrupt Pending	   


	p_time = mtimer_stop();
	printf("p_timee = %d\n", p_time*16);

	//p_time = mtimer_stop();
	//printf("p_timee = %d\n", p_time*16);

	postProcessingDone=1;
	rINTSUBMSK |= (BIT_SUB_POST);
}




⌨️ 快捷键说明

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