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

ATAVRBFLY_FILES/button.h File Reference


Detailed Description

Atmel Corporation

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

Definition in file button.h.

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define BUTTON_A   6
#define BUTTON_B   7
#define BUTTON_C   2
#define BUTTON_D   3
#define BUTTON_O   4
#define PINB_MASK   ((1<<PINB4)|(1<<PINB6)|(1<<PINB7))
#define PINE_MASK   ((1<<PINE2)|(1<<PINE3))

Functions

void Button_Init (void)
char ButtonBouncing (void)
char getkey (void)
void PinChangeInterrupt (void)


Define Documentation

#define BUTTON_A   6
 

Definition at line 29 of file button.h.

Referenced by PinChangeInterrupt().

#define BUTTON_B   7
 

Definition at line 30 of file button.h.

Referenced by PinChangeInterrupt().

#define BUTTON_C   2
 

Definition at line 31 of file button.h.

Referenced by PinChangeInterrupt().

#define BUTTON_D   3
 

Definition at line 32 of file button.h.

Referenced by PinChangeInterrupt().

#define BUTTON_O   4
 

Definition at line 33 of file button.h.

Referenced by PinChangeInterrupt().

#define PINB_MASK   ((1<<PINB4)|(1<<PINB6)|(1<<PINB7))
 

Definition at line 26 of file button.h.

Referenced by Button_Init(), and PinChangeInterrupt().

#define PINE_MASK   ((1<<PINE2)|(1<<PINE3))
 

Definition at line 27 of file button.h.

Referenced by Button_Init(), and PinChangeInterrupt().


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 ButtonBouncing void   ) 
 

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 }

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 }


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