Public Member Functions | Static Public Member Functions | Protected Attributes

roc::I2cDevice Class Reference

Base class to represent a ROC I2C Bus Device. More...

#include <I2cDevice.h>

Inheritance diagram for roc::I2cDevice:
Inheritance graph
[legend]
Collaboration diagram for roc::I2cDevice:
Collaboration graph
[legend]

Public Member Functions

 I2cDevice ()
 Default constructor to make old ROOT hapy.
 I2cDevice (base::Board *board, int port=0, uint8_t addr=0)
 Constructor with full addressing path information.
virtual ~I2cDevice ()
bool isSPI () const
void setPortNumber (int port)
 Set I2C bus port number on ROC.
int getPortNumber () const
 Returns I2C bus port number on ROC.
void setSlaveAddr (uint8_t addr)
 Set slave address of device on I2C bus.
uint8_t getSlaveAddr () const
 Return slave address of device on I2C bus.
int setRegister (uint8_t reg, uint8_t val, bool veri=false)
 Write to device register with optional readback verification.
int getRegister (uint8_t reg, uint8_t &val)
 Read 8 bit from device register.
int getRegister16 (uint8_t reg, uint16_t &val)
 Read 16 bit from device register.
int setRegisterVerify (uint8_t reg, uint8_t valset, uint8_t &valget)
 Write to device register and return the readback value.
int setRegisterArray (uint8_t reg, const uint8_t *val, int nreg, bool veri=false)
 Write to device register array with optional readback verification.
int getRegisterArray (uint8_t reg, uint8_t *val, int nreg)
 Read from device register array.
int setMailboxRegister (uint8_t reg, const uint8_t *val, int nval)
 Write to device mailbox register.
int getMailboxRegister (uint8_t reg, uint8_t *val, int nval)
 Read from device mailbox register.
base::Boardboard ()
 Return reference to roc::Board which hosts the Peripheral.
base::BoardgetBoard () const
 Returns pointer to the roc::Board which hosts the Peripheral.

Static Public Member Functions

static void addAddrMap (base::Board *board)
 Add the I2C interface address set to the address mapping tables.

Protected Attributes

int fUseSPI
 indicate that SPI->I2C interface for SysCore3 should be used
int fPort
 I2C bus port number.
uint8_t fSlaveAddr
 I2C device slave address.
base::BoardfBoard
 board pointer

Detailed Description

Base class to represent a ROC I2C Bus Device.

A ROC can have several I2C bus ports. They are served by a common control logic, a switch determines which port is active at a given time. Each bus can have several devices attached, identified by a slave address.

The class holds the addressing information needed to reach the I2cDevice:

Definition at line 14 of file I2cDevice.h.


Constructor & Destructor Documentation

roc::I2cDevice::I2cDevice (  ) 

Default constructor to make old ROOT hapy.

Definition at line 32 of file I2cDevice.cxx.

roc::I2cDevice::I2cDevice ( base::Board board,
int  port = 0,
uint8_t  addr = 0 
)

Constructor with full addressing path information.

Sets up I2cDevice object with full addressing information

Parameters:
board ROC board pointer
port the I2C bus port number
addr the I2C device slave address

Definition at line 47 of file I2cDevice.cxx.

References fUseSPI, and base::Board::is_SPI_I2C().

roc::I2cDevice::~I2cDevice (  )  [virtual]

Definition at line 55 of file I2cDevice.cxx.


Member Function Documentation

void roc::I2cDevice::addAddrMap ( base::Board board  )  [static]
base::Board & base::Peripheral::board (  )  [inherited]
base::Board* base::Peripheral::getBoard (  )  const [inline, inherited]
int roc::I2cDevice::getMailboxRegister ( uint8_t  reg,
uint8_t *  val,
int  nval 
)

Read from device mailbox register.

Reads nreg 8bit values from a single device register reg. This method is useful for Fifo's or mailbox type registers. The I2C error flags are checked for each transfer, reading is stopped when the first error is detected.

Parameters:
reg first device register number
val value array
nval number of values to read
Returns:
see roc::Board get/put/oper return codes
See also:
setMailboxRegister()

Definition at line 401 of file I2cDevice.cxx.

References getRegister(), and base::Board::operErrBuild().

int roc::I2cDevice::getPortNumber (  )  const [inline]

Returns I2C bus port number on ROC.

Definition at line 32 of file I2cDevice.h.

References fPort.

Referenced by nxyter::NxI2c::printRegisters().

int roc::I2cDevice::getRegister ( uint8_t  reg,
uint8_t &  val 
)

Read 8 bit from device register.

Reads an 8bit value from device register reg and checks I2C status for error flags.

Parameters:
reg device register number
val value
Returns:
see roc::Board get/put/oper return codes
See also:
setRegister()

Definition at line 152 of file I2cDevice.cxx.

References base::Peripheral::board(), fPort, fSlaveAddr, isSPI(), base::Board::kOperBusErr, base::Board::operErrBuild(), and base::Board::operGen().

Referenced by nxyter::FebUtil::acquireTestPulserData(), cmd_autotrim(), cmd_getnx(), getMailboxRegister(), getRegisterArray(), nxyter::NxI2c::getRegMask(), nxyter::NxI2c::getRegTrim(), nxyter::NxI2c::probe(), nxyter::NxI2c::setTestModes(), and nxyter::FebUtil::testNxRegisters().

int roc::I2cDevice::getRegister16 ( uint8_t  reg,
uint16_t &  val 
)

Read 16 bit from device register.

Reads an 16bit value from device register reg and checks I2C status for error flags.

Parameters:
reg device register number
val value
Returns:
see roc::Board get/put/oper return codes

Definition at line 220 of file I2cDevice.cxx.

References base::Peripheral::board(), fPort, fSlaveAddr, isSPI(), and base::Board::operGen().

Referenced by nxyter::FebBase::discoverFebs(), and nxyter::FebBase::getMonAdc().

int roc::I2cDevice::getRegisterArray ( uint8_t  reg,
uint8_t *  val,
int  nreg 
)

Read from device register array.

Reads nreg 8bit values from an array of device registers starting at register number reg. The I2C error flags are checked for each transfer, reading is stopped when the first error is detected.

Parameters:
reg first device register number
val value array
nreg number of registers to read
Returns:
see roc::Board get/put/oper return codes
See also:
setRegisterArray()

Definition at line 350 of file I2cDevice.cxx.

References getRegister(), and base::Board::operErrBuild().

Referenced by nxyter::NxI2c::getCounters(), nxyter::NxI2c::getRegCore(), and nxyter::NxI2c::getRegMask().

uint8_t roc::I2cDevice::getSlaveAddr (  )  const [inline]

Return slave address of device on I2C bus.

Definition at line 40 of file I2cDevice.h.

References fSlaveAddr.

Referenced by cmd_getnx(), nxyter::FebBase::eepromSupport(), nxyter::FebBase::monAdcSupport(), and nxyter::NxI2c::printRegisters().

bool roc::I2cDevice::isSPI (  )  const [inline]

Definition at line 25 of file I2cDevice.h.

References fUseSPI.

Referenced by getRegister(), getRegister16(), setRegister(), and setRegisterVerify().

int roc::I2cDevice::setMailboxRegister ( uint8_t  reg,
const uint8_t *  val,
int  nval 
)

Write to device mailbox register.

Writes the nreg 8bit values from array val to a single device register reg. This method is useful for Fifo's or mailbox type registers. The I2C error flags are checked for each transfer, writing is stopped when the first error is detected.

Parameters:
reg first device register number
val value array
nval number of values to write
Returns:
see roc::Board get/put/oper return codes
See also:
getMailboxRegister()

Definition at line 376 of file I2cDevice.cxx.

References base::Board::operErrBuild(), and setRegister().

Referenced by nxyter::NxI2c::setRegTrim().

void roc::I2cDevice::setPortNumber ( int  port  )  [inline]

Set I2C bus port number on ROC.

Definition at line 28 of file I2cDevice.h.

References fPort.

int roc::I2cDevice::setRegister ( uint8_t  reg,
uint8_t  val,
bool  veri = false 
)

Write to device register with optional readback verification.

Writes the 8bit value val to device register reg. If veri is true, the register contents is read back and verified. The I2C status is checked for error flags after the write and optional read cycle.

Parameters:
reg device register number
val value
veri if true readback verification done (default is false)
Returns:
see roc::Board get/put/oper return codes
See also:
getRegister(), setRegisterVerify()

Definition at line 75 of file I2cDevice.cxx.

References base::Peripheral::board(), fPort, fSlaveAddr, isSPI(), base::Board::kOperBusErr, base::Board::operErrBuild(), and base::Board::operGen().

Referenced by nxyter::FebUtil::acquireTestPulserData(), NxyterWidget::biasRegChanged(), cmd_autosettrh(), cmd_autotrim(), cmd_autovbiass(), cmd_scanmonadc(), cmd_scanvbiasf(), cmd_setnx(), get_vbiass_data(), nxyter::NxI2c::getRegMask(), nxyter::NxI2c::getRegTrim(), nxyter::NxI2c::probe(), setMailboxRegister(), nxyter::FebBase::setNxRegisterAll(), setRegisterArray(), setRegisterVerify(), nxyter::NxI2c::setRegTrim(), nxyter::NxI2c::setTestModes(), and nxyter::FebUtil::testNxRegisters().

int roc::I2cDevice::setRegisterArray ( uint8_t  reg,
const uint8_t *  val,
int  nreg,
bool  veri = false 
)

Write to device register array with optional readback verification.

Writes the nreg 8bit values from array val to an array of device registers starting at register number reg. When veri is true, each value is readback and verified. The I2C error flags are checked for each transfer, writing is stopped when the first error is detected.

Parameters:
reg first device register number
val value array
nreg number of registers to write
veri if true readback verification done (default is false)
Returns:
see roc::Board get/put/oper return codes
See also:
getRegisterArray()

Definition at line 324 of file I2cDevice.cxx.

References base::Board::operErrBuild(), and setRegister().

Referenced by nxyter::NxI2c::setRegCore(), and nxyter::NxI2c::setRegMask().

int roc::I2cDevice::setRegisterVerify ( uint8_t  reg,
uint8_t  valset,
uint8_t &  valget 
)

Write to device register and return the readback value.

Writes the 8bit value valset to device register reg, reads it back and returns the readback value in valget. The I2C status is checked for error flags after the write and read cycle.

Parameters:
reg device register number
valset value to be written
valget value returned from readback
Returns:
see roc::Board get/put/oper return codes
Note:
The method just returns the readback value and does not test whether valget equals valset, thus never returns a base::Board::kOperVerifyErr return code.
See also:
setRegister(), getRegister()

Definition at line 270 of file I2cDevice.cxx.

References base::Peripheral::board(), fPort, fSlaveAddr, isSPI(), base::Board::kOperBusErr, base::Board::operErrBuild(), base::Board::operGen(), and setRegister().

Referenced by nxyter::NxI2c::getRegTrim().

void roc::I2cDevice::setSlaveAddr ( uint8_t  addr  )  [inline]

Set slave address of device on I2C bus.

Definition at line 36 of file I2cDevice.h.

References fSlaveAddr.

Referenced by cmd_setnxaddr(), and nxyter::Feb1nxGenD::Feb1nxGenD().


Field Documentation

base::Board* base::Peripheral::fBoard [protected, inherited]

board pointer

Definition at line 26 of file Peripheral.h.

Referenced by base::Peripheral::board(), base::Peripheral::getBoard(), and base::Peripheral::Peripheral().

int roc::I2cDevice::fPort [protected]

I2C bus port number.

Definition at line 17 of file I2cDevice.h.

Referenced by getPortNumber(), getRegister(), getRegister16(), setPortNumber(), setRegister(), and setRegisterVerify().

uint8_t roc::I2cDevice::fSlaveAddr [protected]

I2C device slave address.

Definition at line 18 of file I2cDevice.h.

Referenced by getRegister(), getRegister16(), getSlaveAddr(), setRegister(), setRegisterVerify(), and setSlaveAddr().

int roc::I2cDevice::fUseSPI [protected]

indicate that SPI->I2C interface for SysCore3 should be used

Definition at line 16 of file I2cDevice.h.

Referenced by I2cDevice(), and isSPI().


The documentation for this class was generated from the following files: