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

📄 hoststack.h

📁 MiniARM2200U-1160(usr)的专用工程模板
💻 H
📖 第 1 页 / 共 2 页
字号:
********************************************************************************************************/
__inline endpoint_info * find_endport_number(device_instance *dviPtr, unsigned char endport_number,
                                   	  unsigned char endport_direction)
{
    return (endpoint_info *)SwiHandle(0x117, dviPtr, endport_number, endport_direction);
}                                   	  

/*********************************************************************************************************
** Function name: Get_bInterfaceProtocol
** Descriptions: 获取接口协议代码
** Input:*dvi_ptr: 设备描述信息结构指针
** Output : 接口协议代码
** Created by:
** Created Date: 
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date: 
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline uint8 Get_bInterfaceProtocol(device_instance *dvi_ptr)
{
    return SwiHandle(0x118, dvi_ptr);
}

/*********************************************************************************************************
** Function name: Get_bInterfaceSubClass
** Descriptions: 获取接口子类代码
** Input:*dvi_ptr: 设备描述信息结构指针
** Output :接口子类代码
** Created by:
** Created Date: 
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date: 
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline uint8 Get_bInterfaceSubClass(device_instance *dvi_ptr)
{
    return SwiHandle(0x119, dvi_ptr);
}

/*********************************************************************************************************
** Function name: atl_open_transfer_instance
** Descriptions: 在传描述符数据结构列表中,查找空闲的传输描述符数据结构
** Input: epi_ptr,端点描述数据结构
** Output : 正常返回:transfer_instance指针
**				  出错返回:ATL_ENDPOINT_ERR
**					  				NO_OPEN_ATL_TRANSFER
** Created by:
** Created Date: 
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date: 
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#define		NO_OPEN_ATL_TRANSFER			(void *)0xFFFFFFFF
#define		ATL_ENDPOINT_ERR				NO_OPEN_ATL_TRANSFER
__inline transfer_instance *atl_open_transfer_instance( endpoint_info * epi_ptr)
{
    return (transfer_instance *)SwiHandle(0x11a, epi_ptr);
}


/*********************************************************************************************************
** Function name: atl_close_transfer_instance
** Descriptions: 通过atl_open_transfer_instance()申请的资源,通过该函数释放.
** Input: tr_instance_ptr,传输描述符数据结构指针
** Output : 无
** Created by:
** Created Date: 
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date: 
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline void atl_close_transfer_instance(transfer_instance *tr_instance_ptr)
{
    SwiHandle(0x11b, tr_instance_ptr);
}




/*********************************************************************************************************
** Function name: h_get_epi_from_tr
** Descriptions: 从传输描述符中获取端点描述信息
** Input:*tr_ptr: 传输描述信息结构指针
** Output :端点描述信息数据结构指针
** Created by:
** Created Date: 
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date: 
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline endpoint_info *h_get_epi_from_tr(transfer_instance *tr_ptr)
{
    return (endpoint_info *)SwiHandle(0x11c, tr_ptr);
}
/*******************************************************************************************************
** 控制传输\批量传输\中断传输 使用的宏
********************************************************************************************************/
#define		CompletionCode_NoEror               0x0
#define		CompletionCode_CRC                  0x1
#define		CompletionCode_BitStuffing          0x2
#define		CompletionCode_DataToggleMismatch   0x3
#define		CompletionCode_Stall                0x4
#define		CompletionCode_DeviceNotResponding  0x5
#define		CompletionCode_PIDCheckFailure      0x6
#define		CompletionCode_UnexpectedPID        0x7
#define		CompletionCode_DataOverrun          0x8
#define		CompletionCode_DataUnderrun         0x9
#define		CompletionCode_BufferOverrun        0xC
#define		CompletionCode_BufferUnderrun       0xD


#define		DirectionPID_OUT            1     // 传输方向,主机到设备
#define		DirectionPID_IN             2     // 传输方向,设备到主机
#define		NoDirection_Just_Hold       3     // 中断传输时使用,无数据传输

/*******************************************************************************************************
** 控制传输 使用的数据结构
********************************************************************************************************/
typedef	struct		req			{
									unsigned char	bmRequestType;
									unsigned char	bRequest;
									unsigned short	wValue;
									unsigned short	wIndex;
									unsigned short	wLength;
								} 
								USB_Device_Request;


/*********************************************************************************************************
** Function name: control_transfer
** Descriptions: 通过该函数处理控制传输。
** Input: *dev_req,设备请求数据结构指针
**		    *dvi_ptr,设备描述结构指针
**		    *data_ptr,	数据传输指针
** Output :正常返回0,出错返回:
**		     error @ SETUP	  0x-0--
**		     error @ DataStage	  0x-1--
**		     error @ StatusStage  0x-2--
**		     error @ CC		  0x--CC	(CC=value 0x01-0x0D)
**		     retry over		  0x--FF
**		     data short		  0x8000 | (0x7FFF & DataLength)
** Created by:
** Created Date: 
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date: 
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline unsigned short control_transfer(USB_Device_Request	*dev_req, 
																	device_instance *dvi_ptr, 
																	unsigned char *data_ptr)
{
    return SwiHandle(0x11d, dev_req, dvi_ptr, data_ptr);
}
/*********************************************************************************************************
** Function name: bulk_transaction
** Descriptions: 批量传输处理函数
** Input: direction,传输方向(DirectionPID_OUT,DirectionPID_IN)
**				*data_ptr,传输数据缓冲区指针
**				*size_ptr,传输数据长度变量指针
**				*hTrInstance,传输描述符数据结构指针
** Output : 正常返回0,
**          出错返回非0,如:completion_code,完成代码
** Created by:
** Created Date: 
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date: 
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline unsigned char bulk_transaction( unsigned char direction, unsigned char *data_ptr, 
																unsigned short *size_ptr, transfer_instance *hTrInstance)		
{
    return SwiHandle(0x11e, direction, data_ptr, size_ptr, hTrInstance);
}
						
/*********************************************************************************************************
** Function name: interrupt_transaction
** Descriptions: 中断传输处理函数
** Input:  direction,传输方向(DirectionPID_OUT,DirectionPID_IN)
**				 *data_ptr,传输数据缓冲区指针
**				 *size_ptr,传输数据长度变量指针
**				 *hTrInstance,传输描述符数据结构指针
** Output : 正常返回0,
**          出错返回非0,如:completion_code,完成代码
** Created by:
** Created Date: 
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date: 
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline unsigned char interrupt_transaction(unsigned char direction, unsigned char *data_ptr, 
                                      unsigned short *size_ptr, transfer_instance *hTrInstance)
{
    return SwiHandle(0x11f, direction, data_ptr, size_ptr, hTrInstance);
}

/*********************************************************************************************************
** Function name: ClearEndpointSTALL
** Descriptions: 清除端点停止状态
** Input: dvi_ptr,USB设备描述信息数据结构
**		    epi_ptr,端点描述信息数据结构
**		    FALSE,出错返回。
** Created by:
** Created Date: 
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date: 
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline unsigned char ClearEndpointSTALL(device_instance *dvi_ptr, endpoint_info *epi_ptr)
{
    return SwiHandle(0x120, dvi_ptr, epi_ptr);
}					
		
    #ifdef __cplusplus
    }
    #endif
						
#endif

/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

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