AlcapDAQ  1
Macros | Typedefs | Enumerations | Functions
CAENComm.h File Reference
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdint.h>

Go to the source code of this file.

Macros

#define STDCALL
 

Typedefs

typedef enum
CAEN_Comm_ConnectionType 
CAENComm_ConnectionType
 
typedef enum CAENComm_ErrorCode CAENComm_ErrorCode
 
typedef enum CAENCOMM_INFO CAENCOMM_INFO
 
typedef enum IRQLevels IRQLevels
 

Enumerations

enum  CAEN_Comm_ConnectionType { CAENComm_USB = 0, CAENComm_PCI_OpticalLink = 1, CAENComm_PCIE_OpticalLink = 2, CAENComm_PCIE = 3 }
 
enum  CAENComm_ErrorCode {
  CAENComm_Success = 0, CAENComm_VMEBusError = -1, CAENComm_CommError = -2, CAENComm_GenericError = -3,
  CAENComm_InvalidParam = -4, CAENComm_InvalidLinkType = -5, CAENComm_InvalidHandler = -6, CAENComm_CommTimeout = -7,
  CAENComm_DeviceNotFound = -8, CAENComm_MaxDevicesError = -9, CAENComm_DeviceAlreadyOpen = -10, CAENComm_NotSupported = -11,
  CAENComm_UnusedBridge = -12, CAENComm_Terminated = -13
}
 
enum  CAENCOMM_INFO {
  CAENComm_PCI_Board_SN = 0, CAENComm_PCI_Board_FwRel = 1, CAENComm_VME_Bridge_SN = 2, CAENComm_VME_Bridge_FwRel1 = 3,
  CAENComm_VME_Bridge_FwRel2 = 4
}
 
enum  IRQLevels {
  IRQ1 = 0x01, IRQ2 = 0x02, IRQ3 = 0x04, IRQ4 = 0x08,
  IRQ5 = 0x10, IRQ6 = 0x20, IRQ7 = 0x40
}
 

Functions

CAENComm_ErrorCode STDCALL CAENComm_DecodeError (int ErrCode, char *ErrMsg)
 Decode error code. More...
 
CAENComm_ErrorCode STDCALL CAENComm_OpenDevice (CAENComm_ConnectionType LinkType, int LinkNum, int ConetNode, uint32_t VMEBaseAddress, int *handle)
 
CAENComm_ErrorCode STDCALL CAENComm_CloseDevice (int handle)
 Close the device. More...
 
CAENComm_ErrorCode STDCALL CAENComm_Write32 (int handle, uint32_t Address, uint32_t Data)
 
CAENComm_ErrorCode STDCALL CAENComm_Write16 (int handle, uint32_t Address, uint16_t Data)
 
CAENComm_ErrorCode STDCALL CAENComm_Read32 (int handle, uint32_t Address, uint32_t *Data)
 Read a 32 bit data from the specified register. More...
 
CAENComm_ErrorCode STDCALL CAENComm_Read16 (int handle, uint32_t Address, uint16_t *Data)
 Read a 16 bit data from the specified register. More...
 
CAENComm_ErrorCode STDCALL CAENComm_MultiRead32 (int handle, uint32_t *Address, int nCycles, uint32_t *data, CAENComm_ErrorCode *ErrorCode)
 
CAENComm_ErrorCode STDCALL CAENComm_MultiRead16 (int handle, uint32_t *Address, int nCycles, uint16_t *data, CAENComm_ErrorCode *ErrorCode)
 
CAENComm_ErrorCode STDCALL CAENComm_MultiWrite16 (int handle, uint32_t *Address, int nCycles, uint16_t *data, CAENComm_ErrorCode *ErrorCode)
 
CAENComm_ErrorCode STDCALL CAENComm_MultiWrite32 (int handle, uint32_t *Address, int nCycles, uint32_t *data, CAENComm_ErrorCode *ErrorCode)
 The function performs a block of single 16bit WriteRegister. More...
 
CAENComm_ErrorCode STDCALL CAENComm_BLTRead (int handle, uint32_t Address, uint32_t *Buff, int BltSize, int *nw)
 Read a block of data from the device using a BLT (32 bit) cycle. More...
 
CAENComm_ErrorCode STDCALL CAENComm_MBLTRead (int handle, uint32_t Address, uint32_t *Buff, int BltSize, int *nw)
 Read a block of data from the device using an MBLT (64 bit) cycle. More...
 
CAENComm_ErrorCode STDCALL CAENComm_VMEIRQCheck (int VMEhandle, uint8_t *Mask)
 The function returns a bit mask indicating the active VME IRQ lines. More...
 
CAENComm_ErrorCode STDCALL CAENComm_IRQDisable (int handle)
 The function disables the IRQ lines. More...
 
CAENComm_ErrorCode STDCALL CAENComm_IRQEnable (int handle)
 The function enaables the IRQ lines. More...
 
CAENComm_ErrorCode STDCALL CAENComm_VMEIACKCycle16 (int VMEhandle, IRQLevels Level, int *BoardID)
 The function performs a 16 bit VME interrupt acknowledge cycle . More...
 
CAENComm_ErrorCode STDCALL CAENComm_VMEIACKCycle32 (int VMEhandle, IRQLevels Level, int *BoardID)
 The function performs a 32 bit VME interrupt acknowledge cycle. More...
 
CAENComm_ErrorCode STDCALL CAENComm_IACKCycle (int handle, IRQLevels Level, int *BoardID)
 The function performs a 16 bit VME interrupt acknowledge cycle . More...
 
CAENComm_ErrorCode STDCALL CAENComm_IRQWait (int handle, uint32_t Timeout)
 The function wait the IRQ until one of them raise or timeout expires. This function can be used ONLY on board NOT controlled by CAEN VME Bridges. More...
 
CAENComm_ErrorCode STDCALL CAENComm_VMEIRQWait (CAENComm_ConnectionType LinkType, int LinkNum, int ConetNode, uint8_t IRQMask, uint32_t Timeout, int *VMEHandle)
 
CAENComm_ErrorCode STDCALL CAENComm_Info (int handle, CAENCOMM_INFO info, char *data)
 The function returns information about serial number or firmware release of the device. More...
 
CAENComm_ErrorCode STDCALL CAENComm_SWRelease (char *SwRel)
 Returns the Software Release of the library. More...
 

Macro Definition Documentation

#define STDCALL

Name CAENComm.h Project CAENComm - Communication Layer Authors Carlo Tintori & Alberto Lucchesi (suppo.nosp@m.rt.c.nosp@m.omput.nosp@m.ing@.nosp@m.caen..nosp@m.it) Version 1.0 Date 2009/09/23

This library provides the low level functions for the access to the devices. By default, this library is based on the CAENVMElib (CAEN VME bridges V1718 and V2718) and the CAENVMElink (USB and CONET).

Definition at line 36 of file CAENComm.h.

Typedef Documentation

typedef enum IRQLevels IRQLevels

Enumeration Type Documentation

Enumerator
CAENComm_USB 
CAENComm_PCI_OpticalLink 
CAENComm_PCIE_OpticalLink 
CAENComm_PCIE 

Definition at line 75 of file CAENComm.h.

Enumerator
CAENComm_Success 
CAENComm_VMEBusError 
CAENComm_CommError 
CAENComm_GenericError 
CAENComm_InvalidParam 
CAENComm_InvalidLinkType 
CAENComm_InvalidHandler 
CAENComm_CommTimeout 
CAENComm_DeviceNotFound 
CAENComm_MaxDevicesError 
CAENComm_DeviceAlreadyOpen 
CAENComm_NotSupported 
CAENComm_UnusedBridge 
CAENComm_Terminated 

Definition at line 82 of file CAENComm.h.

82  {
83 /* Error Types */
84  CAENComm_Success = 0, /* Operation completed successfully */
85  CAENComm_VMEBusError = -1, /* VME bus error during the cycle */
86  CAENComm_CommError = -2, /* Communication error */
87  CAENComm_GenericError = -3, /* Unspecified error */
88  CAENComm_InvalidParam = -4, /* Invalid parameter */
89  CAENComm_InvalidLinkType = -5, /* Invalid Link Type */
90  CAENComm_InvalidHandler = -6, /* Invalid device handler */
91  CAENComm_CommTimeout = -7, /* Communication Timeout */
92  CAENComm_DeviceNotFound = -8, /* Unable to Open the requested Device */
93  CAENComm_MaxDevicesError = -9, /* Maximum number of devices exceeded */
94  CAENComm_DeviceAlreadyOpen = -10, /* The device is already opened */
95  CAENComm_NotSupported = -11, /* Not supported function */
96  CAENComm_UnusedBridge = -12, /* There aren't board controlled by that CAEN Bridge */
97  CAENComm_Terminated = -13, /* Communication terminated by the Device */
Enumerator
CAENComm_PCI_Board_SN 
CAENComm_PCI_Board_FwRel 
CAENComm_VME_Bridge_SN 
CAENComm_VME_Bridge_FwRel1 
CAENComm_VME_Bridge_FwRel2 

Definition at line 100 of file CAENComm.h.

100  {
101  CAENComm_PCI_Board_SN = 0, /* s/n of the PCI/PCIe board */
102  CAENComm_PCI_Board_FwRel = 1, /* Firmware Release fo the PCI/PCIe board */
103  CAENComm_VME_Bridge_SN = 2, /* s/n of the VME bridge */
104  CAENComm_VME_Bridge_FwRel1 = 3, /* Firmware Release for the VME bridge */
105  CAENComm_VME_Bridge_FwRel2 = 4, /* Firmware Release for the optical chipset inside the VME bridge (V2718 only)*/
106 } CAENCOMM_INFO;
enum IRQLevels
Enumerator
IRQ1 
IRQ2 
IRQ3 
IRQ4 
IRQ5 
IRQ6 
IRQ7 

Definition at line 109 of file CAENComm.h.

109  {
110  IRQ1 = 0x01, /* Interrupt level 1 */
111  IRQ2 = 0x02, /* Interrupt level 2 */
112  IRQ3 = 0x04, /* Interrupt level 3 */
113  IRQ4 = 0x08, /* Interrupt level 4 */
114  IRQ5 = 0x10, /* Interrupt level 5 */
115  IRQ6 = 0x20, /* Interrupt level 6 */
116  IRQ7 = 0x40 /* Interrupt level 7 */
117 } IRQLevels;

Function Documentation

CAENComm_ErrorCode STDCALL CAENComm_BLTRead ( int  handle,
uint32_t  Address,
uint32_t *  Buff,
int  BltSize,
int *  nw 
)

Read a block of data from the device using a BLT (32 bit) cycle.

Parameters
[IN]handle: device handler
[IN]Address: data space starting address
[IN]BltSize: size of the Block Read Cycle (in bytes)
[OUT]buff: pointer to the data buffer
[OUT]nw: number of longwords (32 bit) actually read from the device
Returns
0 = Success; negative numbers are error codes
CAENComm_ErrorCode STDCALL CAENComm_CloseDevice ( int  handle)

Close the device.

Parameters
[IN]handle: device handler
Returns
0 = Success; negative numbers are error codes

Referenced by cvUpgrade(), GetFWRel(), KeyInfo(), License(), and WriteKey().

void CAENComm_DecodeError ( int  ErrCode,
char *  ErrMsg 
)

Decode error code.

Parameters
[IN]ErrCode: Error code
[OUT]ErrMsg: string with the error message
Returns
0 = Success; negative numbers are error codes
CAENComm_ErrorCode STDCALL CAENComm_IACKCycle ( int  handle,
IRQLevels  Level,
int *  BoardID 
)

The function performs a 16 bit VME interrupt acknowledge cycle .

Parameters
[IN]handle: device handler
[IN]Level: The VME IRQ level to acknowledge (see IRQLevels enum).
[OUT]BoardID: the Id of the Board that reased the interrupt.
Returns
0 = Success; negative numbers are error codes
CAENComm_ErrorCode STDCALL CAENComm_Info ( int  handle,
CAENCOMM_INFO  info,
char *  data 
)

The function returns information about serial number or firmware release of the device.

Parameters
[IN]handle: device handler
[IN]info: The interested info (see CAENCOMM_INFO enum).
[OUT]data: an array (user defined to 30 byte) with the requested info
Returns
0 = Success; negative numbers are error codes
CAENComm_ErrorCode STDCALL CAENComm_IRQDisable ( int  handle)

The function disables the IRQ lines.

Parameters
[IN]handle: device handler
Returns
0 = Success; negative numbers are error codes
CAENComm_ErrorCode STDCALL CAENComm_IRQEnable ( int  handle)

The function enaables the IRQ lines.

Parameters
[IN]handle: device handler
Returns
0 = Success; negative numbers are error codes
CAENComm_ErrorCode STDCALL CAENComm_IRQWait ( int  handle,
uint32_t  Timeout 
)

The function wait the IRQ until one of them raise or timeout expires. This function can be used ONLY on board NOT controlled by CAEN VME Bridges.

Parameters
[IN]handle: device handler
[IN]Timeout: Timeout in milliseconds.
Returns
0 = Success; negative numbers are error codes
CAENComm_ErrorCode STDCALL CAENComm_MBLTRead ( int  handle,
uint32_t  Address,
uint32_t *  Buff,
int  BltSize,
int *  nw 
)

Read a block of data from the device using an MBLT (64 bit) cycle.

Parameters
[IN]handle: device handler
[IN]Address: data space starting address
[IN]BltSize: size of the Block Read Cycle (in bytes)
[OUT]buff: pointer to the data buffer
[OUT]nw: number of longwords (32 bit) actually read from the device
Returns
0 = Success; negative numbers are error codes
CAENComm_ErrorCode STDCALL CAENComm_MultiRead16 ( int  handle,
uint32_t *  Address,
int  nCycles,
uint16_t *  data,
CAENComm_ErrorCode ErrorCode 
)

Referenced by ReadFlashPage16().

CAENComm_ErrorCode STDCALL CAENComm_MultiRead32 ( int  handle,
uint32_t *  Address,
int  nCycles,
uint32_t *  data,
CAENComm_ErrorCode ErrorCode 
)

Referenced by read_flash_page(), and ReadFlashPage32().

CAENComm_ErrorCode STDCALL CAENComm_MultiWrite16 ( int  handle,
uint32_t *  Address,
int  nCycles,
uint16_t *  data,
CAENComm_ErrorCode ErrorCode 
)
CAENComm_ErrorCode STDCALL CAENComm_MultiWrite32 ( int  handle,
uint32_t *  Address,
int  nCycles,
uint32_t *  data,
CAENComm_ErrorCode ErrorCode 
)

The function performs a block of single 16bit WriteRegister.

Parameters
[IN]handle: device handler
[IN]Address: register address offsets
[IN]nCycles: the number of read to perform
[IN]data: The datas to write to the device
[OUT]ErrorCode: The error codes relaive to each cycle.
Returns
0 = Success; negative numbers are error codes

Referenced by ReadFlashPage32(), and WriteFlashPage32().

CAENComm_ErrorCode STDCALL CAENComm_OpenDevice ( CAENComm_ConnectionType  LinkType,
int  LinkNum,
int  ConetNode,
uint32_t  VMEBaseAddress,
int *  handle 
)
CAENComm_ErrorCode STDCALL CAENComm_Read16 ( int  handle,
uint32_t  Address,
uint16_t *  Data 
)

Read a 16 bit data from the specified register.

Parameters
[IN]handle: device handler
[IN]Address: register address offset
[OUT]Data: The data read from the device
Returns
0 = Success; negative numbers are error codes

Referenced by GetFlashStatus16(), GetFWRel(), read_flash_page(), ReadFlashSecurityReg16(), and validateModel().

CAENComm_ErrorCode STDCALL CAENComm_Read32 ( int  handle,
uint32_t  Address,
uint32_t *  Data 
)

Read a 32 bit data from the specified register.

Parameters
[IN]handle: device handler
[IN]Address: register address offset
[OUT]Data: The data read from the device
Returns
0 = Success; negative numbers are error codes

Referenced by GetFlashStatus32(), GetFWRel(), ReadFlashSecurityReg32(), and validateModel().

CAENComm_ErrorCode STDCALL CAENComm_SWRelease ( char *  SwRel)

Returns the Software Release of the library.

Parameters
[OUT]SwRel: the Software Release of the library
Returns
0 = Success; negative numbers are error codes
CAENComm_ErrorCode STDCALL CAENComm_VMEIACKCycle16 ( int  VMEhandle,
IRQLevels  Level,
int *  BoardID 
)

The function performs a 16 bit VME interrupt acknowledge cycle .

Parameters
[IN]handle: device handler
[IN]Level: The VME IRQ level to acknowledge (see IRQLevels enum).
[OUT]BoardID: the Id of the Board that reased the interrupt.
Returns
0 = Success; negative numbers are error codes
CAENComm_ErrorCode STDCALL CAENComm_VMEIACKCycle32 ( int  VMEhandle,
IRQLevels  Level,
int *  BoardID 
)

The function performs a 32 bit VME interrupt acknowledge cycle.

Parameters
[IN]handle: device handler
[IN]Level: The VME IRQ level to acknowledge (see IRQLevels enum).
[OUT]BoardID: the Id of the Board that reased the interrupt.
Returns
0 = Success; negative numbers are error codes
CAENComm_ErrorCode STDCALL CAENComm_VMEIRQCheck ( int  handle,
uint8_t *  Mask 
)

The function returns a bit mask indicating the active VME IRQ lines.

Parameters
[IN]handle: device handler
[OUT]Mask: A bit-mask indicating the VME IRQ lines.
Returns
0 = Success; negative numbers are error codes
CAENComm_ErrorCode STDCALL CAENComm_VMEIRQWait ( CAENComm_ConnectionType  LinkType,
int  LinkNum,
int  ConetNode,
uint8_t  IRQMask,
uint32_t  Timeout,
int *  VMEHandle 
)
CAENComm_ErrorCode STDCALL CAENComm_Write16 ( int  handle,
uint32_t  Address,
uint16_t  Data 
)
CAENComm_ErrorCode STDCALL CAENComm_Write32 ( int  handle,
uint32_t  Address,
uint32_t  Data 
)