1717#include " hal/LowPowerTickerWrapper.h"
1818#include " platform/Callback.h"
1919
20+ using namespace mbed ::chrono;
21+
2022LowPowerTickerWrapper::LowPowerTickerWrapper (const ticker_data_t *data, const ticker_interface_t *interface, uint32_t min_cycles_between_writes, uint32_t min_cycles_until_match)
2123 : _intf(data->interface), _min_count_between_writes(min_cycles_between_writes + 1 ), _min_count_until_match(min_cycles_until_match + 1 ), _suspended(false )
2224{
@@ -247,12 +249,12 @@ bool LowPowerTickerWrapper::_match_check(timestamp_t current)
247249 _ticker_match_interval_passed (_last_set_interrupt, current, _cur_match_time);
248250}
249251
250- uint32_t LowPowerTickerWrapper::_lp_ticks_to_us (uint32_t ticks)
252+ microseconds_u32 LowPowerTickerWrapper::_lp_ticks_to_us (uint32_t ticks)
251253{
252254 MBED_ASSERT (core_util_in_critical_section ());
253255
254256 // 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 ) ;
256258}
257259
258260void LowPowerTickerWrapper::_schedule_match (timestamp_t current)
@@ -277,7 +279,7 @@ void LowPowerTickerWrapper::_schedule_match(timestamp_t current)
277279 // then don't schedule it again.
278280 if (!_pending_timeout) {
279281 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));
281283 _pending_timeout = true ;
282284 }
283285 return ;
@@ -309,7 +311,7 @@ void LowPowerTickerWrapper::_schedule_match(timestamp_t current)
309311 // Low power ticker incremented to less than _min_count_until_match
310312 // so low power ticker may not fire. Use Timeout to ensure it does fire.
311313 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));
313315 _pending_timeout = true ;
314316 return ;
315317 }
0 commit comments