upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
lidarlitev3.hpp
1 /*
2  * Author: Saloni Jain <saloni.jain@tcs.com>
3  * Author: Niti Rohilla <niti.rohilla@tcs.com>
4  * Copyright (c) 2014 Intel Corporation.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 #pragma once
26 
27 #include <string>
28 #include <mraa/i2c.hpp>
29 
30 #define ADDR 0x62 // device address
31 
32 // registers address
33 #define ACQ_COMMAND 0x00 // Device Command
34 #define STATUS 0x01 // System Status
35 #define SIG_COUNT_VAL 0x02 // Maximum Acquisition Count
36 #define ACQ_CONFIG_REG 0x04 // Acquisition Mode Control
37 #define VELOCITY 0x09 // Velocity measurement output
38 #define PEAK_CORR 0x0C // Peak value in correlation record
39 #define NOISE_PEAK 0x0D // Correaltion record noise floor
40 #define SIGNAL_STRENGTH 0x0E // Received signal strength
41 #define FULL_DELAY_HIGH 0x0F // Distance measurement high byte
42 #define FULL_DELAY_LOW 0x10 // Distance measurement low byte
43 #define OUTER_LOOP_COUNT 0x11 // Burst measurement count conttrol
44 #define REF_COUNT_VAL 0x12 // Reference acquisition count
45 #define LAST_DELAY_HIGH 0x14 // Previous distance measurement high byte
46 #define LAST_DELAY_LOW 0x15 // Previous distance measurement low byte
47 #define UNIT_ID_HIGH 0x16 // Serial number high byte
48 #define UNIT_ID_LOW 0x17 // Serial number low byte
49 #define I2C_ID_HIGH 0x18 // Write serial number high byte for I2C address unclock
50 #define I2C_ID_LOW 0x19 // Write serial number low byte for I2X address unlock
51 #define I2C_SEC_ADDR 0x1A // Write new I2C address after unlock
52 #define THRESHOLD_BYPASS 0x1C // Peak detection threshold bypass
53 #define I2C_CONFIG 0x1E // Default address response control
54 #define COMMAND 0x40 // State command
55 #define MEASURE_DELAY 0x45 // Delay between automatic measurements
56 #define PEAK_BCK 0x4C // Second largest peak value on correlation record
57 #define CORR_DATA 0x52 // Correlation record data lo byte
58 #define CORR_DATA_SIGN 0x53 // Correlation record data high byte
59 #define ACQ_SETTINGS 0x5D // Correaltion record memory bank select
60 #define POWER_CONTROL 0x65 // Power state control
61 
62 #define HIGH 1
63 #define LOW 0
64 
65 namespace upm {
66 
90 class LIDARLITEV3 {
91  public:
98  LIDARLITEV3 (int bus, int devAddr=ADDR);
99 
112  int getDistance ();
113 
122  uint16_t read(int reg, bool monitorBusyFlag);
123 
127  std::string name()
128  {
129  return m_name;
130  }
131 
137  uint8_t i2cReadReg_8 (int reg);
138 
144  uint16_t i2cReadReg_16 (int reg);
145 
152  mraa::Result i2cWriteReg (uint8_t reg, uint8_t value);
153 
154  private:
155  std::string m_name;
156 
157  int m_controlAddr;
158  int m_bus;
159  mraa::I2c m_i2ControlCtx;
160 };
161 
162 }
uint16_t read(int reg, bool monitorBusyFlag)
Definition: lidarlitev3.cxx:59
API for the LIDARLITEV3 Optical Distance Measurement Sensor.
Definition: lidarlitev3.hpp:90
int getDistance()
Definition: lidarlitev3.cxx:50
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
mraa::Result i2cWriteReg(uint8_t reg, uint8_t value)
Definition: lidarlitev3.cxx:124
LIDARLITEV3(int bus, int devAddr=ADDR)
Definition: lidarlitev3.cxx:36
uint16_t i2cReadReg_16(int reg)
Definition: lidarlitev3.cxx:98
uint8_t i2cReadReg_8(int reg)
Definition: lidarlitev3.cxx:113
std::string name()
Definition: lidarlitev3.hpp:127