upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
adis16448.hpp
1 // The MIT License (MIT)
3 //
4 // Submit Date: 03/09/2015
5 // Author: Juan Jose Chong <juanjchong@gmail.com>
6 // Copyright (c) 2015 Juan Jose Chong
7 //
9 // adis16448.hpp
11 //
12 // This library runs on an Intel Edison and uses mraa to acquire data
13 // from an ADIS16448. This data is then scaled and printed onto the terminal.
14 //
15 // This software has been tested to connect to an ADIS16448 through a level shifter
16 // such as the TI TXB0104. The SPI lines (DIN, DOUT, SCLK, /CS) are all wired through
17 // the level shifter and the ADIS16448 is also being powered by the Intel Edison.
18 //
19 // Permission is hereby granted, free of charge, to any person obtaining
20 // a copy of this software and associated documentation files (the
21 // "Software"), to deal in the Software without restriction, including
22 // without limitation the rights to use, copy, modify, merge, publish,
23 // distribute, sublicense, and/or sell copies of the Software, and to
24 // permit persons to whom the Software is furnished to do so, subject to
25 // the following conditions:
26 //
27 // The above copyright notice and this permission notice shall be
28 // included in all copies or substantial portions of the Software.
29 //
30 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 //
39 #include <string>
40 #include <mraa/spi.h>
41 #include <mraa/gpio.h>
42 
43 // User Register Memory Map from Table 6 of the Datasheet
44 #define FLASH_CNT 0x00 //Flash memory write count
45 #define XGYRO_OUT 0x04 //X-axis gyroscope output
46 #define YGYRO_OUT 0x06 //Y-axis gyroscope output
47 #define ZGYRO_OUT 0x08 //Z-axis gyroscope output
48 #define XACCL_OUT 0x0A //X-axis accelerometer output
49 #define YACCL_OUT 0x0C //Y-axis accelerometer output
50 #define ZACCL_OUT 0x0E //Z-axis accelerometer output
51 #define XMAGN_OUT 0X10 //X-axis magnetometer output
52 #define YMAGN_OUT 0x12 //Y-axis magnetometer output
53 #define ZMAGN_OUT 0x14 //Z-axis magnetometer output
54 #define BARO_OUT 0x16 //Barometer pressure measurement, high word
55 #define TEMP_OUT 0x18 //Temperature output
56 #define XGYRO_OFF 0x1A //X-axis gyroscope bias offset factor
57 #define YGYRO_OFF 0x1C //Y-axis gyroscope bias offset factor
58 #define ZGYRO_OFF 0x1E //Z-axis gyroscope bias offset factor
59 #define XACCL_OFF 0x20 //X-axis acceleration bias offset factor
60 #define YACCL_OFF 0x22 //Y-axis acceleration bias offset factor
61 #define ZACCL_OFF 0x24 //Z-axis acceleration bias offset factor
62 #define XMAGN_HIC 0x26 //X-axis magnetometer, hard iron factor
63 #define YMAGN_HIC 0x28 //Y-axis magnetometer, hard iron factor
64 #define ZMAGN_HIC 0x2A //Z-axis magnetometer, hard iron factor
65 #define XMAGN_SIC 0x2C //X-axis magnetometer, soft iron factor
66 #define YMAGN_SIC 0x2E //Y-axis magnetometer, soft iron factor
67 #define ZMAGN_SIC 0x30 //Z-axis magnetometer, soft iron factor
68 #define GPIO_CTRL 0x32 //GPIO control
69 #define MSC_CTRL 0x34 //Misc. control
70 #define SMPL_PRD 0x36 //Sample clock/Decimation filter control
71 #define SENS_AVG 0x38 //Digital filter control
72 #define SEQ_CNT 0x3A //xMAGN_OUT and BARO_OUT counter
73 #define DIAG_STAT 0x3C //System status
74 #define GLOB_CMD 0x3E //System command
75 #define ALM_MAG1 0x40 //Alarm 1 amplitude threshold
76 #define ALM_MAG2 0x42 //Alarm 2 amplitude threshold
77 #define ALM_SMPL1 0x44 //Alarm 1 sample size
78 #define ALM_SMPL2 0x46 //Alarm 2 sample size
79 #define ALM_CTRL 0x48 //Alarm control
80 #define LOT_ID1 0x52 //Lot identification number
81 #define LOT_ID2 0x54 //Lot identification number
82 #define PROD_ID 0x56 //Product identifier
83 #define SERIAL_NUM 0x58 //Lot-specific serial number
84 
85 namespace upm {
107  class ADIS16448{
108 
109  public:
110 
114  ADIS16448(int bus, int rst);
115 
119  ~ADIS16448();
120 
124  void resetDUT();
125 
129  void configSPI();
130 
134  int16_t regRead(uint8_t regAddr);
135 
139  void regWrite(uint8_t regAddr, uint16_t regData);
140 
144  float accelScale(int16_t sensorData);
145 
149  float gyroScale(int16_t sensorData);
150 
154  float tempScale(int16_t sensorData);
155 
159  float pressureScale(int16_t sensorData);
160 
164  float magnetometerScale(int16_t sensorData);
165 
166  private:
167 
168  mraa_spi_context _spi;
169  mraa_gpio_context _rst;
170 
171  };
172 }
173 
float gyroScale(int16_t sensorData)
Definition: adis16448.cxx:208
float accelScale(int16_t sensorData)
Definition: adis16448.cxx:197
void resetDUT()
Definition: adis16448.cxx:102
float pressureScale(int16_t sensorData)
Definition: adis16448.cxx:231
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
void configSPI()
Definition: adis16448.cxx:114
int16_t regRead(uint8_t regAddr)
Definition: adis16448.cxx:139
void regWrite(uint8_t regAddr, uint16_t regData)
Definition: adis16448.cxx:164
float tempScale(int16_t sensorData)
Definition: adis16448.cxx:220
API for the Analog Devices ADIS16448 Accelerometer.
Definition: adis16448.hpp:107
float magnetometerScale(int16_t sensorData)
Definition: adis16448.cxx:243
~ADIS16448()
Definition: adis16448.cxx:82
ADIS16448(int bus, int rst)
Definition: adis16448.cxx:56