[hal] Notifier: simplify ack API (#8457)

Adding an ack parameter to both set and cancel is cleaner than adding
all the set alarm parameters to the ack function. It also provides an
ack-and-cancel method.
This commit is contained in:
Peter Johnson
2025-12-09 20:28:15 -07:00
committed by GitHub
parent 936be71a7d
commit 06a9a055b3
12 changed files with 111 additions and 177 deletions

View File

@@ -25,8 +25,6 @@ void TimedRobot::StartCompetition() {
std::puts("\n********** Robot program startup complete **********");
HAL_ObserveUserProgramStarting();
bool first = true;
// Loop forever, calling the appropriate mode-dependent function
while (true) {
// We don't have to check there's an element in the queue first because
@@ -35,16 +33,9 @@ void TimedRobot::StartCompetition() {
auto callback = m_callbacks.pop();
int32_t status = 0;
if (first) {
first = false;
HAL_SetNotifierAlarm(m_notifier, callback.expirationTime.count(), 0, true,
&status);
WPILIB_CheckErrorStatus(status, "SetNotifierAlarm");
} else {
HAL_AcknowledgeNotifierAlarm(
m_notifier, true, callback.expirationTime.count(), 0, true, &status);
WPILIB_CheckErrorStatus(status, "AcknowledgeNotifierAlarm");
}
HAL_SetNotifierAlarm(m_notifier, callback.expirationTime.count(), 0, true,
true, &status);
WPILIB_CheckErrorStatus(status, "SetNotifierAlarm");
if (WPI_WaitForObject(m_notifier) == 0) {
break;