PAS CO2 Sensor  1.0.3
C++ library for Infineon Photoacoustic Spectroscopy (PAS) XENSIV™ CO2 miniaturized sensor
pas-co2-reg.hpp
Go to the documentation of this file.
1 
10 #ifndef PAS_CO2_REG_HPP_
11 #define PAS_CO2_REG_HPP_
12 
13 #include <stdint.h>
14 #include "pas-co2-types.hpp"
15 
16 namespace pasco2
17 {
18 
24 class Reg
25 {
26  public:
27 
32  enum Addr_t
33  {
34  REG_ADDR_PROD_ID = (0x00U),
35  REG_ADDR_SENS_STS = (0x01U),
38  REG_ADDR_MEAS_CFG = (0x04U),
39  REG_ADDR_CO2PPM_H = (0x05U),
40  REG_ADDR_CO2PPM_L = (0x06U),
41  REG_ADDR_MEAS_STS = (0x07U),
42  REG_ADDR_INT_CFG = (0x08U),
43  REG_ADDR_ALARM_TH_H = (0x09U),
44  REG_ADDR_ALARM_TH_L = (0x0AU),
50  REG_ADDR_SENS_RST = (0x10U)
51  };
54  static const uint8_t regCount = 0x11U;
55  uint8_t regMap[regCount];
57  Reg ();
58  ~Reg ();
59 
60  uint8_t getProductID (void);
61  uint8_t getRevisionID (void);
62 
63  bool isSensorReady (void);
64  bool isPWMPinEnabled (void);
65 
66  bool isTempOutofRange (void);
67  void clearTempOutofRangeFlag (void);
68 
69  bool is12VOutofRange (void);
70  void clear12VOutofRangeFlag (void);
71 
72  bool hasCommErrorOccurred (void);
73  void clearCommErrorFlag (void);
74 
75  int16_t getMeasRate (void);
76  void setMeasRate (const int16_t period);
77 
78  void enablePWMOutput (void);
79  void disablePWMOutput (void);
80  bool isPWMOutputEnabled (void);
81 
82  PWMMode_t getPWMMode (void);
83  void setPWMMode (const PWMMode_t mode);
84 
85  ABOC_t getABOCMode (void);
86  void setABOCMode (const ABOC_t abocMode);
87 
88  void setOperationMode (const OpMode_t mode);
90 
91  uint16_t getCO2PPM (void);
92 
93  bool isDataReady (void);
94 
95  bool hasInterruptOcurred (void);
96  void clearInterruptFlag (void);
97 
98  bool isAlarmSet (void);
99  void clearAlarmFlag (void);
100 
102  void setInterruptIOConf (const IntIOConf_t ioConf);
103 
104  Int_t getInterruptFunc (void);
105  void setInterrutFunc (const Int_t func);
106 
107  Alarm_t getAlarmType (void);
108  void setAlarmType (const Alarm_t func);
109 
110  int16_t getAlarmThreshold (void);
111  void setAlarmThreshold (const int16_t alarmTh);
112 
113  uint16_t getPressCompReference (void);
114  void setPressCompReference (const uint16_t pressRef);
115 
116  int16_t getABOCReference (void);
117  void setABOCReference (const int16_t abocRef);
118 
119  uint8_t getScratchPad (void);
120  void setStratchPad (const uint8_t value);
121 
122  void setSoftReset (void);
123 
124  private:
125 
129  enum Access_t
130  {
131  REG_ACCESS_R = (0x01U),
132  REG_ACCESS_W = (0x02U),
133  REG_ACCESS_RW = (0x03U),
134  REG_ACCESS_RH = (0x05U),
135  REG_ACCESS_RWH = (0x07U),
136  REG_ACCESS_S = (0x08U),
137  REG_ACCESS_RHS = (0x0DU),
138  REG_ACCESS_RES = (0x10U)
139  };
140 
144  typedef struct
145  {
146  uint8_t regAccess;
147  uint8_t regAddress;
148  uint8_t mask;
149  uint8_t position;
150  uint8_t resetValue;
151  }BitField_t;
152 
153  static const BitField_t bitFields[];
158  enum BitFieldReg_t
159  {
160  BITF_PROD = 0,
161  BITF_REV,
162  BITF_SEN_RDY,
163  BITF_PWM_DIS_ST,
164  BITF_ORTMP,
165  BITF_ORVS,
166  BITF_ICCER,
167  BITF_ORTMP_CLR,
168  BITF_ORVS_CLR,
169  BITF_ICCER_CLR,
170  BITF_RES0,
171  BITF_MEAS_RATE_H,
172  BITF_MEAS_RATE_L,
173  BITF_RES1,
174  BITF_RES2,
175  BITF_PWM_OUTEN,
176  BITF_PWM_MODE,
177  BITF_BOC_CFG,
178  BITF_OP_MODE,
179  BITF_CO2_PPM_H,
180  BITF_CO2_PMM_L,
181  BITF_RES3,
182  BITF_RES4,
183  BITF_DRDY,
184  BITF_INT_STS,
185  BITF_ALARM,
186  BITF_INT_STS_CLR,
187  BITF_ALARM_CLR,
188  BITF_RES5,
189  BITF_INT_TYP,
190  BITF_INT_FUNC,
191  BITF_ALARM_TYP,
192  BITF_ALARM_TH_H,
193  BITF_ALARM_TH_L,
194  BITF_PRESS_REF_H,
195  BITF_PRESS_REF_L,
196  BITF_CALIB_REF_H,
197  BITF_CALIB_REF_L,
198  BITF_SCRATCH_PAD,
199  BITF_SRTRG
200  };
201 
202  static const uint8_t softResetValue = 0xA3;
204  bool getBitField (BitField_t bitField, uint8_t & bitFValue);
205  bool setBitField (BitField_t bitField, uint8_t bitFNewValue);
206 };
207 
210 }
211 
212 #endif
Definition: pas-co2-reg.hpp:44
Definition: pas-co2-reg.hpp:34
void setABOCMode(const ABOC_t abocMode)
Definition: pas-co2-reg.cpp:212
Alarm_t getAlarmType(void)
Definition: pas-co2-reg.cpp:311
void clearAlarmFlag(void)
Definition: pas-co2-reg.cpp:278
Definition: pas-co2-reg.hpp:38
int16_t getAlarmThreshold(void)
Definition: pas-co2-reg.cpp:325
uint8_t getRevisionID(void)
Definition: pas-co2-reg.cpp:82
int16_t getMeasRate(void)
Definition: pas-co2-reg.cpp:151
~Reg()
Definition: pas-co2-reg.cpp:68
Reg()
Definition: pas-co2-reg.cpp:62
void setStratchPad(const uint8_t value)
Definition: pas-co2-reg.cpp:391
PWMMode_t getPWMMode(void)
Definition: pas-co2-reg.cpp:189
void enablePWMOutput(void)
Definition: pas-co2-reg.cpp:170
void clearInterruptFlag(void)
Definition: pas-co2-reg.cpp:264
Int_t getInterruptFunc(void)
Definition: pas-co2-reg.cpp:297
OpMode_t getOperationMode(void)
Definition: pas-co2-reg.cpp:218
Definition: pas-co2-i2c.hpp:21
IntIOConf_t
Definition: pas-co2-types.hpp:129
void disablePWMOutput(void)
Definition: pas-co2-reg.cpp:175
void clearCommErrorFlag(void)
Definition: pas-co2-reg.cpp:146
void setPressCompReference(const uint16_t pressRef)
Definition: pas-co2-reg.cpp:357
PWMMode_t
Definition: pas-co2-types.hpp:80
bool is12VOutofRange(void)
Definition: pas-co2-reg.cpp:123
Definition: pas-co2-reg.hpp:40
Definition: pas-co2-reg.hpp:45
Definition: pas-co2-reg.hpp:48
Definition: pas-co2-reg.hpp:49
uint16_t getCO2PPM(void)
Definition: pas-co2-reg.cpp:233
void setMeasRate(const int16_t period)
Definition: pas-co2-reg.cpp:164
Definition: pas-co2-reg.hpp:46
bool isSensorReady(void)
Definition: pas-co2-reg.cpp:91
int16_t getABOCReference(void)
Definition: pas-co2-reg.cpp:363
ABOC_t
Definition: pas-co2-types.hpp:91
void setAlarmType(const Alarm_t func)
Definition: pas-co2-reg.cpp:320
Definition: pas-co2-reg.hpp:43
uint8_t getProductID(void)
Definition: pas-co2-reg.cpp:73
void setInterruptIOConf(const IntIOConf_t ioConf)
Definition: pas-co2-reg.cpp:292
void setInterrutFunc(const Int_t func)
Definition: pas-co2-reg.cpp:306
Definition: pas-co2-reg.hpp:35
Definition: pas-co2-reg.hpp:24
ABOC_t getABOCMode(void)
Definition: pas-co2-reg.cpp:203
IntIOConf_t getInterruptIOConf(void)
Definition: pas-co2-reg.cpp:283
bool isDataReady(void)
Definition: pas-co2-reg.cpp:246
static const uint8_t regCount
Definition: pas-co2-reg.hpp:54
Addr_t
Definition: pas-co2-reg.hpp:32
bool isPWMPinEnabled(void)
Definition: pas-co2-reg.cpp:100
bool isAlarmSet(void)
Definition: pas-co2-reg.cpp:269
Definition: pas-co2-reg.hpp:39
bool isTempOutofRange(void)
Definition: pas-co2-reg.cpp:109
void clear12VOutofRangeFlag(void)
Definition: pas-co2-reg.cpp:132
void setPWMMode(const PWMMode_t mode)
Definition: pas-co2-reg.cpp:198
uint8_t regMap[regCount]
Definition: pas-co2-reg.hpp:55
Int_t
Definition: pas-co2-types.hpp:115
void setAlarmThreshold(const int16_t alarmTh)
Definition: pas-co2-reg.cpp:338
void setABOCReference(const int16_t abocRef)
Definition: pas-co2-reg.cpp:376
OpMode_t
Definition: pas-co2-types.hpp:68
Alarm_t
Definition: pas-co2-types.hpp:140
bool hasCommErrorOccurred(void)
Definition: pas-co2-reg.cpp:137
uint16_t getPressCompReference(void)
Definition: pas-co2-reg.cpp:344
bool isPWMOutputEnabled(void)
Definition: pas-co2-reg.cpp:180
Definition: pas-co2-reg.hpp:42
Definition: pas-co2-reg.hpp:47
Definition: pas-co2-reg.hpp:41
Definition: pas-co2-reg.hpp:37
void setSoftReset(void)
Definition: pas-co2-reg.cpp:396
void setOperationMode(const OpMode_t mode)
Definition: pas-co2-reg.cpp:227
PAS CO2 Types.
void clearTempOutofRangeFlag(void)
Definition: pas-co2-reg.cpp:118
uint8_t getScratchPad(void)
Definition: pas-co2-reg.cpp:382
Definition: pas-co2-reg.hpp:50
bool hasInterruptOcurred(void)
Definition: pas-co2-reg.cpp:255
Definition: pas-co2-reg.hpp:36