config_common.h 2.6 KB

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