8 years, 1 month ago.

RTOS examples for mbed os 5 out of date

Can you update the examples for using RTOS with mbed-os5? When i compile my old code with PlatformIO, i get warnings like: MBED_DEPRECATED... For 'Thread' i found an example: https://developer.mbed.org/questions/73556/How-to-use-RTOS-Threadstart-in-mbed-OS-5/ which help to start a Thread, but I need also an example for starting the 'RtosTimer' in mbed-os5

sstaub

1 Answer

8 years, 1 month ago.

I agree that we should update them. Will look into it.

Here's the new timer API definition: https://github.com/ARMmbed/mbed-os/blob/master/rtos/RtosTimer.h.

For more information on how the RTOS APIs work internally you can look at the RTX docs.

Accepted Answer

Can you give a concrete example?

posted by Stefan Staub 04 Oct 2016

#include "mbed.h"

void fn() {
  printf("Hi!\n");
}

int main() {
    RtosTimer timer(Callback<void()>(fn), osTimerOnce);
    timer.start(1000);

    while (1) {}
}

To run the code in fn after 1 second.

posted by Jan Jongboom 05 Oct 2016