usbd_desc.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef __USBD_DESC__C__
  2. #define __USBD_DESC__C__
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include "usbd_conf.h"
  7. #include "usbd_def.h"
  8. /** Descriptor for the Usb device. */
  9. extern USBD_DescriptorsTypeDef USBD_COMMON_Desc;
  10. #if USBD_GETDESCRIPTORS_ALTMETHOD == 1
  11. extern const uint8_t * USBD_COMMON_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
  12. extern const uint8_t * USBD_COMMON_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
  13. extern const uint8_t * USBD_COMMON_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
  14. extern const uint8_t * USBD_COMMON_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
  15. extern const uint8_t * USBD_COMMON_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
  16. extern const uint8_t * USBD_COMMON_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
  17. extern const uint8_t * USBD_COMMON_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
  18. extern const uint8_t * USBD_COMMON_GetCfgDesc (USBD_SpeedTypeDef speed, uint16_t *length);
  19. extern const uint8_t * USBD_COMMON_GetMsOsStringDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
  20. extern const uint8_t * USBD_COMMON_GetExtCompatIdOsFeatureDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
  21. extern const uint8_t * USBD_COMMON_GetExtPropertiesOsFeatureDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
  22. // @USBD_GETDESCRIPTOR_DEFAULT_HANDLERS_SET
  23. // Allows to inherit the the handlers in the class-specific handlers set:
  24. // You should declare your own @USBD_DescriptorsTypeDef variable, and
  25. // the initialize the contents with your functions by filed names, but
  26. // insert this marco in the top:
  27. // const USBD_DescriptorsTypeDef CustomDescriptorHandlers = {
  28. // USBD_GETDESCRIPTOR_DEFAULT_HANDLERS_SET,
  29. // .GetDeviceDescriptor = MyCustomGetDeviceDescriptor
  30. // .GetInterfaceStrDescriptor = MyCustomGetInterfaceStrDescriptor,
  31. // };
  32. // In the example above only @GetDeviceDescriptor and @GetInterfaceStrDescriptor
  33. // are implemeted in the class and overrided in the structure, all others
  34. // handlers are initialized by the default handler-functions.
  35. //
  36. // INTERNATIONAL STANDARD ISO/IEC 9899, Programming languages — C, Second edition 1999-12-01
  37. // 6.7.8 Initialization, section 19:
  38. // The initialization shall occur in initializer list order, each initializer provided for a
  39. // particular subobject overriding any previously listed initializer for the same subobject; all
  40. // subobjects that are not initialized explicitly shall be initialized implicitly the same as
  41. // objects that have static storage duration.
  42. #define USBD_GETDESCRIPTOR_DEFAULT_HANDLERS_SET \
  43. .GetDeviceDescriptor = USBD_COMMON_DeviceDescriptor\
  44. , .GetLangIDStrDescriptor = USBD_COMMON_LangIDStrDescriptor\
  45. , .GetManufacturerStrDescriptor = USBD_COMMON_ManufacturerStrDescriptor\
  46. , .GetProductStrDescriptor = USBD_COMMON_ProductStrDescriptor\
  47. , .GetSerialStrDescriptor = USBD_COMMON_SerialStrDescriptor\
  48. , .GetConfigurationStrDescriptor = USBD_COMMON_ConfigStrDescriptor\
  49. , .GetInterfaceStrDescriptor = USBD_COMMON_InterfaceStrDescriptor\
  50. , .GetConfigDescriptor = USBD_COMMON_GetCfgDesc\
  51. , .GetMsOsStringDescriptor = USBD_COMMON_GetMsOsStringDescriptor\
  52. , .GetExtCompatIdOsFeatureDescriptor = USBD_COMMON_GetExtCompatIdOsFeatureDescriptor\
  53. USBD_GETUSERSTR_INITIALIZER
  54. #if USBD_SUPPORT_USER_STRING
  55. #define USBD_GETUSERSTR_INITIALIZER ,.GetUsrStrDescriptor = NULL
  56. #else
  57. #define USBD_GETUSERSTR_INITIALIZER
  58. #endif
  59. #endif // USBD_GETDESCRIPTORS_ALTMETHOD
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif /* __USBD_DESC__C__ */