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

#include <pas-co2-pulse.hpp>

Inheritance diagram for PASCO2Pulse:
Collaboration diagram for PASCO2Pulse:

Public Member Functions

 PASCO2Pulse (PWM *const pwm, Timer *const timer=nullptr, pasco2::GPIO *const interrupt=nullptr, pasco2::GPIO *const power3V3=nullptr, pasco2::GPIO *const power12V=nullptr, pasco2::GPIO *const pwmSelect=nullptr)
 PAS CO2 Pulse Constructor. More...
 
virtual ~PASCO2Pulse ()
 PAS CO2 Pulse Destructor. More...
 
Error_t enable ()
 Enables the sensor. More...
 
Error_t disable ()
 Disables the sensor. More...
 
Error_t startMeasure (void(*cback)(void *)=nullptr)
 Triggers the internal measuring of the sensor. More...
 
Error_t stopMeasure ()
 Stops the internal measuring of the sensor. More...
 
Error_t getCO2 (int16_t &co2ppm)
 Gets the CO2 concentration measured. More...
 
Error_t reset ()
 Resets the sensor. More...
 

Constructor & Destructor Documentation

◆ PASCO2Pulse()

PASCO2Pulse::PASCO2Pulse ( PWM *const  pwm,
Timer *const  timer = nullptr,
pasco2::GPIO *const  interrupt = nullptr,
pasco2::GPIO *const  power3V3 = nullptr,
pasco2::GPIO *const  power12V = nullptr,
pasco2::GPIO *const  pwmSelect = nullptr 
)

PAS CO2 Pulse Constructor.

Mandatory arguments:

  • The PWM needs to be provided
  • A timer instance (currently default as nullptr.TODO: Needs to be changed!)

Optional arguments:

  • All GPIO instances.

Most of the GPIO will be fixed by hardware. In particular those enabling the sensor main power and the emitter power. They are part of the sensor library to provide potential absolute control by software. The hardware interface and its features, are also provided in the library. But it can be as well handled externally

Parameters
[in]*PWMPWM instance
[in]*timerTimer instance
[in]*interruptInterrupt GPIO instance. Default is nullptr
[in]*power3V3Power 3V3 control GPIO instance. Default is nullptr
[in]*power12VPower 12V control GPIO instance. Default is nullptr
[in]*pwmSelectPWM select GPIO instance. Default is nullptr
Precondition
None

◆ ~PASCO2Pulse()

PASCO2Pulse::~PASCO2Pulse ( )
virtual

PAS CO2 Pulse Destructor.

Precondition
None

Member Function Documentation

◆ enable()

Error_t PASCO2Pulse::enable ( )

Enables the sensor.

Initializes the controller peripheral interfaces and enable VDD and IR emitter power of the sensor

Note
Optional call. Each API function will set internally the required status for its operation
Returns
PAS CO2 error code
Return values
OKif success
INTF_ERRORif interface error
IC_POWERON_ERRORif power-on error
Precondition
None
Here is the call graph for this function:

◆ disable()

Error_t PASCO2Pulse::disable ( )

Disables the sensor.

Initializes the controller peripheral interfaces and enable VDD and IR emitter power of the sensor

Note
Optional call. Each API function will set internally the required status for its operation
Returns
PAS CO2 error code
Return values
OKif success
INTF_ERRORif interface error
Precondition
None
Here is the call graph for this function:

◆ startMeasure()

Error_t PASCO2Pulse::startMeasure ( void(*)(void *)  cback = nullptr)

Triggers the internal measuring of the sensor.

The PWM select signal will be enabled if it is available. If this signal is fixed on hardware, the sensor will already output the PWM signal without the need of calling startMeasure().

By default, if no other setup has been configured through the serial interface, a pulse train will be provided by the sensor every 1 min.

Optionally, if a callback is passed by argument, the interrupt event will occur approximately 1 second before the measurement starts. This can be used for synching the pwm redouts on the microcontroller. Some example:

volatile bool intFlag = false;
void cback(void *)
{
intFlag = true;
}
int16_t co2ppm;
cotwo.startMeasure(cback);
while(1)
{
while(!intFlag) { // block or yield() };
cotwo.getCO2(co2ppm);
// ... do something with the co2 value ...
intFlag = false;
}
Warning
If no PWM select GPIO instance is available and no interrupt GPIO instance, the function does nothing and returns without error (OK)
Parameters
[in]*cbackPointer to the callback function to be called upon interrupt. Default is nullptr
Returns
PAS CO2 error code
Return values
OKif success
INTF_ERRORif interface error
CONFIG_ERRORif invalid configuration parameter
Precondition
None
Here is the call graph for this function:

◆ stopMeasure()

Error_t PASCO2Pulse::stopMeasure ( )

Stops the internal measuring of the sensor.

Disables the PWM select signal

Warning
PWM select GPIO interface required. If unavailable the function does nothing and returns without error (OK)
Returns
PAS CO2 error code
Return values
OKif success
INTF_ERRORif interface error
Precondition
None
Here is the call graph for this function:

◆ getCO2()

Error_t PASCO2Pulse::getCO2 ( int16_t &  co2ppm)

Gets the CO2 concentration measured.

The value read is zero when no measurement is yet available. In case of error, the read value is set to -1

Parameters
[out]co2ppmCO2 concentration read (in ppm)
Returns
PAS CO2 error code
Return values
OKif success
INTF_ERRORif interface error
Precondition
None
Here is the call graph for this function:

◆ reset()

Error_t PASCO2Pulse::reset ( )

Resets the sensor.

The hardware reset will disable 3V3 power output for 200 ms to perform a hardware reset

Warning
Power 3V3 GPIO interface required. If unavailable the function does nothing and returns without error (OK)
Returns
PAS CO2 error code
Return values
OKif success
INTF_ERRORif interface error
RESET_ERRORif the device reset error
Precondition
None
Here is the call graph for this function:

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