button.c

Go to the documentation of this file.
00001 
00030 #include <includes.h>
00031 
00037 unsigned int button_pushed(unsigned int button)
00038 {
00039   unsigned int button_state;
00040   unsigned int p0_state = FIO0PIN;
00041   unsigned int p1_state = FIO1PIN;
00042   
00043   if (button > 5){
00044     error_occurred(ERROR_BUTTON_OOB);
00045   } else {
00046     switch (button){
00047       case 0: button_state = p1_state & (1<<18);
00048           break;
00049       case 1: button_state = p0_state & (1<<12);
00050           break;
00051       case 2: button_state = p0_state & (1<<13);
00052           break;
00053       case 3: button_state = p0_state & (1<<28);
00054           break;
00055       case 4: button_state = p1_state & (1<<16);
00056           break;
00057       case 5: button_state = p0_state & (1<<30);
00058           break;
00059     }
00060   }
00061   return button_state;
00062 }
00063 
00064 unsigned int button_0(void){return button_pushed(0);} 
00065 unsigned int button_1(void){return button_pushed(1);} 
00066 unsigned int button_2(void){return button_pushed(2);} 
00067 unsigned int button_3(void){return button_pushed(3);} 
00068 unsigned int button_4(void){return button_pushed(4);} 
00069 unsigned int button_5(void){return button_pushed(5);} 
Generated on Tue Jun 29 16:36:14 2010 by  doxygen 1.6.3