Roberto Vázquez
/
frdm_excercise7
ejercicio 7 de interrupciones
main.cpp@0:2190998da98e, 2014-09-25 (annotated)
- Committer:
- rvazquezc
- Date:
- Thu Sep 25 19:00:22 2014 +0000
- Revision:
- 0:2190998da98e
ejercicio 7
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rvazquezc | 0:2190998da98e | 1 | #include "mbed.h" |
rvazquezc | 0:2190998da98e | 2 | #define on 0 |
rvazquezc | 0:2190998da98e | 3 | #define off 1 |
rvazquezc | 0:2190998da98e | 4 | DigitalOut azul(LED_BLUE); |
rvazquezc | 0:2190998da98e | 5 | DigitalOut rojo(LED_RED); |
rvazquezc | 0:2190998da98e | 6 | InterruptIn sw2(SW2); |
rvazquezc | 0:2190998da98e | 7 | DigitalOut verde(LED_GREEN); |
rvazquezc | 0:2190998da98e | 8 | void task(void); |
rvazquezc | 0:2190998da98e | 9 | int main() |
rvazquezc | 0:2190998da98e | 10 | {azul=on; |
rvazquezc | 0:2190998da98e | 11 | rojo=off; |
rvazquezc | 0:2190998da98e | 12 | while (true) { |
rvazquezc | 0:2190998da98e | 13 | azul=!azul; |
rvazquezc | 0:2190998da98e | 14 | rojo=!rojo; |
rvazquezc | 0:2190998da98e | 15 | wait (1.0f); |
rvazquezc | 0:2190998da98e | 16 | sw2.rise(&task); |
rvazquezc | 0:2190998da98e | 17 | } |
rvazquezc | 0:2190998da98e | 18 | } |
rvazquezc | 0:2190998da98e | 19 | void task() |
rvazquezc | 0:2190998da98e | 20 | {verde=on; |
rvazquezc | 0:2190998da98e | 21 | wait (5.0f); |
rvazquezc | 0:2190998da98e | 22 | } |