Brian Silverman | f7f267a | 2017-02-04 16:16:08 -0800 | [diff] [blame^] | 1 | #ifndef PCM_H_
|
| 2 | #define PCM_H_
|
| 3 | #include "ctre.h" //BIT Defines + Typedefs
|
| 4 | #include "CtreCanNode.h"
|
| 5 | class PCM : public CtreCanNode
|
| 6 | {
|
| 7 | public:
|
| 8 | PCM(UINT8 deviceNumber=0);
|
| 9 | ~PCM();
|
| 10 |
|
| 11 | /* Set PCM solenoid state
|
| 12 | *
|
| 13 | * @Return - CTR_Code - Error code (if any) for setting solenoid
|
| 14 | * @Param - idx - ID of solenoid (0-7)
|
| 15 | * @Param - en - Enable / Disable identified solenoid
|
| 16 | */
|
| 17 | CTR_Code SetSolenoid(unsigned char idx, bool en);
|
| 18 |
|
| 19 | /* Set all PCM solenoid states
|
| 20 | *
|
| 21 | * @Return - CTR_Code - Error code (if any) for setting solenoids
|
| 22 | * @Param - state Bitfield to set all solenoids to
|
| 23 | */
|
| 24 | CTR_Code SetAllSolenoids(UINT8 state);
|
| 25 |
|
| 26 | /* Enables PCM Closed Loop Control of Compressor via pressure switch
|
| 27 | * @Return - CTR_Code - Error code (if any) for setting solenoid
|
| 28 | * @Param - en - Enable / Disable Closed Loop Control
|
| 29 | */
|
| 30 | CTR_Code SetClosedLoopControl(bool en);
|
| 31 |
|
| 32 | /* Clears PCM sticky faults (indicators of past faults
|
| 33 | * @Return - CTR_Code - Error code (if any) for setting solenoid
|
| 34 | */
|
| 35 | CTR_Code ClearStickyFaults();
|
| 36 |
|
| 37 | /* Get solenoid state
|
| 38 | *
|
| 39 | * @Return - CTR_Code - Error code (if any)
|
| 40 | * @Param - idx - ID of solenoid (0-7) to return if solenoid is on.
|
| 41 | * @Param - status - true if solenoid enabled, false otherwise
|
| 42 | */
|
| 43 | CTR_Code GetSolenoid(UINT8 idx, bool &status);
|
| 44 |
|
| 45 | /* Get state of all solenoids
|
| 46 | *
|
| 47 | * @Return - CTR_Code - Error code (if any)
|
| 48 | * @Param - status - bitfield of solenoid states
|
| 49 | */
|
| 50 | CTR_Code GetAllSolenoids(UINT8 &status);
|
| 51 |
|
| 52 | /* Get pressure switch state
|
| 53 | * @Return - CTR_Code - Error code (if any)
|
| 54 | * @Param - status - True if pressure adequate, false if low
|
| 55 | */
|
| 56 | CTR_Code GetPressure(bool &status);
|
| 57 |
|
| 58 | /* Get compressor state
|
| 59 | * @Return - CTR_Code - Error code (if any)
|
| 60 | * @Param - status - True if compress ouput is on, false if otherwise
|
| 61 | */
|
| 62 | CTR_Code GetCompressor(bool &status);
|
| 63 |
|
| 64 | /* Get closed loop control state
|
| 65 | * @Return - CTR_Code - Error code (if any)
|
| 66 | * @Param - status - True if closed loop enabled, false if otherwise
|
| 67 | */
|
| 68 | CTR_Code GetClosedLoopControl(bool &status);
|
| 69 |
|
| 70 | /* Get compressor current draw
|
| 71 | * @Return - CTR_Code - Error code (if any)
|
| 72 | * @Param - status - Compressor current returned in Amperes (A)
|
| 73 | */
|
| 74 | CTR_Code GetCompressorCurrent(float &status);
|
| 75 |
|
| 76 | /* Get voltage across solenoid rail
|
| 77 | * @Return - CTR_Code - Error code (if any)
|
| 78 | * @Param - status - Voltage across solenoid rail in Volts (V)
|
| 79 | */
|
| 80 | CTR_Code GetSolenoidVoltage(float &status);
|
| 81 |
|
| 82 | /* Get hardware fault value
|
| 83 | * @Return - CTR_Code - Error code (if any)
|
| 84 | * @Param - status - True if hardware failure detected, false if otherwise
|
| 85 | */
|
| 86 | CTR_Code GetHardwareFault(bool &status);
|
| 87 |
|
| 88 | /* Get compressor fault value
|
| 89 | * @Return - CTR_Code - Error code (if any)
|
| 90 | * @Param - status - True if abnormally high compressor current detected, false if otherwise
|
| 91 | */
|
| 92 | CTR_Code GetCompressorCurrentTooHighFault(bool &status);
|
| 93 |
|
| 94 | /* Get solenoid fault value
|
| 95 | * @Return - CTR_Code - Error code (if any)
|
| 96 | * @Param - status - True if shorted solenoid detected, false if otherwise
|
| 97 | */
|
| 98 | CTR_Code GetSolenoidFault(bool &status);
|
| 99 |
|
| 100 | /* Get compressor sticky fault value
|
| 101 | * @Return - CTR_Code - Error code (if any)
|
| 102 | * @Param - status - True if solenoid had previously been shorted
|
| 103 | * (and sticky fault was not cleared), false if otherwise
|
| 104 | */
|
| 105 | CTR_Code GetCompressorCurrentTooHighStickyFault(bool &status);
|
| 106 | /* Get compressor shorted sticky fault value
|
| 107 | * @Return - CTR_Code - Error code (if any)
|
| 108 | * @Param - status - True if compressor output is shorted, false if otherwise
|
| 109 | */
|
| 110 | CTR_Code GetCompressorShortedStickyFault(bool &status);
|
| 111 | /* Get compressor shorted fault value
|
| 112 | * @Return - CTR_Code - Error code (if any)
|
| 113 | * @Param - status - True if compressor output is shorted, false if otherwise
|
| 114 | */
|
| 115 | CTR_Code GetCompressorShortedFault(bool &status);
|
| 116 | /* Get compressor is not connected sticky fault value
|
| 117 | * @Return - CTR_Code - Error code (if any)
|
| 118 | * @Param - status - True if compressor current is too low,
|
| 119 | * indicating compressor is not connected, false if otherwise
|
| 120 | */
|
| 121 | CTR_Code GetCompressorNotConnectedStickyFault(bool &status);
|
| 122 | /* Get compressor is not connected fault value
|
| 123 | * @Return - CTR_Code - Error code (if any)
|
| 124 | * @Param - status - True if compressor current is too low,
|
| 125 | * indicating compressor is not connected, false if otherwise
|
| 126 | */
|
| 127 | CTR_Code GetCompressorNotConnectedFault(bool &status);
|
| 128 |
|
| 129 | /* Get solenoid sticky fault value
|
| 130 | * @Return - CTR_Code - Error code (if any)
|
| 131 | * @Param - status - True if compressor had previously been shorted
|
| 132 | * (and sticky fault was not cleared), false if otherwise
|
| 133 | */
|
| 134 | CTR_Code GetSolenoidStickyFault(bool &status);
|
| 135 |
|
| 136 | /* Get battery voltage
|
| 137 | * @Return - CTR_Code - Error code (if any)
|
| 138 | * @Param - status - Voltage across PCM power ports in Volts (V)
|
| 139 | */
|
| 140 | CTR_Code GetBatteryVoltage(float &status);
|
| 141 |
|
| 142 | /* Set PCM Device Number and according CAN frame IDs
|
| 143 | * @Return - void
|
| 144 | * @Param - deviceNumber - Device number of PCM to control
|
| 145 | */
|
| 146 | void SetDeviceNumber(UINT8 deviceNumber);
|
| 147 | /* Get number of total failed PCM Control Frame
|
| 148 | * @Return - CTR_Code - Error code (if any)
|
| 149 | * @Param - status - Number of failed control frames (tokenization fails)
|
| 150 | * @WARNING - Return only valid if [SeekDebugFrames] is enabled
|
| 151 | * See function SeekDebugFrames
|
| 152 | * See function EnableSeekDebugFrames
|
| 153 | */
|
| 154 | CTR_Code GetNumberOfFailedControlFrames(UINT16 &status);
|
| 155 |
|
| 156 | /* Get raw Solenoid Blacklist
|
| 157 | * @Return - CTR_Code - Error code (if any)
|
| 158 | * @Param - status - Raw binary breakdown of Solenoid Blacklist
|
| 159 | * BIT7 = Solenoid 1, BIT6 = Solenoid 2, etc.
|
| 160 | * @WARNING - Return only valid if [SeekStatusFaultFrames] is enabled
|
| 161 | * See function SeekStatusFaultFrames
|
| 162 | * See function EnableSeekStatusFaultFrames
|
| 163 | */
|
| 164 | CTR_Code GetSolenoidBlackList(UINT8 &status);
|
| 165 |
|
| 166 | /* Get solenoid Blacklist status
|
| 167 | * - Blacklisted solenoids cannot be enabled until PCM is power cycled
|
| 168 | * @Return - CTR_Code - Error code (if any)
|
| 169 | * @Param - idx - ID of solenoid [0,7]
|
| 170 | * @Param - status - True if Solenoid is blacklisted, false if otherwise
|
| 171 | * @WARNING - Return only valid if [SeekStatusFaultFrames] is enabled
|
| 172 | * See function SeekStatusFaultFrames
|
| 173 | * See function EnableSeekStatusFaultFrames
|
| 174 | */
|
| 175 | CTR_Code IsSolenoidBlacklisted(UINT8 idx, bool &status);
|
| 176 |
|
| 177 | /* Return status of module enable/disable
|
| 178 | * @Return - CTR_Code - Error code (if any)
|
| 179 | * @Param - status - Returns TRUE if PCM is enabled, FALSE if disabled
|
| 180 | */
|
| 181 | CTR_Code isModuleEnabled(bool &status);
|
| 182 |
|
| 183 | /* Get solenoid Blacklist status
|
| 184 | * @Return - CTR_Code - Error code (if any)
|
| 185 | * @Param - idx - ID of solenoid [0,7] to fire one shot pulse.
|
| 186 | */
|
| 187 | CTR_Code FireOneShotSolenoid(UINT8 idx);
|
| 188 |
|
| 189 | /* Configure the pulse width of a solenoid channel for one-shot pulse.
|
| 190 | * Preprogrammed pulsewidth is 10ms resolute and can be between 20ms and 5.1s.
|
| 191 | * @Return - CTR_Code - Error code (if any)
|
| 192 | * @Param - idx - ID of solenoid [0,7] to configure.
|
| 193 | * @Param - durMs - pulse width in ms.
|
| 194 | */
|
| 195 | CTR_Code SetOneShotDurationMs(UINT8 idx,uint32_t durMs);
|
| 196 |
|
| 197 | };
|
| 198 | //------------------ C interface --------------------------------------------//
|
| 199 | extern "C" {
|
| 200 | void * c_PCM_Init(void);
|
| 201 | CTR_Code c_SetSolenoid(void * handle,unsigned char idx,INT8 param);
|
| 202 | CTR_Code c_SetAllSolenoids(void * handle,UINT8 state);
|
| 203 | CTR_Code c_SetClosedLoopControl(void * handle,INT8 param);
|
| 204 | CTR_Code c_ClearStickyFaults(void * handle,INT8 param);
|
| 205 | CTR_Code c_GetSolenoid(void * handle,UINT8 idx,INT8 * status);
|
| 206 | CTR_Code c_GetAllSolenoids(void * handle,UINT8 * status);
|
| 207 | CTR_Code c_GetPressure(void * handle,INT8 * status);
|
| 208 | CTR_Code c_GetCompressor(void * handle,INT8 * status);
|
| 209 | CTR_Code c_GetClosedLoopControl(void * handle,INT8 * status);
|
| 210 | CTR_Code c_GetCompressorCurrent(void * handle,float * status);
|
| 211 | CTR_Code c_GetSolenoidVoltage(void * handle,float*status);
|
| 212 | CTR_Code c_GetHardwareFault(void * handle,INT8*status);
|
| 213 | CTR_Code c_GetCompressorFault(void * handle,INT8*status);
|
| 214 | CTR_Code c_GetSolenoidFault(void * handle,INT8*status);
|
| 215 | CTR_Code c_GetCompressorStickyFault(void * handle,INT8*status);
|
| 216 | CTR_Code c_GetSolenoidStickyFault(void * handle,INT8*status);
|
| 217 | CTR_Code c_GetBatteryVoltage(void * handle,float*status);
|
| 218 | void c_SetDeviceNumber_PCM(void * handle,UINT8 deviceNumber);
|
| 219 | void c_EnableSeekStatusFrames(void * handle,INT8 enable);
|
| 220 | void c_EnableSeekStatusFaultFrames(void * handle,INT8 enable);
|
| 221 | void c_EnableSeekDebugFrames(void * handle,INT8 enable);
|
| 222 | CTR_Code c_GetNumberOfFailedControlFrames(void * handle,UINT16*status);
|
| 223 | CTR_Code c_GetSolenoidBlackList(void * handle,UINT8 *status);
|
| 224 | CTR_Code c_IsSolenoidBlacklisted(void * handle,UINT8 idx,INT8*status);
|
| 225 | }
|
| 226 | #endif
|