⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usbh_hcd.h

📁 epson usb2.0 控制芯片 S1R72V05 固件程序。
💻 H
字号:
/*
 *	description: USBH HCD APIs Definition(global)
 *	Maker	   : Hiromichi Kondo
 *	Copyright  : (C)2005,SEIKO EPSON Corp. All Rights Reserved.
 */


#ifndef USBH_HCD_H
#define USBH_HCD_H

#ifdef __cplusplus
	extern "C" {
#endif /* cplusplus */


/*****************************************
 * Define Definition
 *****************************************/

/* API return value */
#define USBH_HCD_STATUS_SUCCESS					(0L)
#define USBH_HCD_STATUS_NO_DEVICE				(1L)
#define USBH_HCD_STATUS_UNSUCCESSFUL			(-1L)
#define USBH_HCD_STATUS_INVALID_PARAMETER		(-2L)
#define USBH_HCD_STATUS_MEM_ERROR				(-3L)
#define USBH_HCD_STATUS_PIPE_ERROR				(-4L)

/* Message notified to other module */
#define USBH_HCD_MSG_INIT_CMP					(1)
#define USBH_HCD_MSG_SUSPEND_CMP				(2)
#define USBH_HCD_MSG_RESUME_CMP					(3)
#define USBH_HCD_MSG_DETECT_DEV_CONNECT			(4)

/* USBH_HCD_SubmitURB() */
#define USBH_HCD_PIPE_ISOCHRONOUS				(0)
#define USBH_HCD_PIPE_INTERRUPT					(1)
#define USBH_HCD_PIPE_CONTROL					(2)
#define USBH_HCD_PIPE_BULK						(3)
#define USBH_HCD_DIR_IN							(0x80)
#define USBH_HCD_DIR_OUT						(0x00)
#define USBH_HCD_URB_SHORT_NOT_OK				(0x0001)
#define USBH_HCD_URB_ASYNC_UNLINK				(0x0010)
#define USBH_HCD_URB_ZERO_PACKET				(0x0040)
#define USBH_HCD_URB_REQ_DMA					(0x8000)
#define USBH_HCD_URB_STRG_MODE					(0x4000)
#define USBH_HCD_URB_DIRECT_COPY				(0x2000)
#define USBH_HCD_URBSTS_SUCCESS					(0)			/* URB terminated normally */
#define USBH_HCD_URBSTS_OVERFLOW				(1)			/* Overflow */
#define USBH_HCD_URBSTS_REMOTEIO				(2)			/* When the transfer flag is specified as USB_SHORT_NOT_OK */
															/* Receive data that is shorter than the transfer buffer length */
#define USBH_HCD_URBSTS_PIPE					(3)			/* Error on pipe(STALL, Complete-split miss) */
#define USBH_HCD_URBSTS_INPROGRESS				(4)			/* URB is in progress */
#define USBH_HCD_URBSTS_PROTO					(5)			/* Protocol error(CRC error and time-out, etc.) */
#define USBH_HCD_URBSTS_CONNRESET				(6)			/* URB was canceled by USBH_HCD_SubmitURB() */
#define USBH_HCD_URBSTS_NOENT					(7)			/* URB was canceled by USBH_HCD_UnlinkURB() */

/*****************************************
 * Callback Function Definition
 *****************************************/
typedef void ( *USBH_HCD_CALLBACK )( unsigned long message, unsigned long param1, void *pParam );

/*****************************************
 * Enumeration Type Definition
 *****************************************/
typedef enum tagUSBH_HCD_ENUMDEVSTATE{
	USBH_HCD_USB_STATE_NOTATTACHED,			/* Disconnection */
	USBH_HCD_USB_STATE_POWERED,				/* Power ON */
	USBH_HCD_USB_STATE_DEFAULT,				/* After reset USB */
	USBH_HCD_USB_STATE_ADDRESSED,			/* After requesting Set Address */
	USBH_HCD_USB_STATE_CONFIGURED,			/* After requesting Set Configuration (except 0) */
	USBH_HCD_USB_STATE_SUSPENDED			/* USB is suspended */
}USBH_HCD_ENUMDEVSTATE;

typedef enum tagUSBH_HCD_ENUMDEVSPEED{
	USBH_HCD_USB_SPEED_UNKNOWN,				/* Disconnection */
	USBH_HCD_USB_SPEED_LOW,					/* Low-Speed */
	USBH_HCD_USB_SPEED_FULL,				/* Full-Speed */
	USBH_HCD_USB_SPEED_HIGH					/* High-Speed */
}USBH_HCD_ENUMDEVSPEED;

typedef enum tagUSBH_HCD_ENUMSUSPENDLV{
	USBH_HCD_SUSPEND_LV0,					/* Oscillator and PLL all operated */
	USBH_HCD_SUSPEND_LV1,					/* Stop PLL only */
	USBH_HCD_SUSPEND_LV2					/* Stop all oscillator and PLL */
}USBH_HCD_ENUMSUSPENDLV;



/*****************************************
 * Struct Definition
 *****************************************/
typedef struct tagUSBH_HCD_USBDEV{
	void *pHCPriv;							/* (out)Private area for Host Controller */
											/* The memory area for the USB device management is allocated here */
	void *pConfigDesc;						/* Pointer of Configuration Descriptor */
	USBH_HCD_ENUMDEVSTATE eState;			/* (in)USB device state(Addressed and Configured, etc.) */
	USBH_HCD_ENUMDEVSPEED eSpeed;			/* (in)USB device transfering speed(LS,FS,HS) */
	struct tagUSBH_HCD_USBDEV *psParent;	/* (in)If the USB device is not route HUB, it is a pointer to the USB device */
											/* Information structure of HUB that becomes parents */
	unsigned short toggle[2];				/* (io)State of toggle of Endpoint. Which bit position becomes Endpoint number as it */
											/* (toggle[0]:IN, toggle[1]:OUT) */
	unsigned short epMaxPacketIn[16];		/* (in)MaxPacketSize of Endpoint in direction of IN */
	unsigned short epMaxPacketOut[16];		/* (in)MaxPacketSize of Endpoint in direction of OUT */
	unsigned char devNum;					/* USB device address */
	unsigned char port;						/* (in)Port number of connected parents */
}USBH_HCD_USBDEV;


typedef struct tagUSBH_HCD_LIST_HEAD{
	struct tagUSBH_HCD_LIST_HEAD *psNext;	/* Pointer to the next list */
	struct tagUSBH_HCD_LIST_HEAD *psPrev;	/* Pointer to the previous list */
}USBH_HCD_LIST_HEAD;

typedef struct tagUSBH_HCD_URB{
	USBH_HCD_LIST_HEAD	sList;				/* (out)Header for list structure */
	void *pHCPriv;							/* (out)Private area for Host Controller */
	struct tagUSBH_HCD_URB *psNext;			/* Pointer to the next URB structure */
	USBH_HCD_USBDEV *psDev;	 				/* (in)Pointer to USB device information structure */
	unsigned long pipe;						/* PIPE_ISOCHRONOUS */
											/* PIPE_INTERRUPT */
											/* PIPE_CONTROL */
											/* PIPE_BULK */
											/* bit29-24:Reserved */
											/*	 DIR_IN */
											/*	 DIR_OUT */

											/* (in)Pipe information
												Bit31-30: Transfer type
												PIPE_ISOCHRONOUS
												PIPE_INTERRUPT
												PIPE_CONTROL
												PIPE_BULK
											   bit29-24:Reserved
											   bit23-16:EP address(Direction+EP number)
											   bit15-8:USB device address
											   bit7-0: Direction
												 DIR_IN
												 DIR_OUT */
	unsigned short status;					/* URBSTS_SUCCESS */
											/* URBSTS_OVERFLOW */
											/* URBSTS_REMOTEIO */
											/* URBSTS_PIPE */
											/* URBSTS_INPROGRESS */
											/* URBSTS_PROTO */
											/* (out)Status of URB
											   URBSTS_SUCCESS
											 	URB is terminate normally
											   URBSTS_OVERFLOW
											   	Overflow
											   URBSTS_REMOTEIO
												When the transfer flag is specified as USB_SHORT_NOT_OK,
												receive data that is shorter than the transfer buffer length.
											   URBSTS_PIPE
												Pipe Error(CRC error and time-out, etc)
											   URBSTS_INPROGRESS
												Is executing
											   URBSTS_PROTO
												Protocol error(STALL and Complete-split mistake)  */
	unsigned short transFlag;				/* URB_SHORT_NOT_OK */
											/* URB_ISO_ASAP */
											/* URB_ASYNC_UNLINK */
											/* URB_ZERO_PACKET */
											/* URB_REQ_DMA */
											/* URB_STRG_MODE */
											/* URB_DIRECT_COPY */
											/* Transfer flag
											   URB_SHORT_NOT_OK
												  Short packet reception is judged to be an error
											   URB_ISO_ASAP
												 Start frame is specified by Isochronous transfer
											   URB_ASYNC_UNLINK
												 Cancel the URB asynchronously
											   URB_ZERO_PACKET
												 The end of transfer of OUT direction is always a short packet
												 (Also includes the Zero-length packet)
											   URB_REQ_DMA
												 The DMA transfer is demanded
											   URB_STRG_MODE
												 Support function for Bulk Only Transport of Mass Storage Class
											   URB_DIRECT_COPY
												 Direct copy function of USB <-> IDE */
	unsigned char *pSetupPacket;			/* (in)Pointer of SETUP packet data used in Control transfer */
	void *pTransBuf;						/* (in)Pointer of transfer buffer */
	unsigned long transBufLength;			/* (in)The Bytes length of transfer buffer */
	unsigned long actualLength;				/* (out)The transferred Bytes length */
	unsigned short errorCount;				/* Number of packet errors. It is set only with ISO */
	unsigned short interval;				/* (in)Time of interval. It is effective in case of the periodic transfer (Isochronous and Interrupt) */
	unsigned short startFrame;				/* (io)Set the Frame Number that was begun to transfer */
											/* Transfer flag is specified as URB_ISO_ASAP in Isochronous transfer */
											/* Set the beginning Frame Number for Transfer */
	void (*pfnComplete)(struct tagUSBH_HCD_URB *urb);
											/* (In) Pointer of callback function which is called after URB is completed */
}USBH_HCD_URB;



/*****************************************
 * Function Prototype Declaration
 *****************************************/
extern long USBH_HCD_Init( USBH_HCD_CALLBACK pfnCallback );
extern long USBH_HCD_Cleanup( void );
extern long USBH_HCD_AllocDev( USBH_HCD_USBDEV *psUsbDev );
extern long USBH_HCD_FreeDev( USBH_HCD_USBDEV *psUsbDev );
extern long USBH_HCD_GetFrameNum( unsigned short *pFrameNum );
extern long USBH_HCD_SubmitURB( USBH_HCD_URB *psUrb );
extern long USBH_HCD_UnlinkURB( USBH_HCD_URB *psUrb );
extern long USBH_HCD_EndpointDisable( USBH_HCD_USBDEV *psDev, unsigned char epAddress );
extern long USBH_HCD_Suspend( USBH_HCD_ENUMSUSPENDLV suspendLevel, USBH_HCD_CALLBACK pfnCallback );
extern long USBH_HCD_Resume( USBH_HCD_CALLBACK pfnCallback );
extern long USBH_HCD_DetectDevConnect( USBH_HCD_CALLBACK pfnCallback );
extern long USBH_HCD_GetDevVBUSStatus( unsigned char *pVBUSStatus );
extern long USBH_HCD_Interrupt( void );



#ifdef __cplusplus
	}
#endif /* cplusplus */

#endif /* USBH_HCD_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -