config.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Copyright 2020 Evy Dekkers
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #ifdef PS2_USE_USART
  18. #define PS2_CLOCK_PORT PORTD
  19. #define PS2_CLOCK_PIN PIND
  20. #define PS2_CLOCK_DDR DDRD
  21. #define PS2_CLOCK_BIT 5
  22. #define PS2_DATA_PORT PORTD
  23. #define PS2_DATA_PIN PIND
  24. #define PS2_DATA_DDR DDRD
  25. #define PS2_DATA_BIT 2
  26. /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
  27. /* set DDR of CLOCK as input to be slave */
  28. #define PS2_USART_INIT() do { \
  29. PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
  30. PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
  31. UCSR1C = ((1 << UMSEL10) | \
  32. (3 << UPM10) | \
  33. (0 << USBS1) | \
  34. (3 << UCSZ10) | \
  35. (0 << UCPOL1)); \
  36. UCSR1A = 0; \
  37. UBRR1H = 0; \
  38. UBRR1L = 0; \
  39. } while (0)
  40. #define PS2_USART_RX_INT_ON() do { \
  41. UCSR1B = ((1 << RXCIE1) | \
  42. (1 << RXEN1)); \
  43. } while (0)
  44. #define PS2_USART_RX_POLL_ON() do { \
  45. UCSR1B = (1 << RXEN1); \
  46. } while (0)
  47. #define PS2_USART_OFF() do { \
  48. UCSR1C = 0; \
  49. UCSR1B &= ~((1 << RXEN1) | \
  50. (1 << TXEN1)); \
  51. } while (0)
  52. #define PS2_USART_RX_READY (UCSR1A & (1<<RXC1))
  53. #define PS2_USART_RX_DATA UDR1
  54. #define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
  55. #define PS2_USART_RX_VECT USART1_RX_vect
  56. #define PS2_MOUSE_ENABLE_SCROLLING
  57. #define PS2_MOUSE_INIT_DELAY 1000
  58. #define PS2_MOUSE_BTN_LEFT 0
  59. #define PS2_MOUSE_BTN_RIGHT 1
  60. #define PS2_MOUSE_BTN_MIDDLE 2
  61. #define PS2_MOUSE_X_MULTIPLIER 2
  62. #define PS2_MOUSE_Y_MULTIPLIER 2
  63. #define PS2_MOUSE_V_MULTIPLIER 1
  64. #define PS2_MOUSE_SCROLL_BTN_MASK 0
  65. #define PS2_MOUSE_USE_REMOTE_MODE
  66. #endif