| CAEN FERS Library v1.1.4 SDK for FERS systems

Functions
Read/Write registers
API
Collaboration diagram for Read/Write registers:

## Functions
int | FERS_ReadRegister (int handle, uint32_t address, uint32_t *data)
| Read a register of a FERS board. More...
int | FERS_WriteRegister (int handle, uint32_t address, uint32_t data)
| Write a register of a FERS board. More...
int | FERS_WriteRegisterSlice (int handle, uint32_t address, uint32_t start_bit, uint32_t stop_bit, uint32_t data)
| Write a slice of a register of a FERS board. More...
int | FERS_SendCommand (int handle, uint32_t cmd)
| Send a command to the board More...
int | FERS_SendCommandBroadcast (int *handle, uint32_t cmd, uint32_t delay)
| Send a broadcast command to multiple boards connected to a concentrator. More...
int | FERS_I2C_ReadRegister (int handle, uint32_t i2c_dev_addr, uint32_t reg_addr, uint32_t *reg_data)
| Read a register of an I2C register (picoTDC, PLL, ...) More...
int | FERS_I2C_WriteRegister (int handle, uint32_t i2c_dev_addr, uint32_t reg_addr, uint32_t reg_data)
| Write a register of an I2C register (picoTDC, PLL, ...) More...
int | FERS_I2C_WriteRegisterSlice (int handle, uint32_t i2c_dev_addr, uint32_t address, uint32_t start_bit, uint32_t stop_bit, uint32_t data)
| Write a slice of a register of an I2C device. More...
int | FERS_ReadFlashPage (int handle, int pagenum, int size, uint8_t *data)
| Read a page from the flash memory. More...
int | FERS_WriteFlashPage (int handle, int pagenum, int size, uint8_t *data)
| Write a page of the flash memory. More...
int | FERS_XROC_WriteRegister (int handle, int page_addr, int sub_addr, uint8_t data)
| Write a register of the XROC ASIC chip via I2C. More...
int | FERS_XROC_ReadRegister (int handle, int page_addr, int sub_addr, uint8_t *data)
| Read a register of the XROC ASIC chip via I2C. More...
int | FERS_XROC_WriteRegisterSilce (int handle, int page_addr, int sub_addr, uint32_t start_bit, uint32_t stop_bit, uint8_t data)
| Write a register slice of the XROC ASIC chip via I2C. More...
int | FERS_ReadConcentratorInfo (int handle, FERS_CncInfo_t *cinfo)
| Read concentrator info from the device. More...
int | FERS_WriteBoardInfo (int handle, FERS_BoardInfo_t binfo)
| Write Board info into the relevant flash memory page. More...

## Detailed Description

## Function Documentation

## ◆ FERS_ReadRegister()

int FERS_ReadRegister | ( | int | handle,
|  | uint32_t | address,
|  | uint32_t * | data
| ) |  |

Read a register of a FERS board.

Parameters

  [out] | data | register data
  [in] | handle | device handle
  [in] | address | register address

Returns
  0 in case of success, or a negative error code specified in FERSLIB_ErrorCodes

## ◆ FERS_WriteRegister()

int FERS_WriteRegister | ( | int | handle,
|  | uint32_t | address,
|  | uint32_t | data
| ) |  |

Write a register of a FERS board.

Parameters

  [in] | handle | device handle
  [in] | address | register address
  [in] | data | register data

Returns
  0 in case of success, or a negative error code specified in FERSLIB_ErrorCodes

## ◆ FERS_WriteRegisterSlice()

int FERS_WriteRegisterSlice | ( | int | handle,
|  | uint32_t | address,
|  | uint32_t | start_bit,
|  | uint32_t | stop_bit,
|  | uint32_t | data
| ) |  |

Write a slice of a register of a FERS board.

Parameters

  [in] | handle | device handle
  [in] | address | register address
  [in] | start_bit | first bit of the slice (included)
  [in] | stop_bit | last bit of the slice (included)
  [in] | data | slice data

Returns
  0 in case of success, or a negative error code specified in FERSLIB_ErrorCodes

## ◆ FERS_SendCommand()

int FERS_SendCommand | ( | int | handle,
|  | uint32_t | cmd
| ) |  |

Send a command to the board

Parameters

  [in] | handle | device handle
  [in] | cmd | command opcode

Returns
  0 in case of success, or a negative error code specified in FERSLIB_ErrorCodes

## ◆ FERS_SendCommandBroadcast()

int FERS_SendCommandBroadcast | ( | int * | handle,
|  | uint32_t | cmd,
|  | uint32_t | delay
| ) |  |

Send a broadcast command to multiple boards connected to a concentrator.

Parameters

  [in] | handle | device handles of all the board that should receive the command
  [in] | cmd | command opcode
  [in] | delay | execution delay (0 for automatic)

Returns
  0 in case of success, or a negative error code specified in FERSLIB_ErrorCodes

## ◆ FERS_I2C_ReadRegister()

int FERS_I2C_ReadRegister | ( | int | handle,
|  | uint32_t | i2c_dev_addr,
|  | uint32_t | reg_addr,
|  | uint32_t * | reg_data
| ) |  |

Read a register of an I2C register (picoTDC, PLL, ...)

Parameters

  [out] | reg_data | register data
  [in] | handle | device handle
  [in] | i2c_dev_addr | I2C device address (7 bit)
  [in] | reg_addr | register address (in the device)

Returns
  0 in case of success, or a negative error code specified in FERSLIB_ErrorCodes

## ◆ FERS_I2C_WriteRegister()

int FERS_I2C_WriteRegister | ( | int | handle,
|  | uint32_t | i2c_dev_addr,
|  | uint32_t | reg_addr,
|  | uint32_t | reg_data
| ) |  |

Write a register of an I2C register (picoTDC, PLL, ...)

Parameters

  [in] | handle | device handle
  [in] | i2c_dev_addr | I2C device address (7 bit)
  [in] | reg_addr | register address (in the device)
  [in] | reg_data | register data

Returns
  0 in case of success, or a negative error code specified in FERSLIB_ErrorCodes

## ◆ FERS_I2C_WriteRegisterSlice()

int FERS_I2C_WriteRegisterSlice | ( | int | handle,
|  | uint32_t | i2c_dev_addr,
|  | uint32_t | address,
|  | uint32_t | start_bit,
|  | uint32_t | stop_bit,
|  | uint32_t | data
| ) |  |

Write a slice of a register of an I2C device.

Parameters

  [in] | handle | device handle
  [in] | i2c_dev_addr | I2C device address (7 bit)
  [in] | address | register address (in the device)
  [in] | start_bit | first bit of the slice (included)
  [in] | stop_bit | last bit of the slice (included)
  [in] | data | slice data

Returns
  0 in case of success, or a negative error code specified in FERSLIB_ErrorCodes

## ◆ FERS_ReadFlashPage()

int FERS_ReadFlashPage | ( | int | handle,
|  | int | pagenum,
|  | int | size,
|  | uint8_t * | data
| ) |  |

Read a page from the flash memory.

Parameters

  [out] | data | Buffer to store the read data
  [in] | handle | Handle to the FERS device
  [in] | pagenum | Page number to read
  [in] | size | Number of bytes to read

Returns
  0 on success, or a negative error code as defined in FERSLIB_ErrorCodes

## ◆ FERS_WriteFlashPage()

int FERS_WriteFlashPage | ( | int | handle,
|  | int | pagenum,
|  | int | size,
|  | uint8_t * | data
| ) |  |

Write a page of the flash memory.

Warning
  The flash memory contains vital parameters for the board. Overwriting certain pages can damage the hardware!!! Do no use this function withou contacting CAEN first

Parameters

  [in] | handle | Handle to the FERS device
  [in] | pagenum | Page number to write
  [in] | size | Number of bytes to write
  [in] | data | Buffer containing the data to write

Returns
  0 on success, or a negative error code as defined in FERSLIB_ErrorCodes

## ◆ FERS_XROC_WriteRegister()

int FERS_XROC_WriteRegister | ( | int | handle,
|  | int | page_addr,
|  | int | sub_addr,
|  | uint8_t | data
| ) |  |

Write a register of the XROC ASIC chip via I2C.

Parameters

  [in] | handle | Handle to the FERS device
  [in] | page_addr | Page address of the register, indentifies the register group
  [in] | sub_addr | Sub-address of the register, identifies the register in the page
  [in] | data | Data to write

Returns
  0 on success, or a negative error code as defined in FERSLIB_ErrorCodes

## ◆ FERS_XROC_ReadRegister()

int FERS_XROC_ReadRegister | ( | int | handle,
|  | int | page_addr,
|  | int | sub_addr,
|  | uint8_t * | data
| ) |  |

Read a register of the XROC ASIC chip via I2C.

Parameters

  [out] | data | Pointer to store the read value
  [in] | handle | Handle to the FERS device
  [in] | page_addr | Page address of the register, identifies the register group
  [in] | sub_addr | Sub-address of the register, identifies the register in the page

Returns
  0 on success, or a negative error code as defined in FERSLIB_ErrorCodes

## ◆ FERS_XROC_WriteRegisterSilce()

int FERS_XROC_WriteRegisterSilce | ( | int | handle,
|  | int | page_addr,
|  | int | sub_addr,
|  | uint32_t | start_bit,
|  | uint32_t | stop_bit,
|  | uint8_t | data
| ) |  |

Write a register slice of the XROC ASIC chip via I2C.

Parameters

  [in] | handle | Handle to the FERS device
  [in] | page_addr | Page address, identifies the register group
  [in] | sub_addr | Sub-address, identifies the register in the page
  [in] | start_bit | First bit of the slice (included)
  [in] | stop_bit | Last bit of the slice (included)
  [in] | data | Data to write

Returns
  0 on success, or a negative error code as defined in FERSLIB_ErrorCodes

## ◆ FERS_ReadConcentratorInfo()

int FERS_ReadConcentratorInfo | ( | int | handle,
|  | FERS_CncInfo_t * | cinfo
| ) |  |

Read concentrator info from the device.

Parameters

  [out] | cinfo | concentrator info structure
  [in] | handle | concentrator handle

Returns
  0 in case of success, or a negative error code specified in FERSLIB_ErrorCodes

## ◆ FERS_WriteBoardInfo()

int FERS_WriteBoardInfo | ( | int | handle,
|  | FERS_BoardInfo_t | binfo
| ) |  |

Write Board info into the relevant flash memory page.

Warning
  The flash memory contains vital parameters for the board. Overwriting certain pages can damage the hardware!!! Do not use this function without contacting CAEN first

Parameters

  [in] | handle | device handle
  [in] | binfo | board info structure

Returns
  0 in case of success, or a negative error code specified in FERSLIB_ErrorCodes