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

📄 hub.h

📁 usb host在ARM7上的实现
💻 H
字号:
#ifndef _HUB_H
#define _HUB_H

/****************************************************************************/
/*	includes																*/
/****************************************************************************/

#include	"..\_hc_core\dev_ep.h"
#include	"..\_hc_core\transfer.h"


/****************************************************************************/
/*	constants																*/
/****************************************************************************/

/*	Class-specific Requests	*/
//	See USB2.0 specification 11.24.2 Table 11-15 p.420

#define		hub_cls_sp_request_ClearHubFeature			((0x20 << 8) | CLEAR_FEATURE  )
#define		hub_cls_sp_request_ClearPortFeature		((0x23 << 8) | CLEAR_FEATURE  )
//#define	hub_cls_sp_request_GetBusState				((0xA3 << 8) | GET_STATUS     )
#define		hub_cls_sp_request_GetHubDescripter		((0xA0 << 8) | GET_DESCRIPTOR )
#define		hub_cls_sp_request_GetHubStatus			((0xA0 << 8) | GET_STATUS     )
#define		hub_cls_sp_request_GetPortStatus			((0xA3 << 8) | GET_STATUS     )
//#define	hub_cls_sp_request_SetHubDescriptor			((0x20 << 8) | SET_DESCRIPTOR )
#define		hub_cls_sp_request_SetHubFeature			((0x20 << 8) | SET_FEATURE    )
#define		hub_cls_sp_request_SetPortFeature			((0x23 << 8) | SET_FEATURE    )

//	Hub Class Feature Selectors
//	See USB2.0 specification 11.24.2 Table 11-17 p.421
#define		C_HUB_LOCAL_POWER			0	//	Hub
#define		C_HUB_OVER_CURRENT			1	//	Hub
#define		PORT_CONNECTION				0	//	Port
#define		PORT_ENABLE					1	//	Port
#define		PORT_SUSPEND				2	//	Port
#define		PORT_OVER_CURRENT			3	//	Port
#define		PORT_RESET					4	//	Port
#define		PORT_POWER					8	//	Port
#define		PORT_LOW_SPEED				9	//	Port
#define		C_PORT_CONNECTION			16	//	Port
#define		C_PORT_ENABLE				17	//	Port
#define		C_PORT_SUSPEND				18	//	Port
#define		C_PORT_OVER_CURRENT			19	//	Port
#define		C_PORT_RESET				20	//	Port


#define		datalength_of_HUB_DESCRIPTOR	9

#define		MAX_NUM_OF_PORTS				7


/****************************************************************************/
/*	macros																	*/
/****************************************************************************/

#define		device_class_code( x )			(((x)->dev_descriptor).bDeviceClass)									//	"x" will be a device instance pointer


#define		hub_instance_ptr( x )			((hub_instance *)((x)->class_instance_ptr))								//	"x" will be a device instance pointer
#define		hub_descriptor_ptr( x )			(&(( (hub_instance *)((x)->class_instance_ptr) )->hub_descriptor))		//	"x" will be a device instance pointer
#define		number_of_port_in_hub( x )		((hub_descriptor_params *)( hub_descriptor_ptr( x ) ))->bNbrPorts		//	"x" will be a device instance pointer


/****************************************************************************/
/*	types																	*/
/****************************************************************************/

//
//	Hub descriptor defined in USB standard
//
typedef struct  hub_d_param    {	//	Hub Descriptor
									//	See USB2.0 specification 11.23.2.1 Table 11-13 p.417
	unsigned char   	bLength;
	unsigned char   	bDescriptorType;
	unsigned char		bNbrPorts;
	unsigned short  	wHubCharacteristics;
	unsigned char   	bPwrOn2PwrGood;
	unsigned char   	bHubContrCurrent;
	unsigned char   	DeviceRemovable;	//	This field may have variable length
	unsigned char   	PortPwrCtrlMask;	//	This field may have variable length
}hub_descriptor_params;


//
//	Hub parameters for each hub instances.
//
typedef struct  hub_param		{
	device_instance	*device_ptr;				// 集线器设备描述信息结构指针
	unsigned char		hub_descriptor[ datalength_of_HUB_DESCRIPTOR ];// 集线器描述符
	unsigned char		number_of_ports;
	device_instance	*device_on_port[ MAX_NUM_OF_PORTS ];		//	集线器端口设备描述信息结构
	transfer_instance	*tr_instance_ptr;
	unsigned char		ep1_data;				//	Hub and Port Statua Change Bitmap
	unsigned char		polling_rate;				//	Interrupt EP polling rate
}hub_instance;


//
//	Hub event flag to show a hub waiting maintain. Only one instnce will be made.
//
typedef struct	hub_event_flag_st{
	unsigned char		hub_address;
	unsigned char		port_status_change_bit_map;
	unsigned char		topology_layer;
}hub_event_flag;
											

/****************************************************************************/
/*	global vars																*/
/****************************************************************************/

extern hub_event_flag	g_hub_device_event;


/****************************************************************************/
/*	function prototypes														*/
/****************************************************************************/

unsigned short		hub_init_commands( device_instance *dvi_ptr );
void				hub_event_flag_handler( void );
unsigned long		read_hub_device_port_status( device_instance *dvi_ptr, unsigned char port );
unsigned short		hub_dispose_process( device_instance *dvi_ptr );

void				dispose_hub_class_instance( device_instance *dvi_ptr );

void				reset_hub_device_port( device_instance *dvi_ptr, unsigned char port );
void				clear_hub_device_port( device_instance *dvi_ptr, unsigned char port );
void				clear_status_change_bits_in_hub( device_instance *dvi_ptr, unsigned char port, unsigned short pos );

#endif //_HUB_H

⌨️ 快捷键说明

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