📄 sd_pap.c
字号:
/***************************************************************************
* File: sd_pap.c - Plug and Play
*
* The content of this file or document is CONFIDENTIAL and PROPRIETARY
* to Jade Technologies Co., Ltd. It is subject to the terms of a
* License Agreement between Licensee and Jade Technologies Co., Ltd.
* restricting among other things, the use, reproduction, distribution
* and transfer. Each of the embodiments, including this information
* and any derivative work shall retain this copyright notice.
*
* Copyright (c) 2005 Jade Technologies Co., Ltd.
* All rights reserved.
****************************************************************************/
#include "sd.h"
//------------------------------------------------------------------------------
// Global Variables in SD_PAP.C
//------------------------------------------------------------------------------
extern int g_CardStatus;
//------------------------------------------------------------------------------
//
// Inform OS that the card is inserted
// See also: SDI_DetectStatus
//
//------------------------------------------------------------------------------
void SDI_DetectInsert(void)
{
GUID uid = { 0xA4E7EDDA , 0xE575 , 0x4252 ,
{0x9D, 0x6B, 0x41, 0x95,0xD4,0x8B,0xB8,0x65 } };
RETAILMSG(MSG_PAP, (_T("SD:+DetectInsert\r\n")));
AdvertiseInterface( &uid , L"SDI1:" , TRUE );
RETAILMSG(MSG_PAP, (_T("SD:-DetectInsert\r\n")));
}
//------------------------------------------------------------------------------
//
// Inform OS that the card is removed
// See also: SDI_DetectStatus
//
//------------------------------------------------------------------------------
void SDI_DetectRemove(void)
{
GUID uid = { 0xA4E7EDDA , 0xE575 , 0x4252 ,
{0x9D, 0x6B, 0x41, 0x95,0xD4,0x8B,0xB8,0x65 } };
RETAILMSG(MSG_PAP, (_T("SD:+DetectRemove\r\n")));
AdvertiseInterface( &uid , L"SDI1:" , FALSE );
RETAILMSG(MSG_PAP, (_T("SD:-DetectRemove\r\n")));
}
//------------------------------------------------------------------------------
//
// Plug & Play Thread - created when the driver is loaded, and check the status
// of the card. When the status changed, the routine called the two functions
// above, to force OS open or close an instance.
//
// Arguments:
// controller - handle of the instance passed from the main thread.
//
//------------------------------------------------------------------------------
unsigned long WINAPI SDI_DetectStatus(LPVOID controller)
{
// at test period, we suppose the card is always in the socket.
return 1;
SetThreadPriority(GetCurrentThread, 97);
if (controller == NULL || g_CardStatus == STATE_TEST)
return 0;
while (g_CardStatus != STATE_DEINITING)
{
if (g_CardStatus == STATE_OPENED)
{
if (!SDI_IsCardIn((SD_controller*)controller, NULL))
SDI_DetectRemove();
}
if (g_CardStatus == STATE_CLOSED || g_CardStatus == STATE_INITING)
{
if (SDI_IsCardIn((SD_controller*)controller, NULL))
SDI_DetectInsert();
}
if (g_CardStatus == STATE_DEAD)
{
RETAILMSG(MSG_PAP, (_T("SD: Card is DEAD\r\n")));
break;
}
Sleep(100);
}
g_CardStatus = STATE_DEAD;
return 1;
}
//------------------------------------------------------------------------------
//
// Check if the card is in the socket.
//
// Arguments:
// controller - handle of the instance.
// errorcode - record error.
//
//------------------------------------------------------------------------------
BOOL SDI_IsCardIn(SD_controller* controller, unsigned long* errorcode)
{
unsigned long error = 0;
if (!controller)
error = 1;
// at test period, we suppose the card is always in the socket.
RETAILMSG(MSG_PAP, (_T("SD: Card is READY!\r\n")));
return TRUE; //
if ((*(controller->SysDetect)) & 0x01)
return TRUE;
if (error)
{
if (errorcode)
*errorcode = error;
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -