Keyboard firmwares for Atmel AVR and Cortex-M
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

USBDevice_Types.h 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Copyright (c) 2010-2011 mbed.org, MIT License
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
  4. * and associated documentation files (the "Software"), to deal in the Software without
  5. * restriction, including without limitation the rights to use, copy, modify, merge, publish,
  6. * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
  7. * Software is furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in all copies or
  10. * substantial portions of the Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
  13. * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  14. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  15. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. */
  18. #ifndef USBDEVICE_TYPES_H
  19. #define USBDEVICE_TYPES_H
  20. /* Standard requests */
  21. #define GET_STATUS (0)
  22. #define CLEAR_FEATURE (1)
  23. #define SET_FEATURE (3)
  24. #define SET_ADDRESS (5)
  25. #define GET_DESCRIPTOR (6)
  26. #define SET_DESCRIPTOR (7)
  27. #define GET_CONFIGURATION (8)
  28. #define SET_CONFIGURATION (9)
  29. #define GET_INTERFACE (10)
  30. #define SET_INTERFACE (11)
  31. /* bmRequestType.dataTransferDirection */
  32. #define HOST_TO_DEVICE (0)
  33. #define DEVICE_TO_HOST (1)
  34. /* bmRequestType.Type*/
  35. #define STANDARD_TYPE (0)
  36. #define CLASS_TYPE (1)
  37. #define VENDOR_TYPE (2)
  38. #define RESERVED_TYPE (3)
  39. /* bmRequestType.Recipient */
  40. #define DEVICE_RECIPIENT (0)
  41. #define INTERFACE_RECIPIENT (1)
  42. #define ENDPOINT_RECIPIENT (2)
  43. #define OTHER_RECIPIENT (3)
  44. /* Descriptors */
  45. #define DESCRIPTOR_TYPE(wValue) (wValue >> 8)
  46. #define DESCRIPTOR_INDEX(wValue) (wValue & 0xff)
  47. typedef struct {
  48. struct {
  49. uint8_t dataTransferDirection;
  50. uint8_t Type;
  51. uint8_t Recipient;
  52. } bmRequestType;
  53. uint8_t bRequest;
  54. uint16_t wValue;
  55. uint16_t wIndex;
  56. uint16_t wLength;
  57. } SETUP_PACKET;
  58. typedef struct {
  59. SETUP_PACKET setup;
  60. uint8_t *ptr;
  61. uint32_t remaining;
  62. uint8_t direction;
  63. bool zlp;
  64. bool notify;
  65. } CONTROL_TRANSFER;
  66. typedef enum {ATTACHED, POWERED, DEFAULT, ADDRESS, CONFIGURED} DEVICE_STATE;
  67. typedef struct {
  68. volatile DEVICE_STATE state;
  69. uint8_t configuration;
  70. bool suspended;
  71. } USB_DEVICE;
  72. #endif