WPILibC++ 2024.3.2
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] module the CAN ID to initialize
25 * @param[in] allocationLocation the location where the allocation is occurring
26 * (can be null)
27 * @param[out] status Error status variable. 0 on success.
28 * @return the created PH handle
29 */
31 const char* allocationLocation,
32 int32_t* status);
33
34/**
35 * Frees a PCM handle.
36 *
37 * @param[in] handle the PCMhandle
38 */
40
41/**
42 * Checks if a solenoid channel number is valid.
43 *
44 * @param[in] channel the channel to check
45 * @return true if the channel is valid, otherwise false
46 */
48
49/**
50 * Get whether compressor is turned on.
51 *
52 * @param[in] handle the PCM handle
53 * @param[out] status Error status variable. 0 on success.
54 * @return true if the compressor is turned on
55 */
57
58/**
59 * Enables the compressor closed loop control using the digital pressure switch.
60 * The compressor will turn on when the pressure switch indicates that the
61 * system is not full, and will turn off when the pressure switch indicates that
62 * the system is full.
63 *
64 * @param[in] handle the PCM handle
65 * @param[in] enabled true to enable closed loop control
66 * @param[out] status Error status variable. 0 on success.
67 */
69 int32_t* status);
70
71/**
72 * Get whether the PCM closed loop control is enabled.
73 *
74 * @param[in] handle the PCM handle
75 * @param[out] status Error status variable. 0 on success.
76 * @return True if closed loop control is enabled, otherwise false.
77 */
79 int32_t* status);
80
81/**
82 * Returns the state of the pressure switch.
83 *
84 * @param[in] handle the PCM handle
85 * @param[out] status Error status variable. 0 on success.
86 * @return True if pressure switch indicates that the system is full,
87 * otherwise false.
88 */
90 int32_t* status);
91
92/**
93 * Returns the current drawn by the compressor.
94 *
95 * @param[in] handle the PCM handle
96 * @param[out] status Error status variable. 0 on success.
97 * @return The current drawn by the compressor in amps.
98 */
100 int32_t* status);
101
102/**
103 * Return whether the compressor current is currently too high.
104 *
105 * @param[in] handle the PCM handle
106 * @param[out] status Error status variable. 0 on success.
107 * @return True if the compressor current is too high, otherwise false.
108 * @see HAL_GetCTREPCMCompressorShortedStickyFault
109 */
111 int32_t* status);
112
113/**
114 * Returns whether the compressor current has been too high since sticky
115 * faults were last cleared. This fault is persistent and can be cleared by
116 * HAL_ClearAllCTREPCMStickyFaults()
117 *
118 * @param[in] handle the PCM handle
119 * @param[out] status Error status variable. 0 on success.
120 * @return True if the compressor current has been too high since sticky
121 * faults were last cleared.
122 * @see HAL_GetCTREPCMCompressorCurrentTooHighFault()
123 */
125 HAL_CTREPCMHandle handle, int32_t* status);
126
127/**
128 * Returns whether the compressor has been shorted since sticky faults were
129 * last cleared. This fault is persistent and can be cleared by
130 * HAL_ClearAllCTREPCMStickyFaults()
131 *
132 * @param[in] handle the PCM handle
133 * @param[out] status Error status variable. 0 on success.
134 * @return True if the compressor has been shorted since sticky faults were
135 * last cleared, otherwise false.
136 * @see HAL_GetCTREPCMCompressorShortedFault()
137 */
139 int32_t* status);
140
141/**
142 * Returns whether the compressor is currently shorted.
143 *
144 * @param[in] handle the PCM handle
145 * @param[out] status Error status variable. 0 on success.
146 * @return True if the compressor is currently shorted, otherwise false.
147 * @see HAL_GetCTREPCMCompressorShortedStickyFault
148 */
150 int32_t* status);
151
152/**
153 * Returns whether the compressor has been disconnected since sticky faults
154 * were last cleared. This fault is persistent and can be cleared by
155 * HAL_ClearAllCTREPCMStickyFaults()
156 *
157 * @param[in] handle the PCM handle
158 * @param[out] status Error status variable. 0 on success.
159 * @return True if the compressor has been disconnected since sticky faults
160 * were last cleared, otherwise false.
161 * @see HAL_GetCTREPCMCompressorShortedFault()
162 */
164 HAL_CTREPCMHandle handle, int32_t* status);
165
166/**
167 * Returns whether the compressor is currently disconnected.
168 *
169 * @param[in] handle the PCM handle
170 * @param[out] status Error status variable. 0 on success.
171 * @return True if compressor is currently disconnected, otherwise false.
172 * @see HAL_GetCTREPCMCompressorNotConnectedStickyFault()
173 */
175 int32_t* status);
176
177/**
178 * Gets a bitmask of solenoid values.
179 *
180 * @param[in] handle the PCM handle
181 * @param[out] status Error status variable. 0 on success.
182 * @return solenoid values
183 */
184int32_t HAL_GetCTREPCMSolenoids(HAL_CTREPCMHandle handle, int32_t* status);
185
186/**
187 * Sets solenoids on a pneumatics module.
188 *
189 * @param[in] handle the PCM handle
190 * @param[in] mask bitmask to set
191 * @param[in] values solenoid values
192 * @param[out] status Error status variable. 0 on success.
193 */
195 int32_t values, int32_t* status);
196
197/**
198 * Get a bitmask of disabled solenoids.
199 *
200 * @param[in] handle the PCM handle
201 * @param[out] status Error status variable. 0 on success.
202 * @return bitmask of disabled solenoids
203 */
205 int32_t* status);
206
207/**
208 * Returns whether the solenoid has reported a voltage fault since sticky faults
209 * were last cleared. This fault is persistent and can be cleared by
210 * HAL_ClearAllCTREPCMStickyFaults()
211 *
212 * @param[in] handle the PCM handle
213 * @param[out] status Error status variable. 0 on success.
214 * @return True if solenoid is reporting a fault, otherwise false.
215 * @see HAL_GetCTREPCMSolenoidVoltageFault()
216 */
218 int32_t* status);
219/**
220 * Returns whether the solenoid is currently reporting a voltage fault.
221 *
222 * @param[in] handle the PCM handle
223 * @param[out] status Error status variable. 0 on success.
224 * @return True if solenoid is reporting a fault, otherwise false.
225 * @see HAL_GetCTREPCMSolenoidVoltageStickyFault()
226 */
228 int32_t* status);
229
230/**
231 * Clears all sticky faults on this device.
232 *
233 * @param[in] handle the PCM handle
234 * @param[out] status Error status variable. 0 on success.
235 */
237
238/**
239 * Fire a single solenoid shot.
240 *
241 * @param[in] handle the PCM handle
242 * @param[in] index solenoid index
243 * @param[out] status Error status variable. 0 on success.
244 */
245void HAL_FireCTREPCMOneShot(HAL_CTREPCMHandle handle, int32_t index,
246 int32_t* status);
247
248/**
249 * Set the duration for a single solenoid shot.
250 *
251 * @param[in] handle the PCM handle
252 * @param[in] index solenoid index
253 * @param[in] durMs shot duration in ms
254 * @param[out] status Error status variable. 0 on success.
255 */
257 int32_t durMs, int32_t* status);
258
259#ifdef __cplusplus
260} // extern "C"
261#endif
262/** @} */
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.
HAL_CTREPCMHandle HAL_InitializeCTREPCM(int32_t module, const char *allocationLocation, int32_t *status)
Initializes a PCM.
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.
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:67
int32_t HAL_Bool
Definition: Types.h:73