WPILibC++ 2023.4.3
DIO Functions

Functions

HAL_DigitalHandle HAL_InitializeDIOPort (HAL_PortHandle portHandle, HAL_Bool input, const char *allocationLocation, int32_t *status)
 Creates a new instance of a digital port. More...
 
HAL_Bool HAL_CheckDIOChannel (int32_t channel)
 Checks if a DIO channel is valid. More...
 
void HAL_FreeDIOPort (HAL_DigitalHandle dioPortHandle)
 Frees a DIO port. More...
 
void HAL_SetDIOSimDevice (HAL_DigitalHandle handle, HAL_SimDeviceHandle device)
 Indicates the DIO channel is used by a simulated device. More...
 
HAL_DigitalPWMHandle HAL_AllocateDigitalPWM (int32_t *status)
 Allocates a DO PWM Generator. More...
 
void HAL_FreeDigitalPWM (HAL_DigitalPWMHandle pwmGenerator, int32_t *status)
 Frees the resource associated with a DO PWM generator. More...
 
void HAL_SetDigitalPWMRate (double rate, int32_t *status)
 Changes the frequency of the DO PWM generator. More...
 
void HAL_SetDigitalPWMDutyCycle (HAL_DigitalPWMHandle pwmGenerator, double dutyCycle, int32_t *status)
 Configures the duty-cycle of the PWM generator. More...
 
void HAL_SetDigitalPWMPPS (HAL_DigitalPWMHandle pwmGenerator, double dutyCycle, int32_t *status)
 Configures the digital PWM to be a PPS signal with specified duty cycle. More...
 
void HAL_SetDigitalPWMOutputChannel (HAL_DigitalPWMHandle pwmGenerator, int32_t channel, int32_t *status)
 Configures which DO channel the PWM signal is output on. More...
 
void HAL_SetDIO (HAL_DigitalHandle dioPortHandle, HAL_Bool value, int32_t *status)
 Writes a digital value to a DIO channel. More...
 
void HAL_SetDIODirection (HAL_DigitalHandle dioPortHandle, HAL_Bool input, int32_t *status)
 Sets the direction of a DIO channel. More...
 
HAL_Bool HAL_GetDIO (HAL_DigitalHandle dioPortHandle, int32_t *status)
 Reads a digital value from a DIO channel. More...
 
HAL_Bool HAL_GetDIODirection (HAL_DigitalHandle dioPortHandle, int32_t *status)
 Reads the direction of a DIO channel. More...
 
void HAL_Pulse (HAL_DigitalHandle dioPortHandle, double pulseLengthSeconds, int32_t *status)
 Generates a single digital pulse. More...
 
void HAL_PulseMultiple (uint32_t channelMask, double pulseLengthSeconds, int32_t *status)
 Generates a single digital pulse on multiple channels. More...
 
HAL_Bool HAL_IsPulsing (HAL_DigitalHandle dioPortHandle, int32_t *status)
 Checks a DIO line to see if it is currently generating a pulse. More...
 
HAL_Bool HAL_IsAnyPulsing (int32_t *status)
 Checks if any DIO line is currently generating a pulse. More...
 
void HAL_SetFilterSelect (HAL_DigitalHandle dioPortHandle, int32_t filterIndex, int32_t *status)
 Writes the filter index from the FPGA. More...
 
int32_t HAL_GetFilterSelect (HAL_DigitalHandle dioPortHandle, int32_t *status)
 Reads the filter index from the FPGA. More...
 
void HAL_SetFilterPeriod (int32_t filterIndex, int64_t value, int32_t *status)
 Sets the filter period for the specified filter index. More...
 
int64_t HAL_GetFilterPeriod (int32_t filterIndex, int32_t *status)
 Gets the filter period for the specified filter index. More...
 

Detailed Description

Function Documentation

◆ HAL_AllocateDigitalPWM()

HAL_DigitalPWMHandle HAL_AllocateDigitalPWM ( int32_t *  status)

Allocates a DO PWM Generator.

Parameters
[out]statusError status variable. 0 on success.
Returns
the allocated digital PWM handle

◆ HAL_CheckDIOChannel()

HAL_Bool HAL_CheckDIOChannel ( int32_t  channel)

Checks if a DIO channel is valid.

Parameters
channelthe channel number to check
Returns
true if the channel is correct, otherwise false

◆ HAL_FreeDigitalPWM()

void HAL_FreeDigitalPWM ( HAL_DigitalPWMHandle  pwmGenerator,
int32_t *  status 
)

Frees the resource associated with a DO PWM generator.

Parameters
[in]pwmGeneratorthe digital PWM handle
[out]statusError status variable. 0 on success.

◆ HAL_FreeDIOPort()

void HAL_FreeDIOPort ( HAL_DigitalHandle  dioPortHandle)

Frees a DIO port.

Parameters
dioPortHandlethe DIO channel handle

◆ HAL_GetDIO()

HAL_Bool HAL_GetDIO ( HAL_DigitalHandle  dioPortHandle,
int32_t *  status 
)

Reads a digital value from a DIO channel.

Parameters
[in]dioPortHandlethe digital port handle
[out]statusError status variable. 0 on success.
Returns
the state of the specified channel

◆ HAL_GetDIODirection()

HAL_Bool HAL_GetDIODirection ( HAL_DigitalHandle  dioPortHandle,
int32_t *  status 
)

Reads the direction of a DIO channel.

Parameters
[in]dioPortHandlethe digital port handle
[out]statusError status variable. 0 on success.
Returns
true for input, false for output

◆ HAL_GetFilterPeriod()

int64_t HAL_GetFilterPeriod ( int32_t  filterIndex,
int32_t *  status 
)

Gets the filter period for the specified filter index.

Gets the filter period in FPGA cycles. Even though there are 2 different filter index domains (MXP vs HDR), ignore that distinction for now since it compilicates the interface. Set status to NiFpga_Status_SoftwareFault if the filter values miss-match.

Parameters
[in]filterIndexthe filter index, 0 - 2
[out]statusError status variable. 0 on success.

◆ HAL_GetFilterSelect()

int32_t HAL_GetFilterSelect ( HAL_DigitalHandle  dioPortHandle,
int32_t *  status 
)

Reads the filter index from the FPGA.

Gets the filter index used to filter out short pulses.

Parameters
[in]dioPortHandlethe digital port handle
[out]statusError status variable. 0 on success.
Returns
filterIndex the filter index (Must be in the range 0 - 3, where 0 means "none" and 1 - 3 means filter # filterIndex - 1)

◆ HAL_InitializeDIOPort()

HAL_DigitalHandle HAL_InitializeDIOPort ( HAL_PortHandle  portHandle,
HAL_Bool  input,
const char *  allocationLocation,
int32_t *  status 
)

Creates a new instance of a digital port.

Parameters
[in]portHandlethe port handle to create from
[in]inputtrue for input, false for output
[in]allocationLocationthe location where the allocation is occurring (can be null)
[out]statusError status variable. 0 on success.
Returns
the created digital handle

◆ HAL_IsAnyPulsing()

HAL_Bool HAL_IsAnyPulsing ( int32_t *  status)

Checks if any DIO line is currently generating a pulse.

Parameters
[out]statusError status variable. 0 on success.
Returns
true if a pulse on some line is in progress

◆ HAL_IsPulsing()

HAL_Bool HAL_IsPulsing ( HAL_DigitalHandle  dioPortHandle,
int32_t *  status 
)

Checks a DIO line to see if it is currently generating a pulse.

Parameters
[in]dioPortHandlethe digital port handle
[out]statusError status variable. 0 on success.
Returns
true if a pulse is in progress, otherwise false

◆ HAL_Pulse()

void HAL_Pulse ( HAL_DigitalHandle  dioPortHandle,
double  pulseLengthSeconds,
int32_t *  status 
)

Generates a single digital pulse.

Write a pulse to the specified digital output channel. There can only be a single pulse going at any time.

Parameters
[in]dioPortHandlethe digital port handle
[in]pulseLengthSecondsthe active length of the pulse (in seconds)
[out]statusError status variable. 0 on success.

◆ HAL_PulseMultiple()

void HAL_PulseMultiple ( uint32_t  channelMask,
double  pulseLengthSeconds,
int32_t *  status 
)

Generates a single digital pulse on multiple channels.

Write a pulse to the channels enabled by the mask. There can only be a single pulse going at any time.

Parameters
[in]channelMaskthe channel mask
[in]pulseLengthSecondsthe active length of the pulse (in seconds)
[out]statusError status variable. 0 on success.

◆ HAL_SetDigitalPWMDutyCycle()

void HAL_SetDigitalPWMDutyCycle ( HAL_DigitalPWMHandle  pwmGenerator,
double  dutyCycle,
int32_t *  status 
)

Configures the duty-cycle of the PWM generator.

Parameters
[in]pwmGeneratorthe digital PWM handle
[in]dutyCyclethe percent duty cycle to output [0..1]
[out]statusError status variable. 0 on success.

◆ HAL_SetDigitalPWMOutputChannel()

void HAL_SetDigitalPWMOutputChannel ( HAL_DigitalPWMHandle  pwmGenerator,
int32_t  channel,
int32_t *  status 
)

Configures which DO channel the PWM signal is output on.

Parameters
[in]pwmGeneratorthe digital PWM handle
[in]channelthe channel to output on
[out]statusError status variable. 0 on success.

◆ HAL_SetDigitalPWMPPS()

void HAL_SetDigitalPWMPPS ( HAL_DigitalPWMHandle  pwmGenerator,
double  dutyCycle,
int32_t *  status 
)

Configures the digital PWM to be a PPS signal with specified duty cycle.

Parameters
[in]pwmGeneratorthe digital PWM handle
[in]dutyCyclethe percent duty cycle to output [0..1]
[out]statusError status variable. 0 on success.

◆ HAL_SetDigitalPWMRate()

void HAL_SetDigitalPWMRate ( double  rate,
int32_t *  status 
)

Changes the frequency of the DO PWM generator.

The valid range is from 0.6 Hz to 19 kHz.

The frequency resolution is logarithmic.

Parameters
[in]ratethe frequency to output all digital output PWM signals
[out]statusError status variable. 0 on success.

◆ HAL_SetDIO()

void HAL_SetDIO ( HAL_DigitalHandle  dioPortHandle,
HAL_Bool  value,
int32_t *  status 
)

Writes a digital value to a DIO channel.

Parameters
[in]dioPortHandlethe digital port handle
[in]valuethe state to set the digital channel (if it is configured as an output)
[out]statusError status variable. 0 on success.

◆ HAL_SetDIODirection()

void HAL_SetDIODirection ( HAL_DigitalHandle  dioPortHandle,
HAL_Bool  input,
int32_t *  status 
)

Sets the direction of a DIO channel.

Parameters
[in]dioPortHandlethe digital port handle
[in]inputtrue to set input, false for output
[out]statusError status variable. 0 on success.

◆ HAL_SetDIOSimDevice()

void HAL_SetDIOSimDevice ( HAL_DigitalHandle  handle,
HAL_SimDeviceHandle  device 
)

Indicates the DIO channel is used by a simulated device.

Parameters
handlethe DIO channel handle
devicesimulated device handle

◆ HAL_SetFilterPeriod()

void HAL_SetFilterPeriod ( int32_t  filterIndex,
int64_t  value,
int32_t *  status 
)

Sets the filter period for the specified filter index.

Sets the filter period in FPGA cycles. Even though there are 2 different filter index domains (MXP vs HDR), ignore that distinction for now since it compilicates the interface. That can be changed later.

Parameters
[in]filterIndexthe filter index, 0 - 2
[in]valuethe number of cycles that the signal must not transition to be counted as a transition.
[out]statusError status variable. 0 on success.

◆ HAL_SetFilterSelect()

void HAL_SetFilterSelect ( HAL_DigitalHandle  dioPortHandle,
int32_t  filterIndex,
int32_t *  status 
)

Writes the filter index from the FPGA.

Set the filter index used to filter out short pulses.

Parameters
[in]dioPortHandlethe digital port handle
[in]filterIndexthe filter index (Must be in the range 0 - 3, where 0 means "none" and 1 - 3 means filter # filterIndex
  • 1)
[out]statusError status variable. 0 on success.