Skip to content

Commit 4ba9e9c

Browse files
committed
Removed float symbols from Ticker module
Cast rvalue to `int` type when forwarding the call to get rid of float operation. Using Perfect forwarding alone previously removed the float until the compiler upgrade.
1 parent d847f9f commit 4ba9e9c

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

drivers/Ticker.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,12 @@ class Ticker : public TimerEvent, private NonCopyable<Ticker> {
7676

7777
/** Attach a function to be called by the Ticker, specifying the interval in seconds
7878
*
79-
* The method forwards its arguments to attach_us() rather than copying them which
80-
* may not be trivial depending on the callback copied.
81-
* The function is forcibly inlined to not use floating-point operations. This is
82-
* possible given attach_us() expects an integer value for the callback interval.
8379
* @param func pointer to the function to be called
8480
* @param t the time between calls in seconds
8581
*/
86-
#if defined(__ICCARM__)
87-
MBED_FORCEINLINE template <typename F>
88-
#else
89-
template <typename F> MBED_FORCEINLINE
90-
#endif
91-
void attach(F &&func, float t)
82+
MBED_FORCEINLINE void attach(Callback<void()> func, float t)
9283
{
93-
attach_us(std::forward<F>(func), t * 1000000.0f);
84+
attach_us(func, (int)(t * 1000000));
9485
}
9586

9687
/** Attach a member function to be called by the Ticker, specifying the interval in seconds

0 commit comments

Comments
 (0)