config_common.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #ifndef F0
  8. #define B0 0x30
  9. #define B1 0x31
  10. #define B2 0x32
  11. #define B3 0x33
  12. #define B4 0x34
  13. #define B5 0x35
  14. #define B6 0x36
  15. #define B7 0x37
  16. #define C0 0x60
  17. #define C1 0x61
  18. #define C2 0x62
  19. #define C3 0x63
  20. #define C4 0x64
  21. #define C5 0x65
  22. #define C6 0x66
  23. #define C7 0x67
  24. #define D0 0x90
  25. #define D1 0x91
  26. #define D2 0x92
  27. #define D3 0x93
  28. #define D4 0x94
  29. #define D5 0x95
  30. #define D6 0x96
  31. #define D7 0x97
  32. #define E0 0xC0
  33. #define E1 0xC1
  34. #define E2 0xC2
  35. #define E3 0xC3
  36. #define E4 0xC4
  37. #define E5 0xC5
  38. #define E6 0xC6
  39. #define E7 0xC7
  40. #define F0 0xF0
  41. #define F1 0xF1
  42. #define F2 0xF2
  43. #define F3 0xF3
  44. #define F4 0xF4
  45. #define F5 0xF5
  46. #define F6 0xF6
  47. #define F7 0xF7
  48. #define A0 0x00
  49. #define A1 0x01
  50. #define A2 0x02
  51. #define A3 0x03
  52. #define A4 0x04
  53. #define A5 0x05
  54. #define A6 0x06
  55. #define A7 0x07
  56. #endif
  57. /* USART configuration */
  58. #ifdef BLUETOOTH_ENABLE
  59. # ifdef __AVR_ATmega32U4__
  60. # define SERIAL_UART_BAUD 9600
  61. # define SERIAL_UART_DATA UDR1
  62. # define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
  63. # define SERIAL_UART_RXD_VECT USART1_RX_vect
  64. # define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
  65. # define SERIAL_UART_INIT() do { \
  66. /* baud rate */ \
  67. UBRR1L = SERIAL_UART_UBRR; \
  68. /* baud rate */ \
  69. UBRR1H = SERIAL_UART_UBRR >> 8; \
  70. /* enable TX */ \
  71. UCSR1B = _BV(TXEN1); \
  72. /* 8-bit data */ \
  73. UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
  74. sei(); \
  75. } while(0)
  76. # else
  77. # error "USART configuration is needed."
  78. # endif
  79. #endif
  80. #endif