Raul Cortes
/
FRDM46Z_Interrupt
Revision 0:f0bc7bd8ae33, committed 2014-03-18
- Comitter:
- rcortes
- Date:
- Tue Mar 18 00:44:32 2014 +0000
- Commit message:
- Programa para dejar prendido o apagado un led mediante un boton; haciendo uso de subrutinas en las interrupciones
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r f0bc7bd8ae33 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 18 00:44:32 2014 +0000 @@ -0,0 +1,27 @@ +//Programa para dejar prendido o apagado un led mediante un boton +//Haciendo uso de subrutinas en las interrupciones +//Y sin usar el programa principal +#include "mbed.h" +InterruptIn sw1(SW1); +InterruptIn sw3(SW3); + +DigitalOut led_rojo(LED_RED); +DigitalOut led_verde(LED_GREEN); + +void sw1_int() +{ + led_rojo = !led_rojo; +} +void sw3_int() +{ + led_verde = !led_verde; +} +int main() +{ + led_rojo=1; + led_verde=1; + sw1.fall(&sw1_int); // attach the address of the function to the falling edge + sw3.fall(&sw3_int); // attach the address of the function to the falling edge + while(1) { // wait around, interrupts will interrupt this! + } +}
diff -r 000000000000 -r f0bc7bd8ae33 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Mar 18 00:44:32 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1 \ No newline at end of file