5Permission is hereby granted, free of charge, to any person obtaining a
6copy of this software and associated documentation files (the
7"Software"), to deal in the Software without restriction, including
8without limitation the rights to use, copy, modify, merge, publish,
9distribute, sublicense, and/or sell copies of the Software, and to
10permit persons to whom the Software is furnished to do so, subject to
11the following conditions:
12
13The above copyright notice and this permission notice shall be included
14in all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23*/
24
25#ifndef __KX122_REGISTERS_H__
26#define __KX122_REGISTERS_H__
27/* registers */
28// x- hp filter output
29#define KX122_XHP_L 0x00
30#define KX122_XHP_H 0x01
31// y- hp filter output
32#define KX122_YHP_L 0x02
33#define KX122_YHP_H 0x03
34// z- hpfilteroutput
35#define KX122_ZHP_L 0x04
36#define KX122_ZHP_H 0x05
37// output register x
38#define KX122_XOUT_L 0x06
39#define KX122_XOUT_H 0x07
40// output register y
41#define KX122_YOUT_L 0x08
42#define KX122_YOUT_H 0x09
43// output register z
44#define KX122_ZOUT_L 0x0A
45#define KX122_ZOUT_H 0x0B
46// communication selftest
47#define KX122_COTR 0x0C
48// WHO_AM_I
49#define KX122_WHO_AM_I 0x0F
50// current sixfacet posititions
51#define KX122_TSCP 0x10
52// previous six facet positions
53#define KX122_TSPP 0x11
54// This register indicates the triggering axis when a tap/double tap interrupt occurs.
55#define KX122_INS1 0x12
56// This register tells witch function caused an interrupt.
57#define KX122_INS2 0x13
58// This register reports the axis and direction of detected motion.
59#define KX122_INS3 0x14
60// This register reports the status of the interrupt.
61#define KX122_STATUS_REG 0x15
62#define KX122_INT_REL 0x17
63// Read/write control register that controls the main feature set.
64#define KX122_CNTL1 0x18
65// 2' control register
66#define KX122_CNTL2 0x19
67// 3' controlregister
68#define KX122_CNTL3 0x1A
69// This register is responsible for configuring ODR (output data rate) and filter settings
70#define KX122_ODCNTL 0x1B
71// This register controls the settings for the physical interrupt pin INT1
72#define KX122_INC1 0x1C
73// This register controls which axis and direction of detected motion can cause an interrupt.
74#define KX122_INC2 0x1D
75// This register controls which axis and direction of tap/double tap can cause an interrup
76#define KX122_INC3 0x1E
77// This register controls routing of an interrupt reporting to physical interrupt pin INT1
78#define KX122_INC4 0x1F
79// This register controls the settings for the physical interrupt pin INT2.
80#define KX122_INC5 0x20
81// This register controls routing of interrupt reporting to physical interrupt pin INT2
82#define KX122_INC6 0x21
83#define KX122_TILT_TIMER 0x22
84#define KX122_WUFC 0x23
85// This register is responsible for enableing/disabling reporting of Tap/Double Tap.
86#define KX122_TDTRC 0x24
87#define KX122_TDTC 0x25
88#define KX122_TTH 0x26
89#define KX122_TTL 0x27
90#define KX122_FTD 0x28
91#define KX122_STD 0x29
92#define KX122_TLT 0x2A
93#define KX122_TWS 0x2B
94#define KX122_FFTH 0x2C
95#define KX122_FFC 0x2D
96// Free Fall Control: This register contains the counter setting of the Free fall detection.
97#define KX122_FFCNTL 0x2E
98#define KX122_ATH 0x30
99#define KX122_TILT_ANGLE_LL 0x32
100#define KX122_TILT_ANGLE_HL 0x33
101// This register sets the Hysteresis that is placed in between the Screen Rotation states
102#define KX122_HYST_SET 0x34
103// Low Power Control sets the number of samples of accelerometer output to be average
104#define KX122_LP_CNTL 0x35
105// Read/write control register that controls the buffer sample threshold
106#define KX122_BUF_CNTL1 0x3A
107// Read/write control register that controls sample buffer operation
108#define KX122_BUF_CNTL2 0x3B
109// This register reports the status of the sample buffer
110#define KX122_BUF_STATUS_1 0x3C
111// This register reports the status of the sample buffer trigger function
112#define KX122_BUF_STATUS_2 0x3D
113#define KX122_BUF_CLEAR 0x3E
114#define KX122_BUF_READ 0x3F
115// When 0xCA is written to this register, the MEMS self-test function is enabled. Electrostatic-actuation of the accelerometer, results in a DC shift of the X, Y and Z axis outputs. Writing 0x00 to this register will return the accelerometer to normal operation
116#define KX122_SELF_TEST 0x60
117// WHO_AM_I
118#define KX112_WHO_AM_I 0x0F
119// WHO_AM_I
120#define KX123_WHO_AM_I 0x0F
121// WHO_AM_I
122#define KX124_WHO_AM_I 0x0F
123/* registers bits */
124// before set
125#define KX122_COTR_DCSTR_BEFORE (0x55 << 0)
126// after set
127#define KX122_COTR_DCSTR_AFTER (0xAA << 0)
128// WHO_AM_I -value for KX122
129#define KX122_WHO_AM_I_WIA_ID (0x1B << 0)
130// x-left
131#define KX122_TSCP_LE (0x01 << 5)
132// x+right
133#define KX122_TSCP_RI (0x01 << 4)
134// y-down
135#define KX122_TSCP_DO (0x01 << 3)
136// y+up
137#define KX122_TSCP_UP (0x01 << 2)
138// z-facedown
139#define KX122_TSCP_FD (0x01 << 1)
140// z+faceup
141#define KX122_TSCP_FU (0x01 << 0)
142// x-left
143#define KX122_TSPP_LE (0x01 << 5)
144// x+right
145#define KX122_TSPP_RI (0x01 << 4)
146// y-down
147#define KX122_TSPP_DO (0x01 << 3)
148// y+up
149#define KX122_TSPP_UP (0x01 << 2)
150// z-facedown
151#define KX122_TSPP_FD (0x01 << 1)
152// z+faceup
153#define KX122_TSPP_FU (0x01 << 0)
154// x-
155#define KX122_INS1_TLE (0x01 << 5)
156// x+
157#define KX122_INS1_TRI (0x01 << 4)
158// y-
159#define KX122_INS1_TDO (0x01 << 3)
160// y+
161#define KX122_INS1_TUP (0x01 << 2)
162// z-
163#define KX122_INS1_TFD (0x01 << 1)
164// z+
165#define KX122_INS1_TFU (0x01 << 0)
166// Free fall. This bit is cleared when the interrupt latch release register (INL) is read..
167#define KX122_INS2_FFS (0x01 << 7)
168// indicates buffer full interrupt. Automatically cleared when buffer is read.
169#define KX122_INS2_BFI (0x01 << 6)
170// Watermark interrupt, bit is set to one when FIFO has filled up to the value stored in the sample bits.This bit is automatically cleared when FIFO/FILO is read and the content returns to a value below the value stored in the sample bits.
171#define KX122_INS2_WMI (0x01 << 5)
172// indicates that new acceleration data (0x06h to 0x0Bh) is available. This bit is cleared when acceleration data is read or the interrupt release register INT_REL is read.
173#define KX122_INS2_DRDY (0x01 << 4)
174// no tap
175#define KX122_INS2_TDTS_NOTAP (0x00 << 2)
176// single tap event
177#define KX122_INS2_TDTS_SINGLE (0x01 << 2)
178// double tap event
179#define KX122_INS2_TDTS_DOUBLE (0x02 << 2)
180// do not exist
181#define KX122_INS2_TDTS_NA (0x03 << 2)
182// Status of Wake up. This bit is cleared when the interrupt release register INT_REL is read.
183#define KX122_INS2_WUFS (0x01 << 1)
184// Tilt Position status. This bit is cleared when the interrupt release register INT_REL is read.
185#define KX122_INS2_TPS (0x01 << 0)
186// x-
187#define KX122_INS3_XNWU (0x01 << 5)
188// x+
189#define KX122_INS3_XPWU (0x01 << 4)
190// y-
191#define KX122_INS3_YNWU (0x01 << 3)
192// y+
193#define KX122_INS3_YPWU (0x01 << 2)
194// z-
195#define KX122_INS3_ZNWU (0x01 << 1)
196// z+
197#define KX122_INS3_ZPWU (0x01 << 0)
198// INT reports the combined (OR) interrupt information of all features.
199#define KX122_STATUS_REG_INT (0x01 << 4)
200// controls the operating mode of the KX122.
201#define KX122_CNTL1_PC1 (0x01 << 7)
202// determines the performance mode of the KX122. The noise varies with ODR, RES and different LP_CNTL settings possibly reducing the effective resolution.
203#define KX122_CNTL1_RES (0x01 << 6)
204// enables the reporting of the availability of new acceleration data as an interrupt
205#define KX122_CNTL1_DRDYE (0x01 << 5)
206// 2g range
207#define KX122_CNTL1_GSEL_2G (0x00 << 3)
208// 4g range
209#define KX122_CNTL1_GSEL_4G (0x01 << 3)
210// 8g range
211#define KX122_CNTL1_GSEL_8G (0x02 << 3)
212// not valid settings
213#define KX122_CNTL1_GSEL_NA (0x03 << 3)
214// enables the Directional Tap function that will detect single and double tap events.
215#define KX122_CNTL1_TDTE (0x01 << 2)
216// enables the Wake Up (motion detect) function
217#define KX122_CNTL1_WUFE (0x01 << 1)
218// enables the Tilt Position function that will detect changes in device orientation.
219#define KX122_CNTL1_TPE (0x01 << 0)
220// initiates software reset, which performs the RAM reboot routine
453// determines the resolution of the acceleration data samples collected by the sample
454#define KX122_BUF_CNTL2_BRES (0x01 << 6)
455// buffer full interrupt enable bit
456#define KX122_BUF_CNTL2_BFIE (0x01 << 5)
457// watermark level bits 8 and 9
458#define KX122_BUF_CNTL2_SMP_TH8_9 (0x0C << 2)
459// The buffer collects 681 sets of 8-bit low resolution values or 339 sets of 16-bit high resolution values and then stops collecting data, collecting new data only when the buffer is not full
460#define KX122_BUF_CNTL2_BUF_M_FIFO (0x00 << 0)
461// The buffer holds the last 681 sets of 8-bit low resolution values or 339 sets of 16-bit high resolution values. Once the buffer is full, the oldest data is discarded to make room for newer data.
463// When a trigger event occurs, the buffer holds the last data set of SMP[9:0] samples before the trigger event and then continues to collect data until full. New data is collected only when the buffer is not full.
465// The buffer holds the last 681 sets of 8-bit low resolution values or 339 sets of 16-bit high resolution values. Once the buffer is full, the oldest data is discarded to make room for newer data. Reading from the buffer in this mode will return the most recent data first.