You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

usb_private.h 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef usb_serial_h__
  2. #define usb_serial_h__
  3. #include <stdint.h>
  4. #ifdef __cplusplus
  5. extern "C"{
  6. #endif
  7. /**************************************************************************
  8. *
  9. * Configurable Options
  10. *
  11. **************************************************************************/
  12. #define VENDOR_ID 0x16C0
  13. #define PRODUCT_ID 0x0482
  14. #define TRANSMIT_FLUSH_TIMEOUT 4 /* in milliseconds */
  15. #define TRANSMIT_TIMEOUT 25 /* in milliseconds */
  16. /**************************************************************************
  17. *
  18. * Endpoint Buffer Configuration
  19. *
  20. **************************************************************************/
  21. // These buffer sizes are best for most applications, but perhaps if you
  22. // want more buffering on some endpoint at the expense of others, this
  23. // is where you can make such changes. The AT90USB162 has only 176 bytes
  24. // of DPRAM (USB buffers) and only endpoints 3 & 4 can double buffer.
  25. // 0: control 32 64
  26. // 1: debug IN 64 64x2
  27. // 2: debug OUT 32 32x2
  28. // 3: keyboard IN 8x2 8x2
  29. // 4: mouse + joystick IN (IDs) 16x2 16x2
  30. // 5: joystick 16x2
  31. // 6:
  32. #if defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
  33. // Some operating systems, especially Windows, may cache USB device
  34. // info. Changes to the device name may not update on the same
  35. // computer unless the vendor or product ID numbers change, or the
  36. // "bcdDevice" revision code is increased.
  37. #define STR_PRODUCT L"Teensy Keyboard/Mouse/Joystick"
  38. #define ENDPOINT0_SIZE 64
  39. #define DEBUG_INTERFACE 2
  40. #define DEBUG_TX_ENDPOINT 1
  41. #define DEBUG_TX_SIZE 64
  42. #define DEBUG_TX_BUFFER EP_DOUBLE_BUFFER
  43. #define DEBUG_TX_INTERVAL 1
  44. #define DEBUG_RX_ENDPOINT 2
  45. #define DEBUG_RX_SIZE 32
  46. #define DEBUG_RX_BUFFER EP_DOUBLE_BUFFER
  47. #define DEBUG_RX_INTERVAL 2
  48. #define KEYBOARD_INTERFACE 0
  49. #define KEYBOARD_ENDPOINT 3
  50. #define KEYBOARD_SIZE 8
  51. #define KEYBOARD_BUFFER EP_DOUBLE_BUFFER
  52. #define KEYBOARD_INTERVAL 1
  53. #define MOUSE_INTERFACE 1
  54. #define MOUSE_ENDPOINT 4
  55. #define MOUSE_SIZE 8
  56. #define MOUSE_BUFFER EP_DOUBLE_BUFFER
  57. #define MOUSE_INTERVAL 1
  58. #define JOYSTICK_INTERFACE 3
  59. #define JOYSTICK_ENDPOINT 5
  60. #define JOYSTICK_SIZE 16
  61. #define JOYSTICK_BUFFER EP_DOUBLE_BUFFER
  62. #define JOYSTICK_INTERVAL 2
  63. #define NUM_ENDPOINTS 7
  64. #define NUM_INTERFACE 4
  65. #elif defined(__AVR_AT90USB162__)
  66. #define STR_PRODUCT L"Teensy Keyboard/Mouse"
  67. #define ENDPOINT0_SIZE 32
  68. #define DEBUG_INTERFACE 2
  69. #define DEBUG_TX_ENDPOINT 1
  70. #define DEBUG_TX_SIZE 64
  71. #define DEBUG_TX_BUFFER EP_SINGLE_BUFFER
  72. #define DEBUG_TX_INTERVAL 2
  73. #define DEBUG_RX_ENDPOINT 2
  74. #define DEBUG_RX_SIZE 32
  75. #define DEBUG_RX_BUFFER EP_SINGLE_BUFFER
  76. #define DEBUG_RX_INTERVAL 8
  77. #define KEYBOARD_INTERFACE 0
  78. #define KEYBOARD_ENDPOINT 3
  79. #define KEYBOARD_SIZE 8
  80. #define KEYBOARD_BUFFER EP_DOUBLE_BUFFER
  81. #define KEYBOARD_INTERVAL 1
  82. #define MOUSE_INTERFACE 1
  83. #define MOUSE_ENDPOINT 4
  84. #define MOUSE_SIZE 8
  85. #define MOUSE_BUFFER EP_DOUBLE_BUFFER
  86. #define MOUSE_INTERVAL 8
  87. #define NUM_ENDPOINTS 5
  88. #define NUM_INTERFACE 3
  89. #endif
  90. // setup
  91. void usb_init(void); // initialize everything
  92. void usb_shutdown(void); // shut off USB
  93. // variables
  94. extern volatile uint8_t usb_configuration;
  95. extern volatile uint8_t usb_suspended;
  96. extern volatile uint8_t debug_flush_timer;
  97. extern uint8_t keyboard_report_data[];
  98. extern uint8_t keyboard_idle_count;
  99. extern volatile uint8_t keyboard_leds;
  100. extern uint8_t mouse_buttons;
  101. #ifdef JOYSTICK_INTERFACE
  102. extern uint8_t joystick_report_data[12];
  103. #endif
  104. #ifdef __cplusplus
  105. } // extern "C"
  106. #endif
  107. #endif