📄 mobile_demo.c
字号:
////////////////////////////////////////////////////////////////////
/// Camera FIMV20 Demo ISR
void __irq Cam_Demo_DctqIsr(void)
{
unsigned int dctq_flag;
ClearPending(BIT_DCTQ);
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)
{
unsigned int 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)
{
unsigned int 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_VLX;
ClearPending(BIT_VLX);
c_vlxDone=TRUE;
//printf("{v}");
}
#if CAM_ENABLE
void __irq Cam_Demo_Cam_CodecIsr(void)
{
unsigned int camif_flag ,post_flag;
unsigned int optime;
unsigned int completedFrameIndex;
rINTSUBMSK2 |= BIT_SUB_CAMIF_C|BIT_SUB_CAMIF_P|BIT_SUB_POST;
rINTMSK |= BIT_CAMIF_BLOCK_POST;
ClearPending(BIT_CAMIF_BLOCK_POST);
if (rSUBSRCPND2 & BIT_SUB_POST) // post
{
//printf("c\n");
fpsNum++;
rMODE &= ~(1<<6);//Clear Source in POST Processor
rSUBSRCPND2 = BIT_SUB_POST;
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;
}
if ( rLCDCON1 & (1<<21) ) // dual buffering
{
// printf("t1");
rLCDCON1 &= ~(1<<21);
rADDRStart_RGB = rLCDSADDRB2;
rADDREnd_RGB = rLCDSADDRB2 + QVGA_XSIZE*QVGA_YSIZE*2;
}
else
{
// printf("t2");
rLCDCON1 |= (1<<21);
rADDRStart_RGB = rLCDSADDRB1;
rADDREnd_RGB = rLCDSADDRB1 + QVGA_XSIZE*QVGA_YSIZE*2;
}
}
if (rSUBSRCPND2 & BIT_SUB_CAMIF_C) // codec
{
rSUBSRCPND2 = BIT_SUB_CAMIF_C;
switch(camCodecStatus) {
case CAM_STOP_ISSUED:
_CamCodecSetLastIrq();
camCodecStatus=CAM_LASTIRQ_ISSUED;
break;
case CAM_LASTIRQ_ISSUED:
_CamCodecStopHw();
camCodecStatus=CAM_LAST_CAPTURING;
break;
case CAM_LAST_CAPTURING:
camCodecStatus=CAM_STOPPED;
return;
case CAM_STARTED:
//printf("c\n");
camif_flag = _CAMIF_FLAG;
//printf("camif flag = %08x\n", _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:
printf("cb\n");
break;
default:
break;
}
}
rINTSUBMSK2 &= ~(BIT_SUB_CAMIF_C|BIT_SUB_CAMIF_P|BIT_SUB_POST);
rINTMSK &= ~BIT_CAMIF_BLOCK_POST;
}
#endif
////////////////////////////////////////////////////////////////////
unsigned int Timer_PCLK;
void calculate_FPS_WDT(void)
{
rINTSUBMSK &= ~(BIT_SUB_WDT);
rINTMSK &= ~(BIT_TIMER34_WDT); //Watch dog Interrupt service is available
pISR_TIMER34_WDT = (unsigned )fps_WdtIsr;
rWTCON = 0; // wdt reset & interrupt disable
rWTCON = ((51000000/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 & BIT_SUB_WDT){
rSUBSRCPND = BIT_SUB_WDT;
}
if(rSUBSRCPND & BIT_SUB_TIMER3){
rSUBSRCPND = BIT_SUB_TIMER3;
}
ClearPending(BIT_TIMER34_WDT);
rWTCNT = 7813;
rWTCNT = 7813;
// rWTCON = 0;
printf("fps = %d", fpsNum);
fpsNum=0;
//calculate_FPS_WDT();
}
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
}
unsigned int mVariable;
unsigned int mtimer_stop(void)
{
unsigned int 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++;
//printf("variables = %d\n",variable0);
}
#if 0
void MPEG4_ChangePLL(void)
{
int i, pdiv, mdiv, sdiv, HCLKdiv, PCLKdiv, fclk;
printf("[Running change test of M/P/S value]\n");
Timer_PCLK =0;
printf("Input FCLK vlaue\n");
fclk=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;
}
printf("fclk=%d,Mdiv=%d,Pdiv=%d,Sdiv=%d,HCLKdiv=%d,PCLKdiv=%d\n",fclk*1000000,mdiv,pdiv,sdiv,HCLKdiv,PCLKdiv);
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
printf("FCLK=%dMHz,HCLK=%dMHz,PCLK=%dMHz\n",fclk,(fclk/(HCLKdiv+1)),(fclk/(HCLKdiv+1))/(PCLKdiv+1));
printf("...I'm running in changed FCLK...\n");
Timer_PCLK = (fclk*1000000/(HCLKdiv+1))/(PCLKdiv+1);
printf("timer_PCLK = %d\n", Timer_PCLK);
//dhrystone21();
}
#endif
void Test_Post_CIF_16(void)
{
unsigned int p_time;
unsigned int amount;
unsigned int OrgSrcWidth, OrgSrcHeight, SrcWidth, SrcHeight, SrcStartX, SrcStartY;
unsigned int OrgDstWidth, OrgDstHeight, DstWidth, DstHeight, DstStartX, DstStartY;
unsigned int InFrameBuffer, OutFrameBuffer;
unsigned int 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=(_NONCACHE_STARTADDRESS+0x00d00000);
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, (_NONCACHE_STARTADDRESS+0),(_NONCACHE_STARTADDRESS+0x00d00000));
pISR_CAMIF_BLOCK_POST=(unsigned int)Postmpeg;
rINTMSK &= ~(BIT_CAMIF_BLOCK_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_CAMIF_BLOCK_POST;
}
void __irq Postmpeg(void)
{
unsigned int p_time = 0;
rINTSUBMSK=BIT_SUB_CAMIF_P|BIT_SUB_CAMIF_P|BIT_SUB_DEBLOCK|BIT_SUB_POST;
rMODE &= ~(1<<6);//Clear Source in POST Processor
rSUBSRCPND=BIT_SUB_POST; //Clear SUB Interrupt Source Pending.
ClearPending(BIT_CAMIF_BLOCK_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 + -