Main Page | Data Structures | File List | Data Fields | Globals

ATAVRBFLY_FILES/button.c File Reference


Detailed Description

Atmel Corporation

Revision
1.2
Date
Wednesday, January 26, 2005 10:43:44 UTC

Definition in file button.c.

#include <inavr.h>
#include "ioavr.h"
#include "main.h"
#include "button.h"
#include "types.h"

Include dependency graph for button.c:

Include dependency graph

Go to the source code of this file.

Functions

void Button_Init (void)
char getkey (void)
__interrupt void PCINT0_interrupt (void)
__interrupt void PCINT1_interrupt (void)
void PinChangeInterrupt (void)

Variables

unsigned char gButtonTimeout = FALSE
char KEY = NULL
char KEY_VALID = FALSE


Function Documentation

void Button_Init void   ) 
 

Definition at line 50 of file button.c.

References cbi, PINB_MASK, and PINE_MASK.

Referenced by Initialization().

00051 { 00052 // Init port pins 00053 cbi(DDRB,7); 00054 cbi(DDRB,6); 00055 cbi(DDRB,4); 00056 PORTB |= PINB_MASK; 00057 DDRE = 0x00; 00058 PORTE |= PINE_MASK; 00059 00060 // Enable pin change interrupt on PORTB and PORTE 00061 PCMSK0 = PINE_MASK; 00062 PCMSK1 = PINB_MASK; 00063 EIFR = (1<<PCIF0)|(1<<PCIF1); 00064 EIMSK = (1<<PCIE0)|(1<<PCIE1); 00065 }

char getkey void   ) 
 

Definition at line 161 of file button.c.

References FALSE, KEY, KEY_NULL, and KEY_VALID.

Referenced by main().

00162 { 00163 char k; 00164 00165 __disable_interrupt(); 00166 00167 if (KEY_VALID) // Check for unread key in buffer 00168 { 00169 k = KEY; 00170 KEY_VALID = FALSE; 00171 } 00172 else 00173 k = KEY_NULL; // No key stroke available 00174 00175 __enable_interrupt(); 00176 00177 return k; 00178 }

__interrupt void PCINT0_interrupt void   ) 
 

Definition at line 69 of file button.c.

References __interrupt, and PinChangeInterrupt().

00070 { 00071 PinChangeInterrupt(); 00072 }

Here is the call graph for this function:

__interrupt void PCINT1_interrupt void   ) 
 

Definition at line 75 of file button.c.

References __interrupt, and PinChangeInterrupt().

00076 { 00077 PinChangeInterrupt(); 00078 }

Here is the call graph for this function:

void PinChangeInterrupt void   ) 
 

Definition at line 92 of file button.c.

References BUTTON_A, BUTTON_B, BUTTON_C, BUTTON_D, BUTTON_O, FALSE, gButtonTimeout, KEY, KEY_ENTER, KEY_MINUS, KEY_NEXT, KEY_NULL, KEY_PLUS, KEY_PREV, KEY_VALID, PINB_MASK, PINE_MASK, and TRUE.

Referenced by PCINT0_interrupt(), and PCINT1_interrupt().

00093 { 00094 char buttons; 00095 00096 char key; 00097 00098 /* 00099 Read the buttons: 00100 00101 Bit 7 6 5 4 3 2 1 0 00102 --------------------------------------------- 00103 PORTB B A O 00104 PORTE D C 00105 --------------------------------------------- 00106 PORTB | PORTE B A O D C 00107 ============================================= 00108 */ 00109 00110 00111 buttons = (~PINB) & PINB_MASK; 00112 buttons |= (~PINE) & PINE_MASK; 00113 00114 // Output virtual keys 00115 if (buttons & (1<<BUTTON_A)) 00116 key = KEY_PLUS; 00117 else if (buttons & (1<<BUTTON_B)) 00118 key = KEY_MINUS; 00119 else if (buttons & (1<<BUTTON_C)) 00120 key = KEY_PREV; 00121 else if (buttons & (1<<BUTTON_D)) 00122 key = KEY_NEXT; 00123 else if (buttons & (1<<BUTTON_O)) 00124 key = KEY_ENTER; 00125 else 00126 key = KEY_NULL; 00127 00128 00129 if(key != KEY_NULL) 00130 { 00131 if(gButtonTimeout) // gButtonTimeout is set in the LCD_SOF_interrupt in LCD_driver.c 00132 { 00133 if (!KEY_VALID) 00134 { 00135 KEY = key; // Store key in global key buffer 00136 KEY_VALID = TRUE; 00137 } 00138 00139 gButtonTimeout = FALSE; 00140 00141 } 00142 } 00143 00144 EIFR = (1<<PCIF1) | (1<<PCIF0); // Delete pin change interrupt flags 00145 00146 00147 }


Variable Documentation

unsigned char gButtonTimeout = FALSE
 

Definition at line 32 of file button.c.

Referenced by LCD_SOF_interrupt(), and PinChangeInterrupt().

char KEY = NULL
 

Definition at line 34 of file button.c.

Referenced by getkey(), and PinChangeInterrupt().

char KEY_VALID = FALSE
 

Definition at line 35 of file button.c.

Referenced by getkey(), and PinChangeInterrupt().


Generated on Tue Nov 1 16:21:39 2005 for AVR323 Interfacing GSM modems by doxygen 1.3.7