📄 dev_ep.h
字号:
#ifndef _DEV_EP_H
#define _DEV_EP_H
/****************************************************************************/
/* includes */
/****************************************************************************/
#include "..\_hc_core\chap9.h"
/****************************************************************************/
/* constants */
/****************************************************************************/
#define venderID( x ) (((x)->dev_descriptor).idVendor)
#define DEFAULT_BUFFER_SIZE 8
#define MAX_DEVICE_NUM (MAX_DEV_INF_MEMRY+2) // 定义支持最大设备数
#define MAX_ENDPOINT_NUM 16
#define ENDPOINT_BE_FREE 0x1f
#define ENDPOINT_SHARE 0x04// 端点共享标志
typedef struct epi *endpoint_info_ptr;
typedef struct epi
{
unsigned max_packet_size:10; // 端点最大封包
unsigned dev_addr:7; // 设备地址
unsigned ep_num:5; // 端点号
unsigned toggle:1; // DATA0,DATA1
unsigned speed:1; // 传输整速度:全速或低速
unsigned direction:2; // 端点方向
unsigned tr_type:1; // "Async or Iso" for PTD parameter
unsigned transfer_type:3; // Ctrl, Iso, Bulk, Intrr
std_endpoint_descriptor endpoint_descriptor; // 端点描述符
unsigned int endpoint_create_id; // 端点创建ID
struct transfr *tr_instance_ptr; // 传输描述符链表指针
}endpoint_info;
typedef struct dev
{
unsigned char address; // 设备地址
unsigned char speed; //
std_dev_descriptor dev_descriptor; // 设备描述符
std_conf_descriptor conf_descriptor; // 配置描述符
std_interface_descriptor interfacef_descriptor; // 接口描述符
endpoint_info *epi_ptr[ MAX_ENDPOINT_NUM ]; // 端点描述信息指针列表
#ifdef STRING_DESCRIPTOR
unsigned short *string_manufacturer; // 厂商描述符字符串指针
unsigned short *string_product; // 产品描述符字符串指针
unsigned short *string_serialNum; // 设备序列号字符串指针
#endif
void *class_instance_ptr; // 类实例结构指针
unsigned char topology_layer; // 拓朴层,根集线器下的设备为第1层
}device_instance;
/****************************************************************************/
/* function prototypes */
/****************************************************************************/
device_instance *create_device( unsigned char speed, unsigned char topology_layer );
void dispose_device( device_instance **dvi_ptr_ptr );
void device_list_linitialize( void );
device_instance *find_device( unsigned char address );
unsigned short std_request( unsigned char *buff_ptr, device_instance *dvi_ptr, unsigned short req, unsigned short wValue, unsigned short wIndex, unsigned short *wLength );
device_instance *find_class_interface(unsigned char InterfaceClassID, unsigned char DeviceIndex);
unsigned char check_interface_class_ID( device_instance *dviPtr, unsigned char InterfaceClassID );
unsigned char get_interface_class_ID( device_instance *dviPtr );
unsigned char get_device_class_ID( device_instance *dviPtr );
unsigned char get_interface_protocol_ID( device_instance *dviPtr ); // modification by hara
unsigned char check_interface_protocol_ID( device_instance *dviPtr, unsigned char InterfaceProtocolID ); // modification by hara
unsigned char check_interface_subclass_ID( device_instance *dviPtr, unsigned char InterfaceSubclassID ); // modification by hara
unsigned char get_interface_subclass_ID( device_instance *dviPtr ); // modification by hara
device_instance *find_pid_vid( unsigned short VID,unsigned short PID );
endpoint_info * find_endport_type(device_instance *dviPtr, unsigned char endport_type,unsigned char endport_direction,unsigned char index);
endpoint_info * find_endport_number( device_instance *dviPtr,
unsigned char endport_number,
unsigned char endport_direction);
void ini_endpoint_info(void);
void ini_device_instance(void);
endpoint_info * malloc_endpoint_info(void);
/* 新增内容 */
unsigned char ClearEndpointSTALL(device_instance *dvi_ptr, endpoint_info *epi_ptr); // 清除端点停止状态
#define Get_bInterfaceProtocol(dvi_ptr) dvi_ptr->interfacef_descriptor.bInterfaceProtocol
#define Get_bInterfaceSubClass(dvi_ptr) dvi_ptr->interfacef_descriptor.bInterfaceSubClass
#endif //_DEV_EP_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -