Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

usb_private.h 4.9KB

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. // You can change these to give your code its own name. On Windows,
  13. // these are only used before an INF file (driver install) is loaded.
  14. #define STR_MANUFACTURER L"Teensyduino"
  15. #define STR_PRODUCT L"Serial+Keyboard+Mouse+Joystick"
  16. #define STR_SERIAL L"Serial"
  17. // Some operating systems, especially Windows, may cache USB device
  18. // info. Changes to the device name may not update on the same
  19. // computer unless the vendor or product ID numbers change, or the
  20. // "bcdDevice" revision code is increased.
  21. // All USB serial devices are supposed to have a serial number
  22. // (according to Microsoft). On windows, a new COM port is created
  23. // for every unique serial/vendor/product number combination. If
  24. // you program 2 identical boards with 2 different serial numbers
  25. // and they are assigned COM7 and COM8, each will always get the
  26. // same COM port number because Windows remembers serial numbers.
  27. //
  28. // On Mac OS-X, a device file is created automatically which
  29. // incorperates the serial number, eg, /dev/cu-usbmodem12341
  30. //
  31. // Linux by default ignores the serial number, and creates device
  32. // files named /dev/ttyACM0, /dev/ttyACM1... in the order connected.
  33. // Udev rules (in /etc/udev/rules.d) can define persistent device
  34. // names linked to this serial number, as well as permissions, owner
  35. // and group settings.
  36. #define STR_SERIAL_NUMBER L"12345"
  37. // Mac OS-X and Linux automatically load the correct drivers. On
  38. // Windows, even though the driver is supplied by Microsoft, an
  39. // INF file is needed to load the driver. These numbers need to
  40. // match the INF file.
  41. #define VENDOR_ID 0x16C0
  42. #define PRODUCT_ID 0x0487
  43. // When you write data, it goes into a USB endpoint buffer, which
  44. // is transmitted to the PC when it becomes full, or after a timeout
  45. // with no more writes. Even if you write in exactly packet-size
  46. // increments, this timeout is used to send a "zero length packet"
  47. // that tells the PC no more data is expected and it should pass
  48. // any buffered data to the application that may be waiting. If
  49. // you want data sent immediately, call usb_serial_flush_output().
  50. #define TRANSMIT_FLUSH_TIMEOUT 3 /* in milliseconds */
  51. // If the PC is connected but not "listening", this is the length
  52. // of time before usb_serial_getchar() returns with an error. This
  53. // is roughly equivilant to a real UART simply transmitting the
  54. // bits on a wire where nobody is listening, except you get an error
  55. // code which you can ignore for serial-like discard of data, or
  56. // use to know your data wasn't sent.
  57. #define TRANSMIT_TIMEOUT 15 /* in milliseconds */
  58. /**************************************************************************
  59. *
  60. * Endpoint Buffer Configuration
  61. *
  62. **************************************************************************/
  63. #define ENDPOINT0_SIZE 64
  64. #define KEYBOARD_INTERFACE 2
  65. #define KEYBOARD_ENDPOINT 1
  66. #define KEYBOARD_SIZE 8
  67. #define KEYBOARD_BUFFER EP_DOUBLE_BUFFER
  68. #define KEYBOARD_INTERVAL 1
  69. #define CDC_ACM_ENDPOINT 2
  70. #define CDC_ACM_SIZE 16
  71. #define CDC_ACM_BUFFER EP_SINGLE_BUFFER
  72. #define CDC_RX_ENDPOINT 3
  73. #define CDC_RX_SIZE 64
  74. #define CDC_RX_BUFFER EP_DOUBLE_BUFFER
  75. #define CDC_TX_ENDPOINT 4
  76. #define CDC_TX_BUFFER EP_DOUBLE_BUFFER
  77. #define CDC_TX_SIZE 64
  78. #define MOUSE_INTERFACE 3
  79. #define MOUSE_ENDPOINT 5
  80. #define MOUSE_SIZE 8
  81. #define MOUSE_BUFFER EP_DOUBLE_BUFFER
  82. #define MOUSE_INTERVAL 2
  83. #define JOYSTICK_INTERFACE 4
  84. #define JOYSTICK_ENDPOINT 6
  85. #define JOYSTICK_SIZE 16
  86. #define JOYSTICK_BUFFER EP_DOUBLE_BUFFER
  87. #define JOYSTICK_INTERVAL 1
  88. // setup
  89. void usb_init(void); // initialize everything
  90. void usb_shutdown(void); // shut off USB
  91. // zero when we are not configured, non-zero when enumerated
  92. extern volatile uint8_t usb_configuration;
  93. extern volatile uint8_t usb_suspended;
  94. // the time remaining before we transmit any partially full
  95. // packet, or send a zero length packet.
  96. extern volatile uint8_t transmit_flush_timer;
  97. extern uint8_t transmit_previous_timeout;
  98. // serial port settings (baud rate, control signals, etc) set
  99. // by the PC. These are ignored, but kept in RAM because the
  100. // CDC spec requires a read that returns the current settings.
  101. extern volatile uint8_t cdc_line_coding[7];
  102. extern volatile uint8_t cdc_line_rtsdtr;
  103. extern uint8_t keyboard_report_data[];
  104. extern uint8_t keyboard_idle_count;
  105. extern volatile uint8_t keyboard_leds;
  106. extern uint8_t mouse_buttons;
  107. extern uint8_t joystick_report_data[12];
  108. #ifdef __cplusplus
  109. } // extern "C"
  110. #endif
  111. #endif