config_common.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. /* USART configuration */
  48. #ifdef BLUETOOTH_ENABLE
  49. # ifdef __AVR_ATmega32U4__
  50. # define SERIAL_UART_BAUD 9600
  51. # define SERIAL_UART_DATA UDR1
  52. # define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
  53. # define SERIAL_UART_RXD_VECT USART1_RX_vect
  54. # define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
  55. # define SERIAL_UART_INIT() do { \
  56. /* baud rate */ \
  57. UBRR1L = SERIAL_UART_UBRR; \
  58. /* baud rate */ \
  59. UBRR1H = SERIAL_UART_UBRR >> 8; \
  60. /* enable TX */ \
  61. UCSR1B = _BV(TXEN1); \
  62. /* 8-bit data */ \
  63. UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
  64. sei(); \
  65. } while(0)
  66. # else
  67. # error "USART configuration is needed."
  68. #endif
  69. // I'm fairly sure these aren't needed, but oh well - Jack
  70. /*
  71. * PS/2 Interrupt configuration
  72. */
  73. #ifdef PS2_USE_INT
  74. /* uses INT1 for clock line(ATMega32U4) */
  75. #define PS2_CLOCK_PORT PORTD
  76. #define PS2_CLOCK_PIN PIND
  77. #define PS2_CLOCK_DDR DDRD
  78. #define PS2_CLOCK_BIT 1
  79. #define PS2_DATA_PORT PORTD
  80. #define PS2_DATA_PIN PIND
  81. #define PS2_DATA_DDR DDRD
  82. #define PS2_DATA_BIT 0
  83. #define PS2_INT_INIT() do { \
  84. EICRA |= ((1<<ISC11) | \
  85. (0<<ISC10)); \
  86. } while (0)
  87. #define PS2_INT_ON() do { \
  88. EIMSK |= (1<<INT1); \
  89. } while (0)
  90. #define PS2_INT_OFF() do { \
  91. EIMSK &= ~(1<<INT1); \
  92. } while (0)
  93. #define PS2_INT_VECT INT1_vect
  94. #endif
  95. /*
  96. * PS/2 Busywait configuration
  97. */
  98. #ifdef PS2_USE_BUSYWAIT
  99. #define PS2_CLOCK_PORT PORTD
  100. #define PS2_CLOCK_PIN PIND
  101. #define PS2_CLOCK_DDR DDRD
  102. #define PS2_CLOCK_BIT 1
  103. #define PS2_DATA_PORT PORTD
  104. #define PS2_DATA_PIN PIND
  105. #define PS2_DATA_DDR DDRD
  106. #define PS2_DATA_BIT 0
  107. #endif
  108. #endif
  109. #endif