Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

usb_private.h 4.7KB

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