mbed-drivers
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mbed::Timer Class Reference

#include <Timer.h>

Public Member Functions

 Timer (const ticker_data_t *const data)
 
void start ()
 
void stop ()
 
void reset ()
 
float read ()
 
int read_ms ()
 
int read_us ()
 
 operator float ()
 

Protected Member Functions

int slicetime ()
 

Protected Attributes

int _running
 
unsigned int _start
 
int _time
 
const ticker_data_t *const _ticker_data
 

Detailed Description

A general purpose timer

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);
}

Member Function Documentation

float mbed::Timer::read ( )

Get the time passed in seconds

int mbed::Timer::read_ms ( )

Get the time passed in mili-seconds

int mbed::Timer::read_us ( )

Get the time passed in micro-seconds

void mbed::Timer::reset ( )

Reset the timer to 0.

If it was already counting, it will continue

void mbed::Timer::start ( void  )

Start the timer

void mbed::Timer::stop ( void  )

Stop the timer


The documentation for this class was generated from the following files: