亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? nscdevice.cpp

?? 美國國家半導(dǎo)體公司的掃描儀芯片LM9833的驅(qū)動(dòng)程序。
?? CPP
?? 第 1 頁 / 共 5 頁
字號(hào):
/*******************************************************************************
 *	@doc
 *
 *  @module NSCDevice.cpp | 
 *
 *	This module contains <o UsdNSCDevice> object methods and helpers that 
 *	implement the IStiUSDDevice interface which is one of the standard 
 *	STI interfaces
 *
 *  Copyright (c) National Semiconductor Corporation 1999-2000
 *  All rights reserved
 *
 ******************************************************************************/

#include "NSCStiU.h"
#include "NscDevice.h"
#include "NSCUtils.h"
#include "NSCUsbIO.h"

// Uncomment this if the device has to be polled for events otherwise it will
// be assumed that the device will generate events
#define NS_POLL_FOR_EVENTS   

const DWORD NS_READ_DATA_TIMEOUT	= 	20000; // in milliseconds
const DWORD NS_WRITE_DATA_TIMEOUT	=	20000; // in milliseconds
const DWORD NS_READ_CMD_TIMEOUT		=	20000; // in milliseconds
const DWORD NS_WRITE_CMD_TIMEOUT	=	20000; // in milliseconds
const DWORD NS_THREADWAIT_TIMEOUT	=	5000;  // in milliseconds
const DWORD NS_MAX_ERRORSTRING		=	254;   // characters
const UCHAR NS_MAX_INTERRUPT_PACKET	=	1;	   // bytes	
const DWORD NS_MAX_LOCKTIMEOUT		=	1000;  // in milliseconds
const DWORD NS_POLLING_INTERVAL     =   500;   // in milliseconds
const DWORD NS_DEFAULT_KICKSTART	=	250;   // in milliseconds

const DWORD NS_DEFAULT_DEBOUNCE     = 5000;     // in milliseconds
const DWORD NS_MIN_DEBOUNCE         = 500;      // in milliseconds
const DWORD NS_MAX_DEBOUNCE         = 10000;    // in milliseconds

// The "Significant Events" recognized by the interrupt thread
const DWORD NS_DEVICE_INTERRUPT    = 0x0001; // Process a device event
const DWORD NS_SHUTDOWN_REQUEST    = 0x0002; // Shutdown the interrupt thread
const DWORD NS_WAIT_ERROR          = 0x0003; // Error while polling/waiting 
                                            // for events
const DWORD NS_IOCONTROL_ERROR     = 0x004;  // Error while using the IOcontrol
                                            // call to talk to the device

// Temporary define for the device descriptor the next version 
// of the DDK should have this value defined
const UCHAR NS_USB_DEVICE	= 1;

// Constants for reading and writing registers from the 
// LM9831 using the bulk endpoints
const UCHAR COMMAND_BYTE_COUNT	= 4;
const BYTE	LM_COMMAND_REGISTER	= 7;
const BYTE	LM_IOSTATUS_REGISTER = 2;

const BYTE	NS_MISC_IO_BIT[]	= { 0x04, 0x08, 0x10};
const BYTE	NS_EVENT_BIT[]		= { 0x01, 0x02, 0x04};
const BYTE	NS_RESET_BIT		=  0x20 ;

// The first byte for the bulk register reads is the mode 
// byte and this is bit mapped 
// Bit 0 , 1 - Read, 0 - Write
// Bit 1 , 1 - Inc, 0 - No Inc
const BYTE MODE_INC_READ	= 0x03;
const BYTE MODE_NOINC_READ	= 0x01;
const BYTE MODE_INC_WRITE	= 0x02;
const BYTE MODE_NOINC_WRITE = 0x00;

const TCHAR	NSCUSD_MUTEX[] = TEXT("NSCSTIU_MUTEX_");
const TCHAR	NSCUSD_POLLING_MUTEX[] = TEXT("NSCSTIU_POLLING_MUTEX_"); 
const TCHAR NSCUSD_KICKSTART_MUTEX[] = TEXT("NSCSTIU_KICKSTART_MUTEX_");

const BYTE NS_ENABLE_REMOTEWAKEUP   = 3;
const BYTE NS_DISABLE_REMOTEWAKEUP  = 1;

// The prototype for the interrupt thread fucntion
VOID	InterruptThreadFunc(LPVOID  lpParameter);

/*******************************************************************************
DESCRIPTION:

UsdNSCDevice::UsdNSCDevice is the constructor for this class 

PARAMETERS: 

LPUNKNOWN punkOuter - This is the pointer to the controlling unknown, if we are
being aggregated otherwise this will be NULL - For more info on COM 
aggregation, see Inside COM by Dale Rogerson of other articles on the MSDN

RETURN VALUE:
none

NOTES:
    This constructor handles COM delegation using the non delgating unknonw 
    base class. The only other thing that is done here is the creation of the
    event objects that we will need to use later on to signal the event thread 
    to shutdown
*******************************************************************************/
UsdNSCDevice::UsdNSCDevice( LPUNKNOWN punkOuter ):
    m_cRef(1),
    m_punkOuter(NULL),
    m_fValid(FALSE),
    m_pDcb(NULL),
    m_DeviceDataHandle(INVALID_HANDLE_VALUE),
	m_pszDeviceNameA(NULL),
    m_hSignalEvent(INVALID_HANDLE_VALUE),
    m_hThread(NULL),
    m_guidLastEvent(GUID_NULL),
	m_bEventMask(0),
	m_bEventsInitialized(false),
	m_hMutex(NULL),
    m_dwDebounceTime(NS_DEFAULT_DEBOUNCE),
	m_bPolling(false),
	m_bRemoteWakeup(false),
	m_bWHQLTest(false),
	m_dwKickStartTime(NS_DEFAULT_KICKSTART),
	m_hKickStartMutex(NULL)
{
	NSC_TRACE("In UsdNSCDevice::UsdNSCDevice");

	for (int index = 0; index < NS_MAX_OPEN_APPS ; index++)
		m_hPollingMutex[index] = NULL;
    //
    // See if we are aggregated. If we are ( which will be almost always the case )
    // save pointer to controlling Unknown , so subsequent calls will be delegated
    // If not, set the same pointer to "this" .
    // N.b. cast below is important in order to point to right virtual table
    //
    if (punkOuter) 
	{
        m_punkOuter = punkOuter;
    }
    else 
	{
        m_punkOuter = reinterpret_cast<IUnknown*>
                      (static_cast<INonDelegatingUnknown*>
                      (this));
    }

	m_hShutdownEvent =  CreateEvent( NULL,   // Attributes
                                   TRUE,     // Manual reset
                                   FALSE,    // Initial state - not set
                                   NULL );   // Anonymous

    if (m_hShutdownEvent && (INVALID_HANDLE_VALUE !=m_hShutdownEvent)) 
	{
		// We are now properly initialized and ready for action
        m_fValid = TRUE;
    }
}


/*******************************************************************************
DESCRIPTION:

UsdNSCDevice::~UsdNSCDevice is the destructor for this object class

PARAMETERS: 

VOID

RETURN VALUE:
none

NOTES:

This method cleans up after this object. The main actions performed here are 
1) shutting down the event thread in case it is active 
2) Closing the handle to the actual device 
3) Destroying the mutex used for synchronization

*******************************************************************************/
UsdNSCDevice::~UsdNSCDevice( VOID )
{
	NSC_TRACE("In UsdNSCDevice::~UsdNSCDevice");

    // Kill the notification thread if it exists by 
	// making sure that any notification handles are 
	// NULLed out.
    if (m_hSignalEvent && (m_hSignalEvent != INVALID_HANDLE_VALUE))
	{
		SetNotificationHandle(NULL);
	}

    if (m_hShutdownEvent && (m_hShutdownEvent!=INVALID_HANDLE_VALUE)) 
	{
        CloseHandle(m_hShutdownEvent);
    }

	CloseDevice();

    if (m_pszDeviceNameA) 
	{
        delete [] m_pszDeviceNameA;
        m_pszDeviceNameA = NULL;
    }

	// Close the mutex object 
	if (m_hMutex != NULL)
	{
		ReleaseMutex(m_hMutex);
	    CloseHandle(m_hMutex);
	}

	for (int index = 0; index < NS_MAX_OPEN_APPS; index++)
	{
		if (m_hPollingMutex[index] != NULL)
		{
			ReleaseMutex(m_hPollingMutex[index]);
			CloseHandle(m_hPollingMutex[index]);
		}
	}
}


/*******************************************************************************
DESCRIPTION:

UsdNSCDevice::GetCapabilities is called by STI to determine the capabilities
supported by this device 

PARAMETERS: 

PSTI_USD_CAPS pUsdCaps - This structure has to be filled in with data 
indicting the capabilitoes of the device

RETURN VALUE:
STDMETHODIMP  - This is a macro that indicates that we return HRESULT 

NOTES:
    The only capability which we want the STI to know about at this 
    point is the fact that we don't need polling and can generate our 
    own events

*******************************************************************************/
STDMETHODIMP UsdNSCDevice::GetCapabilities( PSTI_USD_CAPS pUsdCaps )
{
	NSC_TRACE("In UsdNSCDevice::GetCapabilities");

	HRESULT hres = STI_OK;

    ZeroMemory(pUsdCaps,sizeof(*pUsdCaps));

    pUsdCaps->dwVersion = STI_VERSION;

    // We support device notifications without polling
    pUsdCaps->dwGenericCaps = STI_USD_GENCAP_NATIVE_PUSHSUPPORT;

    return hres;
}


/*******************************************************************************
DESCRIPTION:

UsdNSCDevice::GetStatus is called by the STI to determine if the device that we 
    represent is still online

PARAMETERS: 

PSTI_DEVICE_STATUS pDevStatus

RETURN VALUE:
STDMETHODIMP - This is a macro that indicates that we return HRESULT 

NOTES:

*******************************************************************************/
STDMETHODIMP UsdNSCDevice::GetStatus( PSTI_DEVICE_STATUS pDevStatus )
{
	WriteToLog(	STI_TRACE_INFORMATION,
				L"In UsdNSCDevice::GetStatus - Online Status : %d, Event Status : %d", 
				pDevStatus->StatusMask & STI_DEVSTATUS_ONLINE_STATE,
				pDevStatus->StatusMask & STI_DEVSTATUS_EVENTS_STATE);

	HRESULT hres = STI_OK;

    //
    // If we are asked, verify whether device is online
    //
    pDevStatus->dwOnlineState = 0L;
    if( pDevStatus->StatusMask & STI_DEVSTATUS_ONLINE_STATE )  
	{
		hres = GetDeviceStatus(pDevStatus);
	}

    //
    // If we are asked, verify state of event
    //
    pDevStatus->dwEventHandlingState = 0L;
    if( pDevStatus->StatusMask & STI_DEVSTATUS_EVENTS_STATE ) 
	{
		if(m_guidLastEvent != GUID_NULL)
		{
			pDevStatus->dwEventHandlingState |= STI_EVENTHANDLING_PENDING;
		}
		
		if (m_hSignalEvent && (m_hSignalEvent!= INVALID_HANDLE_VALUE))
		{
			pDevStatus->dwEventHandlingState |= STI_EVENTHANDLING_ENABLED;
		}

    }

    return hres;
}


/*******************************************************************************
DESCRIPTION:

UsdNSCDevice::DeviceReset

PARAMETERS: 

VOID

RETURN VALUE:
STDMETHODIMP  - This is a macro that indicates that we return HRESULT 

NOTES:

*******************************************************************************/
STDMETHODIMP UsdNSCDevice::DeviceReset( VOID )
{
	NSC_TRACE("In UsdNSCDevice::DeviceReset");

	HRESULT hres = STIERR_NOT_INITIALIZED;

    // Reset the current active device - this can be 
	// accomplished by a DeviceIOControl call with an 
	// IOCTL of RESET_PIPE and a value of all pipes
	// Use the escape command to handle all the niceties
	// of the overlapped IO on this call
    if (INVALID_HANDLE_VALUE != m_DeviceDataHandle) 
	{
		
		DWORD		cbBytesWritten;
		PIPE_TYPE	ePipes = ALL_PIPE;
		hres = Escape(	IOCTL_RESET_PIPE,
						&ePipes,
						sizeof(ePipes),
						NULL,
						0,
						&cbBytesWritten);
    }

    return hres;
}

/*******************************************************************************
DESCRIPTION:

UsdNSCDevice::Diagnostic

PARAMETERS: 

LPDIAG pBuffer

RETURN VALUE:
STDMETHODIMP  - This is a macro that indicates that we return HRESULT 

NOTES:

*******************************************************************************/
STDMETHODIMP UsdNSCDevice::Diagnostic( LPDIAG pBuffer )
{
	NSC_TRACE("In UsdNSCDevice::Diagnostic");

    WriteToLog(	STI_TRACE_INFORMATION,
						L"%s : %s : 0x%X", // Message, Error, Code
						L"UsdNSCDevice::Diagnostic",
						L"testing",
						0) ;

	HRESULT hres = STI_OK;

    // We will try to get the maximum packet size for the 
	// USB pipes. This must obviously be greater than zero
	// If there is an error during this operation or the 
	// size is not greater than zero then the device is offline
    if (INVALID_HANDLE_VALUE != m_DeviceDataHandle) 
	{
		// Get the maximum packet size - this has to be 
		// greater than zero for all the pipes 
		CHANNEL_INFO	channelInfo = {0,0,0};
		DWORD			cbBytesWritten(0);

		hres = Escape(	IOCTL_GET_CHANNEL_ALIGN_RQST,
						NULL,
						0,
						&channelInfo,
						sizeof(channelInfo),
						&cbBytesWritten);

		if (FAILED(hres) ||  !channelInfo.EventChannelSize)
		{
			hres = STIERR_GENERIC;
		    m_dwLastOperationError = ::GetLastError();
			// Fill in the error info using the GetLastErrorInfo call
			GetLastErrorInfo(&pBuffer->sErrorInfo);
		}
		else
		{
		    m_dwLastOperationError = 0;
			GetLastErrorInfo(&pBuffer->sErrorInfo);
		}
    }
	else
	{
		hres = STIERR_NOT_INITIALIZED;		
	}

    return hres;
}


/*******************************************************************************
DESCRIPTION:

SetNotificationHandle

PARAMETERS: 

HANDLE hEvent

RETURN VALUE:
STDMETHODIMP  - This is a macro that indicates that we return HRESULT 

NOTES:
// SYNCHRONIZED

*******************************************************************************/
STDMETHODIMP UsdNSCDevice::SetNotificationHandle( HANDLE hEvent )
{
	WriteToLog(	STI_TRACE_INFORMATION,
				L"In UsdNSCDevice::SetNotificationHandle with handle Ox%X", 
				hEvent);

	HRESULT hres = STI_OK;

    TAKE_CRIT_SECT t(m_cs);

    if (hEvent && (hEvent !=INVALID_HANDLE_VALUE)) 
	{
        m_hSignalEvent = hEvent;

        if (m_DeviceDataHandle != INVALID_HANDLE_VALUE) 
		{
            m_guidLastEvent = GUID_NULL;

            if (!m_hThread) 
			{
			    DWORD   dwThread;
				m_hThread = ::CreateThread(NULL,
                                       2*1024,
                                       (LPTHREAD_START_ROUTINE)InterruptThreadFunc,
                                       (LPVOID)this,
                                       0,
                                       &dwThread);

				WriteToLog(	STI_TRACE_INFORMATION,
							L"%s : %s : 0x%X", // Message, Error, Code
							L"UsdNSCDevice::Enabling notification monitoring",
							L"Created Thread (handle) ",
							m_hThread) ;
            }
        }
        else 
		{
            // If we have not been initialized (like when we are 
			// opened in status mode) we will start listening
			// when we are actually opened in data mode so there is
			// no need to return an error code at this point
			WriteToLog(	STI_TRACE_INFORMATION,
						L"%s : %s : 0x%X", // Message, Error, Code
						L"UsdNSCDevice::Device not initialized",
						L"Deferring notification monitoring",
						0) ;
        }
    }
    else
	{
	    //
        // Disable hardware notifications
        //
        m_hSignalEvent = INVALID_HANDLE_VALUE;

		WriteToLog(	STI_TRACE_INFORMATION,
					L"%s : %s : 0x%X", // Message, Error, Code
					L"UsdNSCDevice::Disabling notification monitoring",
					L"Closing Thread (handle)",
					m_hThread) ;

        if ( m_hThread ) 
		{
			::SetEvent(m_hShutdownEvent);
            WaitForSingleObject(m_hThread, NS_THREADWAIT_TIMEOUT);
            CloseHandle(m_hThread);
            m_hThread = NULL;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产手机| 久久精品亚洲麻豆av一区二区| 九九**精品视频免费播放| 国产精品久久久久久一区二区三区| 欧美日韩一区中文字幕| 国产成人无遮挡在线视频| 亚洲电影一级黄| 国产精品久久久久久户外露出 | 成人黄色综合网站| 青青草国产精品97视觉盛宴| 亚洲啪啪综合av一区二区三区| 久久嫩草精品久久久精品| 精品视频在线免费观看| 99久久免费精品高清特色大片| 韩国女主播一区| 日本不卡一二三| 水野朝阳av一区二区三区| 亚洲三级电影网站| 国产精品毛片久久久久久 | 亚洲日本青草视频在线怡红院| 日韩欧美电影一区| 欧美猛男gaygay网站| 99精品偷自拍| 不卡一区在线观看| 成人晚上爱看视频| 高清成人免费视频| 国产一区美女在线| 国产精品一区二区三区四区 | 国产伦理精品不卡| 精品一区二区三区的国产在线播放| 亚洲成人午夜影院| 亚洲国产成人高清精品| 亚洲在线成人精品| 亚洲成人av免费| 午夜精品成人在线视频| 亚洲成a人v欧美综合天堂| 亚洲一区精品在线| 午夜视频一区二区三区| 亚洲6080在线| 日韩精品91亚洲二区在线观看| 亚洲国产精品一区二区www| 亚洲激情中文1区| 亚洲综合无码一区二区| 亚洲精品大片www| 亚洲综合久久久久| 亚洲线精品一区二区三区八戒| 亚洲一区二区三区激情| 亚洲成人精品在线观看| 奇米888四色在线精品| 久久激五月天综合精品| 国产一区二区成人久久免费影院 | 波多野结衣中文字幕一区二区三区 | 色丁香久综合在线久综合在线观看| 99精品视频在线观看免费| 日本久久电影网| 欧美视频你懂的| 欧美一区2区视频在线观看| 精品国产一二三区| 国产欧美综合色| 综合电影一区二区三区| 亚洲国产一区二区三区| 日韩avvvv在线播放| 国产精品18久久久| 成人av资源网站| 欧美日韩情趣电影| 精品理论电影在线观看| 欧美国产亚洲另类动漫| 夜夜嗨av一区二区三区网页| 日本伊人色综合网| 国产精品99久久不卡二区| 91在线精品一区二区三区| 欧美视频日韩视频| 久久婷婷成人综合色| 亚洲色图欧美偷拍| 日韩成人dvd| 成人涩涩免费视频| 欧美性做爰猛烈叫床潮| 精品国产乱码久久久久久闺蜜| 国产精品的网站| 亚洲成a人在线观看| 国产a视频精品免费观看| 欧美三区在线视频| 久久精品亚洲精品国产欧美| 亚洲精品水蜜桃| 捆绑紧缚一区二区三区视频| 成人av在线网站| 日韩一区二区电影| 亚洲色图19p| 国产自产v一区二区三区c| 91老司机福利 在线| 日韩欧美亚洲国产精品字幕久久久| 中文字幕亚洲成人| 久久99精品久久久久| 色狠狠色噜噜噜综合网| 视频一区二区中文字幕| 成人午夜电影久久影院| 日韩欧美一级二级三级久久久| 亚洲欧美激情插| 国产福利电影一区二区三区| 欧美久久高跟鞋激| 国产精品福利电影一区二区三区四区| 奇米四色…亚洲| 欧美又粗又大又爽| 国产精品国产a级| 国产在线精品免费av| 欧美日韩在线一区二区| 国产精品九色蝌蚪自拍| 六月丁香婷婷久久| 欧美日本免费一区二区三区| 亚洲精品欧美激情| 成人成人成人在线视频| 精品福利一二区| 蜜臀91精品一区二区三区 | 制服丝袜av成人在线看| 亚洲欧洲综合另类| 成人av电影在线| 亚洲国产精品成人综合色在线婷婷| 九一久久久久久| 制服丝袜在线91| 亚欧色一区w666天堂| 在线视频国内自拍亚洲视频| 国产精品国产精品国产专区不蜜| 国产激情一区二区三区四区 | 国产精品美女一区二区三区 | 欧美亚洲一区二区在线观看| 中文字幕亚洲成人| 成人一区在线看| 国产精品免费视频一区| 国产激情偷乱视频一区二区三区| 日韩精品中午字幕| 理论片日本一区| 欧美大片国产精品| 久久精品国产在热久久| 日韩亚洲欧美在线| 久久99精品网久久| 久久久久久免费毛片精品| 国产综合久久久久影院| 国产午夜精品久久久久久免费视| 国产精品一级二级三级| 国产亚洲一二三区| 国产成人精品三级| 国产精品精品国产色婷婷| 成人免费电影视频| 亚洲欧美日韩国产成人精品影院| 色综合视频一区二区三区高清| 亚洲美女精品一区| 欧美少妇xxx| 男女男精品视频网| 久久免费的精品国产v∧| 国产精品中文字幕日韩精品| 国产精品美女久久久久久久久久久| 成人美女视频在线观看18| 亚洲欧美日韩系列| 欧美放荡的少妇| 久久99精品久久久久久久久久久久| 久久久综合九色合综国产精品| 国产成人亚洲综合a∨婷婷图片| 国产精品久线观看视频| 一本久久a久久精品亚洲| 亚洲妇女屁股眼交7| 这里只有精品电影| 国产一区二区精品久久99| 成人欧美一区二区三区| 欧美日韩成人综合| 国产一区二区三区四区五区入口 | 91丝袜呻吟高潮美腿白嫩在线观看| 一片黄亚洲嫩模| 欧美大黄免费观看| 成人精品视频.| 亚洲最大的成人av| xnxx国产精品| 日本久久一区二区三区| 久久国产精品一区二区| 国产精品久久久久久久久久久免费看 | 久久综合精品国产一区二区三区| 国产成人8x视频一区二区| 一区二区久久久久久| 日韩精品中午字幕| 97久久精品人人做人人爽50路| 视频一区二区不卡| 国产亚洲视频系列| 欧美性三三影院| 国产成a人亚洲精品| 天堂影院一区二区| 亚洲欧洲国产专区| 欧美变态凌虐bdsm| 色偷偷88欧美精品久久久| 久久成人免费日本黄色| 亚洲精品免费在线播放| 久久看人人爽人人| 欧美久久高跟鞋激| 91蜜桃免费观看视频| 老鸭窝一区二区久久精品| 亚洲蜜臀av乱码久久精品蜜桃| www亚洲一区| 69堂成人精品免费视频| 91在线你懂得| 国产精品1区2区| 捆绑紧缚一区二区三区视频| 依依成人精品视频|