Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

main.cpp

Committer:
Roietronics
Date:
2016-11-03
Revision:
17:267747192719
Parent:
8:bb09890333fe
Child:
18:7f2d0c1cfb33

File content as of revision 17:267747192719:

#include "mbed.h"
#include "Thread.h"

DigitalOut led1(LED1);

#define mySignal 0x01
class Test 
{
    public:
    osThreadId _id;
    Thread _thread;
        
    void myWorker(void* arge)
    {
        int i;
        i++;
        osSignalSet(_id, mySignal);
        
     }
     
    Test(osThreadId id) :
    _id(id),
    _thread()
    {
      _thread.start(this, &Test::myWorker);  
    }
        
};

// main() runs in its own thread in the OS
// (note the calls to Thread::wait below for delays)
int main() {
    osThreadId id = Thread::gettid();
    Test* test = new Test(id);
    while (true) {
        led1 = !led1;
        Thread::wait(500);
    }
}