WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
Notifier.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stdint.h>
8
9#include "wpi/hal/Types.h"
10#include "wpi/util/string.h"
11
12/**
13 * @defgroup hal_notifier Notifier Functions
14 * @ingroup hal_capi
15 * @{
16 */
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/**
23 * Creates a notifier.
24 *
25 * A notifier is an timer that alarms at an initial and (optionally) repeated
26 * intervals. This can be used to make precise control loops.
27 *
28 * @param[out] status Error status variable. 0 on success.
29 * @return the created notifier
30 */
32
33/**
34 * Sets the HAL notifier thread priority.
35 *
36 * The HAL notifier thread is responsible for managing the system's notifier
37 * interrupt and waking up user's Notifiers when it's their time to run.
38 * Giving the HAL notifier thread real-time priority helps ensure the user's
39 * real-time Notifiers, if any, are notified to run in a timely manner.
40 *
41 * @param[in] realTime Set to true to set a real-time priority, false for
42 * standard priority.
43 * @param[in] priority Priority to set the thread to. For real-time, this is
44 * 1-99 with 99 being highest. For non-real-time, this is
45 * forced to 0. See "man 7 sched" for more details.
46 * @param[out] status Error status variable. 0 on success.
47 * @return True on success.
48 */
50 int32_t* status);
51
52/**
53 * Sets the name of a notifier.
54 *
55 * @param[in] notifierHandle the notifier handle
56 * @param[in] name name
57 * @param[out] status Error status variable. 0 on success.
58 */
60 const struct WPI_String* name, int32_t* status);
61
62/**
63 * Destroys a notifier.
64 *
65 * Destruction wakes up any waiters.
66 *
67 * @param[in] notifierHandle the notifier handle
68 */
70
71/**
72 * Updates the initial and interval alarm times for a notifier.
73 *
74 * The alarmTime is an absolute time (using the WPI_Now() time base) if
75 * absolute is true, or relative to the current time if absolute is false.
76 *
77 * If intervalTime is non-zero, the notifier will alarm periodically following
78 * alarmTime at the given interval.
79 *
80 * If an absolute alarmTime is in the past, the notifier will alarm immediately.
81 *
82 * @param[in] notifierHandle the notifier handle
83 * @param[in] alarmTime the first alarm time (in microseconds)
84 * @param[in] intervalTime the periodic interval time (in microseconds)
85 * @param[in] absolute true if the alarm time is absolute
86 * @param[in] ack true to acknowledge any prior alarm
87 * @param[out] status Error status variable. 0 on success.
88 */
89void HAL_SetNotifierAlarm(HAL_NotifierHandle notifierHandle, uint64_t alarmTime,
90 uint64_t intervalTime, HAL_Bool absolute,
91 HAL_Bool ack, int32_t* status);
92
93/**
94 * Cancels all future notifier alarms for a notifier.
95 *
96 * @param[in] notifierHandle the notifier handle
97 * @param[in] ack true to acknowledge any prior alarm
98 * @param[out] status Error status variable. 0 on success.
99 */
101 int32_t* status);
102
103/**
104 * Indicates the notifier alarm has been serviced. Makes no change to future
105 * alarms.
106 *
107 * One of HAL_SetNotifierAlarm (with ack=true), HAL_CancelNotifierAlarm (with
108 * ack=true), or this function must be called before waiting for the next alarm.
109 *
110 * @param[in] notifierHandle the notifier handle
111 * @param[out] status Error status variable. 0 on success.
112 */
114 int32_t* status);
115
116/**
117 * Gets the overrun count for a notifier.
118 *
119 * An overrun occurs when a notifier's alarm is not serviced before the next
120 * scheduled alarm time.
121 *
122 * @param[in] notifierHandle the notifier handle
123 * @param[out] status Error status variable. 0 on success.
124 * @return overrun count
125 */
127 int32_t* status);
128
129#ifdef __cplusplus
130} // extern "C"
131#endif
132/** @} */
@ name
Definition base.h:690
int32_t HAL_GetNotifierOverrun(HAL_NotifierHandle notifierHandle, int32_t *status)
Gets the overrun count for a notifier.
HAL_Bool HAL_SetNotifierThreadPriority(HAL_Bool realTime, int32_t priority, int32_t *status)
Sets the HAL notifier thread priority.
void HAL_DestroyNotifier(HAL_NotifierHandle notifierHandle)
Destroys a notifier.
void HAL_AcknowledgeNotifierAlarm(HAL_NotifierHandle notifierHandle, int32_t *status)
Indicates the notifier alarm has been serviced.
void HAL_SetNotifierAlarm(HAL_NotifierHandle notifierHandle, uint64_t alarmTime, uint64_t intervalTime, HAL_Bool absolute, HAL_Bool ack, int32_t *status)
Updates the initial and interval alarm times for a notifier.
void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle, HAL_Bool ack, int32_t *status)
Cancels all future notifier alarms for a notifier.
void HAL_SetNotifierName(HAL_NotifierHandle notifierHandle, const struct WPI_String *name, int32_t *status)
Sets the name of a notifier.
HAL_NotifierHandle HAL_CreateNotifier(int32_t *status)
Creates a notifier.
int32_t HAL_Bool
Definition Types.h:75
HAL_Handle HAL_NotifierHandle
Definition Types.h:43
A const UTF8 string.
Definition string.h:12