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

📄 initio.c

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

     //patch4.4@ada@MP3 begin
     #if (MP3_OPTION)
     G_MP3_Mode = 0;
     #endif
     //patch4.4@ada@MP3 end

	//patch4.4@richie@flip
	G_ucFlip = 0x00;

	//patch4.4.1@richie@noncompress
	G_ucNonCompFlag = 0;

	//patch4.5@richie@mlun begin
	#if (MLUN_OPTION)
	//patch4.5@richie@vender info begin
	//if G_ucMSDC_MLUN = 1, First LUN = Build in
	//if G_ucMSDC_MLUN = 2, First LUN = Card
	G_ucMSDC_MLUN = 2;
	//patch4.5@richie@vender info end
	#else
	G_ucMSDC_MLUN = 0;
	#endif
	//patch4.5@richie@mlun end

	//patch4.5@richie@vender info begin
	G_ucMSDC_CARD = K_MEDIA_CARD;
	G_ucMSDC_BUILT_IN = K_MEDIA_BUILT_IN;
	/*
        for (i = 0; i < 8; i++)
                G_ScsiVendorInformation[i] = K_ScsiVendorInformation[i];
        for (i = 0; i < 16; i++)
                G_ScsiProductIdentification[i] = K_ScsiProductIdentification[i];
        for (i = 0; i < 4; i++)
                G_ScsiProductRevisionLevel[i] = K_ScsiProductRevisionLevel[i];
	*/
	//patch4.5@richie@vender info end

	//patch5.0@richie@avi size begin
	// default 320 X 240
	G_usVideoClip_Width = K_VIDEOCLIP_Width;
	G_usVideoClip_Height = K_VIDEOCLIP_Height;
	//patch5.0@richie@avi size end

	//Joe@2003.3.21 10:56 modify begin
	//ChangeTable(1);//patch4.4@jhyu@60HzTable
	ChangeTable(0);//patch4.4@jhyu@50HzTable
	//Joe@2003.3.21 10:56 modify end
	 G_Language=0;

	PlaybackFlag=0;//wendy@2004/9/8
	G_Language=5;
	//Joe@2003.2.24 9:55 add begin
	G_autoTime.min = 1;
	G_AutoTimeInSec = 60;
	G_AutoPowerOffCount = 0;
	G_FlashStatus=K_FlashLightOff;//wendy@2004/8/26
	G_BatteryStatus =K_BATTERY_STATUS_HIGH;//wendy@2004/10/10
	G_FlashChargeFlag=0;//wendy@2004/9/8
	old_Audeokey=10;//wendy@2004/8/28
//	G_FlashOnFlag=1;//wendy@2004/9/30
	 Set_Edge();//wendy@2004/9/9
	//Joe@2003.2.24 9:55 add end
}

//-----------------------------------------------------------------------------
//INITIO_UsbInitialize
//-----------------------------------------------------------------------------
void INITIO_UsbInitialize(void) USING_0
/*++

Routine Description:

        initialize USB function

Arguments:

        none

Return Value:

        none

--*/
{

	//richie@ref 0326
	G_USBMSDC_ubRefreshNeeded = 0;
	//patch4.5@richie@eject
	G_USBMSDC_ucEject = 0;

   	//richie
	G_btBulkIntr = 0;
        //richie@g0201
        //XBYTE[0x2039] &= 0xef;

	//patch4.4@richie@usbvd
	G_btEP0Intr = 0;



	//patch4.5@richie@msdc plug out exception begin
	//power detect GPIO rasing & falling interrupt enable
//	XBYTE[0x2050] |= 0x02;
//	XBYTE[0x2058] |= 0x02;//wendy@2004/8/26
	//patch4.5@richie@msdc plug out exception end


        G_log27c0 = 0;
        G_ucStorIntrf1Class = K_MassStorageClassBo;
        G_ucStorIntrf2Class = K_StillImageClass;
        G_ucPktStorIntrf = K_StorageInterface1; //current packet belongs to which storage interface
        G_ucCtrlPhase = K_CommandPhase;
        G_ucBulkPhase = K_CommandPhase; //cytsai@1122
        G_ulStorDataLength = 0;
        G_ulStorDataIndex = 0;
#if (USBMSDC_OPTION == 2)
        G_USBMSDC_usSizeProcessed = 0;
        G_USBMSDC_ucSenseCodeIdx = 0x00;
        G_USBMSDC_ucCSWStatus = K_USBMSDC_CommandPassed;

		//richie open bulk out first
		XBYTE[0x25a1] = K_USB_CLASS_OUT_OPEN;//0x02;
		XBYTE[0x25d2] = K_USB_CLASS_OUT_ACK_MASK;//0x02;
#endif
#if (USBSIDC_OPTION == 1)
        G_USBSIDC_usSizeProcessed = 0;
        G_USBSIDC_usDeviceStatus = K_PIMARES_OK;
        G_USBSIDC_usResponseCode = K_PIMARES_OK;

		//richie@si0401
      		//richie open bulk out first
		XBYTE[0x25a1] = K_USB_CLASS_OUT_OPEN;//0x02;
		XBYTE[0x25d2] = K_USB_CLASS_OUT_ACK_MASK;//0x02;
#endif

	//richie@1211
        XBYTE[0x25a0] &= 0xfc;          //reject (NAK)
                                        //      next EP0 Out packet
                                        //      next EP0 In packet

        XBYTE[0x25d0] = 0x07;           //enable interrupt for
                                        //      EP0 Setup packet OK
                                        //      EP0 Out packet OK
                                        //      EP0 In packet OK

}

//-----------------------------------------------------------------------------
//INITIO_CpuInitialize
//-----------------------------------------------------------------------------
void INITIO_CpuInitialize(void) USING_0
/*++

Routine Description:

        initialize embedded micro-controller

Arguments:

        none

Return Value:

        none

--*/
{
        TCON = 0x40;                    //TCON:  IT0=0 INT0 negative edge trigger
                                        //       IE0=0 INT0 interrupt flag
                                        //       IT1=0 INT1 negative level trigger
                                        //       IE1=0 INT1 interrupt flag
                                        //       TR0=0 TIMER0 disable
                                        //       TF0=0 TIMER0 overflow flag
                                        //       TR1=1 TIMER1 enable
                                        //       TF1=0 TIMER1 overflow flag

        IP = 0x03;                      //IP:    PX0=1 INT0 priority level
                                        //       PT0=1 TIMER0 priority level
                                        //       PX1=0 INT1 priority level
                                        //       PT1=0 TIMER1 priority level
                                        //       PS=0  Serial Port priority level
                                        //       PT2=0 Timer2 priority level

        IE = 0x81;                      //IE:    EX0=1 INT0 interrupt enable
                                        //       ET0=0 TIMER0 interrupt disable
                                        //       EX1=0 INT1 interrupt disable
                                        //       ET1=0 TIMER1 interrupt disable
                                        //       ES=0  Serial Port interrupt disable
                                        //       ET2=0 TIMER2 interrupt disable
                                        //       EA=1  All interrupts enable

        TMOD = 0x21;                    //TMOD:  Timer0 M1M0=1 (Mode1=16-bit counter)
                                        //       Timer0 C/T~=0 (Timer)
                                        //       Timer0 GATE=0
                                        //       Timer1 M1M0=2 (Mode2=8-bit counter)
                                        //       Timer1 C/T~=0 (Timer)
                                        //       Timer1 GATE=0

        TH1 = 0xf3;

        PCON |= 0x80;                   //PCON:  SMODE=1 double baud rate

        SCON0 = 0x52;                   //SCON0: RI=0  interrupt flag of receiving
                                        //       TI=1  interrupt flag of transmitting
                                        //       RB8=0 stop bit (9th bit) of receiving
                                        //       TB8=0 stop bit (9th bit) of transmitting
                                        //       REN=1 receiving enable
                                        //       SM2=0
                                        //       SM1=1 8-bit UART, baud rate set by software
                                        //       SM0=0
}

//-----------------------------------------------------------------------------
//INITIO_DramInitialize
//-----------------------------------------------------------------------------
void INITIO_DramInitialize(void) USING_0
/*++

Routine Description:

        initialize SDRAM

Arguments:

        none

Return Value:

        none

--*/
{
	//patch4.4@richie@dsi begin
	//dram storage initialize
	//these will reset Dram Storage
#if ( DOSRAM_OPTION == 1 )
		G_ulDRAMSTORLogicalZeroAddr = K_DOSRAM_StartAddress;
		//patch4.4@richie@dsi
		//add variable for dram total size boundary
		G_ulDRAMTotalSize = (ULONG)K_SDRAM_TotalSize;
		DRAM_ResetMBR(TRUE);
		G_ulDRAMSTORFAT1AddrTemp = 0xFFFFFFFF;
#endif
	//patch4.4@richie@dsi end
}

//-----------------------------------------------------------------------------
//INITIO_JpegInitialize
//-----------------------------------------------------------------------------
//patch4.2@ada@0527 for q table
void INITIO_JpegInitialize(void) USING_0
/*++

Routine Description:

        initialize JPEG compression/decompression parameter

Arguments:

        none

Return Value:

        none

--*/
{
//patch5.0@richie@sdram mapping marked
     //EXIFHDR_Initialize_AllExifHeader();
}

//-----------------------------------------------------------------------------
//INITIO_StorageInitialize
//-----------------------------------------------------------------------------
void INITIO_StorageInitialize(void) USING_0
/*++

Routine Description:

        initialize storage

Arguments:

        none

Return Value:

        none

--*/
	{
	BYTE sts; // WWW3

	// WWW30319
	// WWWW start
	#if (CARD_OPTION == 1)
          Card_InitRam();
          //DbgPrint("INITIO_Initialize: Card_InitRam OK\n");
          Card_InitGlobal();
          //DbgPrint("INITIO_Initialize: Card_InitGlobal OK\n");
	#endif
	G_Card_Type = K_MEDIA_CARD;
	//G_Card_Type = K_MEDIA_BUILT_IN;
	// WWWW end

	//patch4.4@richie@dsi begin
	//code move to INITIO_DramInitialize()
	//patch4.2@richie@ds0522 begin
	//#if ( DOSRAM_OPTION == 1 )
	//	G_ulDRAMSTORLogicalZeroAddr = K_DOSRAM_StartAddress;
	//#endif
	//patch4.2@richie@ds0522 end
	//patch4.4@richie@dsi end

	// patch 4.4-9@wyeo@select nand, sdram as default, begin
	// when select nand or dram as default and the card inserted when
	// power on, the card may be written for that fmpio for card is
	// in floating state, so must always pull high to disable card.
	// Later, you switch card, then card library will enable card.
	// Before calling this function use, you must set G_Card_Type.
	// It is suggested that call this function on resume event.
	Card_InactiveCard();

	//Joe@2003.3.18 20:48 add begin
	L2_CardDetect(&sts);
	if (sts == TRUE)
	{
		DELAY_100ms();
		DELAY_100ms();
		UI_CardPowerOnOff(1);
		G_ExtCardStatus = 1;
		DELAY_100ms();
		DELAY_100ms();
		DELAY_100ms();	//Wendy:patch3.10
		DELAY_100ms();//Wendy:patch3.10
	}
	else
	{
		UI_CardPowerOnOff(0);
		G_ExtCardStatus = 0;
	}
	//Joe@2003.3.18 20:48 add end

	// WWW3 start
	sts = STORAGE_Detect();

	//patch4.4@richie@dsi begin
	//code move to INITIO_DramInitialize()
	//patch4.2@richie@ds0509 begin
	//#if ( DOSRAM_OPTION == 1 )
	//if (G_Card_Type == K_MEDIA_DOSRAM)
	//{
		//printf("G_ulDRAMSTORLogicalZeroAddr=%lx\n",G_ulDRAMSTORLogicalZeroAddr);
		//patch4.2@richie@ds0506 do only once after poweron
		//DRAM_ResetMBR(TRUE);

	//}
	//#endif
	//patch4.2@richie@ds0510 end
	//patch4.4@richie@dsi end

	//patch4.4@richie@dsi begin
	//restore G_DOS_SDRAM_FAT1Addr
	#if ( DOSRAM_OPTION == 1 )
	if (G_Card_Type == K_MEDIA_DOSRAM)
	{
		if (G_ulDRAMSTORFAT1AddrTemp != 0xFFFFFFFF)
		{
			G_DOS_SDRAM_FAT1Addr = G_ulDRAMSTORFAT1AddrTemp;
		}
	}
	#endif
	//patch4.4@richie@dsi end


//printf("G_Card_Type=%bx\n",G_Card_Type);

	if (sts == TRUE)
	{
		// WWWW0319
		// when nand is not formatted, please turn on this
		// or you could have special key detect to start
		// format for factory production.
		// sts = STORAGE_Format(0xc1);
		// if (sts)
		// 	DbgPrint("INITIO_Initialize: STORAGE_Format OK %bx\n", G_Card_Type);
		#if 1
		L2_ConfigGTimer(5); //up count and timebase 1 ms
		L2_WriteGTimer(0);
		L2_StartGTimer();
		#endif

	        sts = STORAGE_Initialize(TRUE);
	        if (sts)
             	{
			#if 1
			{
				ULONG time;
				L2_ReadGTimer(&time);
				L2_StopGTimer();
				printf("STORAGE_Initialize time %ld\n", time);
			}
			#endif
	        	//DbgPrint("INITIO_Initialize: STORAGE_Initialize OK %bx\n", G_Card_Type);
             	}
	        else
	        {
			#if 1
			{
				ULONG time;
				L2_ReadGTimer(&time);
				L2_StopGTimer();
				printf("STORAGE_Initialize time %ld\n", time);
			}
			#endif

	        	// WWWW0319
	        	// NOTE:should display to user message
	        	// such as "Can't initialize, do format ?"
	        	// The initialize if false may be because
	        	// not support FAT32, unrecognized format, DOS have problem, etc.

	          	//patch4.5@ada@Complete H/W write protect function begin
			  	if (G_Card_WriteProtect)
			  	{
					//DbgPrint("Card protect\n");
          	   		return;
		  		}
          		//patch4.5@ada@Complete H/W write protect function end

	        	//DbgPrint("INITIO_Initialize: STORAGE_Initialize Fail %bx\n", G_Card_Type);
	        	// try format

				//patch4.5@ada@Complete H/W write protect function begin
	        	//sts = STORAGE_Format(0xc1);
	        	sts = STORAGE_Format(0x41);
				//patch4.5@ada@Complete H/W write protect function end

	        	// NOTE:sts may be FALSE or 1, 2, 3
	        	if (sts != FALSE)
	        	{
	        		//DbgPrint("INITIO_Initialize: Try format OK\n");
	        		sts = STORAGE_Initialize(sts);

	        		if (sts)
                    {
	        			//DbgPrint("INITIO_Initialize: STORAGE_Initialize OK\n");
                    }
	        		else
                    {
	        			//DbgPrint("INITIO_Initialize: STORAGE_Initialize Fail Again\n");
                    }
	        	}
	        	else
               {
	        		//DbgPrint("INITIO_Initialize: Try format Fail\n");
               }
		}
	}
	// WWW3 end

	//patch4.4@richie@dsi begin
	//restore G_DOS_SDRAM_FAT1Addr
	#if ( DOSRAM_OPTION == 1 )
	if (G_Card_Type == K_MEDIA_DOSRAM)
	{
		if (G_ulDRAMSTORFAT1AddrTemp != 0xFFFFFFFF)
		{
			G_DOS_SDRAM_FAT1Addr = G_ulDRAMSTORFAT1AddrTemp;
		}
	}
	else
	{
		G_DOS_SDRAM_FAT1Addr = K_SDRAM_DOS_FAT1Addr;
	}
	#endif

⌨️ 快捷键说明

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