Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit 1b1ed81

Browse files
committed
Added support for low-power timers in mbed implementation
Conditionally selected based on DEVICE_LOWPOWERTIMER
1 parent 65d27b2 commit 1b1ed81

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

equeue_mbed.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,18 @@
1313

1414
#include <stdbool.h>
1515
#include "mbed.h"
16-
#ifdef MBED_CONF_RTOS_PRESENT
17-
#include "rtos.h"
18-
#endif
1916

2017

2118
// Ticker operations
22-
static class GlobalTicker {
19+
class EqueueTicker {
2320
public:
24-
GlobalTicker() {
21+
EqueueTicker() {
2522
_tick = 0;
2623
_timer.start();
27-
_ticker.attach_us(this, &GlobalTicker::step, (1 << 16) * 1000);
24+
_ticker.attach_us(this, &EqueueTicker::update, (1 << 16) * 1000);
2825
};
2926

30-
void step() {
27+
void update() {
3128
_timer.reset();
3229
_tick += 1 << 16;
3330
}
@@ -38,12 +35,19 @@ static class GlobalTicker {
3835

3936
private:
4037
unsigned _tick;
38+
#ifdef DEVICE_LOWPOWERTIMER
39+
LowPowerTimer _timer;
40+
LowPowerTicker _ticker;
41+
#else
4142
Timer _timer;
4243
Ticker _ticker;
43-
} gticker;
44+
#endif
45+
};
46+
47+
static EqueueTicker equeue_ticker;
4448

4549
unsigned equeue_tick() {
46-
return gticker.tick();
50+
return equeue_ticker.tick();
4751
}
4852

4953

0 commit comments

Comments
 (0)