PAS CO2 Sensor  1.0.3
C++ library for Infineon Photoacoustic Spectroscopy (PAS) XENSIV™ CO2 miniaturized sensor
pas-co2-pwm-sw.hpp
Go to the documentation of this file.
1 
10 #ifndef PAS_CO2_PWM_SW_HPP_
11 #define PAS_CO2_PWM_SW_HPP_
12 
13 #include "pas-co2-conf.hpp"
14 
15 #if IS_INTF(PAS_CO2_INTF_PWM_SW)
16 
17 #include "pas-co2-pal-gpio.hpp"
18 #include "pas-co2-pal-timer.hpp"
19 #include "pas-co2-pal-pwm.hpp"
20 
21 namespace pasco2
22 {
23 
29 class PWMSW : public PWM
30 {
31  public:
32 
36  enum Mode_t
37  {
40  };
41 
42  PWMSW (GPIO * const pwmIn,
43  Timer * const timer,
44  Mode_t mode);
45 
46  ~PWMSW ();
47  Error_t init ();
48  Error_t deinit ();
49  Error_t getDuty (double & duty);
50 
51  private:
52 
53  GPIO * const pwmIn;
54  Timer * const timer;
55  Mode_t mode;
56 
57  volatile bool risingEdgeEvent;
58  volatile bool fallingEdgeEvent;
59 
60  static constexpr uint8_t pulseTrainLen = 160;
62  void poll ();
63 
64 
65  typedef void (* cback_t)(void *);
66 
67  static constexpr uint8_t maxGPIOObjs = 4;
68  static uint8_t idxNext;
69  static PWMSW * objPtrVector[maxGPIOObjs];
70  static void * fnPtrVector [maxGPIOObjs];
72  protected:
73 
74  void callback ();
75 
76  static void int0Handler ();
77  static void int1Handler ();
78  static void int2Handler ();
79  static void int3Handler ();
80 
81  static void * isrRegister (PWMSW *objPtr);
82 };
83 
86 }
87 #endif
88 #endif
PWMSW(GPIO *const pwmIn, Timer *const timer, Mode_t mode)
PAS CO2 Software PWM Constructor.
Definition: pas-co2-pwm-sw.cpp:25
Definition: pas-co2-pal-pwm.hpp:23
static void int2Handler()
Interrupt 2 Handler.
Definition: pas-co2-pwm-sw.cpp:301
Error_t getDuty(double &duty)
Gets the PWM input duty cycle in percentage.
Definition: pas-co2-pwm-sw.cpp:115
static void * isrRegister(PWMSW *objPtr)
Register a hardware interrupt for the PWMSW object passed by argument.
Definition: pas-co2-pwm-sw.cpp:326
Mode_t
Measuring Mode.
Definition: pas-co2-pwm-sw.hpp:36
Definition: pas-co2-i2c.hpp:21
Error_t
Definition: pas-co2-types.hpp:24
void callback()
Definition: pas-co2-pwm-sw.cpp:244
static void int0Handler()
Interrupt 0 Handler.
Definition: pas-co2-pwm-sw.cpp:285
static void int1Handler()
Interrupt 1 Handler.
Definition: pas-co2-pwm-sw.cpp:293
Definition: pas-co2-pwm-sw.hpp:39
Error_t deinit()
Deinitializes the PWM.
Definition: pas-co2-pwm-sw.cpp:75
~PWMSW()
PAS CO2 Software PWM Destructor.
Definition: pas-co2-pwm-sw.cpp:37
Definition: pas-co2-pwm-sw.hpp:38
Definition: pas-co2-pal-gpio.hpp:25
Error_t init()
Initializes the PWM.
Definition: pas-co2-pwm-sw.cpp:48
PAS CO2 Timer Platform Abstraction Layer.
Definition: pas-co2-pal-timer.hpp:24
PAS CO2 GPIO Platform Abstraction Layer.
PAS CO2 Library Configuration.
static void int3Handler()
Interrupt 3 Handler.
Definition: pas-co2-pwm-sw.cpp:309
Definition: pas-co2-pwm-sw.hpp:29
PAS CO2 PWM Platform Abstraction Layer.