📄 ncdevice.h
字号:
/******************************************************************************
Copyright (C) 2004, NetChip Technology, Inc. (http://www.netchip.com)
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.
NCDEVICE.H
NetChip device level interface. The lower edge of this module interfaces
to the NetChip Hardware Abstraction Layer (NcHAL); the upper edge connects
to the NetChip API using a private interface. (Applications should not
require access to this module's functions! Applications should use the
NetChip API interface module)
Primarily, the NetChip device level interface handles:
- Chip initialization
- USB Chapter Nine compliance, including enumeration and control transfers
- Device events (PnP, suspend, etc.)
- Support for API
******************************************************************************/
///////////////////////////////////////////////////////////////////////////////
#ifndef NC2272_H
#define NC2272_H
///////////////////////////////////////////////////////////////////////////////
#include <NET2272.h> // NET2272 register and bit field definitions (from NET2272 spec)
#include <NcHal.h> // NetChip Hardware Abstraction Layer
///////////////////////////////////////////////////////////////////////////////
// Public macros:
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Convenient macros for accessing members of the setup packet
// - USB 2.0 9.4 describes several standard eight-byte USB requests. These
// macros help to access individual members: words and bytes within words
#define BMREQUESTTYPE (*(PBYTE)&PrivDeviceObject->SetupPacket.bmRequestType)
#define BREQUEST (*(PBYTE)&PrivDeviceObject->SetupPacket.bRequest)
#define WVALUE (PrivDeviceObject->SetupPacket.wValue.Word)
#define WVALUE_LO (*((PBYTE)&PrivDeviceObject->SetupPacket + _wValueLo))
#define WVALUE_HI (*((PBYTE)&PrivDeviceObject->SetupPacket + _wValueHi))
#define WINDEX (PrivDeviceObject->SetupPacket.wIndex.Word)
#define WINDEX_LO (*((PBYTE)&PrivDeviceObject->SetupPacket + _wIndexLo))
#define WINDEX_HI (*((PBYTE)&PrivDeviceObject->SetupPacket + _wIndexHi))
#define WLENGTH (PrivDeviceObject->SetupPacket.wLength.Word)
#define WLENGTH_LO (*((PBYTE)&PrivDeviceObject->SetupPacket + _wLengthLo))
#define WLENGTH_HI (*((PBYTE)&PrivDeviceObject->SetupPacket + _wLengthHi))
///////////////////////////////////////////////////////////////////////////////
// Interrupt enables for managing the USB state
// - All enables required for managing the USB state are in IRQENB1
#define USB_STATE_IRQENB1 ( \
(1<<ROOT_PORT_RESET_INTERRUPT_ENABLE) | \
(1<<RESUME_INTERRUPT_ENABLE) | \
(1<<SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE) | \
(1<<VBUS_INTERRUPT_ENABLE) | \
0)
///////////////////////////////////////////////////////////////////////////////
// Offset to NET2272 registers in local address space of PCI-RDK board
// - NET2272 lives in PCI-RDK 'expansion' address space
// - Applies to DMA on NetChip's RDK only
#define NETCHIP_LOCAL_OFFSET NCPCI_EXPANSION_LOCAL_OFFSET
#if _NC_RDK_AND_WINDOWS && _NCDEBUG
///////////////////////////////////////////////////////////////////////////////
// Flashing LED support (NetChip NET2272 PCI-RDK only!)
// - There is one LED on the NET2272 daughter board (DB_LED)
// - There is one LED on the PCI-RDK board (RDK_LED)
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Flash LED 1
// - LED 1 is on the NetChip RDK board
// - TRUE to turn LED ON, otherwise OFF
// - If an LED is not available, this macro can evaluate to nothing
#define NC_LED1(on) RdkLed(on)
///////////////////////////////////////////////////////////////////////////////
// Flash LED 2
// - LED 2 is on the NET2272 Daughter Board
// - TRUE to turn LED ON, otherwise OFF
// - If an LED is not available, this macro can evaluate to nothing
#define NC_LED2(on) Net2272DbLed(on)
///////////////////////////////////////////////////////////////////////////////
void
RdkLed(
BOOL On
);
///////////////////////////////////////////////////////////////////////////////
void
Net2272DbLed(
BOOL On
);
///////////////////////////////////////////////////////////////////////////////
#else // _NC_RDK_AND_WINDOWS && _NCDEBUG
#define NC_LED1(on) // Macro evaluates to nothing
#define NC_LED2(on) // Macro evaluates to nothing
///////////////////////////////////////////////////////////////////////////////
#endif // _NC_RDK_AND_WINDOWS && _NCDEBUG
///////////////////////////////////////////////////////////////////////////////
// Public variables
///////////////////////////////////////////////////////////////////////////////
extern PNETCHIP_DATA_TYPE NetchipBaseAddress;
extern NC_TRANSFER_OBJECT PrivateTransferZero;
///////////////////////////////////////////////////////////////////////////////
// Public functions
// - These NetChip Device (NcDev) functions are public for NetChip API firmware,
// but they are NOT expected to be used by client application firmware
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Chip test
// - Verify the NET2272 registers are working properly
NCSTATUS
NcDev_AreYouThere(
void
);
///////////////////////////////////////////////////////////////////////////////
void
NcDev_CleanUp(
void
);
///////////////////////////////////////////////////////////////////////////////
void
NcDev_UsbState(
PNC_DEVICE_OBJECT DeviceObject
);
///////////////////////////////////////////////////////////////////////////////
void
NcDev_ControlHandler(
PNC_DEVICE_OBJECT DeviceObject
);
///////////////////////////////////////////////////////////////////////////////
#endif // NC2272_H
///////////////////////////////////////////////////////////////////////////////
// End of file
///////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -