40 #include "utils/wrap_stdint.h" 53 class TimerMilliScheduler;
77 kMaxDt = (1UL << 31) - 1,
134 void Fired(
void) { mHandler(*
this); }
157 Timer(aInstance, aHandler, aContext) {
167 void Start(uint32_t aDt) { StartAt(GetNow(), aDt); }
177 void StartAt(uint32_t aT0, uint32_t aDt);
199 static uint32_t
SecToMsec(uint32_t aSeconds) {
return aSeconds * 1000u; }
207 static uint32_t
MsecToSec(uint32_t aMilliseconds) {
return aMilliseconds / 1000u; }
235 void (*AlarmStartAt)(
otInstance *aInstance, uint32_t aT0, uint32_t aDt);
237 uint32_t (*AlarmGetNow)(void);
275 void ProcessTimers(
const AlarmApi &aAlarmApi);
283 void SetAlarm(
const AlarmApi &aAlarmApi);
298 static bool IsStrictlyBefore(uint32_t aTimeA, uint32_t aTimeB);
343 static const AlarmApi sAlarmMilliApi;
346 #if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER 347 class TimerMicroScheduler;
353 class TimerMicro:
public Timer 365 Timer(aInstance, aHandler, aContext) {
375 void Start(uint32_t aDt) { StartAt(GetNow(), aDt); }
385 void StartAt(uint32_t aT0, uint32_t aDt);
408 TimerMicroScheduler &GetTimerMicroScheduler(
void)
const;
451 static const AlarmApi sAlarmMicroApi;
453 #endif // OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER This type represents all the static / global variables used by OpenThread allocated in one place...
Definition: openthread-instance.h:59
void Start(uint32_t aDt)
This method schedules the timer to fire a dt milliseconds from now.
Definition: timer.hpp:167
This file defines the types and structures used in the OpenThread library API.
void Add(TimerMilli &aTimer)
This method adds a timer instance to the timer scheduler.
Definition: timer.hpp:326
void(* Handler)(Timer &aTimer)
This function pointer is called when the timer expires.
Definition: timer.hpp:86
This file includes the platform abstraction for the microsecond alarm service.
This file includes definitions for locator class for OpenThread objects.
static uint32_t SecToMsec(uint32_t aSeconds)
This static method returns the number of milliseconds given seconds.
Definition: timer.hpp:199
TimerMilliScheduler(otInstance &aInstance)
This constructor initializes the object.
Definition: timer.hpp:316
uint32_t otPlatAlarmMicroGetNow(void)
Get the current time.
This file includes definitions for maintaining a pointer to arbitrary context information.
This class implements the base timer scheduler.
Definition: timer.hpp:224
This class implements a timer.
Definition: timer.hpp:69
This file includes the platform abstraction for the millisecond alarm service.
This class implements the millisecond timer.
Definition: timer.hpp:145
Timer(otInstance &aInstance, Handler aHandler, void *aContext)
This constructor creates a timer instance.
Definition: timer.hpp:96
void Remove(Timer &aTimer, const AlarmApi &aAlarmApi)
This method removes a timer instance to the timer scheduler.
Definition: timer.cpp:138
void ProcessTimers(const AlarmApi &aAlarmApi)
This method processes the running timers.
Definition: timer.cpp:180
uint32_t GetFireTime(void) const
This method returns the fire time of the timer.
Definition: timer.hpp:110
static uint32_t MsecToSec(uint32_t aMilliseconds)
This static method returns the number of seconds given milliseconds.
Definition: timer.hpp:207
bool IsRunning(void) const
This method indicates whether or not the timer instance is running.
Definition: timer.hpp:119
This class implements definitions for maintaining a pointer to arbitrary context information.
Definition: context.hpp:61
This file includes definitions for tasklets and the tasklet scheduler.
The Alarm APIs definition.
Definition: timer.hpp:233
This class implements locator for otInstance object.
Definition: locator.hpp:63
TimerScheduler(otInstance &aInstance)
This constructor initializes the object.
Definition: timer.hpp:246
This file includes functions for debugging.
void Remove(TimerMilli &aTimer)
This method removes a timer instance to the timer scheduler.
Definition: timer.hpp:334
void ProcessTimers(void)
This method processes the running timers.
Definition: timer.hpp:340
bool DoesFireBefore(const Timer &aTimer, uint32_t aNow)
This method indicates if the fire time of this timer is strictly before the fire time of a second giv...
Definition: timer.cpp:52
void Add(Timer &aTimer, const AlarmApi &aAlarmApi)
This method adds a timer instance to the timer scheduler.
Definition: timer.cpp:93
static uint32_t GetNow(void)
This static method returns the current time in milliseconds.
Definition: timer.hpp:191
This file includes compile-time configuration constants for OpenThread.
uint32_t otPlatAlarmMilliGetNow(void)
Get the current time.
TimerMilli(otInstance &aInstance, Handler aHandler, void *aContext)
This constructor creates a millisecond timer instance.
Definition: timer.hpp:156
This class implements the millisecond timer scheduler.
Definition: timer.hpp:307