33 #include "dev/button.h"
38 static struct button_msg button_msg;
40 static struct process *selecting_proc;
43 button_init(
struct process *proc)
45 button_msg.type = BUTTON_MSG_TYPE;
47 P2DIR &= ~BV(BUTTON_PIN);
48 P2SEL &= ~BV(BUTTON_PIN);
50 P2IES |= BV(BUTTON_PIN);
51 P2IFG &= ~BV(BUTTON_PIN);
53 selecting_proc = proc;
55 P2IE |= BV(BUTTON_PIN);
57 P2IE &= ~BV(BUTTON_PIN);
60 interrupt(PORT2_VECTOR)
61 __button_interrupt(
void)
63 static struct timer debouncetimer;
65 P2IFG &= ~BV(BUTTON_PIN);
67 button_msg.value = P2IN & BV(BUTTON_PIN);
69 if(selecting_proc !=
NULL) {
70 process_post(selecting_proc, PROCESS_EVENT_MSG, &button_msg);