limit_switch.h

00001 /*
00002   limit_switch.h
00003   
00004   Nicolas Williamson - July 2009
00005   
00006 */
00007 
00008 #ifndef __H_LIMIT_SWITCH__
00009 #define __H_LIMIT_SWITCH__
00010 
00014 typedef enum ls_states{
00015   LS_OFF = 0, 
00016   LS_ON 
00017 } LS_STATE;
00018 
00022 typedef struct ls_switch{
00023   unsigned int limit; 
00024   unsigned int count; 
00025   LS_STATE prev; 
00026   LS_STATE state; 
00027   INT_VOID_F function; 
00028 } LIMIT_SWITCH;
00029 
00030 // ***** Functions ***** //
00031 LS_STATE ls_get_state(int ls);
00032 int ls_init_switch(unsigned int new_limit, INT_VOID_F funct);
00033 void ls_update(void);
00034 
00035 
00036 /* Hardware Setup
00037   PINSEL0 &= ~(3<<0); //set P0.0 to GPIO
00038   PINSEL0 &= ~(3<<2); //set P0.1 to GPIO
00039   FIO0DIR &= ~(1<<0); //set P0.0 to input
00040   FIO0DIR &= ~(1<<1); //set P0.1 to input
00041 */
00042 
00043 #endif // __H_LIMIT_SWITCH__
Generated on Tue Jun 29 16:36:14 2010 by  doxygen 1.6.3