mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[hal] Remove HAL_GetPort (#7754)
This commit is contained in:
@@ -26,12 +26,10 @@ using namespace hal;
|
||||
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 >= kNumSmartIo) {
|
||||
if (channel < 0 || channel >= kNumSmartIo) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog", 0,
|
||||
kNumSmartIo, channel);
|
||||
|
||||
@@ -25,14 +25,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 || channel >= kNumSmartIo) {
|
||||
if (channel < 0 || channel >= kNumSmartIo) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
|
||||
kNumSmartIo, channel);
|
||||
|
||||
@@ -24,13 +24,12 @@ 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();
|
||||
|
||||
int16_t channel = getPortHandleChannel(portHandle);
|
||||
if (channel == InvalidHandleIndex || channel >= kNumSmartIo) {
|
||||
if (channel < 0 || channel >= kNumSmartIo) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DutyCycle", 0,
|
||||
kNumSmartIo, channel);
|
||||
|
||||
@@ -81,25 +81,6 @@ uint64_t GetDSInitializeTime() {
|
||||
|
||||
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:
|
||||
|
||||
@@ -68,13 +68,12 @@ void InitializePWM() {}
|
||||
|
||||
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 || channel >= kNumSmartIo) {
|
||||
if (channel < 0 || channel >= kNumSmartIo) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
|
||||
kNumSmartIo, channel);
|
||||
|
||||
Reference in New Issue
Block a user