Getting Started

(lily) #1

Chapter 7: Microcontroller Interrupts and Timers


N_C))

_O))

= KEY_INVALID;

KEY = key; // Store key in global key buffer
TRUE;

rrupt flags
PCIF0);

BLED)

ar getkey(void)

char k;

t change while in
se

KEY_VALID = FALSE;
}
else


// Output virtual keys
if (buttons & (1<<BUTTON_A))
key = KEY_UP;
else if (buttons & (1<<BUTTON_B))
key = KEY_DOWN;
else if (buttons & (1<<BUTTO
key = KEY_LEFT;
else if (buttons & (1<<BUTTON_D))
key = KEY_RIGHT;
else if (buttons & (1<<BUTTON
key = KEY_PUSH;
else
key


if(key != KEY_INVALID)
{
if (!KEY_VALID)
{


KEY_VALID =
}
}


//Delete pin change inte
EIFR = (1<<PCIF1) | (1<<


if(ENA
{
getkey();
}
}


ch
{


cli(); // disable interrrupts so 'KEY' won'
u


if (KEY_VALID) // Check for unread key in buffer
{
k = KEY;

Free download pdf