📄 haldevchk.c
字号:
/****************************************************************
* Viaon Technology (Suzhou) Co.,Ltd
*
* Copyright 2007, Viaon Technology (Suzhou) Co.,Ltd,Suzhou,China
* All rights reserved.
*
*
* Filename: haldevchk.c
*
* Programmer: Greg
*
* Created: 1/2/2008
*
* Description: public functions
*
*
* Change History (most recent first): 2008.1.2
****************************************************************/
#include "haldevchk.h"
#include "libdrive.h"
/*static*/ BYTE data bDEVFlag;
/*static*/ BYTE DEVAttach[2] = {USB_ATTACHED, SD_ATTACHED};
#ifdef ENABLE_DEVICE_DETECT
static BYTE DEVDisattach[2] = {USB_DISATTACHED, SD_DISATTACHED};
static BYTE FSMSta[2] = {FSMSTATE_USB, FSMSTATE_SD};
//For DEV_CHECK_ANOTHER
//Return FALSE, if another device is disattached.
//Return TRUE, if another device is attached.
//For DEV_CHECK_CUR
//Return FALSE, if current device is disattached.
//Return TRUE, if current device is not disattached.
BYTE halDevCheck(BYTE bDev, BYTE bFlag) //Check if the other device is attached/disattached.
{
BYTE data bRet;
if(bFlag == DEV_CHECK_ANOTHER){
if((bDev==USB_DISK)){ //Current device is USB, check SD
bRet = halSDCheck();
//UartOutText("current USB,check SD\r\n");
}else{//Current device is SD, so check USB
//UartOutText("current SD,check USB\r\n");
bRet = halUsbCheck();
}
}else{ //DEV_CHECK_CUR
if((bDev==USB_DISK)){ //Current device is USB
bRet = halUsbChkReg();
}else{//Current device is SD
bRet = halSDCheck();
}
}
return bRet;
}
//This function can only be called when device is attached and enumerated.
void halDevPnP()
{
DRIVE *drv = DriveGet();
if(bgDevChkGap < DEV_CHECK_GAP){
return;
}
bgDevChkGap = 0;
if(mp3status == MP3STATUS_PAUSE){ //Check current device
#if 1
if(halDevCheck(drv->DevID, DEV_CHECK_CUR) == FALSE){
UartOutText("Current device removed\r\n");
FSMState = FSMSTATE_USB;
//FSMState = FSMSta[drv->DevID];
}
#endif
}
#if 1
else{
//Chech the dis-attachment of another device
if(halDevCheck(drv->DevID, DEV_CHECK_ANOTHER) == FALSE){ //Check the another device according to the current device
//UartOutText("-I-: Another Dev Disattached \r\n");
bDEVFlag = DEVDisattach[drv->DevID];
}
//Check the attachment of another device after dis-attachment
if((bDEVFlag == DEVDisattach[drv->DevID])&&(halDevCheck(drv->DevID, DEV_CHECK_ANOTHER) == TRUE)){
FSMState = FSMSta[drv->DevID];
//bDEVFlag = DEVAttach[drv->DevID];;
UartOutText("-I-: Another Dev attached \r\n");
//drv = NULL;
}
}
#endif
return;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -