Keyboard firmwares for Atmel AVR and Cortex-M
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.

config_vusb.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef CONFIG_H
  2. #define CONFIG_H
  3. #define VENDOR_ID 0xFEED
  4. #define PRODUCT_ID 0xC0FE
  5. // TODO: share these strings with usbconfig.h
  6. // Edit usbconfig.h to change these.
  7. #define MANUFACTURER t.m.k.
  8. #define PRODUCT HHKB mod
  9. #define DESCRIPTION t.m.k. keyboard firmware for HHKB mod
  10. /* matrix size */
  11. #define MATRIX_ROWS 8
  12. #define MATRIX_COLS 8
  13. /* key combination for command */
  14. #define IS_COMMAND() ( \
  15. keyboard_report->mods == (BIT_LSHIFT | BIT_RSHIFT) || \
  16. keyboard_report->mods == (BIT_LCTRL | BIT_RSHIFT) \
  17. )
  18. /* mouse keys */
  19. #ifdef MOUSEKEY_ENABLE
  20. # define MOUSEKEY_DELAY_TIME 255
  21. #endif
  22. /* PS/2 lines */
  23. #ifdef PS2_MOUSE_ENABLE
  24. #define PS2_CLOCK_PORT PORTD
  25. #define PS2_CLOCK_PIN PIND
  26. #define PS2_CLOCK_DDR DDRD
  27. #define PS2_CLOCK_BIT 4
  28. #define PS2_DATA_PORT PORTD
  29. #define PS2_DATA_PIN PIND
  30. #define PS2_DATA_DDR DDRD
  31. #define PS2_DATA_BIT 0
  32. // Synchronous USART is used to receive data from keyboard.
  33. // Use RXD pin for PS/2 DATA line and XCK for PS/2 CLOCK.
  34. // NOTE: This is recomended strongly if you use V-USB library.
  35. #define PS2_USE_USART
  36. // External or Pin Change Interrupt is used to receive data from keyboard.
  37. // Use INT1 or PCINTxx for PS/2 CLOCK line. see below.
  38. //#define PS2_USE_INT
  39. #ifdef PS2_USE_USART
  40. // synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge
  41. // set DDR of CLOCK as input to be slave
  42. #define PS2_USART_INIT() do { \
  43. PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
  44. PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
  45. UCSR0C = ((1 << UMSEL00) | \
  46. (3 << UPM00) | \
  47. (0 << USBS0) | \
  48. (3 << UCSZ00) | \
  49. (0 << UCPOL0)); \
  50. UCSR0A = 0; \
  51. UBRR0H = 0; \
  52. UBRR0L = 0; \
  53. } while (0)
  54. #define PS2_USART_RX_INT_ON() do { \
  55. UCSR0B = ((1 << RXCIE0) | \
  56. (1 << RXEN0)); \
  57. } while (0)
  58. #define PS2_USART_RX_POLL_ON() do { \
  59. UCSR0B = (1 << RXEN0); \
  60. } while (0)
  61. #define PS2_USART_OFF() do { \
  62. UCSR0C = 0; \
  63. UCSR0B &= ~((1 << RXEN0) | \
  64. (1 << TXEN0)); \
  65. } while (0)
  66. #define PS2_USART_RX_READY (UCSR0A & (1<<RXC0))
  67. #define PS2_USART_RX_DATA UDR0
  68. #define PS2_USART_ERROR (UCSR0A & ((1<<FE0) | (1<<DOR0) | (1<<UPE0)))
  69. #define PS2_USART_RX_VECT USART_RX_vect
  70. #endif
  71. #ifdef PS2_USE_INT
  72. /* INT1
  73. #define PS2_INT_INIT() do { \
  74. EICRA |= ((1<<ISC11) | \
  75. (0<<ISC10)); \
  76. } while (0)
  77. #define PS2_INT_ON() do { \
  78. EIMSK |= (1<<INT1); \
  79. } while (0)
  80. #define PS2_INT_OFF() do { \
  81. EIMSK &= ~(1<<INT1); \
  82. } while (0)
  83. #define PS2_INT_VECT INT1_vect
  84. */
  85. /* PCINT20 */
  86. #define PS2_INT_INIT() do { \
  87. PCICR |= (1<<PCIE2); \
  88. } while (0)
  89. #define PS2_INT_ON() do { \
  90. PCMSK2 |= (1<<PCINT20); \
  91. } while (0)
  92. #define PS2_INT_OFF() do { \
  93. PCMSK2 &= ~(1<<PCINT20); \
  94. PCICR &= ~(1<<PCIE2); \
  95. } while (0)
  96. #define PS2_INT_VECT PCINT2_vect
  97. #endif
  98. #endif
  99. #endif