C API

C GENERIC

group Generic

Generic utilities and helper functions for the C API.

This group includes base types, macros, and helper functions that are shared across modules. Useful for common operations required by multiple modules.

Functions

addi_data_code AddiDataGetNumberOfDevices(uint8_t *number_of_devices)

Get the Number Of Connected Devices.

Retrieves the number of devices currently detected by the system. This function should be called before AddiDataGetDeviceList().

Parameters:

number_of_devices[out] Pointer to a uint8_t receiving the number of devices.

Returns:

ADDIDATA_SUCCESS_CODE on success.

addi_data_code AddiDataGetDeviceList(AddiDataDeviceStruct *device_list)

Fill device_list with a table of strings containing a strucure list of device Infos.

Fills a preallocated array of AddiDataDeviceStruct with information for each detected device. The array referenced by device_list must be large enough to store all detected devices. Use AddiDataGetNumberOfDevices() beforehand to determine the required size.

Parameters:

device_list[out] Pointer to a preallocated array of AddiDataDeviceStruct that will receive the information for each detected device.

Returns:

ADDIDATA_SUCCESS_CODE on success.

addi_data_code AddiDataGetDeviceStructFromDeviceName(const char *device_id, AddiDataDeviceStruct *device)

Allow to easily recover the device information structure from the device id.

Looks up a device by its unique identifier and fills the provided AddiDataDeviceStruct with the corresponding information.

Parameters:
  • device_id[in] ID of the device

  • device[out] Pointer to a AddiDataDeviceStruct receiving the device information.

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

C COUNTER

group Counter

All Counter functions.

Functions to initialize, start, stop, and read hardware counters. Provides accurate counting for timing and events.

Functions

addi_data_code AddiDataInitCounter(const char *device_id, uint8_t counter_id, uint32_t reload_value, uint32_t options)

Initialize a hardware counter.

Configures a counter with a given reload value and a set of optional configuration flags. The supported options depend on the device model.

Available flags include:

  • COUNT_DIRECTION_UP / COUNT_DIRECTION_DOWN (APCIx-1564 only)

  • COUNTER_FALLING_EDGE_COUNT / COUNTER_RISING_EDGE_COUNT / COUNTER_BOTH_EDGE_COUNT (APCIx-1564 only)

  • SINGLE_CYCLE (APCIx-1500 only)

  • EXTERNAL_TRIGGER (APCIx-1500 only)

  • HARDWARE_GATE (APCIx-1500 only)

Parameters:
  • device_id[in] ID of the device

  • counter_id[in] Which counter to configure

  • reload_value[in] Reload value applied when reaching zero.

  • options[in] Bitfield of configuration options (see ADDI_DATA_TCW_OPTIONS).

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataStartCounter(const char *device_id, uint8_t counter_id)

Start the counter.

Starts the specified counter on the selected device.

Parameters:
  • device_id[in] ID of the device

  • counter_id[in] Counter index to start

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataStopCounter(const char *device_id, uint8_t counter_id)

Stop the counter.

Stops the specified counter on the selected device.

Parameters:
  • device_id[in] ID of the device

  • counter_id[in] Counter index to stop

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataReadCounterValue(const char *device_id, uint8_t counter_id, uint32_t *read_value)

Read the current counter value.

Reads the current value of the specified counter on the selected device.

Parameters:
  • device_id[in] ID of the device

  • counter_id[in] Counter to read

  • read_value[out] Returned counter value

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataReadCounterStatus(const char *device_id, uint8_t counter_id, uint32_t *read_value, uint8_t *is_started, uint8_t *software_trigger, uint8_t *has_expired)

Read the current counter value and status.

Reads the current value and status of the specified counter on the selected device.

Parameters:
  • device_id[in] ID of the device

  • counter_id[in] Counter to read

  • read_value[out] Returned counter value

  • is_started[out] 1 if counter running, otherwise 0

  • software_trigger[out] 1 if counter has been reset through software since last read, otherwise 0

  • has_expired[out] 1 if the counter has reached zero since the last read, otherwise 0.

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataEnableCounterInterrupt(const char *device_id, uint8_t counter_id)

Enable counter interrupts.

Enables interrupts for the specified counter on the selected device.

Parameters:
  • device_id[in] ID of the device

  • counter_id[in] Which counter to enable

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataDisableCounterInterrupt(const char *device_id, uint8_t counter_id)

Disable counter interrupts.

Disables interrupts for the specified counter on the selected device.

Parameters:
  • device_id[in] ID of the device

  • counter_id[in] Which counter to disable

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

C DIGITAL INPUT/OUTPUT

group Digital I/O

Digital input/output control.

Functions to configure and control digital input and output channels. Handles reading and writing digital signals safely.

Functions

addi_data_code AddiDataWriteSingleDigitalOutput(const char *device_id, uint8_t channel, uint8_t value)

Write a value 1 or 0 to the given channel number.

Writes a digital output value to a single channel on the specified device.

Parameters:
  • device_id[in] ID of the device

  • channel[in] which channel to write to

  • value[in] Logical value (0 = off, 1 = on)

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataWriteAllDigitalOutputs(const char *device_id, uint32_t channels, uint8_t value)

Write a value 1 or 0 on masked channels.

Writes a digital output value to multiple channels on the specified device, as specified by a channel mask.

Parameters:
  • device_id[in] ID of the device

  • channels[in] Bitmask selecting channels to write, where each bit represents a channel (1 = write, 0 = ignore)

  • value[in] Logical value (0 = off, 1 = on)

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataGetDigitalOutputsStatus(const char *device_id, uint32_t *output_status)

Get the stored Digital Output status i.e. the known state of outputs from the driver. On certain cards, it doesn’t strictly get the info from the card. It gets the info from the driver. Under normal circumstances, this is equal to the card outputs.

Parameters:
  • device_id[in] ID of the device

  • output_status[out] Pointer receiving the current outputs state (bitmask).

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataReadSingleDigitalInput(const char *device_id, uint8_t channel, uint8_t *value)

Will fill the first bit of value with the current value of channel.

Reads the digital input value from a single channel on the specified device.

Parameters:
  • device_id[in] ID of the device

  • channel[in] channel to read

  • value[out] Pointer receiving the logical value (0 or 1).

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataReadAllDigitalInputs(const char *device_id, uint32_t *channel_values)

Will fill channel_values with the value from each channel, one bit per channel.

Reads the digital input values from all channels on the specified device.

Parameters:
  • device_id[in] ID of the device

  • channel_values[out] Pointer receiving the input bitmask.

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataSetInterruptEventForInputs(const char *device_id, uint32_t channels, DIGITAL_EVENT_TYPE event_type)

Set the interrupt behaviour For Inputs, Old values are be kept and not erased, so multiple calls can be made to set each channels.

Parameters:
  • device_id[in] ID of the device

  • channels[in] Bitmask selecting input channels to configure.

  • event_type[in] Event type that triggers an interrupt.

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataSetInterruptEventForOneInput(const char *device_id, uint8_t channel, DIGITAL_EVENT_TYPE event_type)

Set the interrupt behaviour for a single input. Old should be kept and not erased.

Parameters:
  • device_id[in] ID of the device

  • channel[in] channel to set the interrupt

  • event_type[in] Event type that triggers an interrupt.

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataSetInterruptLogicForPort(const char *device_id, uint8_t port_number, DIGITAL_EVENT_LOGIC event_logic)

Set the Interrupt Logic For the given port_number. On cards that have one port (i.e. card that are not apcix1500), port_number is ignored.

Parameters:
Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataSetOutputMemory(const char *device_id, uint8_t enable)

Activating the output memory will save and use the output state when setting outputs. This means that with output memory, setting a given output will not have influence on other outputs. Without output memory, setting a given output will reset to 0 the other outputs. Defaults to ADDI_DATA_ENABLE.

Parameters:
  • device_id[in] ID of the device

  • enable[in] ADDI_DATA_ENABLE or ADDI_DATA_DISABLE

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataEnableDigitalInterrupt(const char *device_id)

Enable Interrupts for Digital functions.

Parameters:

device_id[in] ID of the device

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataDisableDigitalInterrupt(const char *device_id)

Disable Interrupts for Digital functions.

Parameters:

device_id[in] ID of the device

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataSetDigitalOutputInterrupt(const char *device_id, uint8_t enable_vcc, uint8_t enable_cc)

Configure digital output interrupt sources (VCC / CC)

Parameters:
  • device_id[in] ID of the device

  • enable_vcc[in] Enable VCC interrupt

  • enable_cc[in] Enable CC interrupt

Returns:

ADDIDATA_SUCCESS_CODE on success

addi_data_code AddiDataSetAllDigitalPortsDirection(const char *device_id, uint32_t direction_mask)

Set the direction of all digital ports at once.

Parameters:
  • device_id[in] ID of the device

  • direction_mask[in] A bitmask representing the direction of each port. A 0 bit indicates PORT_INPUT, a 1 bit indicates PORT_OUTPUT. The least significant bit corresponds to port 0.

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataGetAllDigitalPortDirections(const char *device_id, uint32_t *configuration)

Get the direction of all digital ports at once.

Parameters:
  • device_id[in] ID of the device

  • configuration[out] A bitmask representing the direction of each port. A 1 bit indicates PORT_OUTPUT, a 0 bit indicates PORT_INPUT. The least significant bit corresponds to port 0.

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataReadAllDigitalInputsFromPort(const char *device_id, uint8_t port_number, uint8_t *value)

Read all channels of a port and return the values as an integer.

Parameters:
  • device_id[in] ID of the device

  • port_number[in] The number of the port to read

  • value[out] The values of each channel of the port, where a 1 indicates a high value and a 0 indicates a low value

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataWriteSingleDigitalOutputOnPort(const char *device_id, uint8_t channel, uint8_t value, uint8_t port_number)

Write a single value to a channel of a port.

Parameters:
  • device_id[in] ID of the device

  • channel[in] The channel to write (0 to 7 for a port)

  • value[in] The value to write (0 or 1)

  • port_number[in] The number of the port

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataWriteAllDigitalOutputsOnPort(const char *device_id, uint8_t channels_mask, uint8_t value, uint8_t port_number)

Write all channels of a port. Only channels with a corresponding 1 in the channels_mask will be modified.

Parameters:
  • device_id[in] ID of the device

  • channels_mask[in] A bitmask representing the channels to modify (1 to modify, 0 to leave unchanged)

  • value[in] The value to write to the masked channels (0 or 1)

  • port_number[in] The number of the port

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataGetDigitalOutputsStatusOnPort(const char *device_id, uint8_t port_number, uint8_t *output_status)

Get the current output values of a port. Only channels with a corresponding 1 in the channels_mask will be returned.

Parameters:
  • device_id[in] ID of the device

  • port_number[in] The number of the port to query

  • output_status[out] The values of the masked channels, where a 1 indicates a high value and a 0 indicates a low value

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

C INTERRUPT

group Interrupt

All Interrupt functions.

Functions to configure, enable, and handle hardware interrupts. Ensures proper callback registration and event handling.

Functions

addi_data_code AddiDataSetDeviceInterruptCallback(const char *device_id, void (*interrupt_callback)(AddiDataDeviceStruct interrupted_device, InterruptData data))

Set the interrupt callback for the device.

Registers a callback function to be invoked when an interrupt occurs on the specified device.

Parameters:
  • device_id[in] ID of the device

  • interrupt_callback[in] Callback function to handle interrupts, receiving the interrupted device and interrupt data.

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataEnableDeviceInterrupts(const char *device_id)

Enable device-level interrupts.

Allow the device to forward interrupt events to the callback mechanism.

Parameters:

device_id[in] ID of the device

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataDisableDeviceInterrupts(const char *device_id)

Disable device-level interrupts.

Prevents the device from forwarding interrupt events.

Parameters:

device_id[in] ID of the device

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataTestDeviceInterrupts(const char *device_id)

Tests device interrupts by sending a “false” interrupt.

Sends an internal test interrupt through the driver. Useful to verify callback registration and interrupt handling.

Parameters:

device_id[in] ID of the device

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataClearInterruptFifo(const char *device_id)

Asks the driver to clean its internal interrupt fifo. Under normal circumstances, this function is not used. However, if the interrupt routine always as a “Fifo full” flag set, calling this function might unlock the situation.

Parameters:

device_id[in] ID of the device

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

C TIMER

group Timer

All Timer functions.

Functions to initialize, start, stop, and read timers. Useful for precise scheduling and measuring durations.

Functions

addi_data_code AddiDataInitTimer(const char *device_id, uint8_t timer_id, TIMEBASE_UNITS timebase, uint16_t reload_value, uint32_t options)

Initialize a timer.

Configures a timer using a timebase (µs/ms/s), a reload value, and optional flags. For frequency-based devices (e.g., APCIx-1500), the API automatically converts the timebase and reload value to the appropriate hardware frequency. In some cards, only 1 TIMEBASE_UNITS should be used for all timer (e.g. PCIX1500 series).

  • Available flags include:

  • SINGLE_CYCLE (APCIx-1500 only)

  • EXTERNAL_TRIGGER (APCIx-1500 only)

  • HARDWARE_GATE (APCIx-1500 only)

Parameters:
  • device_id[in] ID of the device

  • timer_id[in] Timer index to configure

  • timebase[in] Timebase unit (0=µs, 1=ms, 2=s, 3=custom)

  • reload_value[in] Value that will be reloaded when the flag SINGLE_CYCLE is not set

  • options[in] Bitfield of configuration flags (see ADDI_DATA_TCW_OPTIONS).

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataSetCustomTimerFrequency(const char *device_id, uint32_t frequency)

for frequency based devices (i.e. apcix1500) set a custom frequency for Timer/Watchdog Beware that when setting a custom frequency, value from Read timer will be dependent on this frequency. And init timer should be used with TIMEBASE_UNIT::CUSTOM.

Parameters:
  • device_id – ID of the device

  • frequency – custom frequency in Hz to set

addi_data_code AddiDataStartTimer(const char *device_id, uint8_t timer_id)

Start the timer.

Parameters:
  • device_id[in] ID of the device

  • timer_id[in] which timer to start

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataStopTimer(const char *device_id, uint8_t timer_id)

Stop the timer.

Parameters:
  • device_id[in] ID of the device

  • timer_id[in] which timer to stop

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataReadTimerValue(const char *device_id, uint8_t timer_id, uint32_t *read_value)

Read the current timer value Reads the remaining or current counter value of the timer. On frequency-based timer cards, the returned value may differ from the theoretical reload due to internal conversion.

Parameters:
  • device_id[in] ID of the device

  • timer_id[in] which timer to read

  • read_value[out] returned value

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataReadTimerStatus(const char *device_id, uint8_t timer_id, uint32_t *read_value, uint8_t *is_started, uint8_t *software_trigger, uint8_t *has_expired)

Read the current timer value and status On frequency-based timer cards, the value returned by readTimerStatus may not match the expected reload value directly due to conversion from timebase to frequency.

Parameters:
  • device_id[in] ID of the device

  • timer_id[in] which timer to read

  • read_value[out] returned value

  • is_started[out] 1 if timer is active, 0 otherwise.

  • software_trigger[out] 1 if timer has been reset through software since last read, 0 otherwise

  • has_expired[out] 1 if the timer has reached zero since the last read, otherwise 0.

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataTriggerTimer(const char *device_id, uint8_t timer_id)

Trigger timer.

Parameters:
  • device_id[in] ID of the device

  • timer_id[in] which timer to trigger

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataEnableTimerInterrupt(const char *device_id, uint8_t timer_id)

Enable timer interrupts.

Parameters:
  • device_id[in] ID of the device

  • timer_id[in] which timer to enable

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataDisableTimerInterrupt(const char *device_id, uint8_t timer_id)

Disable timer interrupts.

Parameters:
  • device_id[in] ID of the device

  • timer_id[in] which timer to disable

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

C WATCHDOG

group Watchdog

All Watchdog functions.

Functions to initialize, start, stop, and monitor hardware watchdog timers. Helps ensure system reliability by resetting in case of failures.

Functions

addi_data_code AddiDataInitWatchdog(const char *device_id, uint8_t watchdog_id, TIMEBASE_UNITS timebase, uint16_t reload_value, uint32_t options)

Initialize a watchdog.

Configures a watchdog using a timebase (µs/ms/s), a reload value, and optional flags. For frequency-based boards (e.g. APCIx-1500), the API automatically converts timebase and reload value to hardware frequency.

Available flags include:

  • SINGLE_CYCLE (APCIx-1500 only)

  • EXTERNAL_TRIGGER (APCIx-1500 only)

  • HARDWARE_GATE (APCIx-1500 only)

Parameters:
  • device_id[in] ID of the device

  • watchdog_id[in] Watchdog index to configure.

  • timebase[in] Timebase unit (0=µs, 1=ms, 2=s, 3=custom)

  • reload_value[in] Value that will be reloaded when the flag SINGLE_CYCLE is not set

  • options[in] Bitfield of configuration flags (see ADDI_DATA_TCW_OPTIONS)

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataStartWatchdog(const char *device_id, uint8_t watchdog_id)

Start the watchdog.

Parameters:
  • device_id[in] ID of the device

  • watchdog_id[in] which watchdog to start

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataStopWatchdog(const char *device_id, uint8_t watchdog_id)

Stop the watchdog.

Parameters:
  • device_id[in] ID of the device

  • watchdog_id[in] Which watchdog to stop

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataReadWatchdogValue(const char *device_id, uint8_t watchdog_id, uint32_t *value)

Read the current watchdog value and status On frequency-based watchdog cards, the value returned by readWatchdogValue may not match the expected reload value directly due to conversion from timebase to frequency.

Parameters:
  • device_id[in] ID of the device

  • watchdog_id[in] Which watchdog to read

  • value[out] Returned value

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataReadWatchdogStatus(const char *device_id, uint8_t watchdog_id, uint32_t *read_value, uint8_t *is_started, uint8_t *software_trigger, uint8_t *has_expired)

Read the current watchdog value On frequency-based watchdog cards, the value returned by readWatchdogStatus may not match the expected reload value directly due to conversion from timebase to frequency.

Parameters:
  • device_id[in] ID of the device

  • watchdog_id[in] which watchdog to read

  • read_value[out] returned value

  • is_started[out] Value is 1 if watchdog is running, 0 otherwise

  • software_trigger[out] Set to 1 if Watchdog has been reset through software since last read, 0 otherwise

  • has_expired[out] 1 if the watchdog has reached zero since the last read, otherwise 0.

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataTriggerWatchdog(const char *device_id, uint8_t watchdog_id)

Trigger watchdog.

Parameters:
  • device_id[in] ID of the device

  • watchdog_id[in] Which watchdog to trigger

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataEnableWatchdogInterrupt(const char *device_id, uint8_t watchdog_id)

Enable watchdog interrupts.

Parameters:
  • device_id[in] ID of the device

  • watchdog_id[in] which watchdog to enable

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.

addi_data_code AddiDataDisableWatchdogInterrupt(const char *device_id, uint8_t watchdog_id)

Disable watchdog interrupts.

Parameters:
  • device_id[in] ID of the device

  • watchdog_id[in] which watchdog to disable

Returns:

ADDIDATA_SUCCESS_CODE on success. Otherwise, see Common Error Codes.