usb_config.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef USB_CONFIG_H_
  2. #define USB_CONFIG_H_
  3. /*
  4. * Tiny USB stack
  5. *
  6. * Static stack configuration
  7. */
  8. #include "debug.h"
  9. /* Compile minimal USB stack for bootloader code */
  10. #ifdef BOOTLOADER
  11. # define USB_MINI 1
  12. #else
  13. # define USB_MINI 0
  14. #endif
  15. /* Enable(1)/disable(0) USB debug messages */
  16. #define USB_MESSAGES 1
  17. #if !USB_MINI && USB_MESSAGES
  18. /* Print an integer (8bit or 16bit) together with a message string literal. */
  19. # define usb_print1num(description_string, number) debug_printf(description_string " %X\n", (number))
  20. /* Print two integers (8bit or 16bit) together with message string literals. */
  21. # define usb_print2num(d1, n1, d2, n2) debug_printf(d1 " %X " d2 " %X \n", (n1), (n2))
  22. /* Print a string */
  23. # define usb_printstr(string_literal) debug_printf(string_literal "\n")
  24. /* Dump a memory region */
  25. # define usb_dumpmem(memory, size) debug_dumpmem((memory), (size))
  26. /* Assertion */
  27. # define USB_BUG_ON(cond) BUG_ON(cond)
  28. #else
  29. # define usb_print1num(description_string, number) do { } while (0)
  30. # define usb_print2num(d1, n1, d2, n2) do { } while (0)
  31. # define usb_printstr(string_literal) do { } while (0)
  32. # define usb_dumpmem(memory, size) do { } while (0)
  33. # define USB_BUG_ON(cond) do { if (cond) { } } while (0)
  34. #endif
  35. /* Maximum software packet buffer size for the endpoints. */
  36. #define USBCFG_EP0_MAXSIZE 64
  37. #define USBCFG_EP1_MAXSIZE 64
  38. #define USBCFG_EP2_MAXSIZE 64
  39. /* Power control
  40. * Set to 1, if the device is selfpowered.
  41. * Set to 0, if the device is buspowered. */
  42. #define USBCFG_SELFPOWERED 0
  43. /* Architecture endianness.
  44. * Set to 1 for BigEndian.
  45. * Set to 0 for LittleEndian. */
  46. #define USBCFG_ARCH_BE 0
  47. /* Architecture program memory annotations and access */
  48. #define USB_PROGMEM PROGMEM
  49. #define usb_pgm_read(addr) pgm_read(addr)
  50. #define usb_copy_from_pgm(t, s, l) memcpy_P(t, s, l)
  51. /* Endpoint configuration */
  52. #if USB_MINI
  53. # define USB_WITH_EP1 0
  54. # define USB_WITH_EP2 1
  55. #else
  56. # define USB_WITH_EP1 1
  57. # define USB_WITH_EP2 1
  58. #endif
  59. /* Application layer configuration */
  60. #if USB_MINI
  61. # define USB_APP_HAVE_RESET 0
  62. # define USB_APP_HAVE_HIGHPOWER 0
  63. # define USB_APP_HAVE_CTLSETUPRX 0
  64. # define USB_APP_HAVE_EP1RX 0
  65. # define USB_APP_HAVE_EP1TXPOLL 0
  66. # define USB_APP_HAVE_EP2RX 1
  67. # define USB_APP_HAVE_EP2TXPOLL 0
  68. #else
  69. # define USB_APP_HAVE_RESET 1
  70. # define USB_APP_HAVE_HIGHPOWER 1
  71. # define USB_APP_HAVE_CTLSETUPRX 1
  72. # define USB_APP_HAVE_EP1RX 1
  73. # define USB_APP_HAVE_EP1TXPOLL 1
  74. # define USB_APP_HAVE_EP2RX 1
  75. # define USB_APP_HAVE_EP2TXPOLL 1
  76. #endif
  77. #endif /* USB_CONFIG_H_ */