📄 hwinit.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
//------------------------------------------------------------------------------
//
// File: hwinit.c
//
#include <windows.h>
#include <oal.h>
#include <bulverde.h>
#include <args.h>
#include <image_cfg.h>
#include <usbfntypes.h>
#include <usbfn.h>
#include <rndismini.h>
#include "rndis_pdd.h"
extern BSP_ARGS *g_pBSPArgs;
extern UFN_PDD_INTERFACE_INFO g_pddInterface;
//------------------------------------------------------------------------------
// Performs the hardware initialization (clock, I2C, OTG transceiver, OTG controller)
//
BOOL InitializeHardware()
{
// Plato platform specific hardware initialization
//
volatile BULVERDE_GPIO_REG *pGPIORegs = (BULVERDE_GPIO_REG*)OALPAtoVA(BULVERDE_BASE_REG_PA_GPIO, FALSE);
// Configure the GPIO pin 11 to attach and detach the USB to the bus
//
// set GPIO pin 11 direction to output
pGPIORegs->GPDR0 |= XLLP_BIT_11;
//Enable UDC Soft Disconnect
// pull GPIO pin 11 low to detach the device from the bus
// (just in case it was previously connected)
pGPIORegs->GPCR0 |= XLLP_BIT_11;
OALStall(10000); // 10ms wait
//Enable UDC Soft Connect
// Pull GPIO pin 11 high to attach the device to the bus
pGPIORegs->GPSR0 |= XLLP_BIT_11;
return TRUE;
}
//------------------------------------------------------------------------------
void GetRNDISMACAddress(UINT16 mac[3])
{
mac[0] = g_pBSPArgs->kitl.mac[0];
mac[1] = g_pBSPArgs->kitl.mac[1];
mac[2] = g_pBSPArgs->kitl.mac[2];
}
//------------------------------------------------------------------------------
VOID PXA27X_RndisPowerOff()
{
volatile BULVERDE_GPIO_REG *pGPIORegs = (BULVERDE_GPIO_REG*)OALPAtoVA(BULVERDE_BASE_REG_PA_GPIO, FALSE);
volatile PBULVERDE_CLKMGR_REG m_pDCCLKReg = (PBULVERDE_CLKMGR_REG)OALPAtoVA(BULVERDE_BASE_REG_PA_CLKMGR, FALSE);
UINT32 regval = 0;
OALMSG(OAL_ETHER&&OAL_FUNC, (L"+PXA27X_RndisPowerOff\r\n"));
// Configure the GPIO pin 11 to attach and detach the USB to the bus
//
// set GPIO pin 11 direction to output
pGPIORegs->GPDR0 |= XLLP_BIT_11;
// pull GPIO pin 11 low to detach the device from the bus
pGPIORegs->GPCR0 |= XLLP_BIT_11;
g_pddInterface.pfnPowerDown(g_pddInterface.pvPddContext);
OALMSG(OAL_ETHER&&OAL_FUNC, (L"-PXA27X_RndisPowerOff\r\n"));
}
//------------------------------------------------------------------------------
VOID PXA27X_RndisPowerOn()
{
volatile PBULVERDE_PWRRST_REG pPwrRst_reg = (PBULVERDE_PWRRST_REG) OALPAtoVA(BULVERDE_BASE_REG_PA_PWR, FALSE);
USHORT mac[3] = {0x0002, 0xb392, 0xa8c4}; //Just a default, will be overwritten
OALMSG(OAL_ETHER&&OAL_FUNC, (L"+PXA27X_RndisPowerOn\r\n"));
// Clear the OTGPH (OTG Peripheral Hold) bit in PSSR.
// This will enable the USB lines again.
pPwrRst_reg->pssr |= 0x40;
HostMiniInit(NULL, 0, mac);
OALMSG(OAL_ETHER&&OAL_FUNC, (L"+PXA27X_RndisPowerOn\r\n"));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -