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.

128 lines
2.6 KiB

8 years ago
8 years ago
8 years ago
8 years ago
  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. // I'm fairly sure these aren't needed, but oh well - Jack
  78. /*
  79. * PS/2 Interrupt configuration
  80. */
  81. #ifdef PS2_USE_INT
  82. /* uses INT1 for clock line(ATMega32U4) */
  83. #define PS2_CLOCK_PORT PORTD
  84. #define PS2_CLOCK_PIN PIND
  85. #define PS2_CLOCK_DDR DDRD
  86. #define PS2_CLOCK_BIT 1
  87. #define PS2_DATA_PORT PORTD
  88. #define PS2_DATA_PIN PIND
  89. #define PS2_DATA_DDR DDRD
  90. #define PS2_DATA_BIT 0
  91. #define PS2_INT_INIT() do { \
  92. EICRA |= ((1<<ISC11) | \
  93. (0<<ISC10)); \
  94. } while (0)
  95. #define PS2_INT_ON() do { \
  96. EIMSK |= (1<<INT1); \
  97. } while (0)
  98. #define PS2_INT_OFF() do { \
  99. EIMSK &= ~(1<<INT1); \
  100. } while (0)
  101. #define PS2_INT_VECT INT1_vect
  102. #endif
  103. /*
  104. * PS/2 Busywait configuration
  105. */
  106. #ifdef PS2_USE_BUSYWAIT
  107. #define PS2_CLOCK_PORT PORTD
  108. #define PS2_CLOCK_PIN PIND
  109. #define PS2_CLOCK_DDR DDRD
  110. #define PS2_CLOCK_BIT 1
  111. #define PS2_DATA_PORT PORTD
  112. #define PS2_DATA_PIN PIND
  113. #define PS2_DATA_DDR DDRD
  114. #define PS2_DATA_BIT 0
  115. #endif
  116. #endif
  117. #endif