InterruptIn testcase.

Dependencies:   mbed

Committer:
sjalloq
Date:
Sun Jun 13 20:35:15 2010 +0000
Revision:
0:d8cc88c47749

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sjalloq 0:d8cc88c47749 1 #include "mbed.h"
sjalloq 0:d8cc88c47749 2
sjalloq 0:d8cc88c47749 3 InterruptIn up(p20);
sjalloq 0:d8cc88c47749 4 InterruptIn dn(p19);
sjalloq 0:d8cc88c47749 5 InterruptIn sel(p18);
sjalloq 0:d8cc88c47749 6
sjalloq 0:d8cc88c47749 7 DigitalOut led1(LED1);
sjalloq 0:d8cc88c47749 8 DigitalOut led2(LED2);
sjalloq 0:d8cc88c47749 9 DigitalOut led3(LED3);
sjalloq 0:d8cc88c47749 10 DigitalOut led4(LED4);
sjalloq 0:d8cc88c47749 11
sjalloq 0:d8cc88c47749 12 /* Prototypes */
sjalloq 0:d8cc88c47749 13 void button_up();
sjalloq 0:d8cc88c47749 14 void button_down();
sjalloq 0:d8cc88c47749 15 void button_select();
sjalloq 0:d8cc88c47749 16
sjalloq 0:d8cc88c47749 17 int main() {
sjalloq 0:d8cc88c47749 18
sjalloq 0:d8cc88c47749 19 /* Change the pullup mode of the buttons. */
sjalloq 0:d8cc88c47749 20 up.mode(PullUp);
sjalloq 0:d8cc88c47749 21 dn.mode(PullUp);
sjalloq 0:d8cc88c47749 22 sel.mode(PullUp);
sjalloq 0:d8cc88c47749 23
sjalloq 0:d8cc88c47749 24 /* Init the LEDs */
sjalloq 0:d8cc88c47749 25 led1 = 0;
sjalloq 0:d8cc88c47749 26 led2 = 1;
sjalloq 0:d8cc88c47749 27 led3 = 0;
sjalloq 0:d8cc88c47749 28 led4 = 1;
sjalloq 0:d8cc88c47749 29
sjalloq 0:d8cc88c47749 30 /* Set the functions to call when a button is pushed. */
sjalloq 0:d8cc88c47749 31 //up.fall(&button_up);
sjalloq 0:d8cc88c47749 32 //dn.fall(&button_down);
sjalloq 0:d8cc88c47749 33 sel.fall(&button_select);
sjalloq 0:d8cc88c47749 34
sjalloq 0:d8cc88c47749 35 while (1) {
sjalloq 0:d8cc88c47749 36 wait(2);
sjalloq 0:d8cc88c47749 37 led1 = !led1;
sjalloq 0:d8cc88c47749 38 led2 = !led2;
sjalloq 0:d8cc88c47749 39 led3 = !led3;
sjalloq 0:d8cc88c47749 40 led4 = !led4;
sjalloq 0:d8cc88c47749 41 }
sjalloq 0:d8cc88c47749 42 }
sjalloq 0:d8cc88c47749 43
sjalloq 0:d8cc88c47749 44 void button_up() {
sjalloq 0:d8cc88c47749 45 led1 = !led1;
sjalloq 0:d8cc88c47749 46 wait(1);
sjalloq 0:d8cc88c47749 47 }
sjalloq 0:d8cc88c47749 48
sjalloq 0:d8cc88c47749 49 void button_down() {
sjalloq 0:d8cc88c47749 50 led2 = !led2;
sjalloq 0:d8cc88c47749 51 wait(1);
sjalloq 0:d8cc88c47749 52 }
sjalloq 0:d8cc88c47749 53
sjalloq 0:d8cc88c47749 54 void button_select() {
sjalloq 0:d8cc88c47749 55 led3 = !led3;
sjalloq 0:d8cc88c47749 56 wait(1);
sjalloq 0:d8cc88c47749 57 }
sjalloq 0:d8cc88c47749 58
sjalloq 0:d8cc88c47749 59
sjalloq 0:d8cc88c47749 60