config.h (2127B)
1 /* Copyright 2022 durken (https://github.com/durken1/) 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 17 #pragma once 18 19 20 /* key matrix size */ 21 #define MATRIX_ROWS 4 22 #define MATRIX_COLS 10 23 24 /* COL2ROW or ROW2COL */ 25 #define DIODE_DIRECTION COL2ROW 26 27 #ifdef PS2_DRIVER_USART 28 #define PS2_CLOCK_PIN D5 29 #define PS2_DATA_PIN D2 30 31 /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ 32 /* set DDR of CLOCK as input to be slave */ 33 #define PS2_USART_INIT() do { \ 34 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \ 35 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \ 36 UCSR1C = ((1 << UMSEL10) | \ 37 (3 << UPM10) | \ 38 (0 << USBS1) | \ 39 (3 << UCSZ10) | \ 40 (0 << UCPOL1)); \ 41 UCSR1A = 0; \ 42 UBRR1H = 0; \ 43 UBRR1L = 0; \ 44 } while (0) 45 #define PS2_USART_RX_INT_ON() do { \ 46 UCSR1B = ((1 << RXCIE1) | \ 47 (1 << RXEN1)); \ 48 } while (0) 49 #define PS2_USART_RX_POLL_ON() do { \ 50 UCSR1B = (1 << RXEN1); \ 51 } while (0) 52 #define PS2_USART_OFF() do { \ 53 UCSR1C = 0; \ 54 UCSR1B &= ~((1 << RXEN1) | \ 55 (1 << TXEN1)); \ 56 } while (0) 57 #define PS2_USART_RX_READY (UCSR1A & (1<<RXC1)) 58 #define PS2_USART_RX_DATA UDR1 59 #define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1))) 60 #define PS2_USART_RX_VECT USART1_RX_vect 61 #define PS2_MOUSE_ROTATE 270 /* Compensate for East-facing device orientation. */ 62 #endif