Kionix KX123 accelerometer C++ driver. Can be used for some extend also with kx022, kx023, kx122, etc. when used features are present in sensor.

Dependents:   kionix-kx123-hello

Committer:
MikkoZ
Date:
Thu Oct 06 13:02:55 2016 +0000
Revision:
3:4fd5361ed180
Parent:
2:62891556d47b
Bugfix: get_results_highpass; ; Changed parameter from uint16_t to int16_t as it should be.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikkoZ 0:a3f43eb92f86 1 /* Copyright 2016 Rohm Semiconductor
MikkoZ 0:a3f43eb92f86 2
MikkoZ 0:a3f43eb92f86 3 Licensed under the Apache License, Version 2.0 (the "License");
MikkoZ 0:a3f43eb92f86 4 you may not use this file except in compliance with the License.
MikkoZ 0:a3f43eb92f86 5 You may obtain a copy of the License at
MikkoZ 0:a3f43eb92f86 6
MikkoZ 0:a3f43eb92f86 7 http://www.apache.org/licenses/LICENSE-2.0
MikkoZ 0:a3f43eb92f86 8
MikkoZ 0:a3f43eb92f86 9 Unless required by applicable law or agreed to in writing, software
MikkoZ 0:a3f43eb92f86 10 distributed under the License is distributed on an "AS IS" BASIS,
MikkoZ 0:a3f43eb92f86 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MikkoZ 0:a3f43eb92f86 12 See the License for the specific language governing permissions and
MikkoZ 0:a3f43eb92f86 13 limitations under the License.
MikkoZ 0:a3f43eb92f86 14 */
MikkoZ 0:a3f43eb92f86 15
MikkoZ 0:a3f43eb92f86 16 #ifndef KX123_REGISTERS_H
MikkoZ 0:a3f43eb92f86 17 #define KX123_REGISTERS_H
MikkoZ 0:a3f43eb92f86 18
MikkoZ 0:a3f43eb92f86 19 #define KX123_DEFAULT_SLAVE_ADDRESS 0x1F
MikkoZ 0:a3f43eb92f86 20 #define KX123_SECONDARY_SLAVE_ADDRESS 0x1E
MikkoZ 0:a3f43eb92f86 21
MikkoZ 2:62891556d47b 22 enum e_axis {
MikkoZ 2:62891556d47b 23 KX123_X_N = (uint8_t) (0x01 << 5),
MikkoZ 2:62891556d47b 24 KX123_X_P = (uint8_t) (0x01 << 4),
MikkoZ 2:62891556d47b 25 KX123_Y_N = (uint8_t) (0x01 << 3),
MikkoZ 2:62891556d47b 26 KX123_Y_P = (uint8_t) (0x01 << 2),
MikkoZ 2:62891556d47b 27 KX123_Z_N = (uint8_t) (0x01 << 1),
MikkoZ 2:62891556d47b 28 KX123_Z_P = (uint8_t) (0x01 << 0)
MikkoZ 2:62891556d47b 29 };
MikkoZ 2:62891556d47b 30
MikkoZ 2:62891556d47b 31 #define KX123_AXIS_MASK 0x3f
MikkoZ 2:62891556d47b 32
MikkoZ 2:62891556d47b 33 enum e_interrupt_reason {
MikkoZ 2:62891556d47b 34 KX123_FREEFALL = (uint8_t) (0x01 << 7),
MikkoZ 2:62891556d47b 35 KX122_BUFFER_FULL = (uint8_t) (0x01 << 6),
MikkoZ 2:62891556d47b 36 KX122_WATERMARK = (uint8_t) (0x01 << 5),
MikkoZ 2:62891556d47b 37 KX122_DATAREADY = (uint8_t) (0x01 << 4),
MikkoZ 2:62891556d47b 38 KX122_DOUBLE_TAP = (uint8_t) (0x02 << 2),
MikkoZ 2:62891556d47b 39 KX122_SINGLE_TAP = (uint8_t) (0x01 << 2),
MikkoZ 2:62891556d47b 40 KX122_MOTION_INTERRUPT = (uint8_t) (0x01 << 1),
MikkoZ 2:62891556d47b 41 KX122_TILT_CHANGED = (uint8_t) (0x01 << 0)
MikkoZ 2:62891556d47b 42 };
MikkoZ 2:62891556d47b 43
MikkoZ 2:62891556d47b 44
MikkoZ 0:a3f43eb92f86 45 /* registers */
MikkoZ 0:a3f43eb92f86 46 // x- hp filter output
MikkoZ 0:a3f43eb92f86 47 #define KX122_XHP_L 0x00
MikkoZ 0:a3f43eb92f86 48 #define KX122_XHP_H 0x01
MikkoZ 0:a3f43eb92f86 49 // y- hp filter output
MikkoZ 0:a3f43eb92f86 50 #define KX122_YHP_L 0x02
MikkoZ 0:a3f43eb92f86 51 #define KX122_YHP_H 0x03
MikkoZ 0:a3f43eb92f86 52 // z- hpfilteroutput
MikkoZ 0:a3f43eb92f86 53 #define KX122_ZHP_L 0x04
MikkoZ 0:a3f43eb92f86 54 #define KX122_ZHP_H 0x05
MikkoZ 0:a3f43eb92f86 55 // output register x
MikkoZ 0:a3f43eb92f86 56 #define KX122_XOUT_L 0x06
MikkoZ 0:a3f43eb92f86 57 #define KX122_XOUT_H 0x07
MikkoZ 0:a3f43eb92f86 58 // output register y
MikkoZ 0:a3f43eb92f86 59 #define KX122_YOUT_L 0x08
MikkoZ 0:a3f43eb92f86 60 #define KX122_YOUT_H 0x09
MikkoZ 0:a3f43eb92f86 61 // output register z
MikkoZ 0:a3f43eb92f86 62 #define KX122_ZOUT_L 0x0A
MikkoZ 0:a3f43eb92f86 63 #define KX122_ZOUT_H 0x0B
MikkoZ 0:a3f43eb92f86 64 // communication selftest
MikkoZ 0:a3f43eb92f86 65 #define KX122_COTR 0x0C
MikkoZ 0:a3f43eb92f86 66 // WHO_AM_I
MikkoZ 0:a3f43eb92f86 67 #define KX122_WHO_AM_I 0x0F
MikkoZ 0:a3f43eb92f86 68 // current sixfacet posititions
MikkoZ 0:a3f43eb92f86 69 #define KX122_TSCP 0x10
MikkoZ 0:a3f43eb92f86 70 // previous six facet positions
MikkoZ 0:a3f43eb92f86 71 #define KX122_TSPP 0x11
MikkoZ 0:a3f43eb92f86 72 // This register indicates the triggering axis when a tap/double tap interrupt occurs.
MikkoZ 0:a3f43eb92f86 73 #define KX122_INS1 0x12
MikkoZ 0:a3f43eb92f86 74 // This register tells witch function caused an interrupt.
MikkoZ 0:a3f43eb92f86 75 #define KX122_INS2 0x13
MikkoZ 0:a3f43eb92f86 76 // This register reports the axis and direction of detected motion.
MikkoZ 0:a3f43eb92f86 77 #define KX122_INS3 0x14
MikkoZ 0:a3f43eb92f86 78 // This register reports the status of the interrupt.
MikkoZ 0:a3f43eb92f86 79 #define KX122_STATUS_REG 0x15
MikkoZ 0:a3f43eb92f86 80 // Latched interrupt source information (INS1,INS2, INS3 except WMI/BFI and INT when WMI/BFI is zero) is cleared and physical interrupt latched pin is changed to its inactive state when this register is read. Read value is dummy.
MikkoZ 0:a3f43eb92f86 81 #define KX122_INT_REL 0x17
MikkoZ 0:a3f43eb92f86 82 // Read/write control register that controls the main feature set.
MikkoZ 0:a3f43eb92f86 83 #define KX122_CNTL1 0x18
MikkoZ 0:a3f43eb92f86 84 // 2' control register
MikkoZ 0:a3f43eb92f86 85 #define KX122_CNTL2 0x19
MikkoZ 0:a3f43eb92f86 86 // 3' controlregister
MikkoZ 0:a3f43eb92f86 87 #define KX122_CNTL3 0x1A
MikkoZ 0:a3f43eb92f86 88 // This register is responsible for configuring ODR (output data rate) and filter settings
MikkoZ 0:a3f43eb92f86 89 #define KX122_ODCNTL 0x1B
MikkoZ 0:a3f43eb92f86 90 // This register controls the settings for the physical interrupt pin INT1
MikkoZ 0:a3f43eb92f86 91 #define KX122_INC1 0x1C
MikkoZ 0:a3f43eb92f86 92 // This register controls which axis and direction of detected motion can cause an interrupt.
MikkoZ 0:a3f43eb92f86 93 #define KX122_INC2 0x1D
MikkoZ 0:a3f43eb92f86 94 // This register controls which axis and direction of tap/double tap can cause an interrup
MikkoZ 0:a3f43eb92f86 95 #define KX122_INC3 0x1E
MikkoZ 0:a3f43eb92f86 96 // This register controls routing of an interrupt reporting to physical interrupt pin INT1
MikkoZ 0:a3f43eb92f86 97 #define KX122_INC4 0x1F
MikkoZ 0:a3f43eb92f86 98 // This register controls the settings for the physical interrupt pin INT2.
MikkoZ 0:a3f43eb92f86 99 #define KX122_INC5 0x20
MikkoZ 0:a3f43eb92f86 100 // This register controls routing of interrupt reporting to physical interrupt pin INT2
MikkoZ 0:a3f43eb92f86 101 #define KX122_INC6 0x21
MikkoZ 0:a3f43eb92f86 102 // This register is the initial count register for the tilt position state timer
MikkoZ 0:a3f43eb92f86 103 #define KX122_TILT_TIMER 0x22
MikkoZ 0:a3f43eb92f86 104 // This register is the initial count register for the motion detection timer
MikkoZ 0:a3f43eb92f86 105 #define KX122_WUFC 0x23
MikkoZ 0:a3f43eb92f86 106 // This register is responsible for enableing/disabling reporting of Tap/Double Tap.
MikkoZ 0:a3f43eb92f86 107 #define KX122_TDTRC 0x24
MikkoZ 0:a3f43eb92f86 108 // This register contains counter information for the detection of a double tap event.
MikkoZ 0:a3f43eb92f86 109 #define KX122_TDTC 0x25
MikkoZ 0:a3f43eb92f86 110 // This register represents the 8-bit jerk high threshold to determine if a tap is detected.
MikkoZ 0:a3f43eb92f86 111 #define KX122_TTH 0x26
MikkoZ 0:a3f43eb92f86 112 // This register represents the 8-bit (0d 255d) jerk low threshold to determine if a tap is detected.
MikkoZ 0:a3f43eb92f86 113 #define KX122_TTL 0x27
MikkoZ 0:a3f43eb92f86 114 // This register contains counter information for the detection of any tap event.
MikkoZ 0:a3f43eb92f86 115 #define KX122_FTD 0x28
MikkoZ 0:a3f43eb92f86 116 // This register contains counter information for the detection of a double tap event
MikkoZ 0:a3f43eb92f86 117 #define KX122_STD 0x29
MikkoZ 0:a3f43eb92f86 118 // This register contains counter information for the detection of a tap event.
MikkoZ 0:a3f43eb92f86 119 #define KX122_TLT 0x2A
MikkoZ 0:a3f43eb92f86 120 // This register contains counter information for the detection of single and double taps.
MikkoZ 0:a3f43eb92f86 121 #define KX122_TWS 0x2B
MikkoZ 0:a3f43eb92f86 122 // Free Fall Threshold
MikkoZ 0:a3f43eb92f86 123 #define KX122_FFTH 0x2C
MikkoZ 0:a3f43eb92f86 124 // Free Fall Counter
MikkoZ 0:a3f43eb92f86 125 #define KX122_FFC 0x2D
MikkoZ 0:a3f43eb92f86 126 // Free Fall Control: This register contains the counter setting of the Free fall detection.
MikkoZ 0:a3f43eb92f86 127 #define KX122_FFCNTL 0x2E
MikkoZ 0:a3f43eb92f86 128 // This register sets the threshold for wake-up (motion detect) interrupt is set.
MikkoZ 0:a3f43eb92f86 129 #define KX122_ATH 0x30
MikkoZ 0:a3f43eb92f86 130 // This register sets the low level threshold for tilt angle detection.
MikkoZ 0:a3f43eb92f86 131 #define KX122_TILT_ANGLE_LL 0x32
MikkoZ 0:a3f43eb92f86 132 // This register sets the high level threshold for tilt angle detection.
MikkoZ 0:a3f43eb92f86 133 #define KX122_TILT_ANGLE_HL 0x33
MikkoZ 0:a3f43eb92f86 134 // This register sets the Hysteresis that is placed in between the Screen Rotation states
MikkoZ 0:a3f43eb92f86 135 #define KX122_HYST_SET 0x34
MikkoZ 0:a3f43eb92f86 136 // Low Power Control sets the number of samples of accelerometer output to be average
MikkoZ 0:a3f43eb92f86 137 #define KX122_LP_CNTL 0x35
MikkoZ 0:a3f43eb92f86 138 // Read/write control register that controls the buffer sample threshold
MikkoZ 0:a3f43eb92f86 139 #define KX122_BUF_CNTL1 0x3A
MikkoZ 0:a3f43eb92f86 140 // Read/write control register that controls sample buffer operation
MikkoZ 0:a3f43eb92f86 141 #define KX122_BUF_CNTL2 0x3B
MikkoZ 0:a3f43eb92f86 142 // This register reports the status of the sample buffer
MikkoZ 0:a3f43eb92f86 143 #define KX122_BUF_STATUS_1 0x3C
MikkoZ 0:a3f43eb92f86 144 // This register reports the status of the sample buffer trigger function
MikkoZ 0:a3f43eb92f86 145 #define KX122_BUF_STATUS_2 0x3D
MikkoZ 0:a3f43eb92f86 146 // Latched buffer status information and the entire sample buffer are cleared when any data is written to this register.
MikkoZ 0:a3f43eb92f86 147 #define KX122_BUF_CLEAR 0x3E
MikkoZ 0:a3f43eb92f86 148 // Buffer output register
MikkoZ 0:a3f43eb92f86 149 #define KX122_BUF_READ 0x3F
MikkoZ 0:a3f43eb92f86 150 // 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
MikkoZ 0:a3f43eb92f86 151 #define KX122_SELF_TEST 0x60
MikkoZ 0:a3f43eb92f86 152 /* registers bits */
MikkoZ 0:a3f43eb92f86 153 // before set
MikkoZ 0:a3f43eb92f86 154 #define KX122_COTR_DCSTR_BEFORE (0x55 << 0)
MikkoZ 0:a3f43eb92f86 155 // after set
MikkoZ 0:a3f43eb92f86 156 #define KX122_COTR_DCSTR_AFTER (0xAA << 0)
MikkoZ 0:a3f43eb92f86 157 // WHO_AM_I -value
MikkoZ 0:a3f43eb92f86 158 #define KX012_WHO_AM_I_WAI_ID (0x1A << 0)
MikkoZ 0:a3f43eb92f86 159 #define KX022_WHO_AM_I_WAI_ID (0x14 << 0)
MikkoZ 0:a3f43eb92f86 160 #define KX023_WHO_AM_I_WAI_ID (0x15 << 0)
MikkoZ 0:a3f43eb92f86 161 #define KX23H_WHO_AM_I_WAI_ID (0x1C << 0)
MikkoZ 0:a3f43eb92f86 162 #define KX112_WHO_AM_I_WAI_ID (0x22 << 0)
MikkoZ 0:a3f43eb92f86 163 #define KX122_WHO_AM_I_WAI_ID (0x1B << 0)
MikkoZ 0:a3f43eb92f86 164 #define KX123_WHO_AM_I_WAI_ID (0x20 << 0)
MikkoZ 0:a3f43eb92f86 165 #define KX124_WHO_AM_I_WAI_ID (0x28 << 0)
MikkoZ 0:a3f43eb92f86 166 #define KX222_WHO_AM_I_WAI_ID (0x2C << 0)
MikkoZ 0:a3f43eb92f86 167 #define KX224_WHO_AM_I_WAI_ID (0x2B << 0)
MikkoZ 0:a3f43eb92f86 168 // x-left
MikkoZ 0:a3f43eb92f86 169 #define KX122_TSCP_LE (0x01 << 5)
MikkoZ 0:a3f43eb92f86 170 // x+right
MikkoZ 0:a3f43eb92f86 171 #define KX122_TSCP_RI (0x01 << 4)
MikkoZ 0:a3f43eb92f86 172 // y-down
MikkoZ 0:a3f43eb92f86 173 #define KX122_TSCP_DO (0x01 << 3)
MikkoZ 0:a3f43eb92f86 174 // y+up
MikkoZ 0:a3f43eb92f86 175 #define KX122_TSCP_UP (0x01 << 2)
MikkoZ 0:a3f43eb92f86 176 // z-facedown
MikkoZ 0:a3f43eb92f86 177 #define KX122_TSCP_FD (0x01 << 1)
MikkoZ 0:a3f43eb92f86 178 // z+faceup
MikkoZ 0:a3f43eb92f86 179 #define KX122_TSCP_FU (0x01 << 0)
MikkoZ 0:a3f43eb92f86 180 // x-left
MikkoZ 0:a3f43eb92f86 181 #define KX122_TSPP_LE (0x01 << 5)
MikkoZ 0:a3f43eb92f86 182 // x+right
MikkoZ 0:a3f43eb92f86 183 #define KX122_TSPP_RI (0x01 << 4)
MikkoZ 0:a3f43eb92f86 184 // y-down
MikkoZ 0:a3f43eb92f86 185 #define KX122_TSPP_DO (0x01 << 3)
MikkoZ 0:a3f43eb92f86 186 // y+up
MikkoZ 0:a3f43eb92f86 187 #define KX122_TSPP_UP (0x01 << 2)
MikkoZ 0:a3f43eb92f86 188 // z-facedown
MikkoZ 0:a3f43eb92f86 189 #define KX122_TSPP_FD (0x01 << 1)
MikkoZ 0:a3f43eb92f86 190 // z+faceup
MikkoZ 0:a3f43eb92f86 191 #define KX122_TSPP_FU (0x01 << 0)
MikkoZ 0:a3f43eb92f86 192 // x-
MikkoZ 0:a3f43eb92f86 193 #define KX122_INS1_TLE (0x01 << 5)
MikkoZ 0:a3f43eb92f86 194 // x+
MikkoZ 0:a3f43eb92f86 195 #define KX122_INS1_TRI (0x01 << 4)
MikkoZ 0:a3f43eb92f86 196 // y-
MikkoZ 0:a3f43eb92f86 197 #define KX122_INS1_TDO (0x01 << 3)
MikkoZ 0:a3f43eb92f86 198 // y+
MikkoZ 0:a3f43eb92f86 199 #define KX122_INS1_TUP (0x01 << 2)
MikkoZ 0:a3f43eb92f86 200 // z-
MikkoZ 0:a3f43eb92f86 201 #define KX122_INS1_TFD (0x01 << 1)
MikkoZ 0:a3f43eb92f86 202 // z+
MikkoZ 0:a3f43eb92f86 203 #define KX122_INS1_TFU (0x01 << 0)
MikkoZ 0:a3f43eb92f86 204 // Free fall. This bit is cleared when the interrupt latch release register (INL) is read..
MikkoZ 0:a3f43eb92f86 205 #define KX122_INS2_FFS (0x01 << 7)
MikkoZ 0:a3f43eb92f86 206 // indicates buffer full interrupt. Automatically cleared when buffer is read.
MikkoZ 0:a3f43eb92f86 207 #define KX122_INS2_BFI (0x01 << 6)
MikkoZ 0:a3f43eb92f86 208 // 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.
MikkoZ 0:a3f43eb92f86 209 #define KX122_INS2_WMI (0x01 << 5)
MikkoZ 0:a3f43eb92f86 210 // 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.
MikkoZ 0:a3f43eb92f86 211 #define KX122_INS2_DRDY (0x01 << 4)
MikkoZ 0:a3f43eb92f86 212 // no tap
MikkoZ 0:a3f43eb92f86 213 #define KX122_INS2_TDTS_NOTAP (0x00 << 2)
MikkoZ 0:a3f43eb92f86 214 // single tap event
MikkoZ 0:a3f43eb92f86 215 #define KX122_INS2_TDTS_SINGLE (0x01 << 2)
MikkoZ 0:a3f43eb92f86 216 // double tap event
MikkoZ 0:a3f43eb92f86 217 #define KX122_INS2_TDTS_DOUBLE (0x02 << 2)
MikkoZ 0:a3f43eb92f86 218 // do not exist
MikkoZ 0:a3f43eb92f86 219 #define KX122_INS2_TDTS_NA (0x03 << 2)
MikkoZ 0:a3f43eb92f86 220 // Status of Wake up. This bit is cleared when the interrupt release register INT_REL is read.
MikkoZ 0:a3f43eb92f86 221 #define KX122_INS2_WUFS (0x01 << 1)
MikkoZ 0:a3f43eb92f86 222 // Tilt Position status. This bit is cleared when the interrupt release register INT_REL is read.
MikkoZ 0:a3f43eb92f86 223 #define KX122_INS2_TPS (0x01 << 0)
MikkoZ 0:a3f43eb92f86 224 // x-
MikkoZ 0:a3f43eb92f86 225 #define KX122_INS3_XNWU (0x01 << 5)
MikkoZ 0:a3f43eb92f86 226 // x+
MikkoZ 0:a3f43eb92f86 227 #define KX122_INS3_XPWU (0x01 << 4)
MikkoZ 0:a3f43eb92f86 228 // y-
MikkoZ 0:a3f43eb92f86 229 #define KX122_INS3_YNWU (0x01 << 3)
MikkoZ 0:a3f43eb92f86 230 // y+
MikkoZ 0:a3f43eb92f86 231 #define KX122_INS3_YPWU (0x01 << 2)
MikkoZ 0:a3f43eb92f86 232 // z-
MikkoZ 0:a3f43eb92f86 233 #define KX122_INS3_ZNWU (0x01 << 1)
MikkoZ 0:a3f43eb92f86 234 // z+
MikkoZ 0:a3f43eb92f86 235 #define KX122_INS3_ZPWU (0x01 << 0)
MikkoZ 0:a3f43eb92f86 236 // INT reports the combined (OR) interrupt information of all features.
MikkoZ 0:a3f43eb92f86 237 #define KX122_STATUS_REG_INT (0x01 << 4)
MikkoZ 0:a3f43eb92f86 238 // controls the operating mode of the KX122.
MikkoZ 0:a3f43eb92f86 239 #define KX122_CNTL1_PC1 (0x01 << 7)
MikkoZ 0:a3f43eb92f86 240 // determines the performance mode of the KX122. The noise varies with ODR, RES and different LP_CNTL settings possibly reducing the effective resolution.
MikkoZ 0:a3f43eb92f86 241 #define KX122_CNTL1_RES (0x01 << 6)
MikkoZ 0:a3f43eb92f86 242 // enables the reporting of the availability of new acceleration data as an interrupt
MikkoZ 0:a3f43eb92f86 243 #define KX122_CNTL1_DRDYE (0x01 << 5)
MikkoZ 0:a3f43eb92f86 244 // 2g range
MikkoZ 0:a3f43eb92f86 245 #define KX122_CNTL1_GSEL_2G (0x00 << 3)
MikkoZ 0:a3f43eb92f86 246 // 4g range
MikkoZ 0:a3f43eb92f86 247 #define KX122_CNTL1_GSEL_4G (0x01 << 3)
MikkoZ 0:a3f43eb92f86 248 // 8g range
MikkoZ 0:a3f43eb92f86 249 #define KX122_CNTL1_GSEL_8G (0x02 << 3)
MikkoZ 0:a3f43eb92f86 250 // not valid settings
MikkoZ 0:a3f43eb92f86 251 #define KX122_CNTL1_GSEL_NA (0x03 << 3)
MikkoZ 0:a3f43eb92f86 252 // enables the Directional Tap function that will detect single and double tap events.
MikkoZ 0:a3f43eb92f86 253 #define KX122_CNTL1_TDTE (0x01 << 2)
MikkoZ 0:a3f43eb92f86 254 // enables the Wake Up (motion detect) function
MikkoZ 0:a3f43eb92f86 255 #define KX122_CNTL1_WUFE (0x01 << 1)
MikkoZ 0:a3f43eb92f86 256 // enables the Tilt Position function that will detect changes in device orientation.
MikkoZ 0:a3f43eb92f86 257 #define KX122_CNTL1_TPE (0x01 << 0)
MikkoZ 0:a3f43eb92f86 258 // initiates software reset, which performs the RAM reboot routine
MikkoZ 0:a3f43eb92f86 259 #define KX122_CNTL2_SRST (0x01 << 7)
MikkoZ 0:a3f43eb92f86 260 // command test control
MikkoZ 0:a3f43eb92f86 261 #define KX122_CNTL2_COTC (0x01 << 6)
MikkoZ 0:a3f43eb92f86 262 // x-
MikkoZ 0:a3f43eb92f86 263 #define KX122_CNTL2_LEM (0x01 << 5)
MikkoZ 0:a3f43eb92f86 264 // x+
MikkoZ 0:a3f43eb92f86 265 #define KX122_CNTL2_RIM (0x01 << 4)
MikkoZ 0:a3f43eb92f86 266 // y-
MikkoZ 0:a3f43eb92f86 267 #define KX122_CNTL2_DOM (0x01 << 3)
MikkoZ 0:a3f43eb92f86 268 // y+
MikkoZ 0:a3f43eb92f86 269 #define KX122_CNTL2_UPM (0x01 << 2)
MikkoZ 0:a3f43eb92f86 270 // z-
MikkoZ 0:a3f43eb92f86 271 #define KX122_CNTL2_FDM (0x01 << 1)
MikkoZ 0:a3f43eb92f86 272 // z+
MikkoZ 0:a3f43eb92f86 273 #define KX122_CNTL2_FUM (0x01 << 0)
MikkoZ 0:a3f43eb92f86 274 // 1.5Hz
MikkoZ 0:a3f43eb92f86 275 #define KX122_CNTL3_OTP_1P563 (0x00 << 6)
MikkoZ 0:a3f43eb92f86 276 // 6.25Hz
MikkoZ 0:a3f43eb92f86 277 #define KX122_CNTL3_OTP_6P25 (0x01 << 6)
MikkoZ 0:a3f43eb92f86 278 // 12.5Hz
MikkoZ 0:a3f43eb92f86 279 #define KX122_CNTL3_OTP_12P5 (0x02 << 6)
MikkoZ 0:a3f43eb92f86 280 // 50Hz
MikkoZ 0:a3f43eb92f86 281 #define KX122_CNTL3_OTP_50 (0x03 << 6)
MikkoZ 0:a3f43eb92f86 282 // 50Hz
MikkoZ 0:a3f43eb92f86 283 #define KX122_CNTL3_OTDT_50 (0x00 << 3)
MikkoZ 0:a3f43eb92f86 284 // 100Hz
MikkoZ 0:a3f43eb92f86 285 #define KX122_CNTL3_OTDT_100 (0x01 << 3)
MikkoZ 0:a3f43eb92f86 286 // 200Hz
MikkoZ 0:a3f43eb92f86 287 #define KX122_CNTL3_OTDT_200 (0x02 << 3)
MikkoZ 0:a3f43eb92f86 288 // 400Hz
MikkoZ 0:a3f43eb92f86 289 #define KX122_CNTL3_OTDT_400 (0x03 << 3)
MikkoZ 0:a3f43eb92f86 290 // 12.5Hz
MikkoZ 0:a3f43eb92f86 291 #define KX122_CNTL3_OTDT_12P5 (0x04 << 3)
MikkoZ 0:a3f43eb92f86 292 // 25Hz
MikkoZ 0:a3f43eb92f86 293 #define KX122_CNTL3_OTDT_25 (0x05 << 3)
MikkoZ 0:a3f43eb92f86 294 // 800Hz
MikkoZ 0:a3f43eb92f86 295 #define KX122_CNTL3_OTDT_800 (0x06 << 3)
MikkoZ 0:a3f43eb92f86 296 // 1600Hz
MikkoZ 0:a3f43eb92f86 297 #define KX122_CNTL3_OTDT_1600 (0x07 << 3)
MikkoZ 0:a3f43eb92f86 298 // 0.78Hz
MikkoZ 0:a3f43eb92f86 299 #define KX122_CNTL3_OWUF_0P781 (0x00 << 0)
MikkoZ 0:a3f43eb92f86 300 // 1.563Hz
MikkoZ 0:a3f43eb92f86 301 #define KX122_CNTL3_OWUF_1P563 (0x01 << 0)
MikkoZ 0:a3f43eb92f86 302 // 3.125Hz
MikkoZ 0:a3f43eb92f86 303 #define KX122_CNTL3_OWUF_3P125 (0x02 << 0)
MikkoZ 0:a3f43eb92f86 304 // 6.25Hz
MikkoZ 0:a3f43eb92f86 305 #define KX122_CNTL3_OWUF_6P25 (0x03 << 0)
MikkoZ 0:a3f43eb92f86 306 // 12.5Hz
MikkoZ 0:a3f43eb92f86 307 #define KX122_CNTL3_OWUF_12P5 (0x04 << 0)
MikkoZ 0:a3f43eb92f86 308 // 25Hz
MikkoZ 0:a3f43eb92f86 309 #define KX122_CNTL3_OWUF_25 (0x05 << 0)
MikkoZ 0:a3f43eb92f86 310 // 50Hz
MikkoZ 0:a3f43eb92f86 311 #define KX122_CNTL3_OWUF_50 (0x06 << 0)
MikkoZ 0:a3f43eb92f86 312 // 100Hz
MikkoZ 0:a3f43eb92f86 313 #define KX122_CNTL3_OWUF_100 (0x07 << 0)
MikkoZ 0:a3f43eb92f86 314 // low-pass filter roll off control
MikkoZ 0:a3f43eb92f86 315 #define KX122_ODCNTL_IIR_BYPASS (0x01 << 7)
MikkoZ 0:a3f43eb92f86 316 // low pass filter enable
MikkoZ 0:a3f43eb92f86 317 #define KX122_ODCNTL_LPRO (0x01 << 6)
MikkoZ 0:a3f43eb92f86 318 // 12.5Hz
MikkoZ 0:a3f43eb92f86 319 #define KX122_ODCNTL_OSA_12P5 (0x00 << 0)
MikkoZ 0:a3f43eb92f86 320 // 25Hz
MikkoZ 0:a3f43eb92f86 321 #define KX122_ODCNTL_OSA_25 (0x01 << 0)
MikkoZ 0:a3f43eb92f86 322 // 50Hz
MikkoZ 0:a3f43eb92f86 323 #define KX122_ODCNTL_OSA_50 (0x02 << 0)
MikkoZ 0:a3f43eb92f86 324 // 100Hz
MikkoZ 0:a3f43eb92f86 325 #define KX122_ODCNTL_OSA_100 (0x03 << 0)
MikkoZ 0:a3f43eb92f86 326 // 200Hz
MikkoZ 0:a3f43eb92f86 327 #define KX122_ODCNTL_OSA_200 (0x04 << 0)
MikkoZ 0:a3f43eb92f86 328 // 400Hz
MikkoZ 0:a3f43eb92f86 329 #define KX122_ODCNTL_OSA_400 (0x05 << 0)
MikkoZ 0:a3f43eb92f86 330 // 800Hz
MikkoZ 0:a3f43eb92f86 331 #define KX122_ODCNTL_OSA_800 (0x06 << 0)
MikkoZ 0:a3f43eb92f86 332 // 1600Hz
MikkoZ 0:a3f43eb92f86 333 #define KX122_ODCNTL_OSA_1600 (0x07 << 0)
MikkoZ 0:a3f43eb92f86 334 // 0.78Hz
MikkoZ 0:a3f43eb92f86 335 #define KX122_ODCNTL_OSA_0P781 (0x08 << 0)
MikkoZ 0:a3f43eb92f86 336 // 1.563Hz
MikkoZ 0:a3f43eb92f86 337 #define KX122_ODCNTL_OSA_1P563 (0x09 << 0)
MikkoZ 0:a3f43eb92f86 338 // 3.125Hz
MikkoZ 0:a3f43eb92f86 339 #define KX122_ODCNTL_OSA_3P125 (0x0A << 0)
MikkoZ 0:a3f43eb92f86 340 // 6.25Hz
MikkoZ 0:a3f43eb92f86 341 #define KX122_ODCNTL_OSA_6P25 (0x0B << 0)
MikkoZ 0:a3f43eb92f86 342 // 3200Hz
MikkoZ 0:a3f43eb92f86 343 #define KX122_ODCNTL_OSA_3200 (0x0C << 0)
MikkoZ 0:a3f43eb92f86 344 // 6400Hz
MikkoZ 0:a3f43eb92f86 345 #define KX122_ODCNTL_OSA_6400 (0x0D << 0)
MikkoZ 0:a3f43eb92f86 346 // 12800Hz
MikkoZ 0:a3f43eb92f86 347 #define KX122_ODCNTL_OSA_12800 (0x0E << 0)
MikkoZ 0:a3f43eb92f86 348 // 25600Hz
MikkoZ 0:a3f43eb92f86 349 #define KX122_ODCNTL_OSA_25600 (0x0F << 0)
MikkoZ 0:a3f43eb92f86 350 // pulse 50us, 10us 1600ODR and over
MikkoZ 0:a3f43eb92f86 351 #define KX122_INC1_PWSEL1_50US_10US (0x00 << 6)
MikkoZ 0:a3f43eb92f86 352 // 1*OSA period
MikkoZ 0:a3f43eb92f86 353 #define KX122_INC1_PWSEL1_1XOSA (0x01 << 6)
MikkoZ 0:a3f43eb92f86 354 // 2*OSA period
MikkoZ 0:a3f43eb92f86 355 #define KX122_INC1_PWSEL1_2XOSA (0x02 << 6)
MikkoZ 0:a3f43eb92f86 356 // 4*OSA period
MikkoZ 0:a3f43eb92f86 357 #define KX122_INC1_PWSEL1_4XOSA (0x03 << 6)
MikkoZ 0:a3f43eb92f86 358 // enables/disables the physical interrupt
MikkoZ 0:a3f43eb92f86 359 #define KX122_INC1_IEN1 (0x01 << 5)
MikkoZ 0:a3f43eb92f86 360 // sets the polarity of the physical interrupt pin
MikkoZ 0:a3f43eb92f86 361 #define KX122_INC1_IEA1 (0x01 << 4)
MikkoZ 0:a3f43eb92f86 362 // sets the response of the physical interrupt pin
MikkoZ 0:a3f43eb92f86 363 #define KX122_INC1_IEL1 (0x01 << 3)
MikkoZ 0:a3f43eb92f86 364 // sets the polarity of Self Test
MikkoZ 0:a3f43eb92f86 365 #define KX122_INC1_STPOL (0x01 << 1)
MikkoZ 0:a3f43eb92f86 366 // sets the 3-wire SPI interface
MikkoZ 0:a3f43eb92f86 367 #define KX122_INC1_SPI3E (0x01 << 0)
MikkoZ 0:a3f43eb92f86 368 // OR combination between selected directions
MikkoZ 0:a3f43eb92f86 369 #define KX122_INC2_AOI_OR (0x00 << 6)
MikkoZ 0:a3f43eb92f86 370 // AND combination between selected axes
MikkoZ 0:a3f43eb92f86 371 #define KX122_INC2_AOI_AND (0x01 << 6)
MikkoZ 0:a3f43eb92f86 372 // x negative (x-): 0 = disabled, 1 = enabled
MikkoZ 0:a3f43eb92f86 373 #define KX122_INC2_XNWUE (0x01 << 5)
MikkoZ 0:a3f43eb92f86 374 // x positive (x+): 0 = disabled, 1 = enabled
MikkoZ 0:a3f43eb92f86 375 #define KX122_INC2_XPWUE (0x01 << 4)
MikkoZ 0:a3f43eb92f86 376 // y negative (y-): 0 = disabled, 1 = enabled
MikkoZ 0:a3f43eb92f86 377 #define KX122_INC2_YNWUE (0x01 << 3)
MikkoZ 0:a3f43eb92f86 378 // y positive (y+): 0 = disabled, 1 = enabled
MikkoZ 0:a3f43eb92f86 379 #define KX122_INC2_YPWUE (0x01 << 2)
MikkoZ 0:a3f43eb92f86 380 // z negative (z-): 0 = disabled, 1 = enabled
MikkoZ 0:a3f43eb92f86 381 #define KX122_INC2_ZNWUE (0x01 << 1)
MikkoZ 0:a3f43eb92f86 382 // z positive (z+): 0 = disabled, 1 = enabled
MikkoZ 0:a3f43eb92f86 383 #define KX122_INC2_ZPWUE (0x01 << 0)
MikkoZ 0:a3f43eb92f86 384 // x negative (x-): 0 = disabled, 1 = enabled
MikkoZ 0:a3f43eb92f86 385 #define KX122_INC3_TLEM (0x01 << 5)
MikkoZ 0:a3f43eb92f86 386 // x positive (x+): 0 = disabled, 1 = enabled
MikkoZ 0:a3f43eb92f86 387 #define KX122_INC3_TRIM (0x01 << 4)
MikkoZ 0:a3f43eb92f86 388 // y negative (y-): 0 = disabled, 1 = enabled
MikkoZ 0:a3f43eb92f86 389 #define KX122_INC3_TDOM (0x01 << 3)
MikkoZ 0:a3f43eb92f86 390 // y positive (y+): 0 = disabled, 1 = enabled
MikkoZ 0:a3f43eb92f86 391 #define KX122_INC3_TUPM (0x01 << 2)
MikkoZ 0:a3f43eb92f86 392 // z negative (z-): 0 = disabled, 1 = enabled
MikkoZ 0:a3f43eb92f86 393 #define KX122_INC3_TFDM (0x01 << 1)
MikkoZ 0:a3f43eb92f86 394 // z positive (z+): 0 = disabled, 1 = enabled
MikkoZ 0:a3f43eb92f86 395 #define KX122_INC3_TFUM (0x01 << 0)
MikkoZ 0:a3f43eb92f86 396 // Free fall interrupt reported on physical interrupt INT1
MikkoZ 0:a3f43eb92f86 397 #define KX122_INC4_FFI1 (0x01 << 7)
MikkoZ 0:a3f43eb92f86 398 // Buffer full interrupt reported on physical interrupt pin INT1
MikkoZ 0:a3f43eb92f86 399 #define KX122_INC4_BFI1 (0x01 << 6)
MikkoZ 0:a3f43eb92f86 400 // Watermark interrupt reported on physical interrupt pin INT1
MikkoZ 0:a3f43eb92f86 401 #define KX122_INC4_WMI1 (0x01 << 5)
MikkoZ 0:a3f43eb92f86 402 // Data ready interrupt reported on physical interrupt pin INT1
MikkoZ 0:a3f43eb92f86 403 #define KX122_INC4_DRDYI1 (0x01 << 4)
MikkoZ 0:a3f43eb92f86 404 // Tap/Double Tap interrupt reported on physical interrupt pin INT1
MikkoZ 0:a3f43eb92f86 405 #define KX122_INC4_TDTI1 (0x01 << 2)
MikkoZ 0:a3f43eb92f86 406 // Wake-Up (motion detect) interrupt reported on physical interrupt pin INT1
MikkoZ 0:a3f43eb92f86 407 #define KX122_INC4_WUFI1 (0x01 << 1)
MikkoZ 0:a3f43eb92f86 408 // Tilt position interrupt reported on physical interrupt pin INT1
MikkoZ 0:a3f43eb92f86 409 #define KX122_INC4_TPI1 (0x01 << 0)
MikkoZ 0:a3f43eb92f86 410 // pulse 50us, 10us 1600ODR and over
MikkoZ 0:a3f43eb92f86 411 #define KX122_INC5_PWSEL2_50US_10US (0x00 << 6)
MikkoZ 0:a3f43eb92f86 412 // 1*OSA period
MikkoZ 0:a3f43eb92f86 413 #define KX122_INC5_PWSEL2_1XOSA (0x01 << 6)
MikkoZ 0:a3f43eb92f86 414 // 2*OSA period
MikkoZ 0:a3f43eb92f86 415 #define KX122_INC5_PWSEL2_2XOSA (0x02 << 6)
MikkoZ 0:a3f43eb92f86 416 // 4*OSA period
MikkoZ 0:a3f43eb92f86 417 #define KX122_INC5_PWSEL2_4XOSA (0x03 << 6)
MikkoZ 0:a3f43eb92f86 418 // enables/disables the physical interrupt
MikkoZ 0:a3f43eb92f86 419 #define KX122_INC5_IEN2 (0x01 << 5)
MikkoZ 0:a3f43eb92f86 420 // sets the polarity of the physical interrupt pin
MikkoZ 0:a3f43eb92f86 421 #define KX122_INC5_IEA2 (0x01 << 4)
MikkoZ 0:a3f43eb92f86 422 // sets the response of the physical interrupt pin
MikkoZ 0:a3f43eb92f86 423 #define KX122_INC5_IEL2 (0x01 << 3)
MikkoZ 0:a3f43eb92f86 424 // Interrupt source automatic clear at interup 2 trailing edge
MikkoZ 0:a3f43eb92f86 425 #define KX122_INC5_ACLR2 (0x01 << 1)
MikkoZ 0:a3f43eb92f86 426 // Interrupt source automatic clear at interup 1 trailing edge
MikkoZ 0:a3f43eb92f86 427 #define KX122_INC5_ACLR1 (0x01 << 0)
MikkoZ 0:a3f43eb92f86 428 // FFI2 Free fall interrupt reported on physical interrupt INT2
MikkoZ 0:a3f43eb92f86 429 #define KX122_INC6_FFI2 (0x01 << 7)
MikkoZ 0:a3f43eb92f86 430 // BFI2 Buffer full interrupt reported on physical interrupt pin INT2
MikkoZ 0:a3f43eb92f86 431 #define KX122_INC6_BFI2 (0x01 << 6)
MikkoZ 0:a3f43eb92f86 432 // WMI2 - Watermark interrupt reported on physical interrupt pin INT2
MikkoZ 0:a3f43eb92f86 433 #define KX122_INC6_WMI2 (0x01 << 5)
MikkoZ 0:a3f43eb92f86 434 // DRDYI2 Data ready interrupt reported on physical interrupt pin INT2
MikkoZ 0:a3f43eb92f86 435 #define KX122_INC6_DRDYI2 (0x01 << 4)
MikkoZ 0:a3f43eb92f86 436 // TDTI2 - Tap/Double Tap interrupt reported on physical interrupt pin INT2
MikkoZ 0:a3f43eb92f86 437 #define KX122_INC6_TDTI2 (0x01 << 2)
MikkoZ 0:a3f43eb92f86 438 // WUFI2 Wake-Up (motion detect) interrupt reported on physical interrupt pin INT2
MikkoZ 0:a3f43eb92f86 439 #define KX122_INC6_WUFI2 (0x01 << 1)
MikkoZ 0:a3f43eb92f86 440 // TPI2 Tilt position interrupt reported on physical interrupt pin INT2
MikkoZ 0:a3f43eb92f86 441 #define KX122_INC6_TPI2 (0x01 << 0)
MikkoZ 0:a3f43eb92f86 442 // enables/disables the double tap interrupt
MikkoZ 0:a3f43eb92f86 443 #define KX122_TDTRC_DTRE (0x01 << 1)
MikkoZ 0:a3f43eb92f86 444 // enables/disables single tap interrupt
MikkoZ 0:a3f43eb92f86 445 #define KX122_TDTRC_STRE (0x01 << 0)
MikkoZ 0:a3f43eb92f86 446 // Free fall engine enable
MikkoZ 0:a3f43eb92f86 447 #define KX122_FFCNTL_FFIE (0x01 << 7)
MikkoZ 0:a3f43eb92f86 448 // Free fall interrupt latch/un-latch control
MikkoZ 0:a3f43eb92f86 449 #define KX122_FFCNTL_ULMODE (0x01 << 6)
MikkoZ 0:a3f43eb92f86 450 // Debounce methodology control
MikkoZ 0:a3f43eb92f86 451 #define KX122_FFCNTL_DCRM (0x01 << 3)
MikkoZ 0:a3f43eb92f86 452 // 12.5Hz
MikkoZ 0:a3f43eb92f86 453 #define KX122_FFCNTL_OFFI_12P5 (0x00 << 0)
MikkoZ 0:a3f43eb92f86 454 // 25Hz
MikkoZ 0:a3f43eb92f86 455 #define KX122_FFCNTL_OFFI_25 (0x01 << 0)
MikkoZ 0:a3f43eb92f86 456 // 50Hz
MikkoZ 0:a3f43eb92f86 457 #define KX122_FFCNTL_OFFI_50 (0x02 << 0)
MikkoZ 0:a3f43eb92f86 458 // 100Hz
MikkoZ 0:a3f43eb92f86 459 #define KX122_FFCNTL_OFFI_100 (0x03 << 0)
MikkoZ 0:a3f43eb92f86 460 // 200Hz
MikkoZ 0:a3f43eb92f86 461 #define KX122_FFCNTL_OFFI_200 (0x04 << 0)
MikkoZ 0:a3f43eb92f86 462 // 400Hz
MikkoZ 0:a3f43eb92f86 463 #define KX122_FFCNTL_OFFI_400 (0x05 << 0)
MikkoZ 0:a3f43eb92f86 464 // 800Hz
MikkoZ 0:a3f43eb92f86 465 #define KX122_FFCNTL_OFFI_800 (0x06 << 0)
MikkoZ 0:a3f43eb92f86 466 // 1600Hz
MikkoZ 0:a3f43eb92f86 467 #define KX122_FFCNTL_OFFI_1600 (0x07 << 0)
MikkoZ 0:a3f43eb92f86 468 // No Averaging
MikkoZ 0:a3f43eb92f86 469 #define KX122_LP_CNTL_AVC_NO_AVG (0x00 << 4)
MikkoZ 0:a3f43eb92f86 470 // 2 Samples Averaged
MikkoZ 0:a3f43eb92f86 471 #define KX122_LP_CNTL_AVC_2_SAMPLE_AVG (0x01 << 4)
MikkoZ 0:a3f43eb92f86 472 // 4 Samples Averaged
MikkoZ 0:a3f43eb92f86 473 #define KX122_LP_CNTL_AVC_4_SAMPLE_AVG (0x02 << 4)
MikkoZ 0:a3f43eb92f86 474 // 8 Samples Averaged
MikkoZ 0:a3f43eb92f86 475 #define KX122_LP_CNTL_AVC_8_SAMPLE_AVG (0x03 << 4)
MikkoZ 0:a3f43eb92f86 476 // 16 Samples Averaged (default)
MikkoZ 0:a3f43eb92f86 477 #define KX122_LP_CNTL_AVC_16_SAMPLE_AVG (0x04 << 4)
MikkoZ 0:a3f43eb92f86 478 // 32 Samples Averaged
MikkoZ 0:a3f43eb92f86 479 #define KX122_LP_CNTL_AVC_32_SAMPLE_AVG (0x05 << 4)
MikkoZ 0:a3f43eb92f86 480 // 64 Samples Averaged
MikkoZ 0:a3f43eb92f86 481 #define KX122_LP_CNTL_AVC_64_SAMPLE_AVG (0x06 << 4)
MikkoZ 0:a3f43eb92f86 482 // 128 Samples Averaged
MikkoZ 0:a3f43eb92f86 483 #define KX122_LP_CNTL_AVC_128_SAMPLE_AVG (0x07 << 4)
MikkoZ 0:a3f43eb92f86 484 #define KX122_BUF_CNTL1_SMP_TH0_7 (0xFF << 0)
MikkoZ 0:a3f43eb92f86 485 // controls activation of the sample buffer
MikkoZ 0:a3f43eb92f86 486 #define KX122_BUF_CNTL2_BUFE (0x01 << 7)
MikkoZ 0:a3f43eb92f86 487 // determines the resolution of the acceleration data samples collected by the sample
MikkoZ 0:a3f43eb92f86 488 #define KX122_BUF_CNTL2_BRES (0x01 << 6)
MikkoZ 0:a3f43eb92f86 489 // buffer full interrupt enable bit
MikkoZ 0:a3f43eb92f86 490 #define KX122_BUF_CNTL2_BFIE (0x01 << 5)
MikkoZ 0:a3f43eb92f86 491 // watermark level bits 8 and 9
MikkoZ 0:a3f43eb92f86 492 #define KX122_BUF_CNTL2_SMP_TH8_9 (0x0C << 2)
MikkoZ 0:a3f43eb92f86 493 // 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
MikkoZ 0:a3f43eb92f86 494 #define KX122_BUF_CNTL2_BUF_M_FIFO (0x00 << 0)
MikkoZ 0:a3f43eb92f86 495 // 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.
MikkoZ 0:a3f43eb92f86 496 #define KX122_BUF_CNTL2_BUF_M_STREAM (0x01 << 0)
MikkoZ 0:a3f43eb92f86 497 // 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.
MikkoZ 0:a3f43eb92f86 498 #define KX122_BUF_CNTL2_BUF_M_TRIGGER (0x02 << 0)
MikkoZ 0:a3f43eb92f86 499 // 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.
MikkoZ 0:a3f43eb92f86 500 #define KX122_BUF_CNTL2_BUF_M_FILO (0x03 << 0)
MikkoZ 0:a3f43eb92f86 501 #define KX122_BUF_STATUS_1_SMP_LEV0_7 (0xFF << 0)
MikkoZ 0:a3f43eb92f86 502 // reports the status of the buffers trigger function if this mode has been selected
MikkoZ 0:a3f43eb92f86 503 #define KX122_BUF_STATUS_2_BUF_TRIG (0x01 << 7)
MikkoZ 0:a3f43eb92f86 504 // level High mask
MikkoZ 0:a3f43eb92f86 505 #define KX122_BUF_STATUS_2_SMP_LEV8_10 (0x07 << 0)
MikkoZ 0:a3f43eb92f86 506 // MEMS Test OFF
MikkoZ 0:a3f43eb92f86 507 #define KX122_SELF_TEST_MEMS_TEST_OFF (0x00 << 0)
MikkoZ 0:a3f43eb92f86 508 // MEMS Test ON
MikkoZ 0:a3f43eb92f86 509 #define KX122_SELF_TEST_MEMS_TEST_ON (0xCA << 0)
MikkoZ 0:a3f43eb92f86 510 /*registers bit masks */
MikkoZ 0:a3f43eb92f86 511
MikkoZ 0:a3f43eb92f86 512 #define KX122_COTR_DCSTR_MASK 0xFF
MikkoZ 0:a3f43eb92f86 513
MikkoZ 0:a3f43eb92f86 514 #define KX122_WHO_AM_I_WIA_MASK 0xFF
MikkoZ 0:a3f43eb92f86 515 // status of tap/double tap, bit is released when interrupt release register INT_REL is read.
MikkoZ 0:a3f43eb92f86 516 #define KX122_INS2_TDTS_MASK 0x0C
MikkoZ 0:a3f43eb92f86 517 // selects the acceleration range of the accelerometer outputs
MikkoZ 0:a3f43eb92f86 518 #define KX122_CNTL1_GSEL_MASK 0x18
MikkoZ 0:a3f43eb92f86 519 // sets the output data rate for the Tilt Position function
MikkoZ 0:a3f43eb92f86 520 #define KX122_CNTL3_OTP_MASK 0xC0
MikkoZ 0:a3f43eb92f86 521 // sets the output data rate for the Directional TapTM function
MikkoZ 0:a3f43eb92f86 522 #define KX122_CNTL3_OTDT_MASK 0x38
MikkoZ 0:a3f43eb92f86 523 // sets the output data rate for the general motion detection function and the high-pass filtered outputs
MikkoZ 0:a3f43eb92f86 524 #define KX122_CNTL3_OWUF_MASK 0x07
MikkoZ 0:a3f43eb92f86 525 // acceleration output data rate.
MikkoZ 0:a3f43eb92f86 526 #define KX122_ODCNTL_OSA_MASK 0x0F
MikkoZ 0:a3f43eb92f86 527 // Pulse interrupt 1 width configuration
MikkoZ 0:a3f43eb92f86 528 #define KX122_INC1_PWSEL1_MASK 0xC0
MikkoZ 0:a3f43eb92f86 529 // AND OR configuration for motion detection
MikkoZ 0:a3f43eb92f86 530 #define KX122_INC2_AOI_MASK 0x40
MikkoZ 0:a3f43eb92f86 531 #define KX122_INC2_WUE_MASK 0x3F
MikkoZ 0:a3f43eb92f86 532 #define KX122_INC3_TM_MASK 0x3F
MikkoZ 0:a3f43eb92f86 533 // Pulse interrupt 2 width configuration
MikkoZ 0:a3f43eb92f86 534 #define KX122_INC5_PWSEL2_MASK 0xC0
MikkoZ 0:a3f43eb92f86 535 // Output Data Rate at which the Free fall engine performs its function.
MikkoZ 0:a3f43eb92f86 536 #define KX122_FFCNTL_OFFI_MASK 0x07
MikkoZ 0:a3f43eb92f86 537 #define KX122_HYST_SET_HYST_MASK 0x3F
MikkoZ 0:a3f43eb92f86 538 // Averaging Filter Control
MikkoZ 0:a3f43eb92f86 539 #define KX122_LP_CNTL_AVC_MASK 0x70
MikkoZ 0:a3f43eb92f86 540
MikkoZ 0:a3f43eb92f86 541 #define KX122_BUF_CNTL1_SMP_TH0_MASK 0xFF
MikkoZ 0:a3f43eb92f86 542 #define KX122_BUF_CNTL1_SMP_TH0_7_MASK 0xFF
MikkoZ 0:a3f43eb92f86 543
MikkoZ 0:a3f43eb92f86 544 #define KX122_BUF_CNTL2_SMP_TH8_MASK 0x0C
MikkoZ 0:a3f43eb92f86 545 #define KX122_BUF_CNTL2_SMP_TH8_9_MASK 0x0C
MikkoZ 0:a3f43eb92f86 546 // selects the operating mode of the sample buffer
MikkoZ 0:a3f43eb92f86 547 #define KX122_BUF_CNTL2_BUF_M_MASK 0x03
MikkoZ 0:a3f43eb92f86 548
MikkoZ 0:a3f43eb92f86 549 #define KX122_BUF_STATUS_1_SMP_LEV0_MASK 0xFF
MikkoZ 0:a3f43eb92f86 550 #define KX122_BUF_STATUS_1_SMP_LEV0_7_MASK 0xFF
MikkoZ 0:a3f43eb92f86 551
MikkoZ 0:a3f43eb92f86 552 #define KX122_BUF_STATUS_2_SMP_LEV8_MASK 0x07
MikkoZ 0:a3f43eb92f86 553 #define KX122_BUF_STATUS_2_SMP_LEV8_10_MASK 0x07
MikkoZ 0:a3f43eb92f86 554
MikkoZ 0:a3f43eb92f86 555 #define KX122_SELF_TEST_MEMS_TEST_MASK 0xFF
MikkoZ 0:a3f43eb92f86 556
MikkoZ 0:a3f43eb92f86 557 #endif