WPILibC++ 2027.0.0-alpha-5
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 name of a notifier.
35 *
36 * @param[in] notifierHandle the notifier handle
37 * @param[in] name name
38 * @param[out] status Error status variable. 0 on success.
39 */
41 const struct WPI_String* name, int32_t* status);
42
43/**
44 * Destroys a notifier.
45 *
46 * Destruction wakes up any waiters.
47 *
48 * @param[in] notifierHandle the notifier handle
49 */
51
52/**
53 * Updates the initial and interval alarm times for a notifier.
54 *
55 * The alarmTime is an absolute time (using the WPI_Now() time base) if
56 * absolute is true, or relative to the current time if absolute is false.
57 *
58 * If intervalTime is non-zero, the notifier will alarm periodically following
59 * alarmTime at the given interval.
60 *
61 * If an absolute alarmTime is in the past, the notifier will alarm immediately.
62 *
63 * @param[in] notifierHandle the notifier handle
64 * @param[in] alarmTime the first alarm time (in microseconds)
65 * @param[in] intervalTime the periodic interval time (in microseconds)
66 * @param[in] absolute true if the alarm time is absolute
67 * @param[in] ack true to acknowledge any prior alarm
68 * @param[out] status Error status variable. 0 on success.
69 */
70void HAL_SetNotifierAlarm(HAL_NotifierHandle notifierHandle, uint64_t alarmTime,
71 uint64_t intervalTime, HAL_Bool absolute,
72 HAL_Bool ack, int32_t* status);
73
74/**
75 * Cancels all future notifier alarms for a notifier.
76 *
77 * @param[in] notifierHandle the notifier handle
78 * @param[in] ack true to acknowledge any prior alarm
79 * @param[out] status Error status variable. 0 on success.
80 */
82 int32_t* status);
83
84/**
85 * Indicates the notifier alarm has been serviced. Makes no change to future
86 * alarms.
87 *
88 * One of HAL_SetNotifierAlarm (with ack=true), HAL_CancelNotifierAlarm (with
89 * ack=true), or this function must be called before waiting for the next alarm.
90 *
91 * @param[in] notifierHandle the notifier handle
92 * @param[out] status Error status variable. 0 on success.
93 */
95 int32_t* status);
96
97/**
98 * Gets the overrun count for a notifier.
99 *
100 * An overrun occurs when a notifier's alarm is not serviced before the next
101 * scheduled alarm time.
102 *
103 * @param[in] notifierHandle the notifier handle
104 * @param[out] status Error status variable. 0 on success.
105 * @return overrun count
106 */
108 int32_t* status);
109
110#ifdef __cplusplus
111} // extern "C"
112#endif
113/** @} */
@ name
Definition base.h:690
int32_t HAL_GetNotifierOverrun(HAL_NotifierHandle notifierHandle, int32_t *status)
Gets the overrun count for a notifier.
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:65
HAL_Handle HAL_NotifierHandle
Definition Types.h:37
A const UTF8 string.
Definition string.h:40