From 9832fcfe14f9b6135035a2e09be93826ea54ca2c Mon Sep 17 00:00:00 2001 From: Thad House Date: Thu, 17 Jun 2021 23:03:00 -0700 Subject: [PATCH] [hal] Fix DIO direction getter (#3445) Unset means input, where the code was assuming set means input. --- hal/src/main/native/athena/DIO.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hal/src/main/native/athena/DIO.cpp b/hal/src/main/native/athena/DIO.cpp index 7b6842e218..7b26dd16b1 100644 --- a/hal/src/main/native/athena/DIO.cpp +++ b/hal/src/main/native/athena/DIO.cpp @@ -281,12 +281,12 @@ void HAL_SetDIO(HAL_DigitalHandle dioPortHandle, HAL_Bool value, if (port->channel >= kNumDigitalHeaders + kNumDigitalMXPChannels) { isInput = ((currentOutputEnable.SPIPort >> remapSPIChannel(port->channel)) & - 1) != 0; + 1) == 0; } else if (port->channel < kNumDigitalHeaders) { - isInput = ((currentOutputEnable.Headers >> port->channel) & 1) != 0; + isInput = ((currentOutputEnable.Headers >> port->channel) & 1) == 0; } else { isInput = ((currentOutputEnable.MXP >> remapMXPChannel(port->channel)) & - 1) != 0; + 1) == 0; } if (isInput) { @@ -398,11 +398,11 @@ HAL_Bool HAL_GetDIODirection(HAL_DigitalHandle dioPortHandle, int32_t* status) { if (port->channel >= kNumDigitalHeaders + kNumDigitalMXPChannels) { return ((currentOutputEnable.SPIPort >> remapSPIChannel(port->channel)) & - 1) != 0; + 1) == 0; } else if (port->channel < kNumDigitalHeaders) { - return ((currentOutputEnable.Headers >> port->channel) & 1) != 0; + return ((currentOutputEnable.Headers >> port->channel) & 1) == 0; } else { - return ((currentOutputEnable.MXP >> remapMXPChannel(port->channel)) & 1) != + return ((currentOutputEnable.MXP >> remapMXPChannel(port->channel)) & 1) == 0; } }