3 #include <util/delay.h>
5 /* Check port settings for clock and data line */
6 #if !(defined(PS2_CLOCK_PORT) && \
7 defined(PS2_CLOCK_PIN) && \
8 defined(PS2_CLOCK_DDR) && \
9 defined(PS2_CLOCK_BIT))
10 # error "PS/2 clock port setting is required in config.h"
13 #if !(defined(PS2_DATA_PORT) && \
14 defined(PS2_DATA_PIN) && \
15 defined(PS2_DATA_DDR) && \
16 defined(PS2_DATA_BIT))
17 # error "PS/2 data port setting is required in config.h"
30 PS2_CLOCK_PORT &= ~(1<<PS2_CLOCK_BIT);
31 PS2_CLOCK_DDR |= (1<<PS2_CLOCK_BIT);
36 /* input with pull up */
37 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT);
38 PS2_CLOCK_PORT |= (1<<PS2_CLOCK_BIT);
43 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT);
44 PS2_CLOCK_PORT |= (1<<PS2_CLOCK_BIT);
46 return PS2_CLOCK_PIN&(1<<PS2_CLOCK_BIT);
58 PS2_DATA_PORT &= ~(1<<PS2_DATA_BIT);
59 PS2_DATA_DDR |= (1<<PS2_DATA_BIT);
64 /* input with pull up */
65 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT);
66 PS2_DATA_PORT |= (1<<PS2_DATA_BIT);
71 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT);
72 PS2_DATA_PORT |= (1<<PS2_DATA_BIT);
74 return PS2_DATA_PIN&(1<<PS2_DATA_BIT);