PAS CO2 Sensor  1.0.3
C++ library for Infineon Photoacoustic Spectroscopy (PAS) XENSIV™ CO2 miniaturized sensor
pasco2::I2C Class Reference

#include <pas-co2-i2c.hpp>

Inheritance diagram for pasco2::I2C:
Collaboration diagram for pasco2::I2C:

Public Member Functions

 I2C (I2CPAL *const i2cpal, uint32_t freqHz=dfltFreq)
 I2C interface constructor. More...
 
virtual ~I2C (void)
 I2C interface destructor. More...
 
Error_t init (void)
 Initializes the I2C interface. More...
 
Error_t deinit (void)
 Deinitializes the I2C interface. More...
 
Error_t write (const uint8_t regAddr, const uint8_t *data, uint16_t length)
 Writes data to a register or set of consecutive registers. More...
 
Error_t read (const uint8_t regAddr, uint8_t *data, uint16_t length)
 Reads data from a register or set of consecutive registers. More...
 
Proto_t getProtocol (void)
 Returns the bus protocol. More...
 

Static Public Attributes

static const uint32_t dfltFreq = 400000
 

Additional Inherited Members

- Public Types inherited from pasco2::SBus
enum  Proto_t { BUS_PROTO_I2C = 0, BUS_PROTO_UART = 1 }
 

Constructor & Destructor Documentation

◆ I2C()

I2C::I2C ( I2CPAL *const  i2cpal,
uint32_t  freqHz = dfltFreq 
)

I2C interface constructor.

Parameters
[in]*i2cpalI2C pal interface
[in]freqHzI2C bus frequency in Hz. Default is 400000.
Precondition
None

◆ ~I2C()

I2C::~I2C ( void  )
virtual

I2C interface destructor.

Precondition
None

Member Function Documentation

◆ init()

Error_t I2C::init ( void  )
virtual

Initializes the I2C interface.

Initiliazes the host I2C peripheral and set its clock frequency

Returns
PAS CO2 error code
Return values
OKif success
INTF_ERRORif hardware interface error
Precondition
None

Implements pasco2::SBus.

Here is the call graph for this function:

◆ deinit()

Error_t I2C::deinit ( void  )
virtual

Deinitializes the I2C interface.

Returns
PAS CO2 error code
Return values
OKif success
INTF_ERRORif hardware interface error
Precondition
None

Implements pasco2::SBus.

Here is the call graph for this function:

◆ write()

Error_t I2C::write ( const uint8_t  regAddr,
const uint8_t *  data,
uint16_t  length 
)
virtual

Writes data to a register or set of consecutive registers.

Parameters
[in]regAddrRegister start write address
[in]*dataPointer to the data array to be written
[in]lengthNumber of registers to be written in the bus
Returns
PAS CO2 error code
Return values
OKif success
INTF_ERRORif error
Precondition
init()

Implements pasco2::SBus.

Here is the call graph for this function:

◆ read()

Error_t I2C::read ( const uint8_t  regAddr,
uint8_t *  data,
uint16_t  length 
)
virtual

Reads data from a register or set of consecutive registers.

Parameters
[in]regAddrRegister start read address
[out]*dataPointer to the array that will store the read data
[in]lengthNumber of registers to be read from the bus
Returns
PAS CO2 error code
Return values
OKif success
INTF_ERRORif error
Precondition
init()

Implements pasco2::SBus.

Here is the call graph for this function:

◆ getProtocol()

Proto_t pasco2::I2C::getProtocol ( void  )
inlinevirtual

Returns the bus protocol.

Return values
BUS_PROTO_I2C

Implements pasco2::SBus.

Member Data Documentation

◆ dfltFreq

const uint32_t pasco2::I2C::dfltFreq = 400000
static

Default I2C SCKL frequency


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