Adds SetAllSolenoids function to CTRE PCM code (#419)

Closes #417.
This commit is contained in:
Thad House
2016-12-23 12:35:45 -08:00
committed by Peter Johnson
parent 8f67f2c24c
commit 6844f05c3d
4 changed files with 31 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ HAL_Bool HAL_GetSolenoid(HAL_SolenoidHandle solenoidPortHandle,
int32_t HAL_GetAllSolenoids(int32_t module, int32_t* status);
void HAL_SetSolenoid(HAL_SolenoidHandle solenoidPortHandle, HAL_Bool value,
int32_t* status);
void HAL_SetAllSolenoids(int32_t module, int32_t state, int32_t* status);
int32_t HAL_GetPCMSolenoidBlackList(int32_t module, int32_t* status);
HAL_Bool HAL_GetPCMSolenoidVoltageStickyFault(int32_t module, int32_t* status);
HAL_Bool HAL_GetPCMSolenoidVoltageFault(int32_t module, int32_t* status);

View File

@@ -16,6 +16,13 @@ public:
*/
CTR_Code SetSolenoid(unsigned char idx, bool en);
/* Set all PCM solenoid states
*
* @Return - CTR_Code - Error code (if any) for setting solenoids
* @Param - state Bitfield to set all solenoids to
*/
CTR_Code SetAllSolenoids(UINT8 state);
/* Enables PCM Closed Loop Control of Compressor via pressure switch
* @Return - CTR_Code - Error code (if any) for setting solenoid
* @Param - en - Enable / Disable Closed Loop Control
@@ -192,6 +199,7 @@ public:
extern "C" {
void * c_PCM_Init(void);
CTR_Code c_SetSolenoid(void * handle,unsigned char idx,INT8 param);
CTR_Code c_SetAllSolenoids(void * handle,UINT8 state);
CTR_Code c_SetClosedLoopControl(void * handle,INT8 param);
CTR_Code c_ClearStickyFaults(void * handle,INT8 param);
CTR_Code c_GetSolenoid(void * handle,UINT8 idx,INT8 * status);

View File

@@ -116,6 +116,12 @@ void HAL_SetSolenoid(HAL_SolenoidHandle solenoidPortHandle, HAL_Bool value,
*status = PCM_modules[port->module]->SetSolenoid(port->channel, value);
}
void HAL_SetAllSolenoids(int32_t module, int32_t state, int32_t* status) {
if (!checkPCMInit(module, status)) return;
*status = PCM_modules[module]->SetAllSolenoids(state);
}
int32_t HAL_GetPCMSolenoidBlackList(int32_t module, int32_t* status) {
if (!checkPCMInit(module, status)) return 0;
uint8_t value;

View File

@@ -140,6 +140,19 @@ CTR_Code PCM::SetSolenoid(unsigned char idx, bool en)
return CTR_OKAY;
}
/* Set all PCM solenoid states
*
* @Return - CTR_Code - Error code (if any) for setting solenoids
* @Param - state Bitfield to set all solenoids to
*/
CTR_Code PCM::SetAllSolenoids(UINT8 state) {
CtreCanNode::txTask<PcmControl_t> toFill = GetTx<PcmControl_t>(CONTROL_1 | GetDeviceNumber());
if(toFill.IsEmpty())return CTR_UnexpectedArbId;
toFill->solenoidBits = state;
FlushTx(toFill);
return CTR_OKAY;
}
/* Clears PCM sticky faults (indicators of past faults
*
* @Return - CTR_Code - Error code (if any) for setting solenoid
@@ -465,6 +478,9 @@ extern "C" {
CTR_Code c_SetSolenoid(void * handle, unsigned char idx, INT8 param) {
return ((PCM*) handle)->SetSolenoid(idx, param);
}
CTR_Code c_SetAllSolenoids(void * handle, UINT8 state) {
return ((PCM*) handle)->SetAllSolenoids(state);
}
CTR_Code c_SetClosedLoopControl(void * handle, INT8 param) {
return ((PCM*) handle)->SetClosedLoopControl(param);
}