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