File tree Expand file tree Collapse file tree 2 files changed +7
-41
lines changed Expand file tree Collapse file tree 2 files changed +7
-41
lines changed Original file line number Diff line number Diff line change @@ -143,21 +143,4 @@ extern analogin_config_t adcCurrentConfig;
143
143
144
144
#include " macros.h"
145
145
146
- /* *
147
- * Power Management
148
- **/
149
-
150
- #if DEVICE_LPTICKER
151
- /* *
152
- * Enables the low power timer being used by the timing functions
153
- * millis() and micros()
154
- * */
155
- void enableLowPowerTimer ();
156
-
157
- /* *
158
- * Disables the low power timer
159
- * */
160
- void disableLowPowerTimer ();
161
- #endif
162
-
163
146
#endif
Original file line number Diff line number Diff line change @@ -33,37 +33,19 @@ static mbed::Timer timer;
33
33
34
34
#if DEVICE_LPTICKER
35
35
static mbed::LowPowerTimer lowPowerTimer;
36
- static bool useLowPowerTimer = false ;
37
-
38
- void enableLowPowerTimer (){
39
- timer.stop ();
40
- useLowPowerTimer = true ;
41
- lowPowerTimer.start ();
42
- }
43
-
44
- void disableLowPowerTimer (){
45
- lowPowerTimer.stop ();
46
- useLowPowerTimer = false ;
47
- timer.start ();
48
- }
36
+ #else
37
+ // Fallback for devices which don't support
38
+ // a low power ticker.
39
+ static mbed::Timer lowPowerTimer;
49
40
#endif
50
41
51
-
52
- std::chrono::microseconds elapsedTime (){
53
- #if DEVICE_LPTICKER
54
- return useLowPowerTimer ? lowPowerTimer.elapsed_time () : timer.elapsed_time ();
55
- #else
56
- return timer.elapsed_time ();
57
- #endif
58
- }
59
-
60
42
unsigned long millis ()
61
43
{
62
- return duration_cast<milliseconds>(elapsedTime ()).count ();
44
+ return duration_cast<milliseconds>(lowPowerTimer. elapsed_time ()).count ();
63
45
}
64
46
65
47
unsigned long micros () {
66
- return elapsedTime ().count ();
48
+ return timer. elapsed_time ().count ();
67
49
}
68
50
69
51
void delay (unsigned long ms)
@@ -83,6 +65,7 @@ void delayMicroseconds(unsigned int us)
83
65
void init ()
84
66
{
85
67
timer.start ();
68
+ lowPowerTimer.start ();
86
69
}
87
70
88
71
void yield () {
You can’t perform that action at this time.
0 commit comments