Modification of Mbed-dev library for LQFP48 package microcontrollers: STM32F103C8 (STM32F103C8T6) and STM32F103CB (STM32F103CBT6) (Bluepill boards, Maple mini etc. )

Fork of mbed-STM32F103C8_org by Nothing Special

Embed: (wiki syntax)

« Back to documentation index

Timer Class Reference

Timer Class Reference
[Drivers]

A general purpose timer. More...

#include <Timer.h>

Inherited by LowPowerTimer.

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 mili-seconds.
int read_us ()
 Get the time passed in micro-seconds.
 operator float ()
 An operator shorthand for read()

Detailed Description

A general purpose timer.

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 Timer.h.