usbd_std.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*!
  2. \file usbd_std.h
  3. \brief USB 2.0 standard defines
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-02-10, V1.0.0, firmware for GD32F30x
  8. */
  9. #ifndef USBD_STD_H
  10. #define USBD_STD_H
  11. #include "usb_std.h"
  12. #include "usbd_core.h"
  13. #include "usbd_conf.h"
  14. #include <wchar.h>
  15. #define USBD_LANGID_STR_IDX 0x00U /*!< USB language ID string index*/
  16. #define USBD_MFC_STR_IDX 0x01U /*!< USB manufacturer string index*/
  17. #define USBD_PRODUCT_STR_IDX 0x02U /*!< USB product string index*/
  18. #define USBD_SERIAL_STR_IDX 0x03U /*!< USB serial string index*/
  19. #define USBD_CONFIG_STR_IDX 0x04U /*!< USB configuration string index*/
  20. #define USBD_INTERFACE_STR_IDX 0x05U /*!< USB interface string index*/
  21. #define USB_STATUS_REMOTE_WAKEUP 0x02U /*!< USB remote wakeup status*/
  22. #define USB_STATUS_SELF_POWERED 0x01U /*!< USB self power status*/
  23. #define USB_FEATURE_ENDP_HALT 0x00U /*!< USB halt endpoint feature*/
  24. #define USB_FEATURE_REMOTE_WAKEUP 0x01U /*!< USB remote wakeup feature*/
  25. #define USB_FEATURE_TEST_MODE 0x02U /*!< USB test mode feature*/
  26. #define ENG_LANGID 0x0409U /*!< USB english language id*/
  27. #define CHN_LANGID 0x0804U /*!< USB chinese language id*/
  28. #define USB_DEVICE_DESC_SIZE 0x12U /*!< USB device descriptor size*/
  29. #define LOWBYTE(x) ((uint8_t)((x) & 0x00FFU)) /*!< USB lowbyte operation marco*/
  30. #define HIGHBYTE(x) ((uint8_t)(((x) & 0xFF00U) >> 8U)) /*!< USB highbyte operation marco*/
  31. #define USB_MIN(a, b) (((a) < (b)) ? (a) : (b)) /*!< USB minimum operation marco*/
  32. #define WIDE_STRING(string) _WIDE_STRING(string)
  33. #define _WIDE_STRING(string) L##string
  34. #define USBD_STRING_DESC(string) \
  35. (uint8_t *)&(struct { \
  36. uint8_t _len; \
  37. uint8_t _type; \
  38. wchar_t _data[sizeof(string)]; \
  39. }) { \
  40. sizeof(WIDE_STRING(string)) + 2U - 2U, \
  41. USB_DESCTYPE_STRING, \
  42. WIDE_STRING(string) \
  43. }
  44. #define IS_NOT_EP0(ep_addr) (((ep_addr) != 0x00U) && ((ep_addr) != 0x80U))
  45. /* function declarations */
  46. /* USB device setup transaction*/
  47. usbd_status_enum usbd_setup_transaction (usb_core_handle_struct *pudev);
  48. /* USB device out transaction*/
  49. usbd_status_enum usbd_out_transaction (usb_core_handle_struct *pudev, uint8_t endp_num);
  50. /* USB device in transaction*/
  51. usbd_status_enum usbd_in_transaction (usb_core_handle_struct *pudev, uint8_t endp_num);
  52. /* USB device enum error handle*/
  53. void usbd_enum_error (usb_core_handle_struct *pudev, usb_device_req_struct *req);
  54. #endif /* USBD_STD_H */