Skip to content

Commit abb0a65

Browse files
committed
[Drivers] Let ticker support long us timestamp.
1 parent c90a3a0 commit abb0a65

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

drivers/Ticker.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ void Ticker::detach() {
2929
core_util_critical_section_exit();
3030
}
3131

32-
void Ticker::setup(timestamp_t t) {
32+
void Ticker::setup(us_timestamp_t t) {
3333
core_util_critical_section_enter();
3434
remove();
3535
_delay = t;
36-
insert(_delay + ticker_read(_ticker_data));
36+
insert_absolute(_delay + ticker_read_us(_ticker_data));
3737
core_util_critical_section_exit();
3838
}
3939

4040
void Ticker::handler() {
41-
insert(event.timestamp + _delay);
41+
insert_absolute(event.timestamp + _delay);
4242
_function();
4343
}
4444

drivers/Ticker.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class Ticker : public TimerEvent {
100100
* @param func pointer to the function to be called
101101
* @param t the time between calls in micro-seconds
102102
*/
103-
void attach_us(Callback<void()> func, timestamp_t t) {
103+
void attach_us(Callback<void()> func, us_timestamp_t t) {
104104
_function = func;
105105
setup(t);
106106
}
@@ -118,7 +118,7 @@ class Ticker : public TimerEvent {
118118
MBED_DEPRECATED_SINCE("mbed-os-5.1",
119119
"The attach_us function does not support cv-qualifiers. Replaced by "
120120
"attach_us(callback(obj, method), t).")
121-
void attach_us(T *obj, M method, timestamp_t t) {
121+
void attach_us(T *obj, M method, us_timestamp_t t) {
122122
attach_us(Callback<void()>(obj, method), t);
123123
}
124124

@@ -131,12 +131,12 @@ class Ticker : public TimerEvent {
131131
void detach();
132132

133133
protected:
134-
void setup(timestamp_t t);
134+
void setup(us_timestamp_t t);
135135
virtual void handler();
136136

137137
protected:
138-
timestamp_t _delay; /* Time delay (in microseconds) for re-setting the multi-shot callback. */
139-
Callback<void()> _function; /* Callback. */
138+
us_timestamp_t _delay; /**< Time delay (in microseconds) for re-setting the multi-shot callback. */
139+
Callback<void()> _function; /**< Callback. */
140140
};
141141

142142
} // namespace mbed

0 commit comments

Comments
 (0)