资料介绍
Table of Contents
ADXL362 Input 3-Axis Digital Accelerometer Linux Driver
Supported Devices
Reference Circuits
Evaluation Boards
ADXL362: Micropower 3-Axis MEMS Accelerometer: Digital Output, ±2/±4/±8 g Range
Source Code
Status
Source | Mainlined? |
---|---|
git | In Progress |
Files
Function | File |
---|---|
driver | drivers/input/misc/adxl362.c |
include | include/linux/input/adxl362.h |
Example platform device initialization
For compile time configuration, it’s common Linux practice to keep board- and application-specific configuration out of the main driver file, instead putting it into the board support file.
For devices on custom boards, as typical of embedded and SoC-(system-on-chip) based hardware, Linux uses platform_data to point to board-specific structures describing devices and how they are connected to the SoC. This can include available ports, chip variants, preferred modes, default initialization, additional pin roles, and so on. This shrinks the board-support packages (BSPs) and minimizes board and application specific #ifdefs in drivers.
Digital Accelerometer characteristics are application specific and may vary between boards and models. The platform_data for the device's “struct device” holds this information.
enum adxl_odr { ADXL_ODR_12_5HZ = 13, ADXL_ODR_25HZ = 25, ADXL_ODR_50HZ = 50, ADXL_ODR_100HZ = 100, ADXL_ODR_200HZ = 200, ADXL_ODR_400HZ = 400, }; enum adxl_g_range { ADXL_RANGE_PM_2g = 2, ADXL_RANGE_PM_4g = 4, ADXL_RANGE_PM_8g = 8, }; enum adxl_power_mode { ADXL_NORM_OPERATION = 0, ADXL_LOW_NOISE_MODE = 1, ADXL_ULTRA_LOW_NOISE_MODE = 2, }; struct adxl362_platform_data { /* * data_range: * Measurement range selection +/- 2,4,8 g */ enum adxl_g_range data_range; /* * low_power_mode: * Power versus noise tradeoff. */ enum adxl_power_mode low_power_mode; /* * data_rate: * Selects the output data rate (ODR). */ enum adxl_odr data_rate; /* * half_bw: * Sets the anti-aliasing filter to 1/4 of the output data rate (ODR) */ bool half_bw; /* * watermark_odr: * The Watermark feature can be used to reduce the interrupt/poll load * of the system. The FIFO fills up to watermark value in sample sets * [1..170] and then generates an interrupt. Each ODR can have it's * own watermark. */ u8 watermark_odr_12Hz; u8 watermark_odr_25Hz; u8 watermark_odr_50Hz; u8 watermark_odr_100Hz; u8 watermark_odr_200Hz; u8 watermark_odr_400Hz; /* * When acceleration measurements are received from the ADXL362 * events are sent to the input event subsystem. The following settings * select the event code for ABS x, y and z axis data * respectively. The event codes can also be negated to further account * for sensor orientation. */ s32 ev_code_x; /* (+/-)ABS_X,Y,Z */ s32 ev_code_y; /* (+/-)ABS_X,Y,Z */ s32 ev_code_z; /* (+/-)ABS_X,Y,Z */ s32 abs_fuzz; /* input fuzz val */ /* * [in]activity_threshold: * holds the threshold value for activity detection. * The data format is unsigned. The scale factor is * 1mg/LSB. */ u16 activity_threshold; u16 inactivity_threshold; /* * [in]activity_time: * is an unsigned time value representing the * amount of time that acceleration must be [below]/above the value in * [in]activity_threshold for [in]activity to be declared. * The scale factor is 1ms/LSB. */ u32 inactivity_time; u32 activity_time; /* * referenced_[in]activity_en: * Sets [in]activity detection to operate in referenced mode opposed to * absolute mode. */ bool referenced_activity_en; bool referenced_inactivity_en; /* * Use ADXL362 INT2 pin instead of INT1 pin for interrupt output */ bool use_int2; /* * Optional IRQ flags */ unsigned irqflags; };
static struct adxl362_platform_data adxl362_info = { .data_rate = ADXL_ODR_100HZ, /* 100Hz */ .data_range = ADXL_RANGE_PM_2g, /* +/- 2000mg */ .activity_threshold = 70, /* 70mg (referenced) */ .inactivity_threshold = 30, /* 30mg (referenced) */ .inactivity_time = 10000, /* 10s */ .activity_time = 1, /* 1ms */ .referenced_activity_en = true, /* cancel static accel. of gravity */ .referenced_inactivity_en = true, /* cancel static accel. of gravity */ .watermark_odr_12Hz = 1, .watermark_odr_25Hz = 1, .watermark_odr_50Hz = 1, .watermark_odr_100Hz = 1, .watermark_odr_200Hz = 2, /* limit irq/poll interval to 10ms */ .watermark_odr_400Hz = 4, /* limit irq/poll interval to 10ms */ .ev_code_x = ABS_X, /* default mapping */ .ev_code_y = ABS_Y, .ev_code_z = ABS_Z, };
Declaring SPI slave devices
Unlike PCI or USB devices, SPI devices are not enumerated at the hardware level. Instead, the software must know which devices are connected on each SPI bus segment, and what slave selects these devices are using. For this reason, the kernel code must instantiate SPI devices explicitly. The most common method is to declare the SPI devices by bus number.
This method is appropriate when the SPI bus is a system bus, as in many embedded systems, wherein each SPI bus has a number which is known in advance. It is thus possible to pre-declare the SPI devices that inhabit this bus. This is done with an array of struct spi_board_info, which is registered by calling spi_register_board_info().
For more information see: Documentation/spi/spi-summary
Depending on the DDS IC used, you may need to set the modalias accordingly, matching your part name. It may also required to adjust max_speed_hz. Please consult the datasheet, for maximum spi clock supported by the device in question.
static struct spi_board_info board_spi_board_info[] __initdata = { #if defined(CONFIG_INPUT_ADXL362) || defined(CONFIG_INPUT_ADXL362_MODULE) { .modalias = "adxl362", .platform_data = &adxl362_info, .irq = IRQ_PF6, .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */ .bus_num = 0, .chip_select = 1, .mode = SPI_MODE_0, }, #endif };
static int __init board_init(void) { [--snip--] spi_register_board_info(board_spi_board_info, ARRAY_SIZE(board_spi_board_info)); [--snip--] return 0; } arch_initcall(board_init);
Adding Linux driver support
Configure kernel with “make menuconfig” (alternatively use “make xconfig” or “make qconfig”)
The ADXL34x Driver depends on CONFIG_SPI
Input device support -*- Generic input layer (needed for keyboard, mouse, ...) < > Support for memoryless force-feedback devices < > Polled input device skeleton < > Sparse keymap support library * Userland interfaces * < > Mouse interface < > Joystick interface <*> Event interface < > Event debugging * Input Device Drivers * [ ] Keyboards ---> [ ] Mice ---> [ ] Joysticks/Gamepads ---> [ ] Tablets ---> [ ] Touchscreens ---> [*] Miscellaneous devices ---> --- Miscellaneous devices < > Analog Devices AD714x Capacitance Touch Sensor < > BMA150/SMB380 acceleration sensor support < > MMA8450 - Freescale's 3-Axis, 8/12-bit Digital Accelerometer < > MPU3050 Triaxial gyroscope sensor < > Sharp GP2AP002A00F I2C Proximity/Opto sensor driver < > Polled GPIO tilt switch < > Kionix KXTJ9 tri-axis digital accelerometer < > User level driver support < > PCF8574 Keypad input device < > Rotary encoders connected to GPIO pins < > Analog Devices ADXL34x Three-Axis Digital Accelerometer <*> Analog Devices ADXL362 Three-Axis Digital Accelerometer < > VTI CMA3000 Tri-axis accelerometer Hardware I/O ports --->
Hardware configuration
Driver testing
Driver compiled as a module
root:~> modprobe evdev root:~> modprobe adxl362 input: ADXL362 accelerometer as /devices/platform/bfin-spi.0/spi_master/spi0/spi0.1/input/input0
Driver compiled into the kernel
Your kernel startup messages should include something like this
input: ADXL362 accelerometer as /devices/platform/bfin-spi.0/spi_master/spi0/spi0.1/input/input0
Common Problems
In case you see a message like this
adxl362 spi0.1: Failed to probe (0x00:0x00)
This means that the SPI communication and initilaization with the ADXL362 failed. check bus_num and chip_select in your platform device file
Checking for proper installation
After the kernel boot your device folder should include at least one device node for the accelerometer
root:/> ls -al /dev/input/ drw-r--r-- 2 root root 0 Jan 1 00:03 . drwxr-xr-x 5 root root 0 Jan 1 00:03 .. crw-rw-r-- 1 root root 13, 64 Jan 1 00:03 event0 root:/>
root:~> cat /sys/class/input/input0/name ADXL362 accelerometer
Use the event_test utility to test proper function
root:/> event_test /dev/input/event0 Input driver version is 1.0.1 Input device ID: bus 0x1c vendor 0xad product 0xf2 version 0x1 Input device name: "ADXL362 accelerometer" Supported events: Event type 0 (Sync) Event type 3 (Absolute) Event code 0 (X) Value -144 Min -2000 Max 2000 Event code 1 (Y) Value -256 Min -2000 Max 2000 Event code 2 (Z) Value 398 Min -2000 Max 2000 Testing ... (interrupt to exit) Event: time 43.641571, -------------- Report Sync ------------ Event: time 43.641582, type 3 (Absolute), code 0 (X), value 192 Event: time 43.641588, type 3 (Absolute), code 1 (Y), value 7 Event: time 43.641593, type 3 (Absolute), code 2 (Z), value 291 Event: time 43.641597, -------------- Report Sync ------------ Event: time 43.656442, type 3 (Absolute), code 0 (X), value 211 Event: time 43.656451, type 3 (Absolute), code 1 (Y), value 12 Event: time 43.656456, type 3 (Absolute), code 2 (Z), value 295 Event: time 43.656461, -------------- Report Sync ------------ Event: time 43.656476, type 3 (Absolute), code 1 (Y), value 15 Event: time 43.656481, type 3 (Absolute), code 2 (Z), value 280 Event: time 43.656486, -------------- Report Sync ------------
In case you move the accelerometer and don't receive events, it's likely that something with your Interrupt is wrong.
check irq number in your platform device file
In case you get a message like: evtest: No such device
, it's likely that you have not install the necessary modules
ADXL34x Sysfs runtime controls
root:/> cd sys/class/input/input0/device/ root:/sys/devices/platform/bfin-spi.0/spi_master/spi0/spi0.1> ls -al drwxr-xr-x 4 root root 0 Jan 1 01:40 . drwxr-xr-x 4 root root 0 Jan 1 01:40 .. -rw-rw-r-- 1 root root 4096 Jan 1 01:50 autosleep lrwxrwxrwx 1 root root 0 Jan 1 01:50 driver -> ../../../../../../bus/spi/drivers/adxl362 drwxr-xr-x 3 root root 0 Jan 1 01:40 input -r--r--r-- 1 root root 4096 Jan 1 01:50 modalias drwxr-xr-x 2 root root 0 Jan 1 01:50 power -rw-rw-r-- 1 root root 4096 Jan 1 01:50 rate lrwxrwxrwx 1 root root 0 Jan 1 01:50 subsystem -> ../../../../../../bus/spi -rw-r--r-- 1 root root 4096 Jan 1 01:50 uevent
Controlling the Output Data Rate
Output Data Rate (Hz) | Bandwidth (Hz) |
---|---|
400 | 200 |
200 | 100 |
100 | 50 |
50 | 25 |
25 | 12.5 |
12.5 | 6.25 |
Writing 'Output Data Rate' into rate sets the desired sample rate
Reading rate returns the current Output Data Rate
See table above for supported sample rates
root:/sys/devices/platform/bfin-spi.0/spi_master/spi0/spi0.1> echo 400 > rate root:/sys/devices/platform/bfin-spi.0/spi_master/spi0/spi0.1> cat rate 400
Enabling / Disabling Autosleep Upon Inactivity
Writing '1' into autosleep - enables Autosleep Upon Inactivity
Writing '0' into autosleep - disables Autosleep Upon Inactivity
root:/sys/devices/platform/bfin-spi.0/spi_master/spi0/spi0.1> echo 1 > autosleep root:/sys/devices/platform/bfin-spi.0/spi_master/spi0/spi0.1> echo 0 > autosleep
More Information
ADXL362/6 Android Acceleration Sensor
Using this driver under Android as Acceleration Sensor Follow the link here ADXL362 Android Sensor
- EVADXL362Z ADXL362 分线板
- 低噪声低功耗3轴MEMS加速度计ADXL354/ADXL355 15次下载
- ADXL212:精度±2 g双轴PWM输出加速度计
- EVAL-ADXL327Z:三轴加速度计评估板
- UG-427:评估ADXL377三轴加速度计
- EVAL-ADXL335Z:三轴加速度计评估板
- EVAL-ADXL325Z:三轴加速度计评估板
- ADXL311EB:双轴加速度计评估板
- ADXL375: 3轴、±200 g数字MEMS加速度计
- ADXL701:高精密、低 g 、 数字 Z 轴加速度计
- ADXL375_3轴、±200g数字MEMS加速度计 38次下载
- ADXL362_微功耗、3轴、±2g_±4g_±8g数字输出MEMS加速度计 0次下载
- ADXL278_双轴、高g_iMEMS®加速度计 0次下载
- ADXL213_低成本±1.2g双轴加速度计 0次下载
- ADXL362相关设计资料 79次下载
- e2studio开发三轴加速度计LIS2DW12(4)----测量倾斜度 285次阅读
- 状态监测中数字MEMS加速度计的混叠效应 1095次阅读
- MEMS加速度计中的振动校正 2364次阅读
- 如何使用加速度计提高倾角测量的准确性 2942次阅读
- ADXL345三轴数字加速度计的驱动设计与实现 7550次阅读
- 如何扩展MEMS加速度计的带宽 3826次阅读
- 加速度计的安装方法分享 5001次阅读
- 三轴MEMS加速度计ADXL362的主要特性及应用方案分析 6720次阅读
- 九轴传感器之加速度计是怎么回事 2786次阅读
- digilent三轴MEMS加速度计传感模块介绍 2591次阅读
- digilentPmodACL三轴加速度计介绍 2098次阅读
- LIS33DE三轴加速度计的特点性能分析 4386次阅读
- 关于一种带数模混合输出的加速度计系统的设计和验证 4398次阅读
- 如何用加速度计中断引脚执行唤醒和非运动检测 4607次阅读
- MEMS加速度计的振动校正是如何发生的,并讨论各种测量此参数的技术 7695次阅读
下载排行
本周
- 1电子威廉希尔官方网站 原理第七版PDF电子教材免费下载
- 0.00 MB | 1491次下载 | 免费
- 2单片机典型实例介绍
- 18.19 MB | 95次下载 | 1 积分
- 3S7-200PLC编程实例详细资料
- 1.17 MB | 27次下载 | 1 积分
- 4笔记本电脑主板的元件识别和讲解说明
- 4.28 MB | 18次下载 | 4 积分
- 5开关电源原理及各功能威廉希尔官方网站 详解
- 0.38 MB | 11次下载 | 免费
- 6100W短波放大威廉希尔官方网站 图
- 0.05 MB | 4次下载 | 3 积分
- 7基于单片机和 SG3525的程控开关电源设计
- 0.23 MB | 4次下载 | 免费
- 8基于AT89C2051/4051单片机编程器的实验
- 0.11 MB | 4次下载 | 免费
本月
- 1OrCAD10.5下载OrCAD10.5中文版软件
- 0.00 MB | 234313次下载 | 免费
- 2PADS 9.0 2009最新版 -下载
- 0.00 MB | 66304次下载 | 免费
- 3protel99下载protel99软件下载(中文版)
- 0.00 MB | 51209次下载 | 免费
- 4LabView 8.0 专业版下载 (3CD完整版)
- 0.00 MB | 51043次下载 | 免费
- 5555集成威廉希尔官方网站 应用800例(新编版)
- 0.00 MB | 33562次下载 | 免费
- 6接口威廉希尔官方网站 图大全
- 未知 | 30320次下载 | 免费
- 7Multisim 10下载Multisim 10 中文版
- 0.00 MB | 28588次下载 | 免费
- 8开关电源设计实例指南
- 未知 | 21539次下载 | 免费
总榜
- 1matlab软件下载入口
- 未知 | 935053次下载 | 免费
- 2protel99se软件下载(可英文版转中文版)
- 78.1 MB | 537793次下载 | 免费
- 3MATLAB 7.1 下载 (含软件介绍)
- 未知 | 420026次下载 | 免费
- 4OrCAD10.5下载OrCAD10.5中文版软件
- 0.00 MB | 234313次下载 | 免费
- 5Altium DXP2002下载入口
- 未知 | 233046次下载 | 免费
- 6威廉希尔官方网站 仿真软件multisim 10.0免费下载
- 340992 | 191183次下载 | 免费
- 7十天学会AVR单片机与C语言视频教程 下载
- 158M | 183277次下载 | 免费
- 8proe5.0野火版下载(中文版免费下载)
- 未知 | 138039次下载 | 免费
评论
查看更多