config_common.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #ifndef CONFIG_DEFINITIONS_H
  2. #define CONFIG_DEFINITIONS_H
  3. /* diode directions */
  4. #define COL2ROW 0
  5. #define ROW2COL 1
  6. /* I/O pins */
  7. #define B0 0x30
  8. #define B1 0x31
  9. #define B2 0x32
  10. #define B3 0x33
  11. #define B4 0x34
  12. #define B5 0x35
  13. #define B6 0x36
  14. #define B7 0x37
  15. #define C0 0x60
  16. #define C1 0x61
  17. #define C2 0x62
  18. #define C3 0x63
  19. #define C4 0x64
  20. #define C5 0x65
  21. #define C6 0x66
  22. #define C7 0x67
  23. #define D0 0x90
  24. #define D1 0x91
  25. #define D2 0x92
  26. #define D3 0x93
  27. #define D4 0x94
  28. #define D5 0x95
  29. #define D6 0x96
  30. #define D7 0x97
  31. #define E0 0xC0
  32. #define E1 0xC1
  33. #define E2 0xC2
  34. #define E3 0xC3
  35. #define E4 0xC4
  36. #define E5 0xC5
  37. #define E6 0xC6
  38. #define E7 0xC7
  39. #define F0 0xF0
  40. #define F1 0xF1
  41. #define F2 0xF2
  42. #define F3 0xF3
  43. #define F4 0xF4
  44. #define F5 0xF5
  45. #define F6 0xF6
  46. #define F7 0xF7
  47. #define A0 0x00
  48. #define A1 0x01
  49. #define A2 0x02
  50. #define A3 0x03
  51. #define A4 0x04
  52. #define A5 0x05
  53. #define A6 0x06
  54. #define A7 0x07
  55. /* USART configuration */
  56. #ifdef BLUETOOTH_ENABLE
  57. # ifdef __AVR_ATmega32U4__
  58. # define SERIAL_UART_BAUD 9600
  59. # define SERIAL_UART_DATA UDR1
  60. # define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
  61. # define SERIAL_UART_RXD_VECT USART1_RX_vect
  62. # define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
  63. # define SERIAL_UART_INIT() do { \
  64. /* baud rate */ \
  65. UBRR1L = SERIAL_UART_UBRR; \
  66. /* baud rate */ \
  67. UBRR1H = SERIAL_UART_UBRR >> 8; \
  68. /* enable TX */ \
  69. UCSR1B = _BV(TXEN1); \
  70. /* 8-bit data */ \
  71. UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
  72. sei(); \
  73. } while(0)
  74. # else
  75. # error "USART configuration is needed."
  76. # endif
  77. #endif
  78. #ifdef PS2_USE_BUSYWAIT
  79. # ifndef PS2_CLOCK_PORT
  80. # error "PS2_CLOCK_PORT has to be defined"
  81. # endif
  82. # ifndef PS2_CLOCK_PIN
  83. # error "PS2_CLOCK_PIN has to be defined"
  84. # endif
  85. # ifndef PS2_CLOCK_DDR
  86. # error "PS2_CLOCK_DDR has to be defined"
  87. # endif
  88. # ifndef PS2_CLOCK_BIT
  89. # error "PS2_CLOCK_BIT has to be defined"
  90. # endif
  91. # ifndef PS2_DATA_PORT
  92. # error "PS2_DATA_PORT has to be defined"
  93. # endif
  94. # ifndef PS2_DATA_PIN
  95. # error "PS2_DATA_PIN has to be defined"
  96. # endif
  97. # ifndef PS2_DATA_DDR
  98. # error "PS2_DATA_DDR has to be defined"
  99. # endif
  100. # ifndef PS2_DATA_BIT
  101. # error "PS2_DATA_BIT has to be defined"
  102. # endif
  103. #endif
  104. #ifdef PS2_USE_INT
  105. # ifndef PS2_CLOCK_PORT
  106. # error "PS2_CLOCK_PORT has to be defined"
  107. # endif
  108. # ifndef PS2_CLOCK_PIN
  109. # error "PS2_CLOCK_PIN has to be defined"
  110. # endif
  111. # ifndef PS2_CLOCK_DDR
  112. # error "PS2_CLOCK_DDR has to be defined"
  113. # endif
  114. # ifndef PS2_CLOCK_BIT
  115. # error "PS2_CLOCK_BIT has to be defined"
  116. # endif
  117. # ifndef PS2_DATA_PORT
  118. # error "PS2_DATA_PORT has to be defined"
  119. # endif
  120. # ifndef PS2_DATA_PIN
  121. # error "PS2_DATA_PIN has to be defined"
  122. # endif
  123. # ifndef PS2_DATA_DDR
  124. # error "PS2_DATA_DDR has to be defined"
  125. # endif
  126. # ifndef PS2_DATA_BIT
  127. # error "PS2_DATA_BIT has to be defined"
  128. # endif
  129. # ifndef PS2_INT_INIT
  130. # error "PS2_INT_INIT has to be defined"
  131. # endif
  132. # ifndef PS2_INT_ON
  133. # error "PS2_INT_ON has to be defined"
  134. # endif
  135. # ifndef PS2_INT_OFF
  136. # error "PS2_INT_OFF has to be defined"
  137. # endif
  138. # ifndef PS2_INT_VECT
  139. # error "PS2_INT_VECT has to be defined"
  140. # endif
  141. #endif
  142. #ifdef PS2_USE_USART
  143. # ifndef PS2_CLOCK_PORT
  144. # error "PS2_CLOCK_PORT has to be defined"
  145. # endif
  146. # ifndef PS2_CLOCK_PIN
  147. # error "PS2_CLOCK_PIN has to be defined"
  148. # endif
  149. # ifndef PS2_CLOCK_DDR
  150. # error "PS2_CLOCK_DDR has to be defined"
  151. # endif
  152. # ifndef PS2_CLOCK_BIT
  153. # error "PS2_CLOCK_BIT has to be defined"
  154. # endif
  155. # ifndef PS2_DATA_PORT
  156. # error "PS2_DATA_PORT has to be defined"
  157. # endif
  158. # ifndef PS2_DATA_PIN
  159. # error "PS2_DATA_PIN has to be defined"
  160. # endif
  161. # ifndef PS2_DATA_DDR
  162. # error "PS2_DATA_DDR has to be defined"
  163. # endif
  164. # ifndef PS2_DATA_BIT
  165. # error "PS2_DATA_BIT has to be defined"
  166. # endif
  167. # ifndef PS2_USART_INIT
  168. # error "PS2_USART_INIT has to be defined"
  169. # endif
  170. # ifndef PS2_USART_RX_INT_ON
  171. # error "PS2_USART_RX_INT_ON has to be defined"
  172. # endif
  173. # ifndef PS2_USART_RX_POLL_ON
  174. # error "PS2_USART_RX_POLL_ON has to be defined"
  175. # endif
  176. # ifndef PS2_USART_OFF
  177. # error "PS2_USART_OFF has to be defined"
  178. # endif
  179. # ifndef PS2_USART_RX_READY
  180. # error "PS2_USART_RX_READY has to be defined"
  181. # endif
  182. # ifndef PS2_USART_RX_DATA
  183. # error "PS2_USART_RX_DATA has to be defined"
  184. # endif
  185. # ifndef PS2_USART_ERROR
  186. # error "PS2_USART_ERROR has to be defined"
  187. # endif
  188. # ifndef PS2_USART_RX_VECT
  189. # error "PS2_USART_RX_VECT has to be defined"
  190. # endif
  191. #endif
  192. #endif