upm  0.7.1
Sensor/Actuator repository for libmraa (v1.0.0)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
t6713.hpp
1 /*
2  * Author: HCL
3  * Copyright (c) 2015 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 
26 #include "mraa/i2c.hpp"
27 #include "upm/iCO2Sensor.hpp"
28 
29 namespace upm {
30 
54 namespace t6713_co2
55 {
56  /* COMMAND VALUES */
57  typedef enum
58  {
59  T6713_COMMAND_RESET,
60  T6713_COMMAND_STATUS,
61  T6713_COMMAND_GET_FIRMWARE_REVISION,
62  T6713_COMMAND_GET_GAS_PPM
63  }MODBUS_COMMANDS;
64 
65 
66 
67  typedef enum
68  {
69  ERROR_CONDITION,
70  FLASH_ERROR,
71  CALIBRATION_ERROR,
72  WARMUP_MODE,
73  SINGLE_POINT_CALIBRATION,
74  RS232,
75  I2C,
76  RS485
77  }STATUS;
78 
79  typedef struct
80  {
81  uint8_t function_code;
82  uint8_t register_address_msb;
83  uint8_t register_address_lsb;
84  uint8_t input_registers_to_read_msb;
85  uint8_t input_registers_to_read_lsb;
86 
87  }COMMAND;
88 
89  typedef struct
90  {
91  uint8_t function_code;
92  uint8_t byte_count;
93  uint8_t status_msb;
94  uint8_t status_lsb;
95 
96  }RESPONSE;
97 
98 
99  typedef enum
100  {
101  READ_INPUT_REGISTERS = 4,
102  WRITE_SINGLE_COIL,
103  WRITE_SINGLE_HOLDING_REGISTER
104  }FUNCTION_CODES;
105 }//namespace t6713_co2
106 
107 
108 class T6713 : public ICO2Sensor {
109  public:
115  T6713 (int bus);
116 
120  ~T6713 ();
121 
125  const char* getModuleName();
126 
130  uint16_t getPpm ();
134  uint16_t getFirmwareRevision();
135 
136 
137  private:
138  mraa::Result runCommand(t6713_co2::MODBUS_COMMANDS command);
139  uint16_t getSensorData (t6713_co2::MODBUS_COMMANDS cmd);
140  t6713_co2::STATUS getStatus();
141 
142  int bus;
143  mraa::I2c* i2c;
144  mraa::Result status;
145 };
146 
147 
148 }//namespace upm
T6713(int bus)
Definition: t6713.cxx:52
Definition: t6713.hpp:79
~T6713()
Definition: t6713.cxx:61
Definition: t6713.hpp:89
Interface for CO Sensor.
Definition: iCO2Sensor.hpp:36
const char * getModuleName()
Definition: t6713.cxx:66
uint16_t getPpm()
Definition: t6713.cxx:76
Definition: t6713.hpp:108
uint16_t getFirmwareRevision()
Definition: t6713.cxx:71