Skip to content

Minor Chrono updates #1302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/api/io/Timer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<span class="images">![](../../images/classmbed_1_1_timer.png)<span>Timer class hierarchy</span></span>

Use the Timer interface to create, start, stop and read a timer for measuring precise times (better than millisecond precision).
Use the Timer interface to create, start, stop and read a stopwatch-like timer for measuring precise times (better than millisecond precision).

You can independently create, start and stop any number of Timer objects.

## Warnings and notes

- Timers are based on 64-bit unsigned microsecond counters, but for backward compatibility, the `read_ms()` and `read_us()` methods only return 32-bit signed integers. This limits their range before wrapping to 49 days and 35 minutes respectively. Use `read_high_resolution_us()` to access the full range of over 500,000 years.
- While a Timer is running, deep sleep is blocked to maintain accurate timing. If you don't need microsecond precision, consider using the LowPowerTimer class instead because this does not block deep sleep mode.
- Timers are based on 64-bit signed microsecond counters, giving a range of over 250,000 years.
- While a Timer is running, deep sleep is blocked to maintain accurate timing. If you don't need microsecond precision, consider using the LowPowerTimer or Kernel::Clock classes instead because these do not block deep sleep mode.

## Timer class reference

Expand Down
4 changes: 2 additions & 2 deletions docs/api/rtos/Kernel.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ The Kernel namespace implements interfaces to attach a function to some kernel e

[![View code](https://www.mbed.com/embed/?type=library)](https://os.mbed.com/docs/development/mbed-os-api-doxy/namespacertos_1_1_kernel.html)

## get_ms_count() example
## Kernel::Clock example

The function `get_ms_count()` can be used to read the current RTOS kernel millisecond tick count. The below code snippet demonstrates use of the `get_ms_count()` function to calculate the elapsed time:
The nested class `Clock` can be used to read the current RTOS kernel millisecond tick count as a C++11 Chrono time point. The below code snippet demonstrates use of `Kernel::Clock` to calculate the elapsed time:

[![View code](https://www.mbed.com/embed/?url=https://github.com/ARMmbed/mbed-os-examples-docs_only/blob/master/APIs_RTOS/Kernel_get_ms_count)](https://github.com/ARMmbed/mbed-os-examples-docs_only/blob/master/APIs_RTOS/Kernel_get_ms_count/main.cpp)

Expand Down
5 changes: 3 additions & 2 deletions docs/contributing/guidelines/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ Occasionally, namespaces are used to act as-if "static singleton" objects. One e
Below is an example of typical namespace use in a source file:

```
using namespace rtos;
using namespace rtos; // for ThisThread
using namespace std::chrono_literals; // for 1s

ThisThread::sleep_for(1000);
ThisThread::sleep_for(1s);

```

Expand Down