How to use elapsed_time().count()

Using Mbed Studio 1.3.0

Non-urgent, would just like to get rid of a compiler warning by doing what it suggests, but working out how to has me stumped. All I need, as before, is a global readable uint64_t containing microseconds since boot.

[Warning] AxleCounter.cpp@42,37: ‘read_high_resolution_us’ is deprecated: Use the Chrono-based elapsed_time method. If integer microseconds are needed, you can use elapsed_time().count() [since mbed-os-6.0.0] [-Wdeprecated-declarations]

Hello Jon,

All I need, as before, is a global readable uint64_t containing microseconds since boot.

I would suggest to use the method recommended by Johannes (@JoJoS) in this thread:

Kernel::Clock::now();

Best regards, Zoltan

Many thanks Zoltan

Sorry, I was wrong. The Kernel::Clock::now() returns milliseconds. If you need microseconds then you can try:

#include "mbed.h"

int main() {
    Timer t;

    t.start();
    while(1) {
        auto us = t.elapsed_time().count();
        printf ("Time elapsed since boot: %llu us\r\n", us);
        ThisThread::sleep_for(1s);
    }
}

Thanks again
Regards
Jon