The alarm family of functions are used for creating alarms which call a callback or wake up waiting threads after a period of time.
More...
The alarm family of functions are used for creating alarms which call a callback or wake up waiting threads after a period of time.
Alarms can be one shot alarms which trigger once after a period of time, or periodic which trigger at regular intervals until they are cancelled.
◆ OSAlarmQueue
Definition at line 32 of file alarm.h.
Data Fields |
uint32_t |
tag |
Should always be set to the value OS_ALARM_QUEUE_TAG. |
const char * |
name |
Name set by OSInitAlarmQueueEx. |
OSThreadQueue |
threadQueue |
|
OSAlarm * |
head |
|
OSAlarm * |
tail |
|
◆ OSAlarmLink
◆ OSAlarm
Definition at line 62 of file alarm.h.
Data Fields |
uint32_t |
tag |
Should always be set to the value OS_ALARM_TAG. |
const char * |
name |
Name set from OSCreateAlarmEx. |
OSAlarmCallback |
callback |
The callback to execute once the alarm is triggered. |
uint32_t |
group |
Used with OSCancelAlarms for bulk cancellation of alarms. |
OSTime |
nextFire |
The time when the alarm will next be triggered. |
OSAlarmLink |
link |
Link used for when this OSAlarm object is inside an OSAlarmQueue. |
OSTime |
period |
The period between alarm triggers, this is only set for periodic alarms. |
OSTime |
start |
The time the alarm was started. |
void * |
userData |
User data set with OSSetAlarmUserData and retrieved with OSGetAlarmUserData. |
uint32_t |
state |
The current state of the alarm, internal values. |
OSThreadQueue |
threadQueue |
Queue of threads currently waiting for the alarm to trigger with OSWaitAlarm. |
OSAlarmQueue * |
alarmQueue |
The queue that this alarm is currently in. |
OSContext * |
context |
The context the alarm was triggered on. |
◆ OS_ALARM_QUEUE_TAG
#define OS_ALARM_QUEUE_TAG 0x614C6D51u |
◆ OS_ALARM_TAG
#define OS_ALARM_TAG 0x614C724Du |
◆ OSAlarm
◆ OSAlarmLink
◆ OSAlarmQueue
◆ OSAlarmCallback
◆ OSCancelAlarm()
◆ OSCancelAlarms()
void OSCancelAlarms |
( |
uint32_t |
group | ) |
|
Cancel all alarms which have a matching tag set by OSSetAlarmTag.
- Parameters
-
group | The alarm tag to cancel. |
◆ OSCreateAlarm()
void OSCreateAlarm |
( |
OSAlarm * |
alarm | ) |
|
Initialise an alarm structure.
◆ OSCreateAlarmEx()
void OSCreateAlarmEx |
( |
OSAlarm * |
alarm, |
|
|
const char * |
name |
|
) |
| |
Initialise an alarm structure with a name.
◆ OSGetAlarmUserData()
void* OSGetAlarmUserData |
( |
OSAlarm * |
alarm | ) |
|
Return user data set by OSSetAlarmUserData.
◆ OSInitAlarmQueue()
Initialise an alarm queue structure.
◆ OSInitAlarmQueueEx()
void OSInitAlarmQueueEx |
( |
OSAlarmQueue * |
queue, |
|
|
const char * |
name |
|
) |
| |
Initialise an alarm queue structure with a name.
◆ OSSetAlarm()
Set a one shot alarm to perform a callback after a set amount of time.
- Parameters
-
alarm | The alarm to set. |
time | The duration until the alarm should be triggered. |
callback | The alarm callback to call when the alarm is triggered. |
◆ OSSetPeriodicAlarm()
Set a repeated alarm to execute a callback every interval from start.
- Parameters
-
alarm | The alarm to set. |
start | The duration until the alarm should first be triggered. |
interval | The interval between triggers after the first trigger. |
callback | The alarm callback to call when the alarm is triggered. |
◆ OSSetAlarmTag()
void OSSetAlarmTag |
( |
OSAlarm * |
alarm, |
|
|
uint32_t |
group |
|
) |
| |
Set an alarm tag which is used in OSCancelAlarms for bulk cancellation.
◆ OSSetAlarmUserData()
void OSSetAlarmUserData |
( |
OSAlarm * |
alarm, |
|
|
void * |
data |
|
) |
| |
Set alarm user data which is returned by OSGetAlarmUserData.
◆ OSWaitAlarm()
Sleep the current thread until the alarm has been triggered or cancelled.