PAS CO2 Sensor  1.0.3
C++ library for Infineon Photoacoustic Spectroscopy (PAS) XENSIV™ CO2 miniaturized sensor
pas-co2-i2c.hpp
Go to the documentation of this file.
1 
10 #ifndef PAS_CO2_I2C_HPP_
11 #define PAS_CO2_I2C_HPP_
12 
13 #include "pas-co2-conf.hpp"
14 
15 #if IS_INTF(PAS_CO2_INTF_I2C)
16 
17 #include <stdint.h>
18 #include "pas-co2-sbus.hpp"
19 #include "pas-co2-pal-i2c.hpp"
20 
21 namespace pasco2
22 {
23 
29 class I2C : public SBus
30 {
31  public:
32 
33  static const uint32_t dfltFreq = 400000;
35  I2C (I2CPAL * const i2cpal,
36  uint32_t freqHz = dfltFreq);
37  virtual ~I2C (void);
38 
39  Error_t init (void);
40  Error_t deinit (void);
41 
42  Error_t write (const uint8_t regAddr,
43  const uint8_t * data,
44  uint16_t length);
45  Error_t read (const uint8_t regAddr,
46  uint8_t * data,
47  uint16_t length);
48 
53  Proto_t getProtocol(void) { return BUS_PROTO_I2C; };
54 
55  private:
56 
57  I2CPAL * const i2cpal;
58  uint32_t clkFreq;
59  const uint8_t addr7bits = 0x28;
60 };
61 
64 extern I2C i2c;
65 
66 }
67 
68 #endif
69 #endif
Definition: pas-co2-sbus.hpp:33
PAS CO2 Serial Interface.
PAS CO2 I2C Platform Abstraction Layer.
I2C(I2CPAL *const i2cpal, uint32_t freqHz=dfltFreq)
I2C interface constructor.
Definition: pas-co2-i2c.cpp:24
Definition: pas-co2-i2c.hpp:21
Error_t
Definition: pas-co2-types.hpp:24
Definition: pas-co2-sbus.hpp:23
Proto_t
Definition: pas-co2-sbus.hpp:31
Definition: pas-co2-pal-i2c.hpp:28
Definition: pas-co2-i2c.hpp:29
Error_t init(void)
Initializes the I2C interface.
Definition: pas-co2-i2c.cpp:50
Error_t deinit(void)
Deinitializes the I2C interface.
Definition: pas-co2-i2c.cpp:79
virtual ~I2C(void)
I2C interface destructor.
Definition: pas-co2-i2c.cpp:35
Error_t write(const uint8_t regAddr, const uint8_t *data, uint16_t length)
Writes data to a register or set of consecutive registers.
Definition: pas-co2-i2c.cpp:103
Error_t read(const uint8_t regAddr, uint8_t *data, uint16_t length)
Reads data from a register or set of consecutive registers.
Definition: pas-co2-i2c.cpp:129
Proto_t getProtocol(void)
Returns the bus protocol.
Definition: pas-co2-i2c.hpp:53
PAS CO2 Library Configuration.
static const uint32_t dfltFreq
Definition: pas-co2-i2c.hpp:33