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

📄 hoststack.h

📁 基于周立功m2020-NU201+ASD1.2编写; 通过网络访问插入板中的U盘上指定文件
💻 H
📖 第 1 页 / 共 2 页
字号:
/****************************************Copyright (c)**************************************************
**                               Guangzou ZLG-MCU Development Co.,LTD.
**                                     graduate school
**                                 http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File Name: HostStack.h
** Last modified Date: 2005-12-15
** Last Version: V1.0 
** Description: 
**
**------------------------------------------------------------------------------------------------------
** Created By: Lishan Zhou
** Created date: 2005-12-15
** Version: V1.0 
** Description:
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Description:
**
********************************************************************************************************/
#ifndef __HOST_STACK_H 
#define __HOST_STACK_H

    #ifdef __cplusplus
    extern "C" {
    #endif


#define find_mass_device(x) find_class_interface(0x08, x)   // 查找大容量设备


#define hMedLUN                 void
#define device_instance         void        // 设备描述信息结构指针
#define endpoint_info           void        // 端点描述信息结构指针
#define transfer_instance       void        // 传输描述符描述信息结构指针


typedef struct _MassDriver{
	uint8 	DeID;
	uint8 	LunID;
 	hMedLUN *MediumPtr;
}MassDriver;


/*********************************************************************************************************
** 注册类驱动使用的宏
*********************************************************************************************************/
#define         HUB_CLASS_DEVICE                        0x09

#define         AUDIO_CLASS_INTERFACE                   0x01
#define         HID_CLASS_INTERFACE                     0x03
#define         PRINTER_CLASS_INTERFACE                 0x07
#define         MASSSTRAGE_CLASS_INTERFACE              0x08
#define         HUB_CLASS_INTERFACE                     0x09

/*********************************************************************************************************
** Function name: class_driver_registration
** Descriptions: 注册类设备驱动
** Input:ClassCode,类代码
**       init_commands,安装设备类驱动调用的函数
**       dispose_process,卸载设备类驱动调用的函数
** Output : 正常完成返回0,出错返回非0
********************************************************************************************************/
extern int class_driver_registration(unsigned char ClassCode,
                               unsigned short (*init_commands)( device_instance *dvi_ptr ),
                               unsigned short (*dispose_process)( device_instance *dvi_ptr ));


/*********************************************************************************************************
** Function name: find_device
** Descriptions: 根据设备地址查找设备.
** Input: address,设备地址,地址范围2~127。
** Output: device_instance,设备信息指针
********************************************************************************************************/
extern device_instance *find_device(unsigned char address);


/*********************************************************************************************************
** Function name: find_class_interface
** Descriptions: 查找设备接口类
** Input: InterfaceClassID,查找接口类ID
**          DeviceIndex,同类设备索引号
** Output: device_instance,设备信息指针
********************************************************************************************************/

extern device_instance    *find_class_interface(unsigned char InterfaceClassID, unsigned char DeviceIndex);


/*********************************************************************************************************
** Function name: find_pid_vid
** Descriptions: 根据设备的产家ID号和产品ID号找查设备.
** Input: VID,产家ID号
**        PID,产品ID号
** Output: device_instance,设备信息指针
********************************************************************************************************/
extern device_instance *find_pid_vid(unsigned short VID, unsigned short PID);

/*********************************************************************************************************
** Function name: h_set_class_instance
** Descriptions: 编写设备类驱动时,可能需要使用一些私有数据,通过该函数将私有数据指针,写入到设备描述信息
**               数据结构.
** Input:*dvi_ptr , 设备描述信息数据结构指针
**       *class_instance_ptr, 类设备描述信息数据结构指针(类驱动的私有数据)
** Output : 无
********************************************************************************************************/
extern void h_set_class_instance(device_instance *dvi_ptr, void *class_instance_ptr);

/*********************************************************************************************************
** Function name: h_get_class_instance
** Descriptions: 从设备描述信息数据结构中获取类驱动的私有数据
** Input:*dvi_ptr , 设备描述信息数据结构指针
** Output : 类设备描述信息结构指针
********************************************************************************************************/
extern void *h_get_class_instance(device_instance *dvi_ptr);

/********************************************************************************************************
** 查找设备指定端点使用的宏
********************************************************************************************************/                               
// 端点类型
#define     Ep_TransferType_Control           0x0           // 控制传输端点
#define     Ep_TransferType_Isochronous       0x1           // 同步传输端点
#define     Ep_TransferType_Bulk              0x2           // 批量传输端点
#define     Ep_TransferType_Interrupt         0x3           // 中断传输端点
// 端点方向
#define     Ep_Direction_OUT_ENDPOINT         0             // 主机到设备
#define     Ep_Direction_IN_ENDPOINT          1             // 设备到主机
#define     Ep_Direction_CONTROL_ENDPOINT     2             // 仅为查找控制传输端点使用

/*********************************************************************************************************
** Function name: find_endport_type
** Descriptions: 从指定的设备中查找特定的端点类型.
** Input:dviPtr,设备信息指针
**         endport_type,端点类型
**           endport_direction,端点的方向,输入(1)或输出(0)
**           index,端点序号,如果设备有多个同类型的端点,可以通过序号选择。
** Output : 返回端点指针,空指针查找失败
********************************************************************************************************/
extern endpoint_info  * find_endport_type(device_instance *dviPtr, unsigned char endport_type,
                                          unsigned char endport_direction,unsigned char index);

/*********************************************************************************************************
** Function name: find_endport_number
** Descriptions: 从指定的设备中查找特定的端点,根据端点口与端点传输方向
** Input: dviPtr,设备信息指针
**        endport_number,端点号
**        endport_direction,端点的方向,输入(1)或输出(0)
** Output : 返回端点指针,空指针查找失败
********************************************************************************************************/
extern endpoint_info * find_endport_number(device_instance *dviPtr, unsigned char endport_number,
                                      unsigned char endport_direction);

/*********************************************************************************************************
** Function name: Get_bInterfaceProtocol
** Descriptions: 获取接口协议代码

⌨️ 快捷键说明

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