upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
kxtj3_registers.h
1 /*
2 The MIT License (MIT)
3 Copyright (c) 2017 Kionix Inc.
4 
5 Permission is hereby granted, free of charge, to any person obtaining a
6 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 included
14 in all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24 
25 #ifndef __KXTJ3_REGISTERS_H__
26 #define __KXTJ3_REGISTERS_H__
27 /* registers */
28 // output register x
29 #define KXTJ3_XOUT_L 0x06
30 #define KXTJ3_XOUT_H 0x07
31 // output register y
32 #define KXTJ3_YOUT_L 0x08
33 #define KXTJ3_YOUT_H 0x09
34 // output register z
35 #define KXTJ3_ZOUT_L 0x0A
36 #define KXTJ3_ZOUT_H 0x0B
37 // This register can be used to verify proper integrated circuit functionality
38 #define KXTJ3_DCST_RESP 0x0C
39 // This register can be used for supplier recognition, as it can be factory written to a known byte value.
40 #define KXTJ3_WHO_AM_I 0x0F
41 // This register reports which function caused an interrupt.
42 #define KXTJ3_INT_SOURCE1 0x16
43 // This register reports the axis and direction of detected motion
44 #define KXTJ3_INT_SOURCE2 0x17
45 // This register reports the status of the interrupt
46 #define KXTJ3_STATUS_REG 0x18
47 #define KXTJ3_INT_REL 0x1A
48 // Read/write control register that controls the main feature set
49 #define KXTJ3_CTRL_REG1 0x1B
50 // Read/write control register that provides more feature set control
51 #define KXTJ3_CTRL_REG2 0x1D
52 // This register controls the settings for the physical interrupt pin
53 #define KXTJ3_INT_CTRL_REG1 0x1E
54 // This register controls which axis and direction of detected motion can cause an interrupt
55 #define KXTJ3_INT_CTRL_REG2 0x1F
56 // Read/write control register that configures the acceleration outputs
57 #define KXTJ3_DATA_CTRL_REG 0x21
58 #define KXTJ3_WAKEUP_COUNTER 0x29
59 #define KXTJ3_NA_COUNTER 0x2A
60 // When 0xCA is written to this register, the MEMS self-test function is enabled
61 #define KXTJ3_SELF_TEST 0x3A
62 #define KXTJ3_WAKEUP_THRESHOLD_H 0x6A
63 #define KXTJ3_WAKEUP_THRESHOLD_L 0x6B
64 // This register can be used for supplier recognition, as it can be factory written to a known byte value.
65 #define KXCJC_WHO_AM_I 0x0F
66 /* registers bits */
67 // before set
68 #define KXTJ3_DCST_RESP_DCSTR_BEFORE (0x55 << 0)
69 // after set
70 #define KXTJ3_DCST_RESP_DCSTR_AFTER (0xAA << 0)
71 // WHO_AM_I -value for KXTJ3
72 #define KXTJ3_WHO_AM_I_WIA_ID (0x35 << 0)
73 // indicates that new acceleration data
74 #define KXTJ3_INT_SOURCE1_DRDY (0x01 << 4)
75 // Wake up
76 #define KXTJ3_INT_SOURCE1_WUFS (0x01 << 1)
77 // x-
78 #define KXTJ3_INT_SOURCE2_XNWU (0x01 << 5)
79 // x+
80 #define KXTJ3_INT_SOURCE2_XPWU (0x01 << 4)
81 // y-
82 #define KXTJ3_INT_SOURCE2_YNWU (0x01 << 3)
83 // y+
84 #define KXTJ3_INT_SOURCE2_YPWU (0x01 << 2)
85 // z-
86 #define KXTJ3_INT_SOURCE2_ZNWU (0x01 << 1)
87 // z+
88 #define KXTJ3_INT_SOURCE2_ZPWU (0x01 << 0)
89 // reports the combined (OR) interrupt information of DRDY and WUFS in the interrupt source register
90 #define KXTJ3_STATUS_REG_INT (0x01 << 4)
91 // controls the operating mode of the KXTJ3
92 #define KXTJ3_CTRL_REG1_PC (0x01 << 7)
93 // determines the performance mode of the KXTJ3
94 #define KXTJ3_CTRL_REG1_RES (0x01 << 6)
95 // enables the reporting of the availability of new acceleration data as an interrupt
96 #define KXTJ3_CTRL_REG1_DRDYE (0x01 << 5)
97 // 2g range
98 #define KXTJ3_CTRL_REG1_GSEL_2G (0x00 << 2)
99 // 16g range
100 #define KXTJ3_CTRL_REG1_GSEL_16G (0x01 << 2)
101 // 4g range
102 #define KXTJ3_CTRL_REG1_GSEL_4G (0x02 << 2)
103 // 16g range
104 #define KXTJ3_CTRL_REG1_GSEL_16G2 (0x03 << 2)
105 // 8g range
106 #define KXTJ3_CTRL_REG1_GSEL_8G (0x04 << 2)
107 // 16g range
108 #define KXTJ3_CTRL_REG1_GSEL_16G3 (0x05 << 2)
109 // 8g range with 14b resolution
110 #define KXTJ3_CTRL_REG1_GSEL_8G_14 (0x06 << 2)
111 // 16g range with 14b resolution
112 #define KXTJ3_CTRL_REG1_GSEL_16G_14 (0x07 << 2)
113 // enables 14-bit mode if GSEL = '11'
114 #define KXTJ3_CTRL_REG1_EN16G (0x01 << 2)
115 // enables the Wake Up (motion detect) function.
116 #define KXTJ3_CTRL_REG1_WUFE (0x01 << 1)
117 // initiates software reset
118 #define KXTJ3_CTRL_REG2_SRST (0x01 << 7)
119 // initiates the digital communication self-test function.
120 #define KXTJ3_CTRL_REG2_DCST (0x01 << 4)
121 // 0.78Hz
122 #define KXTJ3_CTRL_REG2_OWUF_0P781 (0x00 << 0)
123 // 1.563Hz
124 #define KXTJ3_CTRL_REG2_OWUF_1P563 (0x01 << 0)
125 // 3.125Hz
126 #define KXTJ3_CTRL_REG2_OWUF_3P125 (0x02 << 0)
127 // 6.25Hz
128 #define KXTJ3_CTRL_REG2_OWUF_6P25 (0x03 << 0)
129 // 12.5Hz
130 #define KXTJ3_CTRL_REG2_OWUF_12P5 (0x04 << 0)
131 // 25Hz
132 #define KXTJ3_CTRL_REG2_OWUF_25 (0x05 << 0)
133 // 50Hz
134 #define KXTJ3_CTRL_REG2_OWUF_50 (0x06 << 0)
135 // 100Hz
136 #define KXTJ3_CTRL_REG2_OWUF_100 (0x07 << 0)
137 // enables/disables the physical interrupt pin
138 #define KXTJ3_INT_CTRL_REG1_IEN (0x01 << 5)
139 // sets the polarity of the physical interrupt pin
140 #define KXTJ3_INT_CTRL_REG1_IEA (0x01 << 4)
141 // sets the response of the physical interrupt pin
142 #define KXTJ3_INT_CTRL_REG1_IEL (0x01 << 3)
143 // selftest polarity
144 #define KXTJ3_INT_CTRL_REG1_STPOL (0x01 << 1)
145 // Unlatched mode motion interrupt; 0=disabled,1=enabled
146 #define KXTJ3_INT_CTRL_REG2_ULMODE (0x01 << 7)
147 // x-
148 #define KXTJ3_INT_CTRL_REG2_XNWU (0x01 << 5)
149 // x+
150 #define KXTJ3_INT_CTRL_REG2_XPWU (0x01 << 4)
151 // y-
152 #define KXTJ3_INT_CTRL_REG2_YNWU (0x01 << 3)
153 // y+
154 #define KXTJ3_INT_CTRL_REG2_YPWU (0x01 << 2)
155 // z-
156 #define KXTJ3_INT_CTRL_REG2_ZNWU (0x01 << 1)
157 // z+
158 #define KXTJ3_INT_CTRL_REG2_ZPWU (0x01 << 0)
159 // 12.5Hz
160 #define KXTJ3_DATA_CTRL_REG_OSA_12P5 (0x00 << 0)
161 // 25Hz
162 #define KXTJ3_DATA_CTRL_REG_OSA_25 (0x01 << 0)
163 // 50Hz
164 #define KXTJ3_DATA_CTRL_REG_OSA_50 (0x02 << 0)
165 // 100Hz
166 #define KXTJ3_DATA_CTRL_REG_OSA_100 (0x03 << 0)
167 // 200Hz
168 #define KXTJ3_DATA_CTRL_REG_OSA_200 (0x04 << 0)
169 // 400Hz
170 #define KXTJ3_DATA_CTRL_REG_OSA_400 (0x05 << 0)
171 // 800Hz
172 #define KXTJ3_DATA_CTRL_REG_OSA_800 (0x06 << 0)
173 // 1600Hz
174 #define KXTJ3_DATA_CTRL_REG_OSA_1600 (0x07 << 0)
175 // 0.78Hz
176 #define KXTJ3_DATA_CTRL_REG_OSA_0P781 (0x08 << 0)
177 // 1.563Hz
178 #define KXTJ3_DATA_CTRL_REG_OSA_1P563 (0x09 << 0)
179 // 3.125Hz
180 #define KXTJ3_DATA_CTRL_REG_OSA_3P125 (0x0A << 0)
181 // 6.25Hz
182 #define KXTJ3_DATA_CTRL_REG_OSA_6P25 (0x0B << 0)
183 // charge on
184 #define KXTJ3_SELF_TEST_MEMS_TEST_ENABLE (0xCA << 0)
185 // charge off
186 #define KXTJ3_SELF_TEST_MEMS_TEST_DISABLE (0x00 << 0)
187 // WHO_AM_I -value for KXCJC
188 #define KXCJC_WHO_AM_I_WIA_ID (0x36 << 0)
189 /*registers bit masks */
190 
191 #define KXTJ3_DCST_RESP_DCSTR_MASK 0xFF
192 
193 #define KXTJ3_WHO_AM_I_WIA_MASK 0xFF
194 // selects the acceleration range of the accelerometer outputs
195 #define KXTJ3_CTRL_REG1_GSEL_MASK 0x1C
196 // sets the Output Data Rate for the Wake Up function
197 #define KXTJ3_CTRL_REG2_OWUF_MASK 0x07
198 // sets the output data rate (ODR)
199 #define KXTJ3_DATA_CTRL_REG_OSA_MASK 0x0F
200 
201 #define KXTJ3_SELF_TEST_MEMS_TEST_MASK 0xFF
202 
203 #define KXCJC_WHO_AM_I_WIA_MASK 0xFF
204 #endif