Renamed "pin" to "channel" and variables with underscores now use mixed case (#194)

This commit is contained in:
Tyler Veness
2016-08-12 13:45:28 -07:00
committed by Peter Johnson
parent 227fdc1a60
commit 45b8e9ab4f
67 changed files with 941 additions and 917 deletions

View File

@@ -20,30 +20,30 @@
namespace {
struct Solenoid {
uint8_t module;
uint8_t pin;
uint8_t channel;
};
}
using namespace hal;
static IndexedHandleResource<HAL_SolenoidHandle, Solenoid,
kNumPCMModules * kNumSolenoidPins,
kNumPCMModules * kNumSolenoidChannels,
HAL_HandleEnum::Solenoid>
solenoidHandles;
extern "C" {
HAL_SolenoidHandle HAL_InitializeSolenoidPort(HAL_PortHandle port_handle,
HAL_SolenoidHandle HAL_InitializeSolenoidPort(HAL_PortHandle portHandle,
int32_t* status) {
int16_t pin = getPortHandlePin(port_handle);
int16_t module = getPortHandleModule(port_handle);
if (pin == InvalidHandleIndex) {
int16_t channel = getPortHandleChannel(portHandle);
int16_t module = getPortHandleModule(portHandle);
if (channel == InvalidHandleIndex) {
*status = HAL_HANDLE_ERROR;
return HAL_kInvalidHandle;
}
// initializePCM will check the module
if (!HAL_CheckSolenoidChannel(pin)) {
if (!HAL_CheckSolenoidChannel(channel)) {
*status = RESOURCE_OUT_OF_RANGE;
return HAL_kInvalidHandle;
}
@@ -54,44 +54,44 @@ HAL_SolenoidHandle HAL_InitializeSolenoidPort(HAL_PortHandle port_handle,
}
auto handle =
solenoidHandles.Allocate(module * kNumSolenoidPins + pin, status);
solenoidHandles.Allocate(module * kNumSolenoidChannels + channel, status);
if (handle == HAL_kInvalidHandle) { // out of resources
*status = NO_AVAILABLE_RESOURCES;
return HAL_kInvalidHandle;
}
auto solenoid_port = solenoidHandles.Get(handle);
if (solenoid_port == nullptr) { // would only occur on thread issues
auto solenoidPort = solenoidHandles.Get(handle);
if (solenoidPort == nullptr) { // would only occur on thread issues
*status = HAL_HANDLE_ERROR;
return HAL_kInvalidHandle;
}
solenoid_port->module = static_cast<uint8_t>(module);
solenoid_port->pin = static_cast<uint8_t>(pin);
solenoidPort->module = static_cast<uint8_t>(module);
solenoidPort->channel = static_cast<uint8_t>(channel);
return handle;
}
void HAL_FreeSolenoidPort(HAL_SolenoidHandle solenoid_port_handle) {
solenoidHandles.Free(solenoid_port_handle);
void HAL_FreeSolenoidPort(HAL_SolenoidHandle solenoidPortHandle) {
solenoidHandles.Free(solenoidPortHandle);
}
HAL_Bool HAL_CheckSolenoidModule(int32_t module) {
return module < kNumPCMModules && module >= 0;
}
HAL_Bool HAL_CheckSolenoidChannel(int32_t pin) {
return pin < kNumSolenoidPins && pin >= 0;
HAL_Bool HAL_CheckSolenoidChannel(int32_t channel) {
return channel < kNumSolenoidChannels && channel >= 0;
}
HAL_Bool HAL_GetSolenoid(HAL_SolenoidHandle solenoid_port_handle,
HAL_Bool HAL_GetSolenoid(HAL_SolenoidHandle solenoidPortHandle,
int32_t* status) {
auto port = solenoidHandles.Get(solenoid_port_handle);
auto port = solenoidHandles.Get(solenoidPortHandle);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return false;
}
bool value;
*status = PCM_modules[port->module]->GetSolenoid(port->pin, value);
*status = PCM_modules[port->module]->GetSolenoid(port->channel, value);
return value;
}
@@ -105,15 +105,15 @@ int32_t HAL_GetAllSolenoids(int32_t module, int32_t* status) {
return value;
}
void HAL_SetSolenoid(HAL_SolenoidHandle solenoid_port_handle, HAL_Bool value,
void HAL_SetSolenoid(HAL_SolenoidHandle solenoidPortHandle, HAL_Bool value,
int32_t* status) {
auto port = solenoidHandles.Get(solenoid_port_handle);
auto port = solenoidHandles.Get(solenoidPortHandle);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}
*status = PCM_modules[port->module]->SetSolenoid(port->pin, value);
*status = PCM_modules[port->module]->SetSolenoid(port->channel, value);
}
int32_t HAL_GetPCMSolenoidBlackList(int32_t module, int32_t* status) {