1 /* vim: set sw=8 ts=8 si : */
2 /*********************************************
3 * Author: Guido Socher, Copyright: GPL
6 **********************************************/
8 #define F_CPU 8000000UL // 4 MHz
9 #include <util/delay.h>
12 // it looks like output port settings need time to propagate. Maybe
13 // caused by input capacitors on the lcd which connect to the same ports.
14 static void kbd_wait(void){
19 // U+=PC3, U-=PC4, I+,store=PB2, I-=PC5
20 // common input wires: PB5, PB3 for store
21 // PC3, PC4, PB2, PC5 are already initialized as output lines
22 // by the LCD driver code
25 // init lcd sets those already so we comment them out here:
27 DDRC|=(1<<DDC3); // output line
28 DDRC|=(1<<DDC4); // output line
29 DDRB|=(1<<DDB2); // output line
30 DDRC|=(1<<DDC5); // output line
33 DDRB&= ~(1<<DDB5); // input line
36 PORTB|= (1<<PINB5); // internal pullup resistor on
37 PORTB|= (1<<PINB3); // internal pullup resistor on
40 uint8_t check_u_button(int16_t *u)
43 PORTC&=~(1<<PORTC3); // to gnd
44 PORTC|=(1<<PORTC4); // to vcc
45 PORTB|=(1<<PORTB2); // to vcc
46 PORTC|=(1<<PORTC5); // to vcc
48 if (bit_is_clear(PINB,PINB5)){
53 PORTC|=(1<<PORTC3); // to vcc
54 PORTC&=~(1<<PORTC4); // to gnd
55 PORTB|=(1<<PORTB2); // to vcc
56 PORTC|=(1<<PORTC5); // to vcc
58 if (bit_is_clear(PINB,PINB5) && (*u)>0){
68 uint8_t check_i_button(int16_t *i)
71 PORTC|=(1<<PORTC3); // to vcc
72 PORTC|=(1<<PORTC4); // to vcc
73 PORTB&=~(1<<PORTB2); // to gnd
74 PORTC|=(1<<PORTC5); // to vcc
76 if (bit_is_clear(PINB,PINB5)){
81 PORTC|=(1<<PORTC3); // to vcc
82 PORTC|=(1<<PORTC4); // to vcc
83 PORTB|=(1<<PORTB2); // to vcc
84 PORTC&=~(1<<PORTC5); // to gnd
86 if (bit_is_clear(PINB,PINB5) && (*i)>0){
96 uint8_t check_store_button(void)
98 // check store button:
99 PORTB&=~(1<<PORTB2); // to gnd
101 if (bit_is_clear(PINB,PINB3)){