📄 pcd.h
字号:
/*-----------------------------------------------------------------------------
$File: //tdi_sw/tdi/source/usb/ctrl_drv/pcd/common/pcd.h $
$DateTime: 2004/12/20 19:06:16 $
$Revision: #5 $
Purpose: Common interface for all PCDs
CONFIDENTIAL AND PROPRIETARY INFORMATION OF SOFTCONNEX TECHNOLOGIES, INC.
Copyright (c) 1999 - 2004 by SoftConnex Technologies, Inc.
This software is protected by copyright laws and international copyright
treaties, as well as other intellectual property laws and treaties. This
software is a CONFIDENTIAL, unpublished work of authorship, and with portions
constituting TRADE SECRETS of SoftConnex Technologies, Inc., a Delaware USA
corporation. Any unauthorized use, disclosure, and/or reproduction of this
software, or any part of this software; or distribution of this software in any
form or by any means; or storage of this software in any database or retrieval
system, without the express written consent of, and license from, SoftConnex
Technologies, Inc. is strictly prohibited. This software is protected under the
copyright and/or trade secret laws in other countries in addition to USA. All
Rights Reserved. Failure to abide by the use, disclosure and/or reproduction
restrictions may result in civil and /or criminal penalties, and will be
prosecuted to the maximum extent of the law.
-----------------------------------------------------------------------------*/
#ifndef _TDI_PCD_H_
#define _TDI_PCD_H_
#define USB_MAX_ENDPOINT 16
#define USB_MAX_CONFIGS 6
#define USB_MAX_STRINGS 6
#define EP_NAK_SET 1
#define EP_NAK_CLEAR 2
#define EP_ERRORS_CLEAR 3
#define EP_HALT_SET 4
#define EP_HALT_CLEAR 5
#define EP_DISABLE 6
#define EP_ENABLE 7
#define PCD_CANCEL_ALL_XFERS NULL
#define USB_START_REMOTE_WAKEUP 1
#define USB_END_REMOTE_WAKEUP 2
#define USB_FORCE_FULL_SPEED 3
#define USB_SET_SELF_POWERED_MODE 4
#define USB_SET_TEST_MODE 5
#define USB_PERIPH_CONNECT 6
#define USB_PERIPH_DISCONNECT 7
/*-----------------------------------------------------------------------------
PERIPHERAL EVENT DEFINES
------------------------------------------------------------------------------*/
#define USB_SERVICE_EP0_EVENT 0x00
#define USB_SERVICE_EP1_EVENT 0x01
#define USB_SERVICE_EP2_EVENT 0x02
#define USB_SERVICE_EP3_EVENT 0x03
#define USB_SERVICE_EP4_EVENT 0x04
#define USB_SERVICE_EP5_EVENT 0x05
#define USB_SERVICE_EP6_EVENT 0x06
#define USB_SERVICE_EP7_EVENT 0x07
#define USB_SERVICE_EP8_EVENT 0x08
#define USB_SERVICE_EP9_EVENT 0x09
#define USB_SERVICE_EP10_EVENT 0x0A
#define USB_SERVICE_EP11_EVENT 0x0B
#define USB_SERVICE_EP12_EVENT 0x0C
#define USB_SERVICE_EP13_EVENT 0x0D
#define USB_SERVICE_EP14_EVENT 0x0E
#define USB_SERVICE_EP15_EVENT 0x0F
#define USB_SERVICE_SETUP_PACKET 0x10
#define USB_SERVICE_BUS_RESET_EVENT 0x11
#define USB_SERVICE_SUSPEND_EVENT 0x12
#define USB_SERVICE_SOF_EVENT 0x13
#define USB_SERVICE_RESUME_EVENT 0x14
#define USB_SERVICE_SPEED_DETECTION_EVENT 0x15
#define USB_SERVICE_VBUS_CHANGE_EVENT 0x16
#define USB_SERVICE_ENUMERATION_DONE_EVENT 0x17
#define USB_SERVICE_ERROR_EVENT 0x18
#define USB_SERVICE_STALL_EVENT 0x19
#define USB_REQUEST_DIRECTION_IN 0x80
typedef enum _UsbState
{
USB_STATE_UNKNOWN,
USB_STATE_DEFAULT,
USB_STATE_POWERED,
USB_STATE_ATTACHED,
USB_STATE_ADDRESS,
USB_STATE_CONFIGURED,
USB_STATE_SUSPENDED
}
UsbState;
typedef enum _TransferStatusType
{
TRANSFER_STATUS_UNKNOWN,
TRANSFER_STATUS_COMPLETE,
TRANSFER_STATUS_CANCELLED
}
TransferStatusType;
typedef struct _PeriphSetupRequest
{
U8 bmRequestType;
U8 bRequest;
U16 wValue;
U16 wIndex;
U16 wLength;
SctBool isSetupDone;
U8* data;
U8 buffer[8];
U16 actualLength;
}
PeriphSetupRequest;
typedef struct _PeriphSetupBuffer
{
PeriphSetupRequest request;
U16 dataPosition;
U16 bufferSize;
SctBool lastPacketHandled;
U32 stage;
}
PeriphSetupBuffer;
/* TdiPurb_STRUCT */
typedef struct _TdiPurb
{
void *data;
U32 length;
U32 lengthSoFar;
U32 dataPosition;
SctStatus status;
void (*callBackFunction) (struct _TdiPurb* urb);
struct _TdiPeriphController* pc;
struct _TdiPeriphEp* ep;
struct _TdiPurb* nextUrb;
SctBool direction;
/* This PURB will be used for entire transfer length and not
** just for this (micro)frame. In case its periodic then the
** callback function will be called only at the end of transfer
** completion (i.e. less than MPS pkt received or equal to requested
** transfer length
*/
SctBool oneShot;
}
TdiPurb;
typedef struct _TdiPeriphEp
{
/* max packet size for this endpoint */
U32 maxPktSize;
/* Any transfer threshold value to get interrupt after that
** many bytes were transferred
*/
U32 transferThreshold;
/* First PURB enqueued for this endpoint. NULL if no transfer
** request was enqueued
*/
TdiPurb* urb;
/* controller buffer area */
U32 controllerBufferSize;
/* Halted? */
SctBool halted;
/* USB address */
U8 address;
/* Endpoint number */
U8 epNumber;
/* Endpoint type - Iso, Intr, Control or Bulk */
U8 type;
/* Send or Receive */
U8 direction;
/* Data toggle */
U8 toggle;
}
TdiPeriphEp;
typedef struct _TdiPeriphController
{
U32* ioBase;
SctBool isSuspended;
SctBool remoteWakeupEnable;
SctBool selfPowered;
SctBool halted;
SctBool testModePending;
U32 speed;
TdiPeriphEp* ep[USB_MAX_ENDPOINT];
U8* currentDeviceDescriptor;
U8* currentConfigDescriptors[USB_MAX_CONFIGS];
U8* stringDescriptors[USB_MAX_STRINGS];
U8* deviceQualifierDescriptor;
U8* currentOtherSpeedConfigDescriptors[USB_MAX_CONFIGS];
PeriphSetupBuffer* setupRequest;
UsbState state;
U32 interruptEnableBitMask;
U32 controllerResourceAddress;
struct _TdiCallbackInfo* callbackLinkStart;
SctStatus (*registerEventCallback)\
(struct _TdiPeriphController* td1120, U32 eventType, void (*eventCallbackFunction)\
(struct _TdiPeriphController* td1120, U32 eventType, void* eventData));
SctBool (*isVBusOn)(struct _TdiPeriphController* td1120);
SctStatus (*resetController)(struct _TdiPeriphController* td1120);
SctStatus (*disableControllerIntr)(struct _TdiPeriphController* td1120);
SctStatus (*enableControllerIntr)(struct _TdiPeriphController* td1120);
SctStatus (*setAddress)(struct _TdiPeriphController* td1120, U32 usbAddress);
SctStatus (*initSetupPhase)(struct _TdiPeriphController* td1120, \
U32 epNum, U8* setupPacketBuffer);
SctStatus (*getSetupPacket)(struct _TdiPeriphController* td1120, \
U32 epNumber, PeriphSetupRequest*);
SctStatus (*transfer)(struct _TdiPeriphController* td1120, TdiPurb* urb);
SctStatus (*getTransferStatus)(struct _TdiPeriphController* td1120, TdiPurb* urb, \
U32* transferStatus);
SctStatus (*cancelTransfer)(struct _TdiPeriphController* td1120, TdiPurb* urb);
SctStatus (*cancelAllEpTransfers)(struct _TdiPeriphController* td1120, TdiPeriphEp* ep);
SctStatus (*setDeviceConfig)(struct _TdiPeriphController* td1120, U32 configNum);
SctStatus (*clearDeviceConfig)(struct _TdiPeriphController* td1120);
SctStatus (*configEp)(struct _TdiPeriphController* td1120, U32 epNum, \
U32 epCommand, TdiPeriphEp* ep);
SctStatus (*createEp)(struct _TdiPeriphController* td1120, \
U32 epAddr, U32 epDir, U32 epType, U32 epMps, TdiPeriphEp** ep);
SctStatus (*destroyEp)(struct _TdiPeriphController* td1120, TdiPeriphEp* ep);
SctStatus (*getEpStatus)(struct _TdiPeriphController* td1120, TdiPeriphEp* ep);
SctStatus (*getDeviceState)(struct _TdiPeriphController* td1120,
U32 *devState);
SctStatus (*setDeviceState)(struct _TdiPeriphController* td1120,
U32 devState);
SctStatus (*getFrameNumber)(struct _TdiPeriphController* td1120, U32* frameNum);
SctStatus (*controlBusParams)(struct _TdiPeriphController* td1120, \
U32 busCtrlCmd, U8 mode);
SctStatus (*getSpeed)(struct _TdiPeriphController* td1120, \
U32 *speed);
SctStatus (*registerDescriptor)(struct _TdiPeriphController* td1120,
U32 descrType, U8 *descriptor, U8 index);
}
TdiPeriphController;
/* Callback function storage structure */
typedef struct _TdiCallbackInfo {
U32 eventType;
void (*callback)(TdiPeriphController*, U32 event, void* eventData);
struct _TdiCallbackInfo* next;
}
TdiCallbackInfo;
/******************************************************************************
Public Functions
******************************************************************************/
#define PCD_RegisterEventCallback(pc, eventType, handler) \
((pc)->registerEventCallback(pc, eventType, handler))
#define PCD_IsVbusOn(pc) \
((pc)->isVBusOn(pc))
#define PCD_ResetController(pc) \
((pc)->resetController(pc))
#define PCD_DisableControllerIntr(pc) \
((pc)->disableControllerIntr(pc))
#define PCD_EnableControllerIntr(pc) \
((pc)->enableControllerIntr(pc))
#define PCD_SetAddress(pc, usbAddress) \
((pc)->setAddress(pc, usbAddress))
#define PCD_InitSetupPhase(pc, epNum, setupPacketBuffer) \
((pc)->initSetupPhase(pc, epNum, setupPacketBuffer))
#define PCD_GetSetupPacket(pc, epNum, setupRequest) \
((pc)->getSetupPacket(pc, epNum, setupRequest))
#define PCD_Transfer(pc, urb) \
((pc)->transfer(pc, urb))
#define PCD_GetTransferStatus(pc, urb, transferStatus) \
((pc)->getTransferStatus(pc, urb, transferStatus))
#define PCD_CancelTransfer(pc, urb) \
((pc)->cancelTransfer(pc, urb))
#define PCD_CancelAllTransfers(pc, ep) \
((pc)->cancelAllEpTransfers(pc, ep))
#define PCD_SetDeviceConfig(pc, configNum) \
((pc)->setDeviceConfig(pc, configNum))
#define PCD_ClearDeviceConfig(pc) \
((pc)->clearDeviceConfig(pc))
#define PCD_ConfigEp(pc, epNum, epCmd, ep) \
((pc)->configEp(pc, epNum, epCmd, ep))
#define PCD_CreateEp(pc, epAddr, epDir, epType, epMps, ep) \
((pc)->createEp(pc, epAddr, epDir, epType, epMps, ep))
#define PCD_DestroyEp(pc, ep) \
((pc)->destroyEp(pc, ep))
#define PCD_GetEpStatus(pc, ep) \
((pc)->getEpStatus(pc, ep))
#define PCD_GetDeviceState(pc, devState) \
((pc)->getDeviceState(pc, devState))
#define PCD_SetDeviceState(pc, devState) \
((pc)->setDeviceState(pc, devState))
#define PCD_GetFrameNumber(pc, frameNum) \
((pc)->getFrameNumber(pc, frameNum))
#define PCD_ControlBusParams(pc, cmd, mode) \
((pc)->controlBusParams(pc, cmd, mode))
#define PCD_GetSpeed(pc, speed) \
((pc)->getSpeed(pc, speed))
#define PCD_RegisterDescriptor(pc, descrType, descr, index) \
((pc)->registerDescriptor(pc, descrType, descr, index))
extern SctBool TD1120P_VerifyId(U32 baseAddress);
extern SctStatus TD1120P_Create(U32 baseAddress, TdiPeriphController** peripHandle);
extern SctStatus TD1120P_Destroy(TdiPeriphController* pc);
extern void TD1120P_InterruptHandler(S32 handle);
#endif /* _TDI_PCD_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -