17
17
#include " hal/LowPowerTickerWrapper.h"
18
18
#include " platform/Callback.h"
19
19
20
+ using namespace mbed ::chrono;
21
+
20
22
LowPowerTickerWrapper::LowPowerTickerWrapper (const ticker_data_t *data, const ticker_interface_t *interface, uint32_t min_cycles_between_writes, uint32_t min_cycles_until_match)
21
23
: _intf(data->interface), _min_count_between_writes(min_cycles_between_writes + 1 ), _min_count_until_match(min_cycles_until_match + 1 ), _suspended(false )
22
24
{
@@ -247,12 +249,12 @@ bool LowPowerTickerWrapper::_match_check(timestamp_t current)
247
249
_ticker_match_interval_passed (_last_set_interrupt, current, _cur_match_time);
248
250
}
249
251
250
- uint32_t LowPowerTickerWrapper::_lp_ticks_to_us (uint32_t ticks)
252
+ microseconds_u32 LowPowerTickerWrapper::_lp_ticks_to_us (uint32_t ticks)
251
253
{
252
254
MBED_ASSERT (core_util_in_critical_section ());
253
255
254
256
// Add 4 microseconds to round up the micro second ticker time (which has a frequency of at least 250KHz - 4us period)
255
- return _us_per_tick * ticks + 4 ;
257
+ return microseconds_u32 ( _us_per_tick * ticks + 4 ) ;
256
258
}
257
259
258
260
void LowPowerTickerWrapper::_schedule_match (timestamp_t current)
@@ -277,7 +279,7 @@ void LowPowerTickerWrapper::_schedule_match(timestamp_t current)
277
279
// then don't schedule it again.
278
280
if (!_pending_timeout) {
279
281
uint32_t ticks = cycles_until_match < _min_count_until_match ? cycles_until_match : _min_count_until_match;
280
- _timeout.attach_us (mbed::callback (this , &LowPowerTickerWrapper::_timeout_handler), _lp_ticks_to_us (ticks));
282
+ _timeout.attach (mbed::callback (this , &LowPowerTickerWrapper::_timeout_handler), _lp_ticks_to_us (ticks));
281
283
_pending_timeout = true ;
282
284
}
283
285
return ;
@@ -309,7 +311,7 @@ void LowPowerTickerWrapper::_schedule_match(timestamp_t current)
309
311
// Low power ticker incremented to less than _min_count_until_match
310
312
// so low power ticker may not fire. Use Timeout to ensure it does fire.
311
313
uint32_t ticks = cycles_until_match < _min_count_until_match ? cycles_until_match : _min_count_until_match;
312
- _timeout.attach_us (mbed::callback (this , &LowPowerTickerWrapper::_timeout_handler), _lp_ticks_to_us (ticks));
314
+ _timeout.attach (mbed::callback (this , &LowPowerTickerWrapper::_timeout_handler), _lp_ticks_to_us (ticks));
313
315
_pending_timeout = true ;
314
316
return ;
315
317
}
0 commit comments