📄 8202_usb_card_if.c
字号:
* *
* Purposes: *
* Check card Storage plug in or not *
* Descriptions: *
* Check card Storage plug in or not *
* Arguments: *
* NONE *
* Returns: *
* 0: FALSE *
* 1: TRUE *
* *
* See also: NONE *
* *
**************************************************************************/
int CardStorageIsPlugIn(void)
{
UINT8 card_result=0;
switch(storage_type)
{
#if defined(COMPACT_FLASH)
case CF_CARD_DEVICE:
#if defined(CARD_SETUP_TYPE_5)
if((PMP_CF_Card_Play==1)&&(PMP_CF_Card_Insert==0))
ircmd_return(); //card_result=1;
else
card_result=0;
#else
if(GPIO_I_GET(CARD_SENSE2_PIN)) card_result=1;
#endif
break;
#endif
#if defined(SD_MMC_CARD)
case SD_CARD_DEVICE:
#ifdef CARD_SETUP_TYPE_4
if(GPIO_I_GET(CARD_SENSE1_PIN)) card_result=1;
#else
if(GPIO_I_GET(CARD_SENSE3_PIN)) card_result=1;
#endif
break;
#endif
#if defined(MEMORY_STICK)
case MS_CARD_DEVICE:
#ifdef CARD_SETUP_TYPE_4
if(GPIO_I_GET(CARD_SENSE2_PIN)) card_result=1;
#else
if(GPIO_I_GET(CARD_SENSE1_PIN)) card_result=1;
#endif
break;
#endif
#if defined(SMART_MEDIA)
case SMC_CARD_DEVICE:
if(GPIO_I_GET(CARD_SENSE1_PIN)) card_result=1;
break;
#endif
default:
break;
}
if(card_result) return FALSE;
else return TRUE;
}
/**************************************************************************
* *
* Function Name: Detect_Card_Storage *
* *
* Purposes: *
* Detect which card exist *
* Descriptions: *
* Use card GPIO to Detect which card exist *
* Arguments: *
* NONE *
* Returns: *
* 0x02: CF ,0x04: SD_MMC ,0x08: MS ,0x10: SMC *
* 0x06: SD+CF ,0x0a: CF+MS ,0x12: CF+SMC *
* *
* See also: NONE *
* *
**************************************************************************/
BYTE Detect_Card_Storage()
{
UINT8 card_sense=0;
BYTE card_storage_type=0;
detect_type &= USB_DEVICE;//liweihua 2004-6-7
#ifdef CARD_SETUP_TYPE_4
card_sense=GPIO_I_GET(CARD_SENSE1_PIN)<<1;
card_sense|=GPIO_I_GET(CARD_SENSE2_PIN);
//printf("card_sense =%x!\n",card_sense);
switch(card_sense)
{
case 2:
card_storage_type|=MS_CARD_DEVICE;
break;
case 1:
card_storage_type|=SD_CARD_DEVICE;
break;
default:
card_storage_type=0;
break;
}
#elif defined(CARD_SETUP_TYPE_5)
card_storage_type|=CF_CARD_DEVICE;
//liweihua mod 2004-12-1
int check_result=PMP_CF_Card_IsPlugIn();
#ifdef SUPPORT_MULTI_PARTITION//liweihua 2004-12-10
if((check_result>1) || (check_result<0))
{
#if defined(FAT_FILE_MODE) && (!defined(PMP_UI))//liweihua 2005-1-5
if(fat_play_mode == 1)
Refresh_FAT_Mode_GUI();
else if((fat_play_mode == 2)&&(pFsJpeg->gifsState == FS_STATE_HDD))
#else
if(pFsJpeg->gifsState == FS_STATE_HDD)
#endif
Refresh_Partition_Menu();
}
else
#endif
if(check_result==1)
PMP_CF_Card_Insert=1;
else
PMP_CF_Card_Insert=0;
#else //CARD_SETUP_TYPE_1 ,CARD_SETUP_TYPE_2,CARD_SETUP_TYPE_3
card_sense=GPIO_I_GET(CARD_SENSE1_PIN)<<2;
card_sense|=GPIO_I_GET(CARD_SENSE2_PIN)<<1;
card_sense|=GPIO_I_GET(CARD_SENSE3_PIN);
//printf("card_sense =%x!\n",card_sense);
switch(card_sense)
{
case 7:
card_storage_type=0;
break;
case 6:
card_storage_type|=SD_CARD_DEVICE;
break;
case 5:
card_storage_type|=CF_CARD_DEVICE;
break;
case 4:
card_storage_type|=CF_CARD_DEVICE;
card_storage_type|=SD_CARD_DEVICE;
break;
case 3:
card_storage_type|=MS_CARD_DEVICE;
break;
case 2:
card_storage_type|=SMC_CARD_DEVICE;
break;
case 1:
card_storage_type|=CF_CARD_DEVICE;
card_storage_type|=MS_CARD_DEVICE;
break;
case 0:
card_storage_type|=CF_CARD_DEVICE;
card_storage_type|=SMC_CARD_DEVICE;
break;
default:
card_storage_type=0;
break;
}
#endif
detect_type |=card_storage_type;//liweihua 2004-6-7
return card_storage_type;
}
#endif //#ifdef SPHE8202_CARD_STORAGE
//-----------------------------------------------------------
#ifdef SUPPORT_USB
extern UINT8 UsbTestUnitReady(BYTE dev_lun);
extern BYTE IsUSBCardReader(void);
extern UINT8 USBEna;
extern UINT8 CBWLUN;
extern UINT8 SLAVE_ENUMERATED;
extern UINT8 USB_ADDR;
extern UINT8 MaxLUN;
extern void USBCardReaderDetect(void);
/**************************************************************************
* *
* Function Name: UsbIsPlugIn *
* *
* Purposes: *
* Detect if the U disk is pluged *
* Descriptions: *
* use UHCI command Detect if the U disk is pluged *
* Arguments: *
* NONE *
* Returns: *
* TRUE or FALSE *
* *
* See also: NONE *
* *
**************************************************************************/
int UsbIsPlugIn(void)
{
int detect_result = 0;
#ifdef HOST_UHCI
detect_result = uhci_slaveDetect();
#else //#define HOST_SL811HS
detect_result = slave_detect();
#endif
if((detect_result == 0) && (card_plug_state == USER_DO_PLUG_IN))
return TRUE;
else if((detect_result == 0) && (card_plug_state == USER_DO_PLUG_OUT))
return FALSE;
else
return FALSE;
}
/**************************************************************************
* *
* Function Name: uhci_slaveDetect *
* *
* Purposes: *
* detect whether the U-Device is plugged in or not *
* Descriptions: *
* This function detect whether the U-Device is plugged in or not. *
* Arguments: *
* NONE *
* Returns: *
* 0: nothing 1: plug in 2: detached *
* See also: NONE *
* *
**************************************************************************/
/**************************************************************************************************
* *
* Description: This function detect whether the U-Device is plugged in or not. *
* *
* Author : wthsin *
* Date : 2004/1/14 08:31pm *
* *
* Update : liweihua 2004-6-7
**************************************************************************************************/
BYTE usb_plug_out_flag; //for USB plug out when copying lijd 2004-11-19 16:15
UINT32 uhci_slaveDetect(void)
{
int result;
//-------------------------------------------------------------------------
// Wait for USB enumeration
//-------------------------------------------------------------------------
if(!SLAVE_ENUMERATED)
{ // wait for an USB device to be inserted
if(uhci_PlugInOutDetect())
{
printf("slave is plug in!!!\n");
usb_plug_out_flag=0;
uhci_reset(); //wthsin 2003/12/30 04:43
USB_ADDR=uDisk_ADDR;
result=EnumUsbDev(USB_ADDR);
if(no_disk_cnt == 1)//liweihua 20040324
system_state=SYSTEM_OPEN; //wthsin, 2004/3/16 07:36pm
if(result)
{ // enumerate USB device, assign USB address = #1
SLAVE_ENUMERATED = TRUE; // Set slave USB device enumerated flag
#ifdef SUPPORT_SLOT_IN_LOADER
card_plug_state = USER_DO_PLUG_IN;
#else
if(play_state != VCD_STATE_OPEN)//liweihua add 2004-3-11
card_plug_state = USER_DO_PLUG_IN;
else
card_plug_state = 0;
#endif
detect_type |= USB_DEVICE; //wthsin ,2004/3/1 03:16pm
MaxLUN = 0; //Maoyong 2004.05.19
return 1;
}
}
}
//-------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -