?? hoststack.h
字號:
/****************************************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) // 查找大容量設(shè)備
__swi(0xaa) unsigned int SwiHandle(int, ...);
#define hMedLUN void
#define device_instance void // 設(shè)備描述信息結(jié)構(gòu)指針
#define endpoint_info void // 端點描述信息結(jié)構(gòu)指針
#define transfer_instance void // 傳輸描述符描述信息結(jié)構(gòu)指針
/*********************************************************************************************************
** Function name: USB_Host_Serve
** Descriptions: USB主機服務(wù)任務(wù),應(yīng)用程序中創(chuàng)建一個任務(wù)調(diào)用該函數(shù)。
** Input: 無
** Output : 無
** Created by:
** Created Date:
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline void USB_Host_Serve(void)
{
SwiHandle(0x10f);
}
/*********************************************************************************************************
** 注冊類驅(qū)動使用的宏
*********************************************************************************************************/
#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: 注冊類設(shè)備驅(qū)動
** Input:ClassCode,類代碼
** init_commands,安裝設(shè)備類驅(qū)動調(diào)用的函數(shù)
** dispose_process,卸載設(shè)備類驅(qū)動調(diào)用的函數(shù)
** Output : 正常完成返回0,出錯返回非0
** Created by:
** Created Date:
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline int class_driver_registration(unsigned char ClassCode,
unsigned short (*init_commands)( device_instance *dvi_ptr ),
unsigned short (*dispose_process)( device_instance *dvi_ptr ))
{
return SwiHandle(0x110, ClassCode, init_commands, dispose_process);
}
/*********************************************************************************************************
** Function name: find_device
** Descriptions: 根據(jù)設(shè)備地址查找設(shè)備.
** Input: address,設(shè)備地址,地址范圍2~127。
** Output: device_instance,設(shè)備信息指針
** Created by:
** Created Date:
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline device_instance *find_device(unsigned char address)
{
return (device_instance *)SwiHandle(0x111, address);
}
/*********************************************************************************************************
** Function name: find_class_interface
** Descriptions: 查找設(shè)備接口類
** Input: InterfaceClassID,查找接口類ID
** DeviceIndex,同類設(shè)備索引號
** Output: device_instance,設(shè)備信息指針
** Created by:
** Created Date:
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline device_instance *find_class_interface(unsigned char InterfaceClassID, unsigned char DeviceIndex)
{
return (device_instance *)SwiHandle(0x112, InterfaceClassID, DeviceIndex);
}
/*********************************************************************************************************
** Function name: find_pid_vid
** Descriptions: 根據(jù)設(shè)備的產(chǎn)家ID號和產(chǎn)品ID號找查設(shè)備.
** Input: VID,產(chǎn)家ID號
** PID,產(chǎn)品ID號
** Output: device_instance,設(shè)備信息指針
** Created by:
** Created Date:
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline device_instance *find_pid_vid(unsigned short VID, unsigned short PID)
{
return (device_instance *)SwiHandle(0x113, VID, PID);
}
/*********************************************************************************************************
** Function name: h_set_class_instance
** Descriptions: 編寫設(shè)備類驅(qū)動時,可能需要使用一些私有數(shù)據(jù),通過該函數(shù)將私有數(shù)據(jù)指針,寫入到設(shè)備描述信息
** 數(shù)據(jù)結(jié)構(gòu).
** Input:*dvi_ptr , 設(shè)備描述信息數(shù)據(jù)結(jié)構(gòu)指針
** *class_instance_ptr, 類設(shè)備描述信息數(shù)據(jù)結(jié)構(gòu)指針(類驅(qū)動的私有數(shù)據(jù))
** Output : 無
** Created by:
** Created Date:
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline void h_set_class_instance(device_instance *dvi_ptr, void *class_instance_ptr)
{
SwiHandle(0x114, dvi_ptr, class_instance_ptr);
}
/*********************************************************************************************************
** Function name: h_get_class_instance
** Descriptions: 從設(shè)備描述信息數(shù)據(jù)結(jié)構(gòu)中獲取類驅(qū)動的私有數(shù)據(jù)
** Input:*dvi_ptr , 設(shè)備描述信息數(shù)據(jù)結(jié)構(gòu)指針
** Output : 類設(shè)備描述信息結(jié)構(gòu)指針
** Created by:
** Created Date:
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline void *h_get_class_instance(device_instance *dvi_ptr)
{
return (void *)SwiHandle(0x115, dvi_ptr);
}
/********************************************************************************************************
** 查找設(shè)備指定端點使用的宏
********************************************************************************************************/
// 端點類型
#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 // 主機到設(shè)備
#define Ep_Direction_IN_ENDPOINT 1 // 設(shè)備到主機
#define Ep_Direction_CONTROL_ENDPOINT 2 // 僅為查找控制傳輸端點使用
/*********************************************************************************************************
** Function name: find_endport_type
** Descriptions: 從指定的設(shè)備中查找特定的端點類型.
** Input:dviPtr,設(shè)備信息指針
** endport_type,端點類型
** endport_direction,端點的方向,輸入(1)或輸出(0)
** index,端點序號,如果設(shè)備有多個同類型的端點,可以通過序號選擇。
** Output : 返回端點指針,空指針查找失敗
** Created by:
** Created Date:
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__inline endpoint_info * find_endport_type(device_instance *dviPtr, unsigned char endport_type,
unsigned char endport_direction,unsigned char index)
{
return (endpoint_info *)SwiHandle(0x116, dviPtr, endport_type, endport_direction, index);
}
/*********************************************************************************************************
** Function name: find_endport_number
** Descriptions: 從指定的設(shè)備中查找特定的端點,根據(jù)端點口與端點傳輸方向
** Input: dviPtr,設(shè)備信息指針
** endport_number,端點號
** endport_direction,端點的方向,輸入(1)或輸出(0)
** Output : 返回端點指針,空指針查找失敗
** Created by:
** Created Date:
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -