12 #include "hal/Types.h"
35 virtual void ResetHandles();
36 static void ResetGlobalHandles();
42 constexpr int16_t InvalidHandleIndex = -1;
82 return static_cast<int16_t>(handle & 0xffff);
93 return static_cast<HAL_HandleEnum>((handle >> 24) & 0xff);
117 return (((handle & 0xFF0000) >> 16) & version) == version;
134 if (!
isHandleType(handle, enumType))
return InvalidHandleIndex;
135 #if !defined(__FRC_ROBORIO__)
158 if (!
isHandleType(handle, HAL_HandleEnum::Port))
return InvalidHandleIndex;
159 return static_cast<uint8_t>(handle & 0xff);
170 if (!
isHandleType(handle, HAL_HandleEnum::Port))
return InvalidHandleIndex;
171 return static_cast<uint8_t>((handle >> 8) & 0xff);
182 if (!
isHandleType(handle, HAL_HandleEnum::Port))
return InvalidHandleIndex;
183 return static_cast<uint8_t>((handle >> 16) & 0xff);
HAL_HandleEnum
Enum of HAL handle types.
Definition: HandlesInternal.h:47
static int16_t getHandleIndex(HAL_Handle handle)
Get the handle index from a handle.
Definition: HandlesInternal.h:80
HAL_PortHandle createPortHandle(uint8_t channel, uint8_t module)
Create a port handle.
WPILib Hardware Abstraction Layer (HAL) namespace.
Definition: UnsafeDIO.h:15
static bool isHandleCorrectVersion(HAL_Handle handle, int16_t version)
Get if the version of the handle is correct.
Definition: HandlesInternal.h:116
static HAL_HandleEnum getHandleType(HAL_Handle handle)
Get the handle type from a handle.
Definition: HandlesInternal.h:91
static int16_t getPortHandleChannel(HAL_PortHandle handle)
Gets the port channel of a port handle.
Definition: HandlesInternal.h:157
static int16_t getPortHandleModule(HAL_PortHandle handle)
Gets the port module of a port handle.
Definition: HandlesInternal.h:169
static bool isHandleType(HAL_Handle handle, HAL_HandleEnum handleType)
Get if the handle is a specific type.
Definition: HandlesInternal.h:103
static int16_t getHandleTypedIndex(HAL_Handle handle, HAL_HandleEnum enumType, int16_t version)
Get if the handle is a correct type and version.
Definition: HandlesInternal.h:131
HAL_PortHandle createPortHandleForSPI(uint8_t channel)
Create a port handle for SPI.
static int16_t getPortHandleSPIEnable(HAL_PortHandle handle)
Gets the SPI channel of a port handle.
Definition: HandlesInternal.h:181
Base for all HAL Handles.
Definition: HandlesInternal.h:29
HAL_Handle createHandle(int16_t index, HAL_HandleEnum handleType, int16_t version)
Create a handle for a specific index, type and version.