2 Author: Invensense <http://invensense.com>
7 - Integrating the Driver in the Linux Kernel
8 - Board and Platform Data
10 - Board File Modifications for compass
14 > Communicating with the Driver in Userspace
15 - Streaming Data to an Userspace Application
17 > Running Test Applications with AMI306 or YAS53x
21 This document describes how to install the Invensense device driver for AMI306
22 and YAS53x series compass chip into a Linux kernel. The Invensense driver
23 currently supports the following sensors:
29 Please refer to the appropriate product specification
30 document for further information regarding the slave address.
32 The following files are included in this package:
37 - inv_ami306_trigger.c
41 - inv_yas53x_trigger.c
44 Integrating the Driver in the Linux Kernel
45 ==========================================
46 Please add the files as follows:
47 - Add all above files to drivers/staging/iio/magnetometer/inv_compass
48 (another directory is acceptable, but this is the recommended destination)
50 In order to see the driver in menuconfig when building the kernel, please
51 make modifications as shown below:
53 modify "drivers/staging/iio/magnetometer/Kconfig" with:
54 >> source "drivers/staging/iio/magnetometer/inv_compass/Kconfig"
56 modify "drivers/staging/iio/magnetometer/Makefile" with:
57 >> obj-y += inv_compass/
60 Board and Platform Data
61 =======================
62 In order to recognize the Invensense device on the I2C bus, the board file must
64 The i2c_board_info instance must be defined as shown below.
68 The platform data (orientation matrix and secondary bus configurations) must be
69 modified as show below, according to your particular platform configuration.
71 Board File Modifications for Secondary I2C Configuration
72 ========================================================
73 For the Panda Board, the board file can be found at
74 arch/arm/mach-omap2/board-omap4panda.c.
75 Please modify the pertinent baord file in your system according to the examples
79 -------------------------------------------------
80 static struct mpu_platform_data compass_data = {
81 .orientation = { 0, 0, 1,
86 static struct i2c_board_info __initdata chip_board_info[] = {
88 I2C_BOARD_INFO("ami306", 0x0E),
89 .platform_data = &compass_data,
93 YAS53x(Use YAS532 as an example)
94 -------------------------------------------------
95 static struct mpu_platform_data compass_data = {
96 .orientation = { 0, -1, 0,
101 static struct i2c_board_info __initdata compass_board_info[] = {
103 I2C_BOARD_INFO("yas532", 0x2E),
104 .platform_data = &compass_data,
110 A successful installation will create the following two new directories under
111 /sys/bus/iio/devices:
115 Also, a new file, "iio:device0", will be created in the /dev/ diretory.
116 (if you have more than one IIO device, the file will be named "iio:deviceX",
120 Communicating with the Driver in Userspace
121 ------------------------------------------
122 The driver generates several files in sysfs upon installation.
123 These files are used to communicate with the driver. The files can be found
124 at /sys/bus/iio/devices/iio:device0 (or ../iio:deviceX as shown above).
126 A brief description of the pertinent files for each Invensense device is shown
131 compass_matrix (read-only)
132 --show the orientation matrix obtained from the board file.
134 sampling_frequency(read and write)
135 --show and change the sampling rate of the sensor.
138 ---------------------
139 YAS53x has all the attributes AMI306 has. It has one more additional attribute:
141 overunderflow(read-only)
142 --value 1 shows an overflow or underflow happens. Need to write into it to make
145 Streaming Data to an Userspace Application
146 ==========================================
147 When streaming data to an userspace application, we recommend that you access
148 compass data via /dev/iio:device0.
150 Please follow the steps below to read data at a constant rate from the driver:
152 1. Write the desired output rate to sampling_frequency.
153 2. Write 1 to enable to turn on the event.
154 3. Read /dev/iio:device0 to get a string of gyro/accel/compass data.
155 4. Parse this string to obtain each compass element.
159 A test application is located under software/simple_apps/mpu_iio.
160 This application is stand-alone in that it cannot be run concurrently with other
161 entities trying to access the device node(s) or sysfs entries; in particular,
164 Running Test Applications
165 ---------------------------------------------------------
166 To run test applications with AMI306 or YAS53x devices,
167 please use the following commands:
170 mpu_iio -n ami306 -c 10 -l 3
173 mpu_iio -n yas532 -c 10 -l 3
175 Please use mpu_iio.c and iio_utils.h as example code for your development