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

📄 joetoevb.c

📁 台湾凌阳方案300万数码相机源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
		 }

		 if (*FOSD_V_num > 8)
			*FOSD_V_num = 8;
		 if (*FOSD_H_num > 25)
			*FOSD_H_num = 25;
	}


//=============================================================================
//void CopySunplusIcon()
//=============================================================================
void CopySunplusIcon(void) USING_0
{
     L2_SetBFBSize(G_DSPHsize,G_DSPVsize);
     L2_SetDisplaySrcImgSize(G_DSPHsize,G_DSPVsize,G_DisplayType);
     L2_CopyImage(K_SDRAM_GrafFontBufAddr, K_GRAFFONT_Width, K_GRAFFONT_Height, 0, 102, 256, 154, K_SDRAM_ImagePlaybackBufAddr, 256, 154, 0, 0);

     L1_ScaleImage(K_SDRAM_ImagePlaybackBufAddr, 256, 154, K_SDRAM_ImagePlaybackDisplayBufAddr, G_DSPHsize, G_DSPVsize, K_SDRAM_ImagePlaybackGeneralBufAddr);

     L2_SetBFBAddr(K_SDRAM_ImagePlaybackDisplayBufAddr);
}

//=============================================================================
//void UI_GetCheckSum()
//=============================================================================
void UI_GetCheckSum(UCHAR TotalBank, PUSHORT CheckSum) USING_0
{
	USHORT addr, ver;
	UCHAR temp1, temp2, bank;

	ver = 0;
	temp1 = XBYTE[0x2C00];
	temp2 = RamPage;
	XBYTE[0x2C00] |= 0x04;

        for(bank = 0; bank < TotalBank ; bank++)
        {
        	RamPage = bank;
                for (addr = 0; addr < 0x8000; addr++)
                {
                        ver += XBYTE[addr + 0x8000];
		}
        }

        XBYTE[0x2C00] = temp1;
        RamPage = temp2;

        *CheckSum = ver;
}

//=============================================================================
//UI_UpdateFOSDTime(UCHAR x, UCHAR y, UCHAR attrib, UCHAR option)
//=============================================================================
void UI_DispRTC(UCHAR x, UCHAR y, UCHAR attrib, UCHAR option) USING_0
{
	L2_ReadRTC(&G_DATEINFO);
	L2_RTCTransferText(&G_DATEINFO,Text_NowDateTime);

	if (option == 0)	//	YYYY/MM/DD HH:MM:SS
	{
		UI_PrintOSDString(Text_NowDateTime, x, y, attrib);
	}

	else if (option == 1)	//	YYYY/MM/DD
	{
		Text_NowDateTime[10] = '\0';
		UI_PrintOSDString(Text_NowDateTime, x, y, attrib);
	}

	else if (option == 2)	//	YYYY/MM/DD HH:MM:SS
	{
		UI_PrintOSDString(Text_NowDateTime + 11, x, y, attrib);
	}

	else// if (option == 3)	//	YYYY/MM/DD'\n'  HH:MM:SS
	{
		UI_PrintOSDString(Text_NowDateTime + 11, x+2, y+1, attrib);
		Text_NowDateTime[10] = '\0';
		UI_PrintOSDString(Text_NowDateTime, x, y, attrib);
	}
}
//=============================================================================
//UI_DisplaySpareFrame(UCHAR x, UCHAR y, UCHAR attrib)
//=============================================================================

void UI_DisplaySpareFrame(UCHAR x, UCHAR y, UCHAR attrib) USING_0
{
	USHORT G_SpareFrame;
	UCHAR str[8];
	USHORT freeCluster;

	freeCluster = DOS_GetDiskSpace();
	//printf("freeCluster:%4u\n", freeCluster);

	UI_PrintOSDString("     ", x, y, UI_MENU_DEHIGHLIGHT_COLOR);

	if( (G_CameraOptions.function == K_UIOPTION_FUNCTION_VIDEO) ||
	    (G_CameraOptions.function == K_UIOPTION_FUNCTION_192VIDEO) )
	{
		ULONG tt;//

		if (G_CameraOptions.function == K_UIOPTION_FUNCTION_VIDEO)
			tt = ((ULONG)G_usVideoClip_Width * (ULONG)G_usVideoClip_Height * 10 / 8);
		if (G_CameraOptions.function == K_UIOPTION_FUNCTION_192VIDEO)
			tt = ((ULONG)G_usVideoClip_Width * (ULONG)G_usVideoClip_Height * 10 / 6);

		//patch5.06@Joe@2003.8.1 14:44 add begin
		if (((ULONG) freeCluster * G_DOS_ClusterSize) > ((ULONG)1024*1024))
			freeCluster = freeCluster - ((ULONG)1024*1024) / G_DOS_ClusterSize;
		else
			freeCluster = 0;
		//patch5.06@Joe@2003.8.1 14:44 add begin

		G_SpareFrame = (ULONG) freeCluster * G_DOS_ClusterSize / tt;

		if (G_SpareFrame < 8)
			G_SpareFrame = 0;		//lower limit 8s
		else
			G_SpareFrame -= 8;
		if (G_SpareFrame >= 100*60)
			G_SpareFrame = 99*60+59;	//upper limit 99:59

		sprintf(str,"%02u:%02u", (int) G_SpareFrame/60, (int) G_SpareFrame%60);
	//	UI_PrintOSDString(str,x,y,attrib);
	}

	else
	{
		ULONG tt;

		if(G_CameraOptions.ImageQty == K_UIOPTION_IMGQTY_HIGH)
		{
			G_Image_QTableIndex = K_Q95;
		}
		else
		{
			G_Image_QTableIndex = K_Qxx;
		}

		if (G_CameraOptions.ImageSize == K_UIOPTION_IMGSIZE_LOW)
		{
			tt = ((ULONG)K_SNAP_Resolution_Low_Width * (ULONG)K_SNAP_Resolution_Low_Height)  * 2;

		}
		else if (G_CameraOptions.ImageSize == K_UIOPTION_IMGSIZE_MIDDLE)
		{
			tt =((ULONG)K_SNAP_Resolution_Middle_Width * (ULONG)K_SNAP_Resolution_Middle_Height)  * 2;
		}
		else if (G_CameraOptions.ImageSize == K_UIOPTION_IMGSIZE_HIGH)
		{
			tt = ((ULONG)K_SENSOR_CaptureWidth * (ULONG)K_SENSOR_CaptureHeight)  * 2;
		}
		#if(INTERPOLATION_OPTION == 1)
		else if (G_CameraOptions.ImageSize == K_UIOPTION_IMGSIZE_INTERPOLATION)
		{
			tt = ((ULONG)K_SNAP_Resolution_Interpolation_Width * (ULONG)K_SNAP_Resolution_Interpolation_Height)  * 2;
	       }
	      #endif

		if (tt <= (320L*240L*2L))
			tt = tt / 3;
		else if (tt <= (640L*480L*2L))
			tt = tt / 4;
		else if (tt <= (800L*600L*2L))
			tt = tt * 2 / 9;
		else if (tt <= (1024L*800L*2L))
			tt = tt / 5;
		else if (tt <= (1280L*1024L*2L))
			tt = tt / 5;
		else
			tt = tt / 5;

		tt = tt * ((G_Image_QTableIndex & 0x0f) + 1) / (K_Q95 + 1);
//Davis:patch3.11 add------------------
		if (((ULONG) freeCluster * G_DOS_ClusterSize) < ((ULONG)600*450))
			freeCluster = 0;
//Davis:patch3.11 add------------------
		G_SpareFrame = (ULONG) freeCluster * G_DOS_ClusterSize / tt;

		if (G_SpareFrame<1)
			G_SpareFrame=0;		//lower limit 1
//		else
//			G_SpareFrame--;
		if (G_SpareFrame>=10000)
			G_SpareFrame=9999;	//upper limit 9999
		sprintf(str,"%u", (int) G_SpareFrame);
		UI_PrintOSDString(str, x, y, attrib);
	}
}




//-----------------------------------------------------------------------------
//L2_Suspend
//-----------------------------------------------------------------------------
/*
routine description:
    Put the SPCA533 into suspend mode. This function puts all internal analog
  macros into the power-down mode and stops the clocks. The GPIO is not
  handled by this function because the functions of the GPIO depend on
  the customer application.

arguments:
  Mode:
     0: normal
     1: reset the CPU if resumed

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

UCHAR L2_Suspend_UI(UCHAR Mode) USING_0
{
	UCHAR status;
	UCHAR tmp;

//	#if (TURNKEY_OPTION)
  	UCHAR i;
//	#endif

	status = L2K_SUCCESS;
	TIMER0_Stop();		//lirw add for suspend@04/11/04

//#################################################################################################
//The complete suspend process for turnkey. SDRAM and NANDF are not powered off, and SDRAM enter
//suspend.
//#################################################################################################
//	#if (TURNKEY_OPTION)
  	tmp = MemStretch;
  	MemStretch = 0x01;

	XBYTE[0x20D0] |= 0x02; //UI resume interrupt enable
  	XBYTE[0x2530] = 0x01; //USB SRAM test enable
  	XBYTE[0x2532] = 0x00; //USB SRAM page selection

  	XBYTE[0x2001] = 0x0C; //power down TV encode
  	XBYTE[0x2670] = 0x01; //power down audio ADC
  	XBYTE[0x2675] = 0x00; //power down audio DAC
  	XBYTE[0x2080] = 0x00; //power down TGPLL
  	XBYTE[0x2006] = 0x01; //all DRAM pins are enalbed

	//turnkey_patch2.2@ada@suspend current begin
	for (i = 0; i < 5; i++)
	{
		TGOeState[i] = XBYTE[0x2007 + i];
	}
/*
	XBYTE[0x2007] = 0x00;
	XBYTE[0x2008] = 0x00;
	XBYTE[0x2009] = 0x00;
	XBYTE[0x200a] = 0xff;
	XBYTE[0x200b] = 0x03;
*/
	//turnkey_patch2.2@ada@suspend current end

  	L2_SuspendFront();    //suspend front
	
	L2_EnterExitSelfRefresh(0);	//SDRAM enter self-refresh

	//Set Usb in suspend

	UI_UsbDPlusPullHigh(K_DPlusPullHighResistorOff);
	G_FlashStatus = K_FlashLightOff;
	UI_FlashLight_Power(0);
	UI_SensorPowerOnOff(0);
/*
//test
	//Set FMGPIO state in suspend
	for (i = 0; i < 8; i++)
	{
		FmGpioState[i] = XBYTE[0x2401 + i];
	}


	if (G_Card_Type == K_MEDIA_NANDF)
	{
  		XBYTE[0x2401] = 0x00;
	  	XBYTE[0x2402] = 0x00;
  		XBYTE[0x2403] = 0x00;
	  	XBYTE[0x2404] = 0x00;
  		XBYTE[0x2405] = 0xFD;
	 	XBYTE[0x2406] = 0xFF;
  		XBYTE[0x2407] = 0xFF;
	  	XBYTE[0x2408] = 0xFF;
	}
	else
	{
		if (G_Card_Type == K_MEDIA_CFC)
		{
	  		XBYTE[0x2401] = 0x00;
		  	XBYTE[0x2402] = 0x01;
	  		XBYTE[0x2403] = 0x00;
	  		XBYTE[0x2404] = 0x00;
  			XBYTE[0x2405] = 0x1F;
	 		XBYTE[0x2406] = 0xFF;
	  		XBYTE[0x2407] = 0xFF;
		  	XBYTE[0x2408] = 0xFF;
		}
	}
*/

	UI_FMgpioSuspendCtl();

	UI_DTVgpioSuspendCtl();
	//CF_Power(0);		//Lirw add for sleep circuit
	
	UI_GENgpioSuspendCtl();

	L2_ConfigGPIOBit(22,0);	//DET_A
	
	XBYTE[0x2b07] = 0x10;    //Mshutter is Self Timer LED(high active)
	L2_SetGPIOBit(19,1);	//Only Snap key can be as the UI resume key
  	UI_UIResumeDetectIntrEnable(K_UIResumeIntrEnable,K_GpioLow2HighEvent);
	L2_Wait(100);
  	XBYTE[0x2004] = 0x05; //resume length 5ms
  	if (Mode == 0x01)
	{
    		XBYTE[0x2003] = 0x03; //suspend and reset CPU when resume
	}
  	else
	{
    		XBYTE[0x2003] = 0x01; //suspend and don't reset CPU when resume
  	}
  	

//lirw add for susnpend@04/11/04 begin
#if 0
G_KeepPressPowerOn = 0;
	while(G_KeepPressPowerOn == 0)
	{
	UI_BusyLed(1);		//lirw add for suspend test@04/11/04
//	printf("Enter suspend circle G_KeepPressPowerOn= %d\n",(int)G_KeepPressPowerOn);
		XBYTE[0x2003] = 0x00;
		XBYTE[0x2003] = 0x01; 
		/*
  		if (Mode == 0x01)
		{
    			XBYTE[0x2003] = 0x03; //suspend and reset CPU when resume
		}
  		else
		{
    			XBYTE[0x2003] = 0x01; //suspend and don't reset CPU when resume
  		}
		*/
		//if ((P3^4)!= 0)
		if (PWR_DET!= 0)	
		{
			L2_Wait(1000);
			//if ((P3^4) != 0)
			if (PWR_DET != 0)	
			{
				G_KeepPressPowerOn = 1;
			}
			else
				{
				//L2_Resume_UI();
				tmp = MemStretch;
  	MemStretch = 0x01;

  	//patch5.03@Joe@2003.4.2 10:02 add begin
  	G_AutoPowerOffCount = 0;
  	//patch5.03@Joe@2003.4.2 10:03 add end

  	XBYTE[0x2003] = 0x00; //clear swsuspend
	XBYTE[0x20D0] &= 0xfd; //UI resume interrupt disable

  	XBYTE[0x2530] = 0x00; //USB SRAM test enable
  	XBYTE[0x2532] = 0x00; //USB SRAM page selection

	L2_EnterExitSelfRefresh(1);	//SDRAM exit self-refresh

	UI_UIResumeDetectIntrEnable(K_UIResumeIntrDisable,K_GpioLow2HighEvent);
/*2004-3-12 13:33*//*#Lin@@Begin*/
	UI_FMgpioResumeCtl();

	UI_DTVgpioResumeCtl();

	UI_GENgpioResumeCtl();
	//L2_SetGPIOBit(14,1);
	
				//Mode=0;
				goto  suspend_begin;
			}
		}
    }
	#endif
//lirw add for susnpend@04/11/04 end
	L2_Wait(50);
  	MemStretch = tmp;

	// return
	//PRINT_L2("        L2_Suspend: Exit\n");

  return(status);
}

//-----------------------------------------------------------------------------
//L2_Resume
//-----------------------------------------------------------------------------
/*
routine description:
    Resume the operation of the SPCA533. It clears the related interrupt and puts
  all the IO pins back to the normal operation states. In firmware coding,
  this function must be called right after the Suspend function.

arguments:
  none

return value:
  none
*/

void L2_Resume_UI(void) USING_0
{
  //body
 // printf("        L2_Resume: Enter\n");

//#################################################################################################
//The complete resume process for turnkey. USB plugging out and pushing Menu key can wake up the
//camera system.
//#################################################################################################
	#if (TURNKEY_OPTION)
	UCHAR tmp;
//	UCHAR name[12];
//	UCHAR FOSD_V_num;
	UCHAR i;

  //body
  //PRINT_L2("        L2_Resume: Enter\n");
  	tmp = MemStretch;
  	MemStretch = 0x01;

  	XBYTE[0x2003] = 0x00; //clear swsuspend
	XBYTE[0x20D0] &= 0xfd; //UI resume interrupt disable

  	XBYTE[0x2530] = 0x00; //USB SRAM test enable
  	XBYTE[0x2532] = 0x00; //USB SRAM page selection

	L2_EnterExitSelfRefresh(1);	//SDRAM exit self-refresh

	UI_UIResumeDetectIntrEnable(K_UIResumeIntrDisable,K_GpioLow2HighEvent);
/*2004-3-12 13:33*//*#Lin@@Begin*/
	UI_FMgpioResumeCtl();

	UI_DTVgpioResumeCtl();

	UI_GENgpioResumeCtl();

#if	0
	XBYTE[0x2405] = FmGpioState[2];
	XBYTE[0x2406] = FmGpioState[3];
	
	XBYTE[0x2401] = FmGpioState[0];
	XBYTE[0x2402] = FmGpioState[1];

	for(i = 0; i < 6; i++) {
		XBYTE[0x2038 + i] = GenGpioState[i + 6];
	}
	for(i = 0; i < 6; i++) {
		XBYTE[0x2030 + i] = GenGpioState[i];
	}

#endif	
/*2004-3-12 11:40*//*#Lin@@To here*/

	//Return FMGPIO state
/*	for (i = 0; i < 8; i++)
	{
		XBYTE[0x2401 + i] = FmGpioState[i];
	}
*/

/*
	UI_FMgpioRes

⌨️ 快捷键说明

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