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

📄 hub.h

📁 使用ISP1362芯片的USB_OTG参考设计源代码比较新的版本
💻 H
字号:
/*
**  WASABI-Hot! version 1.2c    (Hub sub-unit)
**
**
**      -- copyright (c) 2001-2004 by Philips Japan, Ltd. -- All rights reserved --
**
**
**      ** This code has been made to check/learn                          ** 
**      **                             the ISP1362/ISP1363 functionalities **
**      ** Release 06-Aug-2004                                             **
**
**      OKANO, Akifumi
**      
**		Application Laboratory, Mobile and Connectivity
**      Semiconductors Div, Philips Japan Ltd.
**      akifumi.okano@philips.com
**      +81-3-3740-4668 
*/

#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;				//	points itself
									unsigned char				hub_descriptor[ datalength_of_HUB_DESCRIPTOR ];
									unsigned char				number_of_ports;
									device_instance				*portctl_device_on_port[ MAX_NUM_OF_PORTS ];		//	points devices at downstream ports
									unsigned char				tr_index;
									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			gp_hub_event;


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

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

void				hub_reset_hub_device_port( device_instance *dvi_ptr, unsigned char port );
void				hub_clear_hub_device_port( device_instance *dvi_ptr, unsigned char port );
void				hub_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 + -