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

📄 8202_usb_card_if.c

📁 Sunplus 8202S source code.
💻 C
📖 第 1 页 / 共 4 页
字号:
    if((detect_type)&&(now_valid_type))
    {
	detect_result = storage_parity_type[now_valid_type];
    }
    else
    	now_valid_type = 0;
    	
    	detect_result_last = detect_result;
  	//dingzhy for debug switch function
    	//psprintf(RegionValStr[REGION2], "D %x L %x V %x",detect_type,detect_result_last,now_valid_type);
	//PrintOsdMsg(STR_OS_SPACE, REGION2, 1, 1);
    #endif
    
    if((detect_result==0)&&(storage_type==0)) 
    {
        //printf("-------- Do nothing! ------\n");
        return;
    }
    else if((detect_result!=0)&&((storage_type)==0))   
    {
        printf("-------- Card/USB Insert! ------\n");
        printf("media_type = %d",media_type);
        #ifndef SWITCH_CD_CARD_USB//liweihua 2004-6-9
        if(no_disk_cnt == 1)             //liweihua 20040324
        #endif
            system_state=SYSTEM_OPEN;   
        if(play_state != VCD_STATE_OPEN) //liweihua add 2004-3-11
            card_plug_state = USER_DO_PLUG_IN;    
        storage_type = detect_result;
     if(media_type != MEDIA_CD)//nono 2004-9-24 20:17
     {
        t_disp = 0;     //wthsin, 2004/7/6 11:39pm
        remain= 0;
     }
        if(media_type == MEDIA_CARD)
            SwitchMedia(CD2CARD);
#ifdef SUPPORT_CARDREADER_TEST
        else if ((Is_MIDI_STATE())&&(gIsMidiSelMenu))
        {
            printf("polling_storage MidiCard_GetCardFile \n");
            MidiCard_GetCardFile();
        }
#endif
    }
    //else if((storage_type!=0)&&(storage_type!=detect_result))
    else if( (storage_type!=0)&& ((storage_type & detect_type) == 0) )
    {
        printf("-------- Card/USB Remove! ------\n");

        MediaIsEmpty = MEDIA_NOT_EMPTY;//dingzhy 05-1-11 20:26

        #ifdef IR_SWITCH_CD_USB_CF_OTHER   //dingzhy for tonic 4-10-22 13:19
        	now_valid_type = 0;    //for bug:move media,always show no media
        #endif

     #ifdef MP3_ONLY_STOP_TO_GUI 
            if( (play_state==VCD_STATE_MP3_FILELIST) && (media_type==MEDIA_CARD) )
            {
	         ShowTitle();
	         SwitchMedia(CARD2CD); 	    //wsf 2004-9-16 16:43
	     	}
	 #endif 
	   
        if(media_type == MEDIA_CARD)
        { 
            SwitchMedia(CARD2CD);   //Maoyong 2004-8-11 22:52 marked above and add this.
        }
#ifdef SUPPORT_CARDREADER_TEST
        if ((Is_MIDI_STATE())&&(gIsMidiSelMenu))
        {
            MidiCardReadInit();
        }
#endif
        if(play_state != VCD_STATE_OPEN)
            card_plug_state = USER_DO_PLUG_OUT;

     #ifdef SPHE8202_CARD_STORAGE
        if(storage_type!=USB_DEVICE)    //wthsin, 2004/6/28 10:09am
         Card_power_off();      //Power Off      
     #endif//SPHE8202_CARD_STORAGE

        detect_result = 0;
        storage_type = 0;	
        t_disp = 0;     //wthsin, 2004/7/6 11:39pm
        remain= 0;
     }
}
/**************************************************************************
 *                                                                        *
 *  Function Name: CardSetBrowse                                          *
 *                                                                        *
 *  Purposes:                                                             *
 *    set system to play card media                                       *
 *  Descriptions:                                                         *
 *    set system to play card media                                       *
 *  Arguments:                                                            *
 *          NONE                                                          *
 *  Returns:     NONE                                                     *
 *                                                                        *
 *  See also:    NONE                                                     *
 *                                                                        *
 **************************************************************************/
//commone function to make system play card media now. Maoyong 2004.05.17
void CardSetBrowse(void)
{
     full_scrn = 0;  //Maoyong 2004-8-11 23:02 for clear setup menu, must place before ClearOsdMsg
     ClearOsdMsg(0);
     t_disp = 0;
     #ifdef SUPPORT_MULTI_PARTITION//liweihua 2004-10-25 8:56
     browser = HddCardBrowse;
     #else
     browser = read_iso9660;
     #endif
     cd_type_loaded=CDROM;
     cd_type=CDROM;
     play_state=VCD_STATE_CLOSE;
     Mp3ReadFinish = 0;//liweihua 2004-5-13
     memset(pFsJpeg, 0, sizeof(FSJPEGDATA));//liweihua add 2004-5-8 9:11
     system_state=SYSTEM_BROWSE;
     sys_cmd=CMD_FUNC|CMD_FUNC_CLOSE;
     media_type = MEDIA_CARD;
     
     //customized osd information for card reading
     //Maoyong 2004.05.25 build funtions in ircmd.card.c, need to make osd display until
     //read all card files for some cards has too many files and take long times
     show_card_reading_osd(SHOW_MEDIA);
}
/**************************************************************************
 *                                                                        *
 *  Function Name: PMP_CF_Card_IsPlugIn                                   *
 *                                                                        *
 *  Purposes:                                                             *
 *    Detect if the PMP'CF is pluged                                      *
 *  Descriptions:                                                         *
 *    Detect if the PMP'CF is pluged                                      *
 *  Arguments:                                                            *
 *          NONE                                                          *
 *  Returns:                                                              *
 *          0: nothing  2: CF plug in  -2: CF plug out                    *
 *  See also:    NONE                                                     *
 *                                                                        *
 **************************************************************************/
#ifdef CARD_SETUP_TYPE_5
UINT8 sense_check_result=0;//liweihua add 2004-11-30
int PMP_CF_Card_IsPlugIn()
{
    UINT8 cf_card_result=0;
    UINT8 check_result;
    
    check_result = sense_check_result;
    sense_check_result = GPIO_I_GET(CF_INS_SENSE);
    
    if(check_result != sense_check_result)
    {
        if(!sense_check_result)
        {
            printf("CF plug in!\n");
            return 2;
        }
        else
        {
            printf("CF plug out!\n");
            return -2;
        }	
    }     
    if(!sense_check_result)  cf_card_result=1;
     //printf("cf_card_result =%x!\n",cf_card_result);
     return cf_card_result;
}       
#endif// CARD_SETUP_TYPE_5

#endif //#if defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE)

/**************************************************************************
 *                                                                        *
 *  Function Name: pc_usb_access_mode                                     *
 *                                                                        *
 *  Purposes:                                                             *
 *    Set system to  PC USB MODE                                          *
 *  Descriptions:                                                         *
 *    when connect computer with usb, Set system to  PC USB MODE          *
 *  Arguments:                                                            *
 *          NONE                                                          *
 *  Returns:     NONE                                                     *
 *                                                                        *
 *  See also:    NONE                                                     *
 *                                                                        *
 **************************************************************************/
#ifdef PMP_DVD 
void pc_usb_access_mode()
{
   delay_1ms(50); //Continous 50ms Detect "USB INSERT"
   if(!GPIO_I_GET(PC_USB_CONNECT_PIN)) return;
   watchdog_onoff(0);    // disable watchdog 
   psprintf(RegionValStr[REGION1], "PC USB MODE");
   PrintOsdMsg(STR_OS_SPACE, REGION1, 0, 1); 
  #ifdef PMP_PCB_VER_C 
   regs0->fm_gpio_mode = 9; //8202 IDE PIN => Hi-Z
   UINT16 temp;
   temp=regs0->gpio_mode_B;
   regs0->gpio_mode_B=0;
  #endif //#ifdef PMP_PCB_VER_C
   GPIO_O_SET(IDE_BUS_SWITCH_CONTROL_PIN,0);
  #ifdef PMP_PCB_VER_C 
   GPIO_O_SET(USB_DEVICE_CHIP_POWER_PIN,0);
   delay_1ms(300); 
  #endif //#ifdef PMP_PCB_VER_C
   GPIO_O_SET(USB_DEVICE_CHIP_POWER_PIN,1);
   GPIO_O_SET(CARD_POWER_RESET,0); 
   
   while(GPIO_I_GET(PC_USB_CONNECT_PIN));
   
   GPIO_O_SET(IDE_BUS_SWITCH_CONTROL_PIN,1);
  #ifdef PMP_PCB_VER_B 
   GPIO_O_SET(USB_DEVICE_CHIP_POWER_PIN,0);
  #else //PMP_PCB_VER_C
   regs0->gpio_mode_B=temp;
  #endif //#ifdef PMP_PCB_VER_B
   watchdog_onoff(1);      // enable watchdog
   watchdog_renew(0xffff);//reset watchdog
   ClearOsdMsg(1); 
   system_state= SYSTEM_OPEN;
   ircmd_stop();
   ircmd_return();
}
/**************************************************************************
 *                                                                        *
 *  Function Name: PMP_PC_Usb_PlugInOut                                   *
 *                                                                        *
 *  Purposes:                                                             *
 *    detect if usb connect to computer                                   *
 *  Descriptions:                                                         *
 *    detect if usb connect to computer                                   *
 *  Arguments:                                                            *
 *          NONE                                                          *
 *  Returns:     NONE                                                     *
 *                                                                        *
 *  See also:    NONE                                                     *
 *                                                                        *
 **************************************************************************/
UINT8 pc_usb_vcc_flag=0;
void PMP_PC_Usb_PlugInOut()
{
   if(pc_usb_vcc_flag==0)
   {
     if(GPIO_I_GET(PC_USB_CONNECT_PIN))
     {
        #ifdef PMP_UI//liweihua 2005-1-17
        pmpkey_return();
        #endif
        pc_usb_access_mode();
        pc_usb_vcc_flag=1;
     }    
   } 
   else //(pc_usb_vcc_flag==0)
   {
     if(!GPIO_I_GET(PC_USB_CONNECT_PIN))
     {
        pc_usb_vcc_flag=0;
     }
   }  
}  
#endif //#ifdef PMP_DVD 

⌨️ 快捷键说明

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