libpropeller
Making PropellerGCC Easier
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Enumerations
Enumerator
Macros
Pages
libpropeller
libpropeller
stopwatch
stopwatch.h
Go to the documentation of this file.
1
#ifndef LIBPROPELLER_STOPWATCH_H_
2
#define LIBPROPELLER_STOPWATCH_H_
3
4
5
#ifndef UNIT_TEST
6
#include <propeller.h>
7
#endif
8
9
// Yes, there is an compile warning here for redefine...
10
// It's because Unity includes propeller.h, which has CNT and CLKFREQ defined.
11
#ifdef UNIT_TEST
12
#define CNT unit_CNT
13
#define CLKFREQ unit_CLKFREQ
14
extern
unsigned
int
unit_CNT
;
15
extern
unsigned
int
unit_CLKFREQ
;
16
#endif
17
27
class
Stopwatch
{
28
public
:
29
33
Stopwatch
() {
34
Start
();
//This call suppresses a warning.
35
Reset
();
36
}
37
40
void
Reset
(
void
) {
41
started_ =
false
;
42
}
43
46
void
Start
(
void
) {
47
start_CNT_ = CNT;
48
started_ =
true
;
49
}
50
55
int
GetElapsed
(
void
)
const
{
56
if
(started_ ==
true
) {
57
return
(CNT - start_CNT_) / (CLKFREQ / 1000);
58
}
else
{
59
return
0;
60
}
61
}
62
67
bool
GetStarted
(
void
)
const
{
68
return
started_;
69
}
70
71
private
:
72
unsigned
int
start_CNT_;
73
bool
started_;
74
75
};
76
77
78
79
80
#endif // LIBPROPELLER_STOPWATCH_H_
Generated on Fri Oct 25 2013 23:41:46 for libpropeller by
1.8.4