practica 2 ejercicio 9

Dependencies:   mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 
00004 DigitalIn Sw(A5);
00005 DigitalOut Led(D4);
00006 int estado=1;
00007 
00008 void threadled(void const *argument)
00009 {
00010     while (1) {
00011         Thread::signal_wait(0x1);
00012         Led = !Led;
00013 
00014     }
00015 }
00016 
00017 int main()
00018 {
00019     Thread thread(threadled, NULL, osPriorityNormal, DEFAULT_STACK_SIZE);
00020 
00021     while (true) {
00022         if (estado&&(!Sw)) {
00023             thread.signal_set(0x1);
00024         }
00025         estado=Sw;
00026         Thread::wait(200);
00027     }
00028 }