David Pasztor / Mbed 2 deprecated Motor_control

Dependencies:   mbed-rtos mbed

main.cpp

Committer:
NKarandey
Date:
2017-03-17
Revision:
40:04a05851ae7b
Parent:
39:ae41a212c170
Child:
41:d52445129908

File content as of revision 40:04a05851ae7b:

#include "mbed.h"
#include "rtos.h"

// Thread thread;
//
// volatile int counter = 0;
//
// void serialThread() {
//   while(true) {
//     // printf("Hey\n");
//     counter++;
//     Thread::wait(1000);
//   }
// }
//
// int main() {
//   printf("Hello\n\r");
//   thread.start(&serialThread);
//
//   while(true) {
//     printf("%d\n\r", counter);
//     Thread::wait(500);
//     wait(5);
//   }
//
//   return 0;
// }
// #include "mbed.h"
// #include "rtos.h"
 
Mutex stdio_mutex;
 
void notify(const char* name, int state) {
    stdio_mutex.lock();
    printf("%s: %d\n\r", name, state);
    stdio_mutex.unlock();
}
 
void test_thread(void const *args) {
    while (true) {
        notify((const char*)args, 0); Thread::wait(1000);
        notify((const char*)args, 1); Thread::wait(1000);
    }
}
 
int main() {
    Thread t2;
    Thread t3;
 
    t2.start(callback(test_thread, (void *)"Th 2"));
    t3.start(callback(test_thread, (void *)"Th 3"));
 
    test_thread((void *)"Th 1");
}