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.
Fork of HardwareTimersLib by
HardwareTimer.h
- Committer:
- mgottscho
- Date:
- 2014-03-08
- Revision:
- 0:47acc8320421
- Child:
- 2:5056ec8c52e8
File content as of revision 0:47acc8320421:
/* HardwareTimer.h
* Tested with mbed board: FRDM-KL46Z
* Author: Mark Gottscho
* mgottscho@ucla.edu
*/
#ifndef HARDWARETIMER_H
#define HARDWARETIMER_H
#include "mbed.h"
#include "PreciseTime.h"
/**
* This provides a base class from which actual hardware timers should derive their implementations.
* This allows for a nice software interface regardless of the particular timer used.
*/
class HardwareTimer {
public:
/**
* Constructs a new HardwareTimer.
* @param tickValue the amount of time corresponding to each timer tick. Units are arbitrary. Depends on specific timer clock rate.
*/
HardwareTimer(uint32_t tickValue);
~HardwareTimer();
/**
* @returns true if this timer is valid. If false, no timing mechanisms are functional.
*/
bool valid();
/**
* @returns true if the timer is running.
*/
bool isEnabled();
/**
* @returns the amount of time corresponding to each timer tick. Units are arbitrary. Depends on specific timer clock rate.
*/
float tickValue();
/**
* Enables the timer.
*/
virtual void enableTimer() = 0;
/**
* Disables the timer.
*/
virtual void disableTimer() = 0;
/**
* Gets the timer value in a nice form.
* Note that in general, the timer may overflow, leading to saturated values obtained from getTime().
* To maximize resolution, accuracy, performance, and range, it is recommended to use
* getTick() for most purposes. getTime() is mostly for convenience.
* @returns the current tick converted into a PreciseTime representation.
*/
virtual PreciseTime getTime() = 0;
/**
* @returns the current tick number. Convert to real time units by multiplying by tickValue(), which may have arbitrary units.
*/
virtual uint32_t getTick() = 0;
protected:
bool __valid;
bool __enabled;
uint32_t __tickValue; //how many <units> per tick
};
#endif
