2 #include <util/delay.h>
4 /* Check port settings for clock and data line */
5 #if !(defined(PS2_CLOCK_PORT) && \
6 defined(PS2_CLOCK_PIN) && \
7 defined(PS2_CLOCK_DDR) && \
8 defined(PS2_CLOCK_BIT))
9 # error "PS/2 clock port setting is required in config.h"
12 #if !(defined(PS2_DATA_PORT) && \
13 defined(PS2_DATA_PIN) && \
14 defined(PS2_DATA_DDR) && \
15 defined(PS2_DATA_BIT))
16 # error "PS/2 data port setting is required in config.h"
29 PS2_CLOCK_PORT &= ~(1<<PS2_CLOCK_BIT);
30 PS2_CLOCK_DDR |= (1<<PS2_CLOCK_BIT);
35 /* input with pull up */
36 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT);
37 PS2_CLOCK_PORT |= (1<<PS2_CLOCK_BIT);
42 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT);
43 PS2_CLOCK_PORT |= (1<<PS2_CLOCK_BIT);
45 return PS2_CLOCK_PIN&(1<<PS2_CLOCK_BIT);
57 PS2_DATA_PORT &= ~(1<<PS2_DATA_BIT);
58 PS2_DATA_DDR |= (1<<PS2_DATA_BIT);
63 /* input with pull up */
64 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT);
65 PS2_DATA_PORT |= (1<<PS2_DATA_BIT);
70 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT);
71 PS2_DATA_PORT |= (1<<PS2_DATA_BIT);
73 return PS2_DATA_PIN&(1<<PS2_DATA_BIT);