usbTargLib.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:9k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* usbTargLib.h - Defines interface to usbTargLib.c */
  2. /* Copyright 2000 Wind River Systems, Inc. */
  3. /*
  4. Modification history
  5. --------------------
  6. 01b,18sep01,wef  merge from wrs.tor2_0.usb1_1-f for veloce
  7. 01d,07may01,wef  changed module number to be (module sub num << 8) | 
  8.                  M_usbPeriphLib
  9. 01c,02may01,wef  changed module number to be M_<module> + M_usbPeriphLib
  10. 01b,05dec00,wef  moved Module number defs to vwModNum.h - add this
  11.                  to #includes
  12. 01a,04aug99,rcb  First.
  13. */
  14. /*
  15. DESCRIPTION
  16. Defines the interface to usbTargLib.c. usbTargLib.c implements a hardware-
  17. independent interface to USB target controller drivers.
  18. */
  19. #ifndef __INCusbTargLibh
  20. #define __INCusbTargLibh
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* includes */
  25. #include "usb/usbHandleLib.h"
  26. #include "usb/usb.h"
  27. #include "drv/usb/target/usbTcd.h"
  28. #include "vwModNum.h"           /* USB Module number def's */
  29. /* defines */
  30. #define USBT_NAME_LEN     32     /* max usbTargLib string len */
  31. /* usbTargLib error codes */
  32. /* 
  33.  * USB errnos are defined as being part of the USB peripheral Module, as are 
  34.  * all vxWorks module numbers, but the USB Module number is further divided 
  35.  * into sub-modules.  Each sub-module has upto 255 values for its own error 
  36.  * codes
  37.  */
  38.  
  39. #define USB_TARG_SUB_MODULE  1
  40. #define M_usbTargLib  ( (USB_TARG_SUB_MODULE  << 8) | M_usbPeriphLib )
  41. #define usbTargErr(x) (M_usbTargLib | (x))
  42. #define S_usbTargLib_BAD_PARAM usbTargErr(1)
  43. #define S_usbTargLib_BAD_HANDLE  usbTargErr(2)
  44. #define S_usbTargLib_OUT_OF_MEMORY usbTargErr(3)
  45. #define S_usbTargLib_OUT_OF_RESOURCES usbTargErr(4) 
  46. #define S_usbTargLib_NOT_IMPLEMENTED usbTargErr(5)
  47. #define S_usbTargLib_GENERAL_FAULT usbTargErr(6)
  48. #define S_usbTargLib_NOT_INITIALIZED usbTargErr(7)
  49. #define S_usbTargLib_CANNOT_CANCEL usbTargErr(8)
  50. #define S_usbTargLib_TCD_FAULT usbTargErr(9)
  51. #define S_usbTargLib_ENDPOINT_IN_USE usbTargErr(10)
  52. #define S_usbTargLib_APP_FAULT usbTargErr(11)
  53. /* typedefs */
  54. typedef GENERIC_HANDLE USB_TARG_CHANNEL, *pUSB_TARG_CHANNEL;
  55. typedef GENERIC_HANDLE USB_TARG_DESCR, *pUSB_TARG_DESCR;
  56. typedef GENERIC_HANDLE USB_TARG_PIPE, *pUSB_TARG_PIPE;
  57. /* USB_TARG_INFO */
  58. typedef struct usb_targ_info
  59.     {
  60.     UINT16 speed;     /* target speed: USB_SPEED_xxxx */
  61.     UINT16 numEndpoints;     /* count of endpoints to follow */
  62.     pUSB_TARG_ENDPOINT_INFO pEndpoints;     /* pointer to array of endpoints */
  63.     } USB_TARG_INFO, *pUSB_TARG_INFO;
  64. /* caller-supplied target callbacks */
  65. /* target management callback */
  66. typedef STATUS (*USB_TARG_MANAGEMENT_FUNC)
  67.     (
  68.     pVOID param,
  69.     USB_TARG_CHANNEL targChannel,
  70.     UINT16 mngmtCode     /* management code */
  71.     );
  72. /* control pipe callbacks */
  73. typedef STATUS (*USB_TARG_FEATURE_CLEAR_FUNC)
  74.     (
  75.     pVOID param,
  76.     USB_TARG_CHANNEL targChannel,
  77.     UINT8 requestType,
  78.     UINT16 feature,
  79.     UINT16 index
  80.     );
  81. typedef STATUS (*USB_TARG_FEATURE_SET_FUNC)
  82.     (
  83.     pVOID param,
  84.     USB_TARG_CHANNEL targChannel,
  85.     UINT8 requestType,
  86.     UINT16 feature,
  87.     UINT16 index
  88.     );
  89. typedef STATUS (*USB_TARG_CONFIGURATION_GET_FUNC)
  90.     (
  91.     pVOID param,
  92.     USB_TARG_CHANNEL targChannel,
  93.     pUINT8 pConfiguration
  94.     );
  95. typedef STATUS (*USB_TARG_CONFIGURATION_SET_FUNC)
  96.     (
  97.     pVOID param,
  98.     USB_TARG_CHANNEL targChannel,
  99.     UINT8 configuration
  100.     );
  101. typedef STATUS (*USB_TARG_DESCRIPTOR_GET_FUNC)
  102.     (
  103.     pVOID param,
  104.     USB_TARG_CHANNEL targChannel,
  105.     UINT8 requestType,
  106.     UINT8 descriptorType,
  107.     UINT8 descriptorIndex,
  108.     UINT16 languageId,
  109.     UINT16 length,
  110.     pUINT8 pBfr,
  111.     pUINT16 pActLen
  112.     );
  113. typedef STATUS (*USB_TARG_DESCRIPTOR_SET_FUNC)
  114.     (
  115.     pVOID param,
  116.     USB_TARG_CHANNEL targChannel,
  117.     UINT8 requestType,
  118.     UINT8 descriptorType,
  119.     UINT8 descriptorIndex,
  120.     UINT16 languageId,
  121.     UINT16 length
  122.     );
  123. typedef STATUS (*USB_TARG_INTERFACE_GET_FUNC)
  124.     (
  125.     pVOID param,
  126.     USB_TARG_CHANNEL targChannel,
  127.     UINT16 interfaceIndex,
  128.     pUINT8 pAlternateSetting
  129.     );
  130. typedef STATUS (*USB_TARG_INTERFACE_SET_FUNC)
  131.     (
  132.     pVOID param,
  133.     USB_TARG_CHANNEL targChannel,
  134.     UINT16 interfaceIndex,
  135.     UINT8 alternateSetting
  136.     );
  137. typedef STATUS (*USB_TARG_STATUS_GET_FUNC)
  138.     (
  139.     pVOID param,
  140.     USB_TARG_CHANNEL targChannel,
  141.     UINT16 requestType,
  142.     UINT16 index,
  143.     UINT16 length,
  144.     pUINT8 pBfr,
  145.     pUINT16 pActLen
  146.     );
  147. typedef STATUS (*USB_TARG_ADDRESS_SET_FUNC)
  148.     (
  149.     pVOID param,
  150.     USB_TARG_CHANNEL targChannel,
  151.     UINT16 deviceAddress
  152.     );
  153. typedef STATUS (*USB_TARG_SYNCH_FRAME_GET_FUNC)
  154.     (
  155.     pVOID param,
  156.     USB_TARG_CHANNEL targChannel,
  157.     UINT16 endpoint,
  158.     pUINT16 pFrameNo
  159.     );
  160. typedef STATUS (*USB_TARG_VENDOR_SPECIFIC_FUNC)
  161.     (
  162.     pVOID param,
  163.     USB_TARG_CHANNEL targChannel,
  164.     UINT8 requestType,
  165.     UINT8 request,
  166.     UINT16 value,
  167.     UINT16 index,
  168.     UINT16 length
  169.     );
  170. typedef struct usb_targ_callback_table
  171.     {
  172.     /* device management callbacks */
  173.     USB_TARG_MANAGEMENT_FUNC mngmtFunc;
  174.     /* Control pipe callbacks */
  175.     USB_TARG_FEATURE_CLEAR_FUNC featureClear;
  176.     USB_TARG_FEATURE_SET_FUNC featureSet;
  177.     USB_TARG_CONFIGURATION_GET_FUNC configurationGet;
  178.     USB_TARG_CONFIGURATION_SET_FUNC configurationSet;
  179.     USB_TARG_DESCRIPTOR_GET_FUNC descriptorGet;
  180.     USB_TARG_DESCRIPTOR_SET_FUNC descriptorSet;
  181.     USB_TARG_INTERFACE_GET_FUNC interfaceGet;
  182.     USB_TARG_INTERFACE_SET_FUNC interfaceSet;
  183.     USB_TARG_STATUS_GET_FUNC statusGet;
  184.     USB_TARG_ADDRESS_SET_FUNC addressSet;
  185.     USB_TARG_SYNCH_FRAME_GET_FUNC synchFrameGet;
  186.     USB_TARG_VENDOR_SPECIFIC_FUNC vendorSpecific;
  187.     } USB_TARG_CALLBACK_TABLE, *pUSB_TARG_CALLBACK_TABLE;
  188. /* function prototypes */
  189. STATUS usbTargVersionGet
  190.     (
  191.     pUINT16 pVersion, /* usbTargLib version */
  192.     pCHAR pMfg /* usbTargLib manufacturer */
  193.     );
  194. STATUS usbTargInitialize (void);
  195. STATUS usbTargShutdown (void);
  196. STATUS usbTargTcdAttach
  197.     (
  198.     USB_TCD_EXEC_FUNC tcdExecFunc, /* TCD entry point */
  199.     pVOID tcdParam, /* TCD parameter */
  200.     pUSB_TARG_CALLBACK_TABLE pCallbacks,/* caller-supplied callbacks */
  201.     pVOID callbackParam, /* caller-defined callback param */
  202.     pUSB_TARG_CHANNEL pTargChannel, /* handle to target on return */
  203.     pUINT16 pNumEndpoints, /* bfr to receive nbr of endpoints */
  204.     pUSB_TARG_ENDPOINT_INFO *ppEndpoints/* bfr to rcv ptr to endpt array */
  205.     );
  206. STATUS usbTargTcdDetach
  207.     (
  208.     USB_TARG_CHANNEL targChannel /* target to detach */
  209.     );
  210. STATUS usbTargEndpointInfoGet
  211.     (
  212.     USB_TARG_CHANNEL targChannel, /* target channel */
  213.     pUINT16 pNumEndpoints, /* receives nbr of endpoints */
  214.     pUSB_TARG_ENDPOINT_INFO *ppEndpoints/* receives ptr to array */
  215.     );
  216. STATUS usbTargEnable
  217.     (
  218.     USB_TARG_CHANNEL targChannel /* target to enable */
  219.     );
  220. STATUS usbTargDisable
  221.     (
  222.     USB_TARG_CHANNEL targChannel /* target to disable */
  223.     );
  224. STATUS usbTargPipeCreate
  225.     (
  226.     USB_TARG_CHANNEL targChannel, /* target channel */
  227.     UINT16 endpointId, /* endpoint ID to use for pipe */
  228.     UINT16 endpointId2,  /* needed for control pipes only */
  229.     UINT16 endpointNum,  /* endpoint number to assign */
  230.     UINT16 configuration, /* associated configuration */
  231.     UINT16 interface, /* associated interface */
  232.     UINT16 transferType, /* USB_XFRTYPE_xxxx */
  233.     UINT16 direction, /* USB_DIR_xxxx */
  234.     pUSB_TARG_PIPE pPipeHandle /* returned pipe handle */
  235.     );
  236. STATUS usbTargPipeDestroy
  237.     (
  238.     USB_TARG_PIPE pipeHandle /* pipe to be destroyed */
  239.     );
  240. STATUS usbTargTransfer
  241.     (
  242.     USB_TARG_PIPE pipeHandle, /* pipe for transfer */
  243.     pUSB_ERP pErp /* ERP describing transfer */
  244.     );
  245. STATUS usbTargTransferAbort
  246.     (
  247.     USB_TARG_PIPE pipeHandle, /* pipe for transfer to abort */
  248.     pUSB_ERP pErp /* ERP to be aborted */
  249.     );
  250. STATUS usbTargControlResponseSend
  251.     (
  252.     USB_TARG_CHANNEL targChannel, /* target channel */
  253.     UINT16 bfrLen, /* length of response, or 0 */
  254.     pUINT8 pBfr  /* ptr to bfr or NULL */
  255.     );
  256. STATUS usbTargControlPayloadRcv
  257.     (
  258.     USB_TARG_CHANNEL targChannel, /* target channel */
  259.     pUSB_ERP pErp /* ERP to receive control OUT data */
  260.     );
  261. STATUS usbTargPipeStatusSet
  262.     (
  263.     USB_TARG_CHANNEL targChannel, /* target channel */
  264.     USB_TARG_PIPE pipeHandle, /* pipe handle or NULL for ctrl pipe */
  265.     UINT16 state /* USBT_PIPE_STALLED/UNSTALLED */
  266.     );
  267. STATUS usbTargCurrentFrameGet
  268.     (
  269.     USB_TARG_CHANNEL targChannel, /* target channel */
  270.     pUINT16 pFrameNo /* current frame number */
  271.     );
  272. STATUS usbTargSignalResume
  273.     (
  274.     USB_TARG_CHANNEL targChannel /* target channel */
  275.     );
  276. #ifdef __cplusplus
  277. }
  278. #endif
  279. #endif /* __INCusbTargLibh */
  280. /* End of file. */