Brian Tilton
/
BTilton-Lab2_Joystick_Interupt
Lab2_Part3 working
Fork of Bootcamp-Interrupt_Polling_Joystick by
main.cpp@1:102ef7d39407, 2013-04-23 (annotated)
- Committer:
- avnisha
- Date:
- Tue Apr 23 05:49:39 2013 +0000
- Revision:
- 1:102ef7d39407
- Parent:
- 0:0e4db18afd77
- Child:
- 2:d18857b99d3c
Bootcamp joystick
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 | 1:102ef7d39407 | 4 | InterruptIn fire(p14); |
avnisha | 1:102ef7d39407 | 5 | DigitalOut led(LED1); |
avnisha | 1:102ef7d39407 | 6 | DigitalOut flash(LED4); |
avnisha | 1:102ef7d39407 | 7 | |
avnisha | 1:102ef7d39407 | 8 | void ISR1() { |
avnisha | 1:102ef7d39407 | 9 | led = !led; |
avnisha | 1:102ef7d39407 | 10 | } |
avnisha | 1:102ef7d39407 | 11 | |
avnisha | 1:102ef7d39407 | 12 | int main() |
avnisha | 1:102ef7d39407 | 13 | { |
avnisha | 1:102ef7d39407 | 14 | fire.rise(&ISR1); |
avnisha | 1:102ef7d39407 | 15 | fire.fall(&ISR1); |
avnisha | 1:102ef7d39407 | 16 | |
avnisha | 1:102ef7d39407 | 17 | while (1) { |
avnisha | 1:102ef7d39407 | 18 | flash = !flash; |
avnisha | 1:102ef7d39407 | 19 | wait(0.25); |
avnisha | 1:102ef7d39407 | 20 | } |
avnisha | 1:102ef7d39407 | 21 | } |
avnisha | 1:102ef7d39407 | 22 | |
avnisha | 1:102ef7d39407 | 23 | #ifdef OLD |
chris | 0:0e4db18afd77 | 24 | #include "mbed.h" |
chris | 0:0e4db18afd77 | 25 | |
chris | 0:0e4db18afd77 | 26 | BusIn joy(p15,p12,p13,p16); |
avnisha | 1:102ef7d39407 | 27 | InterruptIn fire(p14); |
chris | 0:0e4db18afd77 | 28 | |
chris | 0:0e4db18afd77 | 29 | BusOut leds(LED1,LED2,LED3,LED4); |
chris | 0:0e4db18afd77 | 30 | |
chris | 0:0e4db18afd77 | 31 | int main() |
chris | 0:0e4db18afd77 | 32 | { |
chris | 0:0e4db18afd77 | 33 | while(1) { |
chris | 0:0e4db18afd77 | 34 | if (fire) { |
chris | 0:0e4db18afd77 | 35 | leds=0xf; |
chris | 0:0e4db18afd77 | 36 | } else { |
chris | 0:0e4db18afd77 | 37 | leds=joy; |
chris | 0:0e4db18afd77 | 38 | } |
chris | 0:0e4db18afd77 | 39 | wait(0.1); |
chris | 0:0e4db18afd77 | 40 | } |
chris | 0:0e4db18afd77 | 41 | } |
avnisha | 1:102ef7d39407 | 42 | #endif |