Initialization

To initialize an Ndigo5G:

The following example shows a basic setup of an Ndigo5G using the default initialization parameters. A complete coding example can be found on github.com/cronologic-de/ndigo5g_babel or in Code example.

int status;

// get a default set of initialization parameters
ndigo_init_parameters params;
status = ndigo_get_default_init_parameters(&params);
if (status != NDIGO_OK) { /* handle error */ }

// initialize a device
const char* err_message;
ndigo_device* device = ndigo_init(&params, &status, &err_message);
if (status != NDIGO_OK) { /* handle error */ }

// use device

// after usage, free up all resources by closing the device
status = ndigo_close(device)
int ndigo_get_default_init_parameters(ndigo_init_parameters *init)

Sets up the standard parameters.

Gets a set of default parameters for ndigo_init(). This must always be used to initialize the ndigo_init_parameters structure.

Parameters:

init[in] Pointer to a structure in which to store the initialization values.

Returns:

A status code.

ndigo_device *ndigo_init(ndigo_init_parameters *params, int *error_code, const char **error_message)

Open and initialize an Ndigo5G board.

Which Ndigo5G board will be initialized is determined by ndigo_init_parameters::card_index.

Parameters:
  • params[in] Pointer to the structure that contains the initialization parameters.

  • error_code[out] Pointer to where the error code will be stored.

  • error_message[out] Pointer to a char pointer to where an error message as plain text will be stored.

Returns:

A pointer to an initialized Ndigo5G device.

int ndigo_close(ndigo_device *device)

Finalize the driver for this device.

Parameters:

device[in] Pointer to the device.

Returns:

A status code.

int ndigo_get_init_parameters(ndigo_device *device, ndigo_init_parameters *init_params)

Get init parameters of a device.

Parameters:
  • device[in] Pointer to the device.

  • init_params[out] Pointer to a struct to be filled.

Returns:

A status code.

struct ndigo_init_parameters

Struct for the initialization of the Ndigo board.

This structure must be completely initialized by calling ndigo_get_default_init_parameters() before initializing an Ndigo5G using ndigo_init().

Public Members

int version

Version number.

It is increased when the definition of the structure is changed. The increment can be larger than one to match driver version numbers or similar.

Set to 0 for all versions up to first release.

Must be set to NDIGO_API_VERSION.

int card_index

The index in the list of installed Ndigo boards that should be initialized.

There might be multiple boards in the system that are handled by this driver as reported by ndigo count devices. This index selects one of them. Boards are enumerated depending on the PCIe slot. The lower the bus number and the lower the slot number the lower the card index.

int board_id

8-bit board ID number.

This number is filled into each packet created by the board and is useful if data streams of multiple boards will be merged. If boards of different types that use a compatible data format are used in a system each board should get a unique ID.

Can be changed with ndigo_set_board_id().

ndigo_bool_t use_external_clock

Use 10MHz clock supplied by IPC at band cable.

Must be set for all slaves when synchronizing multiple boards.

ndigo_bool_t drive_external_clock

Drive internal 10MHz clock of this board to IPC at band cable.

Must be set for the master board when synchronizing multiple boards.

ndigo_bool_t is_slave

Data acquisition of this board is controlled by the master board.

ndigo_bool_t multiboard_sync

Set whether board is used in a multiple boards environment.

int direct_sync

If >0, the direct sync method is used for multi-board applications.

Value corresponds to accuracy (higher values for more accurate phase match).

int sync_period

Period of the multi-card sync pulse.

Should be set to 4 if only Ndigo5G boards are present in the system. If other boards are synchronized, the correct value is the lowest common denominator of the value of all boards.

Ignored for single board setups.

int sync_delay

Fine tap delay for incoming sync signals.

Ignored for single board setups.

int sync_delay_master

Fine tap delay for sync signals.

Ignored for single board setups

ndigo_bool_t force_window_calibration

Window calibration.

If true, a valid data window is automatically detected at initialization.

If false, values from flash memory are used in order to set the data window to the correct position.

Defaults to false.

ndigo_bool_t hptdc_sync_enabled

Enable the CLK and sync line for the HPTDC.

Must be set to false.

If an HPTDC is connected to the board this enables the CLK and sync line for the HPTDC.

int64_t buffer_size[8]

The minimum size of the host buffer.

If set to 0, the default size of 16MByte is used.

Only buffer_size[0] is used.

int buffer_type

Type of buffer.

Possible values follow. Currently, this has to be set to NDIGO_BUFFER_ALLOCATE.

NDIGO_BUFFER_ALLOCATE 0

Buffer is allocated by the device driver.

NDIGO_BUFFER_USE_PHYSICAL 1

Not implemented. Do not use.

NDIGO_BUFFER_USE_PREALLOCATED 2

Not implemented. Do not use.

uint64_t buffer_address

The start of the memory address in case NDIGO_BUFFER_USE_PHYSICAL is used.

Currently ignored. May be used for future buffer types.

The buffers will be allocated with the sizes given by ndigo_init_parameters::buffer_size.

unsigned int preallocated_buffer_size

The size of the preallocated buffer.

Used if NDIGO_BUFFER_USE_PREALLOCATED is used.

int variant

Specify board variant.

Can be used to activate future device variants, such as different base frequencies.

Defaults to 0.

int device_type

A constant for the different devices from cronologic.

Initialized by ndigo_get_default_init_parameters() and set to CRONO_DEVICE_NDIGO5G.

Must be left unchanged.

int dma_read_delay

The write pointer is delayed by this number 4n clock periods.

The write pointer update is delayed by this number of 4n clock periods to hide race conditions between software and DMA.

Initialized by ndigo_get_default_init_parameters().

struct ndigo_device

Contains information on the current device.

Returned by ndigo_init.

Public Members

bool is_valid
void *ndigo