Brian Tilton
/
BTilton-Lab2_Joystick_Interupt
Lab2_Part3 working
Fork of Bootcamp-Interrupt_Polling_Joystick by
main.cpp@2:d18857b99d3c, 2013-10-07 (annotated)
- Committer:
- avnisha
- Date:
- Mon Oct 07 20:14:38 2013 +0000
- Revision:
- 2:d18857b99d3c
- Parent:
- 1:102ef7d39407
- Child:
- 3:22fdf3a4be19
ok
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
avnisha | 1:102ef7d39407 | 1 | |
avnisha | 1:102ef7d39407 | 2 | #include "mbed.h" |
avnisha | 1:102ef7d39407 | 3 | |
avnisha | 2:d18857b99d3c | 4 | // |
avnisha | 2:d18857b99d3c | 5 | // ignore interrupt version till we discuss that topic |
avnisha | 2:d18857b99d3c | 6 | // |
avnisha | 2:d18857b99d3c | 7 | |
avnisha | 2:d18857b99d3c | 8 | #ifdef INTERRUPT |
avnisha | 1:102ef7d39407 | 9 | InterruptIn fire(p14); |
avnisha | 1:102ef7d39407 | 10 | DigitalOut led(LED1); |
avnisha | 1:102ef7d39407 | 11 | DigitalOut flash(LED4); |
avnisha | 1:102ef7d39407 | 12 | |
avnisha | 1:102ef7d39407 | 13 | void ISR1() { |
avnisha | 1:102ef7d39407 | 14 | led = !led; |
avnisha | 1:102ef7d39407 | 15 | } |
avnisha | 1:102ef7d39407 | 16 | |
avnisha | 1:102ef7d39407 | 17 | int main() |
avnisha | 1:102ef7d39407 | 18 | { |
avnisha | 1:102ef7d39407 | 19 | fire.rise(&ISR1); |
avnisha | 1:102ef7d39407 | 20 | fire.fall(&ISR1); |
avnisha | 1:102ef7d39407 | 21 | |
avnisha | 1:102ef7d39407 | 22 | while (1) { |
avnisha | 1:102ef7d39407 | 23 | flash = !flash; |
avnisha | 1:102ef7d39407 | 24 | wait(0.25); |
avnisha | 1:102ef7d39407 | 25 | } |
avnisha | 1:102ef7d39407 | 26 | } |
avnisha | 1:102ef7d39407 | 27 | |
avnisha | 2:d18857b99d3c | 28 | #endif |
avnisha | 2:d18857b99d3c | 29 | |
chris | 0:0e4db18afd77 | 30 | #include "mbed.h" |
chris | 0:0e4db18afd77 | 31 | |
chris | 0:0e4db18afd77 | 32 | BusIn joy(p15,p12,p13,p16); |
avnisha | 1:102ef7d39407 | 33 | InterruptIn fire(p14); |
chris | 0:0e4db18afd77 | 34 | |
chris | 0:0e4db18afd77 | 35 | BusOut leds(LED1,LED2,LED3,LED4); |
chris | 0:0e4db18afd77 | 36 | |
chris | 0:0e4db18afd77 | 37 | int main() |
chris | 0:0e4db18afd77 | 38 | { |
chris | 0:0e4db18afd77 | 39 | while(1) { |
chris | 0:0e4db18afd77 | 40 | if (fire) { |
chris | 0:0e4db18afd77 | 41 | leds=0xf; |
chris | 0:0e4db18afd77 | 42 | } else { |
chris | 0:0e4db18afd77 | 43 | leds=joy; |
chris | 0:0e4db18afd77 | 44 | } |
chris | 0:0e4db18afd77 | 45 | wait(0.1); |
chris | 0:0e4db18afd77 | 46 | } |
chris | 0:0e4db18afd77 | 47 | } |
avnisha | 2:d18857b99d3c | 48 |