📄 ms2_usbfn.cpp
字号:
//
// 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 <XSBASE270_G.h>
#include <xllp_cpld.h>
class MS2UsbDevice: public BulUsbDevice {
public:
MS2UsbDevice(LPCTSTR lpActivePath)
: BulUsbDevice(lpActivePath)
{
m_pCPLDReg = NULL;
}
virtual ~MS2UsbDevice() {
if (m_pCPLDReg)
MmUnmapIoSpace(m_pCPLDReg,0);
}
virtual DWORD Init(PVOID pvMddContext,PUFN_MDD_INTERFACE_INFO pMddInterfaceInfo, PUFN_PDD_INTERFACE_INFO pPddInterfaceInfo)
{
DWORD dwReturn = ERROR_INVALID_DATA;
if (m_pCPLDReg==NULL) {
PHYSICAL_ADDRESS ioPhysicalBase = { XSBASE270_G_BASE_REG_PA_CPLD, 0 };
m_pCPLDReg =(PXSBASE270_G_CPLD_REGS) MmMapIoSpace(ioPhysicalBase, sizeof(XSBASE270_G_CPLD_REGS),FALSE) ;
}
if (m_pCPLDReg) {
dwReturn = BulUsbDevice::Init(pvMddContext, pMddInterfaceInfo, pPddInterfaceInfo);
}
return dwReturn;
}
virtual DWORD Start() {
DWORD dwReturn = BulUsbDevice::Start();
if (dwReturn == ERROR_SUCCESS) {
//Enable UDC Soft Connect
m_pCPLDReg->BCR2 |= XLLP_BCR2_VBUS_ON;
}
return dwReturn;
}
virtual DWORD Stop() {
DWORD dwReturn = BulUsbDevice::Stop();
if (dwReturn == ERROR_SUCCESS) {
//Disable UDC Soft Connect
m_pCPLDReg->BCR2 &= ~XLLP_BCR2_VBUS_ON;
}
return dwReturn;
}
virtual BOOL IsCableAttached() {
return ((m_pCPLDReg->STATUS & XLLP_STS_USB1_WAKE)!=0);
};
private:
volatile PXSBASE270_G_CPLD_REGS m_pCPLDReg;
};
BulUsbDevice * CreateBulUsbDevice(LPCTSTR lpActivePath)
{
return new MS2UsbDevice(lpActivePath);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -