WPILibC++ 2023.4.3-108-ge5452e3
Interrupts.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 "hal/AnalogTrigger.h"
10#include "hal/Types.h"
11
12/**
13 * @defgroup hal_interrupts Interrupts Functions
14 * @ingroup hal_capi
15 * @{
16 */
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/**
23 * Initializes an interrupt.
24 *
25 * @param[out] status Error status variable. 0 on success.
26 * @return the created interrupt handle
27 */
29
30/**
31 * Frees an interrupt.
32 *
33 * @param interruptHandle the interrupt handle
34 */
36
37/**
38 * Waits for the defined interrupt to occur.
39 *
40 * @param[in] interruptHandle the interrupt handle
41 * @param[in] timeout timeout in seconds
42 * @param[in] ignorePrevious if true, ignore interrupts that happened before
43 * waitForInterrupt was called
44 * @param[out] status Error status variable. 0 on success.
45 * @return the mask of interrupts that fired
46 */
48 double timeout, HAL_Bool ignorePrevious,
49 int32_t* status);
50
51/**
52 * Waits for any interrupt covered by the mask to occur.
53 *
54 * @param[in] interruptHandle the interrupt handle to use for the context
55 * @param[in] mask the mask of interrupts to wait for
56 * @param[in] timeout timeout in seconds
57 * @param[in] ignorePrevious if true, ignore interrupts that happened before
58 * waitForInterrupt was called
59 * @param[out] status Error status variable. 0 on success.
60 * @return the mask of interrupts that fired
61 */
63 int64_t mask, double timeout,
64 HAL_Bool ignorePrevious, int32_t* status);
65
66/**
67 * Returns the timestamp for the rising interrupt that occurred most recently.
68 *
69 * This is in the same time domain as HAL_GetFPGATime(). It only contains the
70 * bottom 32 bits of the timestamp. If your robot has been running for over 1
71 * hour, you will need to fill in the upper 32 bits yourself.
72 *
73 * @param[in] interruptHandle the interrupt handle
74 * @param[out] status Error status variable. 0 on success.
75 * @return timestamp in microseconds since FPGA Initialization
76 */
78 int32_t* status);
79
80/**
81 * Returns the timestamp for the falling interrupt that occurred most recently.
82 *
83 * This is in the same time domain as HAL_GetFPGATime(). It only contains the
84 * bottom 32 bits of the timestamp. If your robot has been running for over 1
85 * hour, you will need to fill in the upper 32 bits yourself.
86 *
87 * @param[in] interruptHandle the interrupt handle
88 * @param[out] status Error status variable. 0 on success.
89 * @return timestamp in microseconds since FPGA Initialization
90 */
92 int32_t* status);
93
94/**
95 * Requests interrupts on a specific digital source.
96 *
97 * @param[in] interruptHandle the interrupt handle
98 * @param[in] digitalSourceHandle the digital source handle (either a
99 * HAL_AnalogTriggerHandle or a
100 * HAL_DigitalHandle)
101 * @param[in] analogTriggerType the trigger type if the source is an
102 * AnalogTrigger
103 * @param[out] status Error status variable. 0 on success.
104 */
106 HAL_Handle digitalSourceHandle,
107 HAL_AnalogTriggerType analogTriggerType,
108 int32_t* status);
109
110/**
111 * Sets the edges to trigger the interrupt on.
112 *
113 * Note that both edges triggered is a valid configuration.
114 *
115 * @param[in] interruptHandle the interrupt handle
116 * @param[in] risingEdge true for triggering on rising edge
117 * @param[in] fallingEdge true for triggering on falling edge
118 * @param[out] status Error status variable. 0 on success.
119 */
121 HAL_Bool risingEdge, HAL_Bool fallingEdge,
122 int32_t* status);
123
124/**
125 * Releases a waiting interrupt.
126 *
127 * This will release both rising and falling waiters.
128 *
129 * @param[in] interruptHandle the interrupt handle to release
130 * @param[out] status Error status variable. 0 on success.
131 */
133 int32_t* status);
134#ifdef __cplusplus
135} // extern "C"
136#endif
137/** @} */
HAL_AnalogTriggerType
The type of analog trigger to trigger on.
Definition: AnalogTrigger.h:21
int64_t HAL_ReadInterruptFallingTimestamp(HAL_InterruptHandle interruptHandle, int32_t *status)
Returns the timestamp for the falling interrupt that occurred most recently.
void HAL_RequestInterrupts(HAL_InterruptHandle interruptHandle, HAL_Handle digitalSourceHandle, HAL_AnalogTriggerType analogTriggerType, int32_t *status)
Requests interrupts on a specific digital source.
void HAL_ReleaseWaitingInterrupt(HAL_InterruptHandle interruptHandle, int32_t *status)
Releases a waiting interrupt.
void HAL_CleanInterrupts(HAL_InterruptHandle interruptHandle)
Frees an interrupt.
void HAL_SetInterruptUpSourceEdge(HAL_InterruptHandle interruptHandle, HAL_Bool risingEdge, HAL_Bool fallingEdge, int32_t *status)
Sets the edges to trigger the interrupt on.
int64_t HAL_WaitForInterrupt(HAL_InterruptHandle interruptHandle, double timeout, HAL_Bool ignorePrevious, int32_t *status)
Waits for the defined interrupt to occur.
HAL_InterruptHandle HAL_InitializeInterrupts(int32_t *status)
Initializes an interrupt.
int64_t HAL_ReadInterruptRisingTimestamp(HAL_InterruptHandle interruptHandle, int32_t *status)
Returns the timestamp for the rising interrupt that occurred most recently.
int64_t HAL_WaitForMultipleInterrupts(HAL_InterruptHandle interruptHandle, int64_t mask, double timeout, HAL_Bool ignorePrevious, int32_t *status)
Waits for any interrupt covered by the mask to occur.
int32_t HAL_Bool
Definition: Types.h:73
int32_t HAL_Handle
Definition: Types.h:17
HAL_Handle HAL_InterruptHandle
Definition: Types.h:41
::int32_t int32_t
Definition: Meta.h:57
::int64_t int64_t
Definition: Meta.h:59