USB_Structs_H.#1
上传用户:gxz1972
上传日期:2019-09-13
资源大小:323k
文件大小:4k
源码类别:

传真(Fax)编程

开发平台:

C/C++

  1. //-----------------------------------------------------------------------------
  2. // USB_Structs.h
  3. //-----------------------------------------------------------------------------
  4. //-----------------------------------------------------------------------------
  5. // Copyright 2007 Vson Technology, Inc.
  6. // http://www.usbmcu.com
  7. //
  8. // Program Description:
  9. //
  10. //
  11. //
  12. //
  13. //
  14. // MCU:            C8051F347
  15. // Tool chain:     Keil C51 7.50 / Keil EVAL C51
  16. //                 Silicon Laboratories IDE version 2.6
  17. // Command Line:   
  18. // Project Name:   TR1000
  19. //
  20. //
  21. // Release 1.0
  22. //    -All changes by Brian Cai
  23. //    -24 JUL 2007
  24. //
  25. //
  26. #include "USB_Config_H.h"
  27. #include "USB_Descriptors_H.h"
  28. #ifndef  _USB_STRUCTS_H_
  29. #define  _USB_STRUCTS_H_
  30. //-----------------------------------------------------------------------------
  31. // Global Constants
  32. //-----------------------------------------------------------------------------
  33. /*
  34. #ifndef _BYTE_DEF_
  35. #define _BYTE_DEF_
  36. typedef unsigned char BYTE;
  37. #endif   /* _BYTE_DEF_ */
  38. /*
  39. #ifndef _UINT_DEF_
  40. #define _UINT_DEF_
  41. typedef unsigned int UINT;
  42. #endif   /*_UINT_DEF_*/
  43. #ifndef _WORD_DEF_
  44. #define _WORD_DEF_
  45. typedef union {unsigned int i; unsigned char c[2];} WORD;
  46. #endif   /* _WORD_DEF_ */
  47. typedef struct IF_STATUS {
  48.    BYTE bNumAlts;             // Number of alternate choices for this
  49.                               // interface
  50.    BYTE bCurrentAlt;          // Current alternate setting for this interface
  51.                               // zero means this interface does not exist
  52.                               // or the device is not configured
  53.    BYTE bIfNumber;            // Interface number for this interface
  54.                               // descriptor
  55.    } IF_STATUS;
  56. typedef IF_STATUS * PIF_STATUS;
  57. // Configuration status - only valid in configured state
  58. // This data structure assumes a maximum of 2 interfaces for any given
  59. // configuration, and a maximum of 4 interface descriptors (including
  60. // all alternate settings).
  61. typedef struct DEVICE_STATUS {
  62.    BYTE bCurrentConfig;       // Index number for the selected config
  63.    BYTE bDevState;            // Current device state
  64.    BYTE bRemoteWakeupSupport; // Does this device support remote wakeup?
  65.    BYTE bRemoteWakeupStatus;  // Device remote wakeup enabled/disabled
  66.    BYTE bSelfPoweredStatus;   // Device self- or bus-powered
  67.    BYTE bNumInterf;           // Number of interfaces for this configuration
  68.    BYTE bTotalInterfDsc;      // Total number of interface descriptors for
  69.                               // this configuration (includes alt.
  70.                               // descriptors)
  71.    BYTE* pConfig;             // Points to selected configuration desc
  72.    IF_STATUS IfStatus[MAX_IF];// Array of interface status structures
  73.    } DEVICE_STATUS;
  74. typedef DEVICE_STATUS * PDEVICE_STATUS;
  75. // Control endpoint command (from host)
  76. typedef struct EP0_COMMAND {
  77.    BYTE  bmRequestType;       // Request type
  78.    BYTE  bRequest;            // Specific request
  79.    WORD  wValue;              // Misc field
  80.    WORD  wIndex;              // Misc index
  81.    WORD  wLength;             // Length of the data segment for this request
  82.   } EP0_COMMAND;
  83. // Endpoint status (used for IN, OUT, and Endpoint0)
  84. typedef struct EP_STATUS {
  85.    BYTE  bEp;                 // Endpoint number (address)
  86.    UINT  uNumBytes;           // Number of bytes available to transmit
  87.    UINT  uMaxP;               // Maximum packet size
  88.    BYTE  bEpState;            // Endpoint state
  89.    void *pData;               // Pointer to data to transmit
  90.    WORD  wData;               // Storage for small data packets
  91.    } EP_STATUS;
  92. typedef EP_STATUS * PEP_STATUS;
  93. // Descriptor structure
  94. // This structure contains all usb descriptors for the device.
  95. // The descriptors are held in array format, and are accessed with the offsets
  96. // defined in the header file "usb_desc.h". The constants used in the
  97. // array declarations are also defined in header file "usb_desc.h".
  98. typedef struct DESCRIPTORS {
  99.    BYTE bStdDevDsc[STD_DSC_SIZE];
  100.    BYTE bCfg1[CFG_DSC_SIZE + IF_DSC_SIZE*CFG1_IF_DSC + EP_DSC_SIZE*CFG1_EP_DSC];
  101. } DESCRIPTORS;
  102. #endif   // USB_STRUCTS_H
  103. //-----------------------------------------------------------------------------
  104. // End Of File
  105. //-----------------------------------------------------------------------------