📄 ms2_usbfn.cpp.svn-base
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Module Name:
ms2_usbfn.cpp
Abstract:
Bulverde USB Function Driver.
--*/
#include <windows.h>
#include <ceddk.h>
#include <ddkreg.h>
#include <nkintr.h> // needed for SYSINTR_NOP
#include <bulverde.h>
#include <xllp_gpio.h>
#include <bul_usbfn.h>
#include <mainstoneii.h>
#include <xllp_bcr.h>
class MS2UsbDevice: public BulUsbDevice {
public:
MS2UsbDevice(LPCTSTR lpActivePath)
: BulUsbDevice(lpActivePath)
{
m_pBCRReg = NULL;
}
virtual ~MS2UsbDevice() {
if (m_pBCRReg)
MmUnmapIoSpace(m_pBCRReg,0);
}
virtual DWORD Init(PVOID pvMddContext,PUFN_MDD_INTERFACE_INFO pMddInterfaceInfo, PUFN_PDD_INTERFACE_INFO pPddInterfaceInfo)
{
DWORD dwReturn = ERROR_INVALID_DATA;
NKDbgPrintfW(TEXT("++ USBFN Init...\r\n"));
if (m_pBCRReg==NULL) {
PHYSICAL_ADDRESS ioPhysicalBase = { MAINSTONEII_BASE_REG_PA_FPGA, 0 };
m_pBCRReg =(PMAINSTONEII_BLR_REGS) MmMapIoSpace(ioPhysicalBase, sizeof(MAINSTONEII_BLR_REGS),FALSE) ;
}
if (m_pBCRReg) {
dwReturn = BulUsbDevice::Init(pvMddContext, pMddInterfaceInfo, pPddInterfaceInfo);
}
return dwReturn;
}
virtual DWORD Start() {
DWORD dwReturn = BulUsbDevice::Start();
if (dwReturn == ERROR_SUCCESS) {
//Enable UDC Soft Connect
m_pBCRReg->misc_wr2 &= ~XLLP_BCR_MISCWR2_NUSBC_SC;
}
return dwReturn;
}
virtual DWORD Stop() {
DWORD dwReturn = BulUsbDevice::Stop();
if (dwReturn == ERROR_SUCCESS) {
//Enable UDC Soft Connect
//m_pBCRReg->MISCWR2 &= ~XLLP_BCR_MISCWR2_NUSBC_SC;
m_pBCRReg->misc_wr2 |= XLLP_BCR_MISCWR2_NUSBC_SC;
}
return dwReturn;
}
virtual BOOL IsCableAttached() {
return ((m_pBCRReg->misc_rd & XLLP_BCR_MISCRR1_USB_CBL)!=0);
};
private:
volatile PMAINSTONEII_BLR_REGS m_pBCRReg;
};
BulUsbDevice * CreateBulUsbDevice(LPCTSTR lpActivePath)
{
return new MS2UsbDevice(lpActivePath);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -