📄 hoststack.h
字号:
** Input:*dvi_ptr: 设备描述信息结构指针
** Output : 接口协议代码
********************************************************************************************************/
extern uint8 Get_bInterfaceProtocol(device_instance *dvi_ptr);
/*********************************************************************************************************
** Function name: Get_bInterfaceSubClass
** Descriptions: 获取接口子类代码
** Input:*dvi_ptr: 设备描述信息结构指针
** Output :接口子类代码
********************************************************************************************************/
extern uint8 Get_bInterfaceSubClass(device_instance *dvi_ptr);
/*********************************************************************************************************
** Function name: atl_open_transfer_instance
** Descriptions: 在传描述符数据结构列表中,查找空闲的传输描述符数据结构
** Input: epi_ptr,端点描述数据结构
** Output : 正常返回:transfer_instance指针
** 出错返回:ATL_ENDPOINT_ERR
** NO_OPEN_ATL_TRANSFER
********************************************************************************************************/
#define NO_OPEN_ATL_TRANSFER (void *)0xFFFFFFFF
#define ATL_ENDPOINT_ERR NO_OPEN_ATL_TRANSFER
extern transfer_instance *atl_open_transfer_instance( endpoint_info * epi_ptr);
/*********************************************************************************************************
** Function name: atl_close_transfer_instance
** Descriptions: 通过atl_open_transfer_instance()申请的资源,通过该函数释放.
** Input: tr_instance_ptr,传输描述符数据结构指针
** Output : 无
********************************************************************************************************/
extern void atl_close_transfer_instance(transfer_instance *tr_instance_ptr);
/*********************************************************************************************************
** Function name: h_get_epi_from_tr
** Descriptions: 从传输描述符中获取端点描述信息
** Input:*tr_ptr: 传输描述信息结构指针
** Output :端点描述信息数据结构指针
********************************************************************************************************/
extern endpoint_info *h_get_epi_from_tr(transfer_instance *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)
********************************************************************************************************/
extern unsigned short control_transfer(USB_Device_Request *dev_req,
device_instance *dvi_ptr,
unsigned char *data_ptr);
/*********************************************************************************************************
** Function name: bulk_transaction
** Descriptions: 批量传输处理函数
** Input: direction,传输方向(DirectionPID_OUT,DirectionPID_IN)
** *data_ptr,传输数据缓冲区指针
** *size_ptr,传输数据长度变量指针
** *hTrInstance,传输描述符数据结构指针
** Output : 正常返回0,
** 出错返回非0,如:completion_code,完成代码
********************************************************************************************************/
extern unsigned char bulk_transaction( unsigned char direction, unsigned char *data_ptr,
unsigned short *size_ptr, transfer_instance *hTrInstance);
/*********************************************************************************************************
** Function name: interrupt_transaction
** Descriptions: 中断传输处理函数
** Input: direction,传输方向(DirectionPID_OUT,DirectionPID_IN)
** *data_ptr,传输数据缓冲区指针
** *size_ptr,传输数据长度变量指针
** *hTrInstance,传输描述符数据结构指针
** Output : 正常返回0,
** 出错返回非0,如:completion_code,完成代码
********************************************************************************************************/
extern unsigned char interrupt_transaction(unsigned char direction, unsigned char *data_ptr,
unsigned short *size_ptr, transfer_instance *hTrInstance);
/*********************************************************************************************************
** Function name: ClearEndpointSTALL
** Descriptions: 清除端点停止状态
** Input: dvi_ptr: USB设备描述信息数据结构
** epi_ptr: 端点描述信息数据结构
** Output : TRUE: 正常返回
** FALSE: 出错返回。
********************************************************************************************************/
extern unsigned char ClearEndpointSTALL(device_instance *dvi_ptr, endpoint_info *epi_ptr);
/*********************************************************************************************************
** Function name: MassDriverIni
** Descriptions: 大容量类初始化
** Input: none
** Output : none
********************************************************************************************************/
extern void MassDriverIni(void);
/*********************************************************************************************************
** Function name: USB_Host_init
** Descriptions: USB主机初始化
** Input: none
** Output : none
********************************************************************************************************/
extern void USB_Host_init(void);
#ifdef __cplusplus
}
#endif
#endif
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -