config.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. Copyright 2012 Jun Wako <wakojun@gmail.com>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #pragma once
  15. /* key matrix size */
  16. #define MATRIX_COLS 6
  17. #define MATRIX_ROWS 9
  18. /* default pin-out */
  19. #define MATRIX_COL_PINS \
  20. { F4, F1, F0, D6, D0, D1 }
  21. #define MATRIX_ROW_PINS \
  22. { F5, F6, F7, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN }
  23. #define TRACKPOINT_PINS \
  24. { B7, B6, D7 }
  25. /*
  26. * Keyboard Matrix Assignments
  27. *
  28. * Change this to how you wired your keyboard
  29. * COLS: AVR pins used for columns, left to right
  30. * ROWS: AVR pins used for rows, top to bottom
  31. * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
  32. * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
  33. *
  34. */
  35. #define DIODE_DIRECTION COL2ROW
  36. /* key combination for command */
  37. #define IS_COMMAND() (get_mods() == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT) | MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)))
  38. /*
  39. * Feature disable options
  40. * These options are also useful to firmware size reduction.
  41. */
  42. /* disable debug print */
  43. // #define NO_DEBUG
  44. /* disable print */
  45. // #define NO_PRINT
  46. /* disable action features */
  47. //#define NO_ACTION_LAYER
  48. //#define NO_ACTION_TAPPING
  49. //#define NO_ACTION_ONESHOT
  50. #define PS2_MOUSE_INIT_DELAY 2000
  51. #define BATTERY_POLL 30000
  52. #define MAX_VOLTAGE 4.2
  53. #define MIN_VOLTAGE 3.2
  54. #ifndef __ASSEMBLER__ // assembler doesn't like enum in .h file
  55. enum led_sequence {
  56. LED_IND_LINUX,
  57. LED_IND_APPLE,
  58. LED_IND_WINDOWS,
  59. LED_IND_QWERTY,
  60. LED_IND_ALT,
  61. LED_IND_AUDIO,
  62. LED_IND_BLUETOOTH,
  63. LED_IND_USB,
  64. LED_IND_BATTERY,
  65. LED_IND_CAPSLOCK,
  66. LED_IND_GUI,
  67. LED_IND_FUN,
  68. LED_IND_NUM,
  69. LED_IND_PUNC,
  70. LED_IND_EMOJI,
  71. LED_IND_GREEK,
  72. LED_BKSP,
  73. LED_ENT,
  74. LED_RSFT,
  75. LED_RCTL,
  76. LED_RALT,
  77. LED_SLSH,
  78. LED_SCLN,
  79. LED_P,
  80. LED_O,
  81. LED_L,
  82. LED_DOT,
  83. LED_RGUI,
  84. LED_GREEK,
  85. LED_COMM,
  86. LED_K,
  87. LED_I,
  88. LED_U,
  89. LED_J,
  90. LED_M,
  91. LED_FUN,
  92. LED_RSPC,
  93. LED_N,
  94. LED_HH,
  95. LED_Y,
  96. LED_TRACKPOINT3,
  97. LED_TRACKPOINT2,
  98. LED_TRACKPOINT1,
  99. LED_T,
  100. LED_G,
  101. LED_B,
  102. LED_LSPC,
  103. LED_NUM,
  104. LED_V,
  105. LED_F,
  106. LED_R,
  107. LED_E,
  108. LED_D,
  109. LED_C,
  110. LED_EMPTY,
  111. LED_LGUI,
  112. LED_X,
  113. LED_S,
  114. LED_W,
  115. LED_Q,
  116. LED_A,
  117. LED_Z,
  118. LED_LALT,
  119. LED_LCTL,
  120. LED_LSFT,
  121. LED_ESC,
  122. LED_TAB,
  123. LED_TOTAL
  124. };
  125. # define RGBSPS_NUM LED_TOTAL
  126. #endif
  127. /* PS/2 mouse */
  128. #ifdef PS2_DRIVER_BUSYWAIT
  129. # define PS2_CLOCK_PIN D3
  130. # define PS2_DATA_PIN D2
  131. #endif
  132. /* PS/2 mouse interrupt version */
  133. #ifdef PS2_DRIVER_INTERRUPT
  134. /* uses INT1 for clock line(ATMega32U4) */
  135. # define PS2_CLOCK_PIN D3
  136. # define PS2_DATA_PIN D2
  137. # define PS2_INT_INIT() \
  138. do { \
  139. EICRA |= ((1 << ISC31) | (0 << ISC30)); \
  140. } while (0)
  141. # define PS2_INT_ON() \
  142. do { \
  143. EIMSK |= (1 << INT3); \
  144. } while (0)
  145. # define PS2_INT_OFF() \
  146. do { \
  147. EIMSK &= ~(1 << INT3); \
  148. } while (0)
  149. # define PS2_INT_VECT INT3_vect
  150. #endif
  151. /* PS/2 mouse USART version */
  152. #ifdef PS2_DRIVER_USART
  153. /* XCK for clock line and RXD for data line */
  154. #define PS2_CLOCK_PIN D5
  155. #define PS2_DATA_PIN D2
  156. /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
  157. /* set DDR of CLOCK as input to be slave */
  158. # define PS2_USART_INIT() \
  159. do { \
  160. PS2_CLOCK_DDR &= ~(1 << PS2_CLOCK_BIT); \
  161. PS2_DATA_DDR &= ~(1 << PS2_DATA_BIT); \
  162. UCSR1C = ((1 << UMSEL10) | (3 << UPM10) | (0 << USBS1) | (3 << UCSZ10) | (0 << UCPOL1)); \
  163. UCSR1A = 0; \
  164. UBRR1H = 0; \
  165. UBRR1L = 0; \
  166. } while (0)
  167. # define PS2_USART_RX_INT_ON() \
  168. do { \
  169. UCSR1B = ((1 << RXCIE1) | (1 << RXEN1)); \
  170. } while (0)
  171. # define PS2_USART_RX_POLL_ON() \
  172. do { \
  173. UCSR1B = (1 << RXEN1); \
  174. } while (0)
  175. # define PS2_USART_OFF() \
  176. do { \
  177. UCSR1C = 0; \
  178. UCSR1B &= ~((1 << RXEN1) | (1 << TXEN1)); \
  179. } while (0)
  180. # define PS2_USART_RX_READY (UCSR1A & (1 << RXC1))
  181. # define PS2_USART_RX_DATA UDR1
  182. # define PS2_USART_ERROR (UCSR1A & ((1 << FE1) | (1 << DOR1) | (1 << UPE1)))
  183. # define PS2_USART_RX_VECT USART1_RX_vect
  184. #endif