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.

137 lines
3.6 KiB

  1. /*
  2. Copyright 2012 Jun Wako <wakojun@gmail.com>
  3. Copyright 2016 Priyadi Iman Nurcahyo <priyadi@priyadi.net>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef CONFIG_H
  16. #define CONFIG_H
  17. #define VENDOR_ID 0xFEED
  18. #define PRODUCT_ID 0x6535
  19. #define DEVICE_VER 0x0100
  20. #define MANUFACTURER QMK
  21. #define PRODUCT IBM Terminal Keyboard
  22. /* matrix size */
  23. #define MATRIX_ROWS 17 // keycode bit: 3-0
  24. #define MATRIX_COLS 8 // keycode bit: 6-4
  25. /* legacy keymap support */
  26. #define USE_LEGACY_KEYMAP
  27. /* key combination for command */
  28. #define IS_COMMAND() ( \
  29. get_mods() == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_RALT) | MOD_BIT(KC_RCTL)) \
  30. )
  31. /*
  32. * PS/2 USART configuration for ATMega32U4
  33. */
  34. #ifdef PS2_USE_USART
  35. /* XCK for clock line */
  36. #define PS2_CLOCK_PORT PORTD
  37. #define PS2_CLOCK_PIN PIND
  38. #define PS2_CLOCK_DDR DDRD
  39. #define PS2_CLOCK_BIT 5
  40. /* RXD for data line */
  41. #define PS2_DATA_PORT PORTD
  42. #define PS2_DATA_PIN PIND
  43. #define PS2_DATA_DDR DDRD
  44. #define PS2_DATA_BIT 2
  45. /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
  46. /* set DDR of CLOCK as input to be slave */
  47. #define PS2_USART_INIT() do { \
  48. PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
  49. PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
  50. UCSR1C = ((1 << UMSEL10) | \
  51. (3 << UPM10) | \
  52. (0 << USBS1) | \
  53. (3 << UCSZ10) | \
  54. (0 << UCPOL1)); \
  55. UCSR1A = 0; \
  56. UBRR1H = 0; \
  57. UBRR1L = 0; \
  58. } while (0)
  59. #define PS2_USART_RX_INT_ON() do { \
  60. UCSR1B = ((1 << RXCIE1) | \
  61. (1 << RXEN1)); \
  62. } while (0)
  63. #define PS2_USART_RX_POLL_ON() do { \
  64. UCSR1B = (1 << RXEN1); \
  65. } while (0)
  66. #define PS2_USART_OFF() do { \
  67. UCSR1C = 0; \
  68. UCSR1B &= ~((1 << RXEN1) | \
  69. (1 << TXEN1)); \
  70. } while (0)
  71. #define PS2_USART_RX_READY (UCSR1A & (1<<RXC1))
  72. #define PS2_USART_RX_DATA UDR1
  73. #define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
  74. #define PS2_USART_RX_VECT USART1_RX_vect
  75. #endif
  76. /*
  77. * PS/2 Interrupt configuration
  78. */
  79. #ifdef PS2_USE_INT
  80. /* uses INT1 for clock line(ATMega32U4) */
  81. #define PS2_CLOCK_PORT PORTD
  82. #define PS2_CLOCK_PIN PIND
  83. #define PS2_CLOCK_DDR DDRD
  84. #define PS2_CLOCK_BIT 1
  85. #define PS2_DATA_PORT PORTD
  86. #define PS2_DATA_PIN PIND
  87. #define PS2_DATA_DDR DDRD
  88. #define PS2_DATA_BIT 0
  89. #define PS2_INT_INIT() do { \
  90. EICRA |= ((1<<ISC11) | \
  91. (0<<ISC10)); \
  92. } while (0)
  93. #define PS2_INT_ON() do { \
  94. EIMSK |= (1<<INT1); \
  95. } while (0)
  96. #define PS2_INT_OFF() do { \
  97. EIMSK &= ~(1<<INT1); \
  98. } while (0)
  99. #define PS2_INT_VECT INT1_vect
  100. #endif
  101. /*
  102. * PS/2 Busywait configuration
  103. */
  104. #ifdef PS2_USE_BUSYWAIT
  105. #define PS2_CLOCK_PORT PORTD
  106. #define PS2_CLOCK_PIN PIND
  107. #define PS2_CLOCK_DDR DDRD
  108. #define PS2_CLOCK_BIT 1
  109. #define PS2_DATA_PORT PORTD
  110. #define PS2_DATA_PIN PIND
  111. #define PS2_DATA_DDR DDRD
  112. #define PS2_DATA_BIT 0
  113. #endif
  114. #endif