Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-os-example-wifi-milkcocoa MilkcocoaOsSample_Eth MilkcocoaOsSample_ESP8266 MilkcocoaOsSample_Eth_DigitalIn
OldTimer Class Reference
[Drivers]
A general purpose timer. More...
#include <OldTimer.h>
Public Member Functions | |
| void | start () |
| Start the timer. | |
| void | stop () |
| Stop the timer. | |
| void | reset () |
| Reset the timer to 0. | |
| float | read () |
| Get the time passed in seconds. | |
| int | read_ms () |
| Get the time passed in milli-seconds. | |
| int | read_us () |
| Get the time passed in micro-seconds. | |
| operator float () | |
| An operator shorthand for read() | |
| us_timestamp_t | read_high_resolution_us () |
| Get in a high resolution type the time passed in micro-seconds. | |
Detailed Description
A general purpose timer.
- Note:
- Synchronization level: Interrupt safe
Example:
// Count the time to toggle a LED #include "mbed.h" Timer timer; DigitalOut led(LED1); int begin, end; int main() { timer.start(); begin = timer.read_us(); led = !led; end = timer.read_us(); printf("Toggle the led takes %d us", end - begin); }
Definition at line 49 of file OldTimer.h.
Member Function Documentation
| operator float | ( | ) |
An operator shorthand for read()
Definition at line 82 of file OldTimer.cpp.
| float read | ( | ) |
Get the time passed in seconds.
- Returns:
- Time passed in seconds
Definition at line 50 of file OldTimer.cpp.
| us_timestamp_t read_high_resolution_us | ( | ) |
Get in a high resolution type the time passed in micro-seconds.
Definition at line 58 of file OldTimer.cpp.
| int read_ms | ( | ) |
Get the time passed in milli-seconds.
- Returns:
- Time passed in milli seconds
Definition at line 54 of file OldTimer.cpp.
| int read_us | ( | ) |
Get the time passed in micro-seconds.
- Returns:
- Time passed in micro seconds
Definition at line 46 of file OldTimer.cpp.
| void reset | ( | ) |
Reset the timer to 0.
If it was already counting, it will continue
Definition at line 75 of file OldTimer.cpp.
| void start | ( | ) |
Start the timer.
Definition at line 30 of file OldTimer.cpp.
| void stop | ( | ) |
Stop the timer.
Definition at line 39 of file OldTimer.cpp.
Generated on Tue Jul 12 2022 21:37:29 by
1.7.2