WPILibC++ 2027.0.0-alpha-2
Loading...
Searching...
No Matches
CTREPCM.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/Types.h"
10
11/**
12 * @defgroup hal_ctre_pcm CTRE Pneumatic Control Module (PCM) Functions
13 * @ingroup hal_capi
14 * @{
15 */
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/**
22 * Initializes a PCM.
23 *
24 * @param[in] busId the CAN bus ID
25 * @param[in] module the CAN ID to initialize
26 * @param[in] allocationLocation the location where the allocation is occurring
27 * (can be null)
28 * @param[out] status Error status variable. 0 on success.
29 * @return the created PH handle
30 */
31HAL_CTREPCMHandle HAL_InitializeCTREPCM(int32_t busId, int32_t module,
32 const char* allocationLocation,
33 int32_t* status);
34
35/**
36 * Frees a PCM handle.
37 *
38 * @param[in] handle the PCMhandle
39 */
41
42/**
43 * Checks if a solenoid channel number is valid.
44 *
45 * @param[in] channel the channel to check
46 * @return true if the channel is valid, otherwise false
47 */
49
50/**
51 * Get whether compressor is turned on.
52 *
53 * @param[in] handle the PCM handle
54 * @param[out] status Error status variable. 0 on success.
55 * @return true if the compressor is turned on
56 */
58
59/**
60 * Enables the compressor closed loop control using the digital pressure switch.
61 * The compressor will turn on when the pressure switch indicates that the
62 * system is not full, and will turn off when the pressure switch indicates that
63 * the system is full.
64 *
65 * @param[in] handle the PCM handle
66 * @param[in] enabled true to enable closed loop control
67 * @param[out] status Error status variable. 0 on success.
68 */
70 int32_t* status);
71
72/**
73 * Get whether the PCM closed loop control is enabled.
74 *
75 * @param[in] handle the PCM handle
76 * @param[out] status Error status variable. 0 on success.
77 * @return True if closed loop control is enabled, otherwise false.
78 */
80 int32_t* status);
81
82/**
83 * Returns the state of the pressure switch.
84 *
85 * @param[in] handle the PCM handle
86 * @param[out] status Error status variable. 0 on success.
87 * @return True if pressure switch indicates that the system is full,
88 * otherwise false.
89 */
91 int32_t* status);
92
93/**
94 * Returns the current drawn by the compressor.
95 *
96 * @param[in] handle the PCM handle
97 * @param[out] status Error status variable. 0 on success.
98 * @return The current drawn by the compressor in amps.
99 */
101 int32_t* status);
102
103/**
104 * Return whether the compressor current is currently too high.
105 *
106 * @param[in] handle the PCM handle
107 * @param[out] status Error status variable. 0 on success.
108 * @return True if the compressor current is too high, otherwise false.
109 * @see HAL_GetCTREPCMCompressorShortedStickyFault
110 */
112 int32_t* status);
113
114/**
115 * Returns whether the compressor current has been too high since sticky
116 * faults were last cleared. This fault is persistent and can be cleared by
117 * HAL_ClearAllCTREPCMStickyFaults()
118 *
119 * @param[in] handle the PCM handle
120 * @param[out] status Error status variable. 0 on success.
121 * @return True if the compressor current has been too high since sticky
122 * faults were last cleared.
123 * @see HAL_GetCTREPCMCompressorCurrentTooHighFault()
124 */
126 HAL_CTREPCMHandle handle, int32_t* status);
127
128/**
129 * Returns whether the compressor has been shorted since sticky faults were
130 * last cleared. This fault is persistent and can be cleared by
131 * HAL_ClearAllCTREPCMStickyFaults()
132 *
133 * @param[in] handle the PCM handle
134 * @param[out] status Error status variable. 0 on success.
135 * @return True if the compressor has been shorted since sticky faults were
136 * last cleared, otherwise false.
137 * @see HAL_GetCTREPCMCompressorShortedFault()
138 */
140 int32_t* status);
141
142/**
143 * Returns whether the compressor is currently shorted.
144 *
145 * @param[in] handle the PCM handle
146 * @param[out] status Error status variable. 0 on success.
147 * @return True if the compressor is currently shorted, otherwise false.
148 * @see HAL_GetCTREPCMCompressorShortedStickyFault
149 */
151 int32_t* status);
152
153/**
154 * Returns whether the compressor has been disconnected since sticky faults
155 * were last cleared. This fault is persistent and can be cleared by
156 * HAL_ClearAllCTREPCMStickyFaults()
157 *
158 * @param[in] handle the PCM handle
159 * @param[out] status Error status variable. 0 on success.
160 * @return True if the compressor has been disconnected since sticky faults
161 * were last cleared, otherwise false.
162 * @see HAL_GetCTREPCMCompressorShortedFault()
163 */
165 HAL_CTREPCMHandle handle, int32_t* status);
166
167/**
168 * Returns whether the compressor is currently disconnected.
169 *
170 * @param[in] handle the PCM handle
171 * @param[out] status Error status variable. 0 on success.
172 * @return True if compressor is currently disconnected, otherwise false.
173 * @see HAL_GetCTREPCMCompressorNotConnectedStickyFault()
174 */
176 int32_t* status);
177
178/**
179 * Gets a bitmask of solenoid values.
180 *
181 * @param[in] handle the PCM handle
182 * @param[out] status Error status variable. 0 on success.
183 * @return Bitmask containing the state of the solenoids. The LSB represents
184 * solenoid 0.
185 */
186int32_t HAL_GetCTREPCMSolenoids(HAL_CTREPCMHandle handle, int32_t* status);
187
188/**
189 * Sets solenoids on a pneumatics module.
190 *
191 * @param[in] handle the PCM handle
192 * @param[in] mask Bitmask indicating which solenoids to set. The LSB represents
193 * solenoid 0.
194 * @param[in] values Bitmask indicating the desired states of the solenoids. The
195 * LSB represents solenoid 0.
196 * @param[out] status Error status variable. 0 on success.
197 */
199 int32_t values, int32_t* status);
200
201/**
202 * Get a bitmask of disabled solenoids.
203 *
204 * @param[in] handle the PCM handle
205 * @param[out] status Error status variable. 0 on success.
206 * @return Bitmask indicating disabled solenoids. The LSB represents solenoid 0.
207 */
209 int32_t* status);
210
211/**
212 * Returns whether the solenoid has reported a voltage fault since sticky faults
213 * were last cleared. This fault is persistent and can be cleared by
214 * HAL_ClearAllCTREPCMStickyFaults()
215 *
216 * @param[in] handle the PCM handle
217 * @param[out] status Error status variable. 0 on success.
218 * @return True if solenoid is reporting a fault, otherwise false.
219 * @see HAL_GetCTREPCMSolenoidVoltageFault()
220 */
222 int32_t* status);
223/**
224 * Returns whether the solenoid is currently reporting a voltage fault.
225 *
226 * @param[in] handle the PCM handle
227 * @param[out] status Error status variable. 0 on success.
228 * @return True if solenoid is reporting a fault, otherwise false.
229 * @see HAL_GetCTREPCMSolenoidVoltageStickyFault()
230 */
232 int32_t* status);
233
234/**
235 * Clears all sticky faults on this device.
236 *
237 * @param[in] handle the PCM handle
238 * @param[out] status Error status variable. 0 on success.
239 */
241
242/**
243 * Fire a single solenoid shot.
244 *
245 * @param[in] handle the PCM handle
246 * @param[in] index solenoid index
247 * @param[out] status Error status variable. 0 on success.
248 */
250 int32_t* status);
251
252/**
253 * Set the duration for a single solenoid shot.
254 *
255 * @param[in] handle the PCM handle
256 * @param[in] index solenoid index
257 * @param[in] durMs shot duration in ms
258 * @param[out] status Error status variable. 0 on success.
259 */
261 int32_t durMs, int32_t* status);
262
263#ifdef __cplusplus
264} // extern "C"
265#endif
266/** @} */
HAL_Bool HAL_GetCTREPCMClosedLoopControl(HAL_CTREPCMHandle handle, int32_t *status)
Get whether the PCM closed loop control is enabled.
HAL_Bool HAL_GetCTREPCMCompressorShortedFault(HAL_CTREPCMHandle handle, int32_t *status)
Returns whether the compressor is currently shorted.
void HAL_ClearAllCTREPCMStickyFaults(HAL_CTREPCMHandle handle, int32_t *status)
Clears all sticky faults on this device.
HAL_Bool HAL_GetCTREPCMCompressor(HAL_CTREPCMHandle handle, int32_t *status)
Get whether compressor is turned on.
HAL_Bool HAL_GetCTREPCMCompressorNotConnectedStickyFault(HAL_CTREPCMHandle handle, int32_t *status)
Returns whether the compressor has been disconnected since sticky faults were last cleared.
void HAL_FireCTREPCMOneShot(HAL_CTREPCMHandle handle, int32_t index, int32_t *status)
Fire a single solenoid shot.
HAL_Bool HAL_GetCTREPCMPressureSwitch(HAL_CTREPCMHandle handle, int32_t *status)
Returns the state of the pressure switch.
void HAL_SetCTREPCMSolenoids(HAL_CTREPCMHandle handle, int32_t mask, int32_t values, int32_t *status)
Sets solenoids on a pneumatics module.
int32_t HAL_GetCTREPCMSolenoidDisabledList(HAL_CTREPCMHandle handle, int32_t *status)
Get a bitmask of disabled solenoids.
int32_t HAL_GetCTREPCMSolenoids(HAL_CTREPCMHandle handle, int32_t *status)
Gets a bitmask of solenoid values.
HAL_Bool HAL_GetCTREPCMSolenoidVoltageFault(HAL_CTREPCMHandle handle, int32_t *status)
Returns whether the solenoid is currently reporting a voltage fault.
HAL_Bool HAL_GetCTREPCMCompressorNotConnectedFault(HAL_CTREPCMHandle handle, int32_t *status)
Returns whether the compressor is currently disconnected.
HAL_Bool HAL_GetCTREPCMCompressorCurrentTooHighFault(HAL_CTREPCMHandle handle, int32_t *status)
Return whether the compressor current is currently too high.
void HAL_SetCTREPCMClosedLoopControl(HAL_CTREPCMHandle handle, HAL_Bool enabled, int32_t *status)
Enables the compressor closed loop control using the digital pressure switch.
HAL_Bool HAL_GetCTREPCMCompressorCurrentTooHighStickyFault(HAL_CTREPCMHandle handle, int32_t *status)
Returns whether the compressor current has been too high since sticky faults were last cleared.
double HAL_GetCTREPCMCompressorCurrent(HAL_CTREPCMHandle handle, int32_t *status)
Returns the current drawn by the compressor.
HAL_Bool HAL_GetCTREPCMSolenoidVoltageStickyFault(HAL_CTREPCMHandle handle, int32_t *status)
Returns whether the solenoid has reported a voltage fault since sticky faults were last cleared.
HAL_Bool HAL_CheckCTREPCMSolenoidChannel(int32_t channel)
Checks if a solenoid channel number is valid.
void HAL_SetCTREPCMOneShotDuration(HAL_CTREPCMHandle handle, int32_t index, int32_t durMs, int32_t *status)
Set the duration for a single solenoid shot.
HAL_CTREPCMHandle HAL_InitializeCTREPCM(int32_t busId, int32_t module, const char *allocationLocation, int32_t *status)
Initializes a PCM.
void HAL_FreeCTREPCM(HAL_CTREPCMHandle handle)
Frees a PCM handle.
HAL_Bool HAL_GetCTREPCMCompressorShortedStickyFault(HAL_CTREPCMHandle handle, int32_t *status)
Returns whether the compressor has been shorted since sticky faults were last cleared.
HAL_Handle HAL_CTREPCMHandle
Definition Types.h:65
int32_t HAL_Bool
Definition Types.h:73