defs.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * defs.h
  3. *
  4. * USB standard definitions and private interfaces.
  5. *
  6. * Written & released by Keir Fraser <keir.xen@gmail.com>
  7. *
  8. * This is free and unencumbered software released into the public domain.
  9. * See the file COPYING for more details, or visit <http://unlicense.org>.
  10. */
  11. /* Full Speed Max Packet Size */
  12. #define USB_FS_MPS 64
  13. /* bRequest: Standard Request Codes */
  14. #define GET_STATUS 0
  15. #define CLEAR_FEATURE 1
  16. #define SET_FEATURE 3
  17. #define SET_ADDRESS 5
  18. #define GET_DESCRIPTOR 6
  19. #define SET_DESCRIPTOR 7
  20. #define GET_CONFIGURATION 8
  21. #define SET_CONFIGURATION 9
  22. #define GET_INTERFACE 10
  23. #define SET_INTERFACE 11
  24. #define SYNCH_FRAME 12
  25. /* Descriptor Types */
  26. #define DESC_DEVICE 1
  27. #define DESC_CONFIGURATION 2
  28. #define DESC_STRING 3
  29. #define DESC_INTERFACE 4
  30. #define DESC_ENDPOINT 5
  31. #define DESC_DEVICE_QUALIFIER 6
  32. #define DESC_OTHER_SPEED_CONFIGURATION 7
  33. #define DESC_INTERFACE_POWER 8
  34. #define DESC_CS_INTERFACE 0x24
  35. #define USB_CLASS_CDC_DATA 0x0a
  36. struct __packed usb_device_request {
  37. uint8_t bmRequestType;
  38. uint8_t bRequest;
  39. uint16_t wValue;
  40. uint16_t wIndex;
  41. uint16_t wLength;
  42. };
  43. extern const uint8_t device_descriptor[];
  44. extern const uint8_t config_descriptor[];
  45. #define NR_STRING_DESC 3
  46. extern const char *string_descriptors[];
  47. extern struct ep0 {
  48. struct usb_device_request req;
  49. uint8_t data[128];
  50. int data_len;
  51. struct {
  52. const uint8_t *p;
  53. int todo;
  54. bool_t trunc;
  55. } tx;
  56. } ep0;
  57. #define ep0_data_out() (!(ep0.req.bmRequestType & 0x80))
  58. #define ep0_data_in() (!ep0_data_out())
  59. /* USB CDC ACM */
  60. bool_t cdc_acm_handle_class_request(void);
  61. bool_t cdc_acm_set_configuration(void);
  62. /* USB Core */
  63. extern uint8_t pending_addr;
  64. bool_t handle_control_request(void);
  65. /* USB Hardware */
  66. void usb_configure_ep(uint8_t ep, uint8_t type, uint32_t size);
  67. #define WARN printk
  68. /*
  69. * Local variables:
  70. * mode: C
  71. * c-file-style: "Linux"
  72. * c-basic-offset: 4
  73. * tab-width: 4
  74. * indent-tabs-mode: nil
  75. * End:
  76. */