![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-or-later */ 0002 /* 0003 * include/linux/input/adxl34x.h 0004 * 0005 * Digital Accelerometer characteristics are highly application specific 0006 * and may vary between boards and models. The platform_data for the 0007 * device's "struct device" holds this information. 0008 * 0009 * Copyright 2009 Analog Devices Inc. 0010 */ 0011 0012 #ifndef __LINUX_INPUT_ADXL34X_H__ 0013 #define __LINUX_INPUT_ADXL34X_H__ 0014 0015 #include <linux/input.h> 0016 0017 struct adxl34x_platform_data { 0018 0019 /* 0020 * X,Y,Z Axis Offset: 0021 * offer user offset adjustments in twoscompliment 0022 * form with a scale factor of 15.6 mg/LSB (i.e. 0x7F = +2 g) 0023 */ 0024 0025 s8 x_axis_offset; 0026 s8 y_axis_offset; 0027 s8 z_axis_offset; 0028 0029 /* 0030 * TAP_X/Y/Z Enable: Setting TAP_X, Y, or Z Enable enables X, 0031 * Y, or Z participation in Tap detection. A '0' excludes the 0032 * selected axis from participation in Tap detection. 0033 * Setting the SUPPRESS bit suppresses Double Tap detection if 0034 * acceleration greater than tap_threshold is present during the 0035 * tap_latency period, i.e. after the first tap but before the 0036 * opening of the second tap window. 0037 */ 0038 0039 #define ADXL_SUPPRESS (1 << 3) 0040 #define ADXL_TAP_X_EN (1 << 2) 0041 #define ADXL_TAP_Y_EN (1 << 1) 0042 #define ADXL_TAP_Z_EN (1 << 0) 0043 0044 u8 tap_axis_control; 0045 0046 /* 0047 * tap_threshold: 0048 * holds the threshold value for tap detection/interrupts. 0049 * The data format is unsigned. The scale factor is 62.5 mg/LSB 0050 * (i.e. 0xFF = +16 g). A zero value may result in undesirable 0051 * behavior if Tap/Double Tap is enabled. 0052 */ 0053 0054 u8 tap_threshold; 0055 0056 /* 0057 * tap_duration: 0058 * is an unsigned time value representing the maximum 0059 * time that an event must be above the tap_threshold threshold 0060 * to qualify as a tap event. The scale factor is 625 us/LSB. A zero 0061 * value will prevent Tap/Double Tap functions from working. 0062 */ 0063 0064 u8 tap_duration; 0065 0066 /* 0067 * tap_latency: 0068 * is an unsigned time value representing the wait time 0069 * from the detection of a tap event to the opening of the time 0070 * window tap_window for a possible second tap event. The scale 0071 * factor is 1.25 ms/LSB. A zero value will disable the Double Tap 0072 * function. 0073 */ 0074 0075 u8 tap_latency; 0076 0077 /* 0078 * tap_window: 0079 * is an unsigned time value representing the amount 0080 * of time after the expiration of tap_latency during which a second 0081 * tap can begin. The scale factor is 1.25 ms/LSB. A zero value will 0082 * disable the Double Tap function. 0083 */ 0084 0085 u8 tap_window; 0086 0087 /* 0088 * act_axis_control: 0089 * X/Y/Z Enable: A '1' enables X, Y, or Z participation in activity 0090 * or inactivity detection. A '0' excludes the selected axis from 0091 * participation. If all of the axes are excluded, the function is 0092 * disabled. 0093 * AC/DC: A '0' = DC coupled operation and a '1' = AC coupled 0094 * operation. In DC coupled operation, the current acceleration is 0095 * compared with activity_threshold and inactivity_threshold directly 0096 * to determine whether activity or inactivity is detected. In AC 0097 * coupled operation for activity detection, the acceleration value 0098 * at the start of activity detection is taken as a reference value. 0099 * New samples of acceleration are then compared to this 0100 * reference value and if the magnitude of the difference exceeds 0101 * activity_threshold the device will trigger an activity interrupt. In 0102 * AC coupled operation for inactivity detection, a reference value 0103 * is used again for comparison and is updated whenever the 0104 * device exceeds the inactivity threshold. Once the reference 0105 * value is selected, the device compares the magnitude of the 0106 * difference between the reference value and the current 0107 * acceleration with inactivity_threshold. If the difference is below 0108 * inactivity_threshold for a total of inactivity_time, the device is 0109 * considered inactive and the inactivity interrupt is triggered. 0110 */ 0111 0112 #define ADXL_ACT_ACDC (1 << 7) 0113 #define ADXL_ACT_X_EN (1 << 6) 0114 #define ADXL_ACT_Y_EN (1 << 5) 0115 #define ADXL_ACT_Z_EN (1 << 4) 0116 #define ADXL_INACT_ACDC (1 << 3) 0117 #define ADXL_INACT_X_EN (1 << 2) 0118 #define ADXL_INACT_Y_EN (1 << 1) 0119 #define ADXL_INACT_Z_EN (1 << 0) 0120 0121 u8 act_axis_control; 0122 0123 /* 0124 * activity_threshold: 0125 * holds the threshold value for activity detection. 0126 * The data format is unsigned. The scale factor is 0127 * 62.5 mg/LSB. A zero value may result in undesirable behavior if 0128 * Activity interrupt is enabled. 0129 */ 0130 0131 u8 activity_threshold; 0132 0133 /* 0134 * inactivity_threshold: 0135 * holds the threshold value for inactivity 0136 * detection. The data format is unsigned. The scale 0137 * factor is 62.5 mg/LSB. A zero value may result in undesirable 0138 * behavior if Inactivity interrupt is enabled. 0139 */ 0140 0141 u8 inactivity_threshold; 0142 0143 /* 0144 * inactivity_time: 0145 * is an unsigned time value representing the 0146 * amount of time that acceleration must be below the value in 0147 * inactivity_threshold for inactivity to be declared. The scale factor 0148 * is 1 second/LSB. Unlike the other interrupt functions, which 0149 * operate on unfiltered data, the inactivity function operates on the 0150 * filtered output data. At least one output sample must be 0151 * generated for the inactivity interrupt to be triggered. This will 0152 * result in the function appearing un-responsive if the 0153 * inactivity_time register is set with a value less than the time 0154 * constant of the Output Data Rate. A zero value will result in an 0155 * interrupt when the output data is below inactivity_threshold. 0156 */ 0157 0158 u8 inactivity_time; 0159 0160 /* 0161 * free_fall_threshold: 0162 * holds the threshold value for Free-Fall detection. 0163 * The data format is unsigned. The root-sum-square(RSS) value 0164 * of all axes is calculated and compared to the value in 0165 * free_fall_threshold to determine if a free fall event may be 0166 * occurring. The scale factor is 62.5 mg/LSB. A zero value may 0167 * result in undesirable behavior if Free-Fall interrupt is 0168 * enabled. Values between 300 and 600 mg (0x05 to 0x09) are 0169 * recommended. 0170 */ 0171 0172 u8 free_fall_threshold; 0173 0174 /* 0175 * free_fall_time: 0176 * is an unsigned time value representing the minimum 0177 * time that the RSS value of all axes must be less than 0178 * free_fall_threshold to generate a Free-Fall interrupt. The 0179 * scale factor is 5 ms/LSB. A zero value may result in 0180 * undesirable behavior if Free-Fall interrupt is enabled. 0181 * Values between 100 to 350 ms (0x14 to 0x46) are recommended. 0182 */ 0183 0184 u8 free_fall_time; 0185 0186 /* 0187 * data_rate: 0188 * Selects device bandwidth and output data rate. 0189 * RATE = 3200 Hz / (2^(15 - x)). Default value is 0x0A, or 100 Hz 0190 * Output Data Rate. An Output Data Rate should be selected that 0191 * is appropriate for the communication protocol and frequency 0192 * selected. Selecting too high of an Output Data Rate with a low 0193 * communication speed will result in samples being discarded. 0194 */ 0195 0196 u8 data_rate; 0197 0198 /* 0199 * data_range: 0200 * FULL_RES: When this bit is set with the device is 0201 * in Full-Resolution Mode, where the output resolution increases 0202 * with RANGE to maintain a 4 mg/LSB scale factor. When this 0203 * bit is cleared the device is in 10-bit Mode and RANGE determine the 0204 * maximum g-Range and scale factor. 0205 */ 0206 0207 #define ADXL_FULL_RES (1 << 3) 0208 #define ADXL_RANGE_PM_2g 0 0209 #define ADXL_RANGE_PM_4g 1 0210 #define ADXL_RANGE_PM_8g 2 0211 #define ADXL_RANGE_PM_16g 3 0212 0213 u8 data_range; 0214 0215 /* 0216 * low_power_mode: 0217 * A '0' = Normal operation and a '1' = Reduced 0218 * power operation with somewhat higher noise. 0219 */ 0220 0221 u8 low_power_mode; 0222 0223 /* 0224 * power_mode: 0225 * LINK: A '1' with both the activity and inactivity functions 0226 * enabled will delay the start of the activity function until 0227 * inactivity is detected. Once activity is detected, inactivity 0228 * detection will begin and prevent the detection of activity. This 0229 * bit serially links the activity and inactivity functions. When '0' 0230 * the inactivity and activity functions are concurrent. Additional 0231 * information can be found in the ADXL34x datasheet's Application 0232 * section under Link Mode. 0233 * AUTO_SLEEP: A '1' sets the ADXL34x to switch to Sleep Mode 0234 * when inactivity (acceleration has been below inactivity_threshold 0235 * for at least inactivity_time) is detected and the LINK bit is set. 0236 * A '0' disables automatic switching to Sleep Mode. See the 0237 * Sleep Bit section of the ADXL34x datasheet for more information. 0238 */ 0239 0240 #define ADXL_LINK (1 << 5) 0241 #define ADXL_AUTO_SLEEP (1 << 4) 0242 0243 u8 power_mode; 0244 0245 /* 0246 * fifo_mode: 0247 * BYPASS The FIFO is bypassed 0248 * FIFO FIFO collects up to 32 values then stops collecting data 0249 * STREAM FIFO holds the last 32 data values. Once full, the FIFO's 0250 * oldest data is lost as it is replaced with newer data 0251 * 0252 * DEFAULT should be ADXL_FIFO_STREAM 0253 */ 0254 0255 #define ADXL_FIFO_BYPASS 0 0256 #define ADXL_FIFO_FIFO 1 0257 #define ADXL_FIFO_STREAM 2 0258 0259 u8 fifo_mode; 0260 0261 /* 0262 * watermark: 0263 * The Watermark feature can be used to reduce the interrupt load 0264 * of the system. The FIFO fills up to the value stored in watermark 0265 * [1..32] and then generates an interrupt. 0266 * A '0' disables the watermark feature. 0267 */ 0268 0269 u8 watermark; 0270 0271 /* 0272 * When acceleration measurements are received from the ADXL34x 0273 * events are sent to the event subsystem. The following settings 0274 * select the event type and event code for new x, y and z axis data 0275 * respectively. 0276 */ 0277 u32 ev_type; /* EV_ABS or EV_REL */ 0278 0279 u32 ev_code_x; /* ABS_X,Y,Z or REL_X,Y,Z */ 0280 u32 ev_code_y; /* ABS_X,Y,Z or REL_X,Y,Z */ 0281 u32 ev_code_z; /* ABS_X,Y,Z or REL_X,Y,Z */ 0282 0283 /* 0284 * A valid BTN or KEY Code; use tap_axis_control to disable 0285 * event reporting 0286 */ 0287 0288 u32 ev_code_tap[3]; /* EV_KEY {X-Axis, Y-Axis, Z-Axis} */ 0289 0290 /* 0291 * A valid BTN or KEY Code for Free-Fall or Activity enables 0292 * input event reporting. A '0' disables the Free-Fall or 0293 * Activity reporting. 0294 */ 0295 0296 u32 ev_code_ff; /* EV_KEY */ 0297 u32 ev_code_act_inactivity; /* EV_KEY */ 0298 0299 /* 0300 * Use ADXL34x INT2 pin instead of INT1 pin for interrupt output 0301 */ 0302 u8 use_int2; 0303 0304 /* 0305 * ADXL346 only ORIENTATION SENSING feature 0306 * The orientation function of the ADXL346 reports both 2-D and 0307 * 3-D orientation concurrently. 0308 */ 0309 0310 #define ADXL_EN_ORIENTATION_2D 1 0311 #define ADXL_EN_ORIENTATION_3D 2 0312 #define ADXL_EN_ORIENTATION_2D_3D 3 0313 0314 u8 orientation_enable; 0315 0316 /* 0317 * The width of the deadzone region between two or more 0318 * orientation positions is determined by setting the Deadzone 0319 * value. The deadzone region size can be specified with a 0320 * resolution of 3.6deg. The deadzone angle represents the total 0321 * angle where the orientation is considered invalid. 0322 */ 0323 0324 #define ADXL_DEADZONE_ANGLE_0p0 0 /* !!!0.0 [deg] */ 0325 #define ADXL_DEADZONE_ANGLE_3p6 1 /* 3.6 [deg] */ 0326 #define ADXL_DEADZONE_ANGLE_7p2 2 /* 7.2 [deg] */ 0327 #define ADXL_DEADZONE_ANGLE_10p8 3 /* 10.8 [deg] */ 0328 #define ADXL_DEADZONE_ANGLE_14p4 4 /* 14.4 [deg] */ 0329 #define ADXL_DEADZONE_ANGLE_18p0 5 /* 18.0 [deg] */ 0330 #define ADXL_DEADZONE_ANGLE_21p6 6 /* 21.6 [deg] */ 0331 #define ADXL_DEADZONE_ANGLE_25p2 7 /* 25.2 [deg] */ 0332 0333 u8 deadzone_angle; 0334 0335 /* 0336 * To eliminate most human motion such as walking or shaking, 0337 * a Divisor value should be selected to effectively limit the 0338 * orientation bandwidth. Set the depth of the filter used to 0339 * low-pass filter the measured acceleration for stable 0340 * orientation sensing 0341 */ 0342 0343 #define ADXL_LP_FILTER_DIVISOR_2 0 0344 #define ADXL_LP_FILTER_DIVISOR_4 1 0345 #define ADXL_LP_FILTER_DIVISOR_8 2 0346 #define ADXL_LP_FILTER_DIVISOR_16 3 0347 #define ADXL_LP_FILTER_DIVISOR_32 4 0348 #define ADXL_LP_FILTER_DIVISOR_64 5 0349 #define ADXL_LP_FILTER_DIVISOR_128 6 0350 #define ADXL_LP_FILTER_DIVISOR_256 7 0351 0352 u8 divisor_length; 0353 0354 u32 ev_codes_orient_2d[4]; /* EV_KEY {+X, -X, +Y, -Y} */ 0355 u32 ev_codes_orient_3d[6]; /* EV_KEY {+Z, +Y, +X, -X, -Y, -Z} */ 0356 }; 0357 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |