mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Switches HAL to fixed length signed integers, and adds our own HAL_Bool Type (#155)
* Switches HAL to fixed length signed integers, and adds our own HAL_Bool type * Replaces HAL Floats with Doubles Doubles are just as fast as floats with optimizations turned on, so switches to all doubles. All made doubles for consistency. * Prepends HAL/ to HAL include files. Also fixes some range errors
This commit is contained in:
committed by
Peter Johnson
parent
4a98e68815
commit
b51e85ae26
@@ -17,27 +17,26 @@ using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_CompressorHandle HAL_InitializeCompressor(uint8_t module, int32_t* status) {
|
||||
// fail on invalid index;
|
||||
if (!HAL_CheckCompressorModule(module)) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
HAL_CompressorHandle HAL_InitializeCompressor(int32_t module, int32_t* status) {
|
||||
// Use status to check for invalid index
|
||||
initializePCM(module, status);
|
||||
if (*status != 0) {
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
initializePCM(module);
|
||||
|
||||
// As compressors can have unlimited objects, just create a
|
||||
// handle with the module number as the index.
|
||||
|
||||
return (HAL_CompressorHandle)createHandle(module, HAL_HandleEnum::Compressor);
|
||||
return (HAL_CompressorHandle)createHandle(static_cast<int16_t>(module),
|
||||
HAL_HandleEnum::Compressor);
|
||||
}
|
||||
|
||||
bool HAL_CheckCompressorModule(uint8_t module) {
|
||||
return module < kNumPCMModules;
|
||||
HAL_Bool HAL_CheckCompressorModule(int32_t module) {
|
||||
return (module < kNumPCMModules) && (module >= 0);
|
||||
}
|
||||
|
||||
bool HAL_GetCompressor(HAL_CompressorHandle compressor_handle,
|
||||
int32_t* status) {
|
||||
HAL_Bool HAL_GetCompressor(HAL_CompressorHandle compressor_handle,
|
||||
int32_t* status) {
|
||||
int16_t index =
|
||||
getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor);
|
||||
if (index == InvalidHandleIndex) {
|
||||
@@ -53,7 +52,7 @@ bool HAL_GetCompressor(HAL_CompressorHandle compressor_handle,
|
||||
}
|
||||
|
||||
void HAL_SetCompressorClosedLoopControl(HAL_CompressorHandle compressor_handle,
|
||||
bool value, int32_t* status) {
|
||||
HAL_Bool value, int32_t* status) {
|
||||
int16_t index =
|
||||
getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor);
|
||||
if (index == InvalidHandleIndex) {
|
||||
@@ -65,8 +64,8 @@ void HAL_SetCompressorClosedLoopControl(HAL_CompressorHandle compressor_handle,
|
||||
*status = module->SetClosedLoopControl(value);
|
||||
}
|
||||
|
||||
bool HAL_GetCompressorClosedLoopControl(HAL_CompressorHandle compressor_handle,
|
||||
int32_t* status) {
|
||||
HAL_Bool HAL_GetCompressorClosedLoopControl(
|
||||
HAL_CompressorHandle compressor_handle, int32_t* status) {
|
||||
int16_t index =
|
||||
getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor);
|
||||
if (index == InvalidHandleIndex) {
|
||||
@@ -81,8 +80,8 @@ bool HAL_GetCompressorClosedLoopControl(HAL_CompressorHandle compressor_handle,
|
||||
return value;
|
||||
}
|
||||
|
||||
bool HAL_GetCompressorPressureSwitch(HAL_CompressorHandle compressor_handle,
|
||||
int32_t* status) {
|
||||
HAL_Bool HAL_GetCompressorPressureSwitch(HAL_CompressorHandle compressor_handle,
|
||||
int32_t* status) {
|
||||
int16_t index =
|
||||
getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor);
|
||||
if (index == InvalidHandleIndex) {
|
||||
@@ -97,8 +96,8 @@ bool HAL_GetCompressorPressureSwitch(HAL_CompressorHandle compressor_handle,
|
||||
return value;
|
||||
}
|
||||
|
||||
float HAL_GetCompressorCurrent(HAL_CompressorHandle compressor_handle,
|
||||
int32_t* status) {
|
||||
double HAL_GetCompressorCurrent(HAL_CompressorHandle compressor_handle,
|
||||
int32_t* status) {
|
||||
int16_t index =
|
||||
getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor);
|
||||
if (index == InvalidHandleIndex) {
|
||||
@@ -112,7 +111,7 @@ float HAL_GetCompressorCurrent(HAL_CompressorHandle compressor_handle,
|
||||
|
||||
return value;
|
||||
}
|
||||
bool HAL_GetCompressorCurrentTooHighFault(
|
||||
HAL_Bool HAL_GetCompressorCurrentTooHighFault(
|
||||
HAL_CompressorHandle compressor_handle, int32_t* status) {
|
||||
int16_t index =
|
||||
getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor);
|
||||
@@ -127,7 +126,7 @@ bool HAL_GetCompressorCurrentTooHighFault(
|
||||
|
||||
return value;
|
||||
}
|
||||
bool HAL_GetCompressorCurrentTooHighStickyFault(
|
||||
HAL_Bool HAL_GetCompressorCurrentTooHighStickyFault(
|
||||
HAL_CompressorHandle compressor_handle, int32_t* status) {
|
||||
int16_t index =
|
||||
getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor);
|
||||
@@ -142,8 +141,8 @@ bool HAL_GetCompressorCurrentTooHighStickyFault(
|
||||
|
||||
return value;
|
||||
}
|
||||
bool HAL_GetCompressorShortedStickyFault(HAL_CompressorHandle compressor_handle,
|
||||
int32_t* status) {
|
||||
HAL_Bool HAL_GetCompressorShortedStickyFault(
|
||||
HAL_CompressorHandle compressor_handle, int32_t* status) {
|
||||
int16_t index =
|
||||
getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor);
|
||||
if (index == InvalidHandleIndex) {
|
||||
@@ -157,8 +156,8 @@ bool HAL_GetCompressorShortedStickyFault(HAL_CompressorHandle compressor_handle,
|
||||
|
||||
return value;
|
||||
}
|
||||
bool HAL_GetCompressorShortedFault(HAL_CompressorHandle compressor_handle,
|
||||
int32_t* status) {
|
||||
HAL_Bool HAL_GetCompressorShortedFault(HAL_CompressorHandle compressor_handle,
|
||||
int32_t* status) {
|
||||
int16_t index =
|
||||
getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor);
|
||||
if (index == InvalidHandleIndex) {
|
||||
@@ -172,7 +171,7 @@ bool HAL_GetCompressorShortedFault(HAL_CompressorHandle compressor_handle,
|
||||
|
||||
return value;
|
||||
}
|
||||
bool HAL_GetCompressorNotConnectedStickyFault(
|
||||
HAL_Bool HAL_GetCompressorNotConnectedStickyFault(
|
||||
HAL_CompressorHandle compressor_handle, int32_t* status) {
|
||||
int16_t index =
|
||||
getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor);
|
||||
@@ -187,8 +186,8 @@ bool HAL_GetCompressorNotConnectedStickyFault(
|
||||
|
||||
return value;
|
||||
}
|
||||
bool HAL_GetCompressorNotConnectedFault(HAL_CompressorHandle compressor_handle,
|
||||
int32_t* status) {
|
||||
HAL_Bool HAL_GetCompressorNotConnectedFault(
|
||||
HAL_CompressorHandle compressor_handle, int32_t* status) {
|
||||
int16_t index =
|
||||
getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor);
|
||||
if (index == InvalidHandleIndex) {
|
||||
|
||||
Reference in New Issue
Block a user