/** apci3120Lib.h
 *
 *  Author: N. Gissler
 *  Creation: 26.04.2019
 *  $LastChangedDate: 2016-11-14 17:00:03 +0100 (Mon, 14 Nov 2016) $
 *  $LastChangedRevision: 1494 $
 *
 *  Copyright (C) 2014 ADDI-DATA GmbH
 *
 *  ADDI-DATA GmbH
 *  Airpark Business Center
 *  Airport Boulevard B210
 *  77836 Rheinmünster
 *  Germany
 *  Tel: +49(0)7229/1847-0    |  Fax: +49(0)7229/1847-200
 *  http://www.addi-data-com  |  info@addi-data.com
 **/

/***********************************************/

#ifndef __APCI3120LIB_H__
#define __APCI3120LIB_H__

/***********************************************/

#include <inttypes.h>

/***********************************************/

/** \defgroup PCI3120_User xPCIx-171x user-space functions
 *  @{
 *      \addtogroup General_User General functions
 *      \ingroup PCI3120_User
 *      @{
 *      The general functions are intended to work with the xPCIx-171x boards, independently of the FMs loaded.
 */

/** Returns the number of detected boards.
 *
 * @param[out]  boardCount Number of boards
 *
 * @retval 0  No error
 * @retval <0 System error
 */
int i_APCI3120_GetNumberOfBoards(uint8_t *boardCount);

/** Frees the ressources allocated to access a board.
 *
 * @param[in]  boardId Target board identifier
 *
 * @retval 0  No error
 * @retval <0 System error
 */
int i_APCI3120_CloseBoard(uint8_t boardId);

/***********************************************/

int i_APCI3120_Read4DigitalInputs(uint8_t boardId, unsigned char *values);

int i_APCI3120_SetDigitalOutputMemoryOn(uint8_t boardId);
int i_APCI3120_SetDigitalOutputMemoryOff(uint8_t boardId);
int i_APCI3120_Set4DigitalOutputsOn(uint8_t boardId, unsigned long mask);
int i_APCI3120_Set4DigitalOutputsOff(uint8_t boardId, unsigned long mask);

/***********************************************/

float computeVoltage(unsigned int value, unsigned int full_scale);

int i_APCI3120_Read1AnalogInput(uint8_t boardId, unsigned int *arg);
int i_APCI3120_ReadMoreAnalogInputs(uint8_t boardId, unsigned int *arg);

/***********************************************/

int i_APCI3120_Write1AnalogOutput(uint8_t boardId, unsigned int *arg);

/***********************************************/


int i_APCI3120_InitAnalogInputSequenceAcquisition(uint8_t boardId, struct apci3120_sequence_acquisition_data *sequence_data);
int i_APCI3120_StartAnalogInputSequenceAcquisition(uint8_t boardId, struct apci3120_sequence_acquisition_data *sequence_data);
int i_APCI3120_StopAnalogInputSequenceAcquisition(uint8_t boardId);

/***********************************************/
int i_APCI3120_SetBoardInterruptRoutine(uint8_t boardId);
int i_APCI3120_ResetBoardInterruptRoutine(uint8_t boardId);

/***********************************************/

int i_APCI3120_EventWait(uint8_t boardId, apci3120_event_t *evt);

int i_APCI3120_EventEmpty(uint8_t boardId);

/***********************************************/
/**
 *      @}
 */

/***********************************************/

/**
 *  @}
 */

#endif // __APCI3120LIB_H__
