📄 bvd_udc_ser.h
字号:
/*
** INTEL CONFIDENTIAL
** Copyright 2000-2003 Intel Corporation All Rights Reserved.
**
** The source code contained or described herein and all documents
** related to the source code (Material) are owned by Intel Corporation
** or its suppliers or licensors. Title to the Material remains with
** Intel Corporation or its suppliers and licensors. The Material contains
** trade secrets and proprietary and confidential information of Intel
** or its suppliers and licensors. The Material is protected by worldwide
** copyright and trade secret laws and treaty provisions. No part of the
** Material may be used, copied, reproduced, modified, published, uploaded,
** posted, transmitted, distributed, or disclosed in any way without Intel抯
** prior express written permission.
**
** No license under any patent, copyright, trade secret or other intellectual
** property right is granted to or conferred upon you by disclosure or
** delivery of the Materials, either expressly, by implication, inducement,
** estoppel or otherwise. Any license under such intellectual property rights
** must be express and approved by Intel in writing.
*/
/*
Module Name: $Workfile: bvd_udc_ser.h $
$Date: 9/09/03 7:08p $
Abstract:
Holds PDD definitions for sample USB Function driver.
Notes:
*/
#ifndef __XSC1_USB_SER_H__
#define __XSC1_USB_SER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "Bvd1.h"
#include "drv_glob.h"
//Here are the names of the values stored in the registry
#define SA_REG_IOLEN_VAL_NAME TEXT("IoLen")
#define SA_REG_IOLEN_VAL_LEN sizeof( DWORD )
#define SA_REG_IRQ_VAL_NAME TEXT("Irq")
#define SA_REG_IRQ_VAL_LEN sizeof( DWORD )
#define SA_REG_DEVINDEX_VAL_NAME TEXT("DeviceArrayIndex")
#define SA_REG_DEVINDEX_VAL_LEN sizeof( DWORD )
// We can be built with a simple setting 0, or optionally add
// a second setting which includes an interrupt endpoint
// #define INT_SETTING 1
// Strict timing requirements at enumeration. Use a relatively high priority
#define DEFAULT_THREAD_PRIO 100
// We poll for device detach at the following rate.
#define SA_USB_POLL_RATE 1000
// And simulate disconnect if SOF unchanged this many interations
#define SOF_STABLE_MAX 3
// Use this macro to determine if we are in Data0 or Data1 phase
//
#define DATA1( dat_cnt ) ( ((++dat_cnt) & 0x01) )
// We use a callback for serial events
typedef VOID (*EVENT_FUNC)(PVOID Arg1, ULONG Arg2);
// Here is the callback for serial events
typedef VOID (*PFN_SER_EVENT) (
PVOID pHandle, // PHW_INDEP_INFO, but pdd doesn't know it
UINT32 events // What events where encountered?
);
// Definitions of EP0 state machine.
#define WAIT_FOR_SETUP 1
#define DATA_STATE_XMIT 2
#define DATA_STATE_RCVR 3
#define WAIT_FOR_OUT_STATUS 4
#define WAIT_FOR_IN_STATUS 5
//#pragma pack(4)
//#pragma optimize("", off)
/*
* @doc HWINTERNAL
* @struct SER_INFO | Private structure.
*/
typedef struct __SER_INFO {
// Keep a copy of DCB since we rely on may of its parms
DCB dcb; // @field Device Control Block (copy of DCB in MDD)
// And the same thing applies for CommTimeouts
COMMTIMEOUTS CommTimeouts; // @field Copy of CommTimeouts structure
ULONG CommErrors; // @field Bitfield representing Win32 comm error status.
ULONG ModemStatus; // @field Bitfield representing Win32 modem status.
CRITICAL_SECTION HwRegCritSec;// @field Protects SA_USB registers from non-atomic
// access (addr/data pairs)
CRITICAL_SECTION TransmitCritSec; // @field Protects UART TX FIFO from simultaneous access
ULONG OpenCount; // @field Count of simultaneous opens.
ULONG DroppedBytes; // @field Number of dropped bytes
COMSTAT Status; // @field Bitfield representing Win32 comm status.
HANDLE FlushDone; // @field Handle to flush done event.
// We have our own dispatch thread.
HANDLE pDispatchThread; // @field ReceiveThread
DWORD KillRxThread:1; // @field Flag to terminate SA_USB_DispatchThread.
HANDLE hSerialEvent; // @field Interrupt event
// now hardware specific goodies
DWORD dwIOLen; // @field IO Length
DWORD dwIRQ; // @field Interrupt number for this peripheral
DWORD dwDevIndex; // @field Index of device
WORD wSOFStableCnt; // @field How many iterations without SOF
//volatile INTC_REGS *pINTCRegs; // Interrupt Controller registers base address
volatile XLLP_INTC_T *pINTCRegs; // Interrupt Controller registers base address
volatile UDC_REGS *pUDCRegs; // UDC registers base address
volatile XLLP_CLKMGR_T *pCLKRegs; //CLK Base Address
//volatile GPIO_REGS *pGPIORegs; // GPIO registers base address
volatile XLLP_GPIO_T *pGPIORegs; // GPIO registers base address
volatile DRIVER_GLOBALS *pDrvGlobals; // Driver globals base address
//volatile BLR_REGS *pBLRReg; // @field for board specific stuff
volatile XLLP_BCR_T *pBCRReg; // @field for board specific stuff
int eState; // @field Current EP0 state machine
// EP0 Data Xfer info
int nXmitLength; // @field Current EP0 xfer length
PBYTE pXmitData; // @field Pointer to xmit data for EP0
int nXmitIndex; // @field Index into the current EP0 xmit buffer
int nXmitReq; // @field Requested amount of data on EP0
SetupPKG dReq; // @field USB endpoint 0 command
BYTE cIntStat; // @field Last known interrupt status
BYTE dConfIdx; // @field USB Configuration Index
BYTE dInterface; // @field USB Interface Index
BYTE dSetting; // @field USB Setting Index
BYTE dAddress; // @field USB device Address
UINT8 cOpenCount; // @field Count of concurrent opens
COMMPROP CommProp; // @field Pointer to CommProp structure.
PVOID pMddHead; // @field First arg to mdd callbacks.
PHWOBJ pHWObj; // @field Pointer to PDDs HWObj structure
BOOL fIRMode; // @field Boolean, are we running in IR mode?
DWORD UDC_Reset;
DWORD UDC_ResetTimeOut;
// We have an event callback into the MDD
EVENT_FUNC EventCallback; // This callback exists in MDD
} SER_INFO, *PSER_INFO;
// And now, all the function prototypes
PVOID
SerInit(
ULONG Identifier,
PVOID pMddHead,
PHWOBJ pHWObj
);
BOOL SerPostInit(
PVOID pHead
);
BOOL SerDeinit(
PVOID pHead
);
BOOL SerOpen(
PVOID pHead
);
ULONG SerClose(
PVOID pHead
);
VOID SerClearDTR(
PVOID pHead
);
VOID SerSetDTR(
PVOID pHead
);
VOID SerClearRTS(
PVOID pHead
);
VOID SerSetRTS(
PVOID pHead
);
VOID SerClearBreak(
PVOID pHead
);
VOID SerSetBreak(
PVOID pHead
);
VOID SerClearBreak(
PVOID pHead
);
VOID SerSetBreak(
PVOID pHead
);
ULONG SerGetByteNumber(
PVOID pHead
);
VOID SerDisableXmit(
PVOID pHead
);
VOID SerEnableXmit(
PVOID pHead
);
BOOL SerSetBaudRate(
PVOID pHead,
ULONG BaudRate // ULONG representing decimal baud rate.
);
BOOL SerSetDCB(
PVOID pHead,
LPDCB lpDCB // Pointer to DCB structure
);
ULONG SerSetCommTimeouts(
PVOID pHead,
LPCOMMTIMEOUTS lpCommTimeouts // Pointer to CommTimeout structure
);
ULONG SerGetRxBufferSize(
PVOID pHead
);
INTERRUPT_TYPE SerGetInterruptType(
PVOID pHead
);
ULONG SerRxIntr(
PVOID pHead,
PUCHAR pRxBuffer, // Pointer to receive buffer
ULONG *pBufflen // In = max bytes to read, out = bytes read
);
VOID SerTxIntr(
PVOID pHead,
PUCHAR pTxBuffer,
ULONG *pBufflen
);
VOID SerLineIntr(
PVOID pHead
);
VOID SerModemIntr(
PVOID pHead
);
ULONG SerGetStatus(
PVOID pHead,
LPCOMSTAT lpStat // Pointer to LPCOMMSTAT to hold status.
);
VOID SerReset(
PVOID pHead
);
VOID SerGetModemStatus(
PVOID pHead,
PULONG pModemStatus // PULONG passed in by user.
);
VOID SerPurgeComm(
PVOID pHead,
DWORD fdwAction // Action to take.
);
BOOL SerXmitComChar(
PVOID pHead,
UCHAR ComChar // Character to transmit.
);
BOOL SerPowerOn(
PVOID pHead
);
BOOL SerPowerOff(
PVOID pHead
);
BOOL SerIoctl(
PVOID pHead,
DWORD dwCode,
PBYTE pBufIn,
DWORD dwLenIn,
PBYTE pBufOut,
DWORD dwLenOut,
PDWORD pdwActualOut
);
//*********************************************************
// Functions from the SA_USB HW support file
//*********************************************************
void SA_USB_DoEndpoint0(
PSER_INFO pHWHead,
PDWORD pModemStatus
);
INTERRUPT_TYPE SA_USB_GetInterruptType(
PSER_INFO pHWHead
);
void SA_USB_Init(
PSER_INFO pHWHead
);
void SA_USB_DeInit(
PSER_INFO pHWHead
);
void SA_USB_LineIntHandler(
PSER_INFO pHWHead
);
BOOL SA_USB_RxIntHandler(
PSER_INFO pHWHead,
PUCHAR pRxBuffer,
ULONG *pBuffLen
);
void SA_USB_TxIntHandler(
PSER_INFO pHWHead,
PUCHAR pTxBuffer,
ULONG *pBuffLen
);
void SA_USB_PowerOff(
PSER_INFO pHWHead
);
void SA_USB_PowerOn(
PSER_INFO pHWHead
);
void SA_USB_CableEvent(
PSER_INFO pHWHead
);
void ServiceEP0(
PSER_INFO pHWHead,
PDWORD pModemStatus
);
#ifdef __cplusplus
}
#endif
#endif __XSC1_USB_SER_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -