[hal] Remove HAL_GetPort (#7754)

This commit is contained in:
Thad House
2025-01-30 18:59:34 -08:00
committed by GitHub
parent 6e704370b3
commit ad29d45dfb
44 changed files with 84 additions and 272 deletions

View File

@@ -19,11 +19,9 @@ void InitializeAnalogInput() {}
extern "C" {
HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
HAL_PortHandle portHandle, const char* allocationLocation,
int32_t* status) {
int32_t channel, const char* allocationLocation, int32_t* status) {
hal::init::CheckInit();
int16_t channel = getPortHandleChannel(portHandle);
if (channel == InvalidHandleIndex || channel >= kNumAnalogInputs) {
if (channel < 0 || channel >= kNumAnalogInputs) {
*status = RESOURCE_OUT_OF_RANGE;
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Input",
0, kNumAnalogInputs, channel);

View File

@@ -31,14 +31,12 @@ void InitializeDIO() {
extern "C" {
HAL_DigitalHandle HAL_InitializeDIOPort(HAL_PortHandle portHandle,
HAL_Bool input,
HAL_DigitalHandle HAL_InitializeDIOPort(int32_t channel, HAL_Bool input,
const char* allocationLocation,
int32_t* status) {
hal::init::CheckInit();
int16_t channel = getPortHandleChannel(portHandle);
if (channel == InvalidHandleIndex) {
if (channel < 0 || channel >= kNumDigitalChannels) {
*status = RESOURCE_OUT_OF_RANGE;
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
kNumDigitalChannels, channel);

View File

@@ -33,7 +33,7 @@ void InitializeDutyCycle() {
} // namespace hal::init
extern "C" {
HAL_DutyCycleHandle HAL_InitializeDutyCycle(HAL_PortHandle portHandle,
HAL_DutyCycleHandle HAL_InitializeDutyCycle(int32_t channel,
const char* allocationLocation,
int32_t* status) {
hal::init::CheckInit();
@@ -51,7 +51,7 @@ HAL_DutyCycleHandle HAL_InitializeDutyCycle(HAL_PortHandle portHandle,
}
int16_t index = getHandleIndex(handle);
SimDutyCycleData[index].digitalChannel = getPortHandleChannel(portHandle);
SimDutyCycleData[index].digitalChannel = channel;
SimDutyCycleData[index].initialized = true;
SimDutyCycleData[index].simDevice = 0;
dutyCycle->index = index;

View File

@@ -112,25 +112,6 @@ void InitializeHAL() {
extern "C" {
HAL_PortHandle HAL_GetPort(int32_t channel) {
// Dont allow a number that wouldn't fit in a uint8_t
if (channel < 0 || channel >= 255) {
return HAL_kInvalidHandle;
}
return createPortHandle(channel, 1);
}
HAL_PortHandle HAL_GetPortWithModule(int32_t module, int32_t channel) {
// Dont allow a number that wouldn't fit in a uint8_t
if (channel < 0 || channel >= 255) {
return HAL_kInvalidHandle;
}
if (module < 0 || module >= 255) {
return HAL_kInvalidHandle;
}
return createPortHandle(channel, module);
}
const char* HAL_GetErrorMessage(int32_t code) {
switch (code) {
case 0:

View File

@@ -63,13 +63,12 @@ static inline int32_t GetFullRangeScaleFactor(DigitalPort* port) {
extern "C" {
HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle portHandle,
HAL_DigitalHandle HAL_InitializePWMPort(int32_t channel,
const char* allocationLocation,
int32_t* status) {
hal::init::CheckInit();
int16_t channel = getPortHandleChannel(portHandle);
if (channel == InvalidHandleIndex) {
if (channel < 0 || channel >= kNumPWMChannels) {
*status = RESOURCE_OUT_OF_RANGE;
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
kNumPWMChannels, channel);