WPILibC++ 2024.3.2

WPILib Hardware Abstraction Layer (HAL) namespace. More...

Namespaces

namespace  detail
 
namespace  impl
 

Classes

class  DigitalHandleResource
 The DigitalHandleResource class is a way to track handles. More...
 
struct  DIOSetProxy
 Proxy class for directly manipulating the DIO pins. More...
 
class  fpga_clock
 A std::chrono compatible wrapper around the FPGA Timer. More...
 
struct  HalCallbackListener
 
class  Handle
 A move-only C++ wrapper around a HAL handle. More...
 
class  HandleBase
 Base for all HAL Handles. More...
 
class  IndexedClassedHandleResource
 The IndexedClassedHandleResource class is a way to track handles. More...
 
class  IndexedHandleResource
 The IndexedHandleResource class is a way to track handles. More...
 
class  InterruptManager
 
class  LimitedClassedHandleResource
 The LimitedClassedHandleResource class is a way to track handles. More...
 
class  LimitedHandleResource
 The LimitedHandleResource class is a way to track handles. More...
 
class  SerialHelper
 A class for deterministically getting information about Serial Ports. More...
 
class  SimBoolean
 C++ wrapper around a HAL simulator boolean value handle. More...
 
class  SimCallbackRegistry
 Simulation callback registry. More...
 
class  SimDataValue
 Simulation data value wrapper. More...
 
class  SimDevice
 A move-only C++ wrapper around a HAL simulator device handle. More...
 
class  SimDouble
 C++ wrapper around a HAL simulator double value handle. More...
 
class  SimEnum
 C++ wrapper around a HAL simulator enum value handle. More...
 
class  SimInt
 C++ wrapper around a HAL simulator int value handle. More...
 
class  SimLong
 C++ wrapper around a HAL simulator long value handle. More...
 
class  SimValue
 C++ wrapper around a HAL simulator value handle. More...
 
class  UnlimitedHandleResource
 The UnlimitedHandleResource class is a way to track handles. More...
 

Typedefs

using SPIPort = Handle< HAL_SPIPort, HAL_SPI_kInvalid >
 A move-only C++ wrapper around HAL_SPIPort. More...
 
using I2CPort = Handle< HAL_I2CPort, HAL_I2C_kInvalid >
 A move-only C++ wrapper around HAL_I2CPort. More...
 

Enumerations

enum class  HAL_HandleEnum {
  Undefined = 0 , DIO = wpi::kHandleTypeHALBase , Port = 2 , Notifier = 3 ,
  Interrupt = 4 , AnalogOutput = 5 , AnalogInput = 6 , AnalogTrigger = 7 ,
  Relay = 8 , PWM = 9 , DigitalPWM = 10 , Counter = 11 ,
  FPGAEncoder = 12 , Encoder = 13 , Compressor = 14 , Solenoid = 15 ,
  AnalogGyro = 16 , Vendor = 17 , SimulationJni = 18 , CAN = 19 ,
  SerialPort = 20 , DutyCycle = 21 , DMA = 22 , AddressableLED = 23 ,
  CTREPCM = 24 , CTREPDP = 25 , REVPDH = 26 , REVPH = 27
}
 Enum of HAL handle types. More...
 

Functions

template<typename Functor >
void UnsafeManipulateDIO (HAL_DigitalHandle handle, int32_t *status, Functor func)
 Unsafe digital output set function This function can be used to perform fast and deterministically set digital outputs. More...
 
static int16_t getHandleIndex (HAL_Handle handle)
 Get the handle index from a handle. More...
 
static HAL_HandleEnum getHandleType (HAL_Handle handle)
 Get the handle type from a handle. More...
 
static bool isHandleType (HAL_Handle handle, HAL_HandleEnum handleType)
 Get if the handle is a specific type. More...
 
static bool isHandleCorrectVersion (HAL_Handle handle, int16_t version)
 Get if the version of the handle is correct. More...
 
int16_t getHandleTypedIndex (HAL_Handle handle, HAL_HandleEnum enumType, int16_t version)
 Get if the handle is a correct type and version. More...
 
int16_t getPortHandleChannel (HAL_PortHandle handle)
 Gets the port channel of a port handle. More...
 
int16_t getPortHandleModule (HAL_PortHandle handle)
 Gets the port module of a port handle. More...
 
int16_t getPortHandleSPIEnable (HAL_PortHandle handle)
 Gets the SPI channel of a port handle. More...
 
HAL_PortHandle createPortHandle (uint8_t channel, uint8_t module)
 Create a port handle. More...
 
HAL_PortHandle createPortHandleForSPI (uint8_t channel)
 Create a port handle for SPI. More...
 
HAL_Handle createHandle (int16_t index, HAL_HandleEnum handleType, int16_t version)
 Create a handle for a specific index, type and version. More...
 

Variables

constexpr int16_t InvalidHandleIndex = -1
 

Detailed Description

WPILib Hardware Abstraction Layer (HAL) namespace.

Typedef Documentation

◆ I2CPort

A move-only C++ wrapper around HAL_I2CPort.

Does not ensure destruction.

◆ SPIPort

A move-only C++ wrapper around HAL_SPIPort.

Does not ensure destruction.

Enumeration Type Documentation

◆ HAL_HandleEnum

enum class hal::HAL_HandleEnum
strong

Enum of HAL handle types.

Vendors/Teams should use Vendor (17).

Enumerator
Undefined 
DIO 
Port 
Notifier 
Interrupt 
AnalogOutput 
AnalogInput 
AnalogTrigger 
Relay 
PWM 
DigitalPWM 
Counter 
FPGAEncoder 
Encoder 
Compressor 
Solenoid 
AnalogGyro 
Vendor 
SimulationJni 
CAN 
SerialPort 
DutyCycle 
DMA 
AddressableLED 
CTREPCM 
CTREPDP 
REVPDH 
REVPH 

Function Documentation

◆ createHandle()

HAL_Handle hal::createHandle ( int16_t  index,
HAL_HandleEnum  handleType,
int16_t  version 
)

Create a handle for a specific index, type and version.

Note the version is not checked on the roboRIO.

Parameters
indexthe index
handleTypethe handle type
versionthe handle version
Returns
the created handle

◆ createPortHandle()

HAL_PortHandle hal::createPortHandle ( uint8_t  channel,
uint8_t  module 
)

Create a port handle.

Parameters
channelthe channel
modulethe module
Returns
port handle for the module and channel

◆ createPortHandleForSPI()

HAL_PortHandle hal::createPortHandleForSPI ( uint8_t  channel)

Create a port handle for SPI.

Parameters
channelthe SPI channel
Returns
port handle for the channel

◆ getHandleIndex()

static int16_t hal::getHandleIndex ( HAL_Handle  handle)
inlinestatic

Get the handle index from a handle.

Parameters
handlethe handle
Returns
the index

◆ getHandleType()

static HAL_HandleEnum hal::getHandleType ( HAL_Handle  handle)
inlinestatic

Get the handle type from a handle.

Parameters
handlethe handle
Returns
the type

◆ getHandleTypedIndex()

int16_t hal::getHandleTypedIndex ( HAL_Handle  handle,
HAL_HandleEnum  enumType,
int16_t  version 
)
inline

Get if the handle is a correct type and version.

Note the version is not checked on the roboRIO.

Parameters
handlethe handle
enumTypethe type to check
versionthe handle version to check
Returns
true if the handle is proper version and type, otherwise false.

◆ getPortHandleChannel()

int16_t hal::getPortHandleChannel ( HAL_PortHandle  handle)
inline

Gets the port channel of a port handle.

Parameters
handlethe port handle
Returns
the port channel

◆ getPortHandleModule()

int16_t hal::getPortHandleModule ( HAL_PortHandle  handle)
inline

Gets the port module of a port handle.

Parameters
handlethe port handle
Returns
the port module

◆ getPortHandleSPIEnable()

int16_t hal::getPortHandleSPIEnable ( HAL_PortHandle  handle)
inline

Gets the SPI channel of a port handle.

Parameters
handlethe port handle
Returns
the port SPI channel

◆ isHandleCorrectVersion()

static bool hal::isHandleCorrectVersion ( HAL_Handle  handle,
int16_t  version 
)
inlinestatic

Get if the version of the handle is correct.

Do not use on the roboRIO, used specifically for the sim to handle resets.

Parameters
handlethe handle
versionthe handle version to check
Returns
true if the handle is the right version, otherwise false

◆ isHandleType()

static bool hal::isHandleType ( HAL_Handle  handle,
HAL_HandleEnum  handleType 
)
inlinestatic

Get if the handle is a specific type.

Parameters
handlethe handle
handleTypethe type to check
Returns
true if the type is correct, otherwise false

◆ UnsafeManipulateDIO()

template<typename Functor >
void hal::UnsafeManipulateDIO ( HAL_DigitalHandle  handle,
int32_t *  status,
Functor  func 
)

Unsafe digital output set function This function can be used to perform fast and deterministically set digital outputs.

This function holds the DIO lock, so calling anything other then functions on the Proxy object passed as a parameter can deadlock your program.

Parameters
[in]handlethe HAL digital handle of the pin to toggle.
[out]statusstatus check
[in]funcA functor taking a ref to a DIOSetProxy object.

Variable Documentation

◆ InvalidHandleIndex

constexpr int16_t hal::InvalidHandleIndex = -1
constexpr