blob: 68aa6aa25ed8d39eb8889770a41a5d8265745e57 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
void wait_until_key_pressed(void)
{
unsigned char temp1, temp2;
unsigned int i;
do {
temp1 = PINC; // read input
for(i=0;i<65535;i++);
temp2 = PINC; // read input
temp1 = (temp1 & temp2); // debounce input
} while ( temp1 & _BV(PINC4) );
loop_until_bit_is_set(PINC,PINC4); /* wait until key is released */
}
int main (void)
{
// configure to read center press on joy switch
DDRC &=~ (1 << PC4); /* Pin PC4 input */
PORTC |= (1 << PC4); /* Pin PC4 pull-up enabled */
for (;;) { /* loop forever */
// turn on LCD backlight LED
PORTD = 0xff;
wait_until_key_pressed();
PORTD = 0;
wait_until_key_pressed();
}
return 0;
}
|