This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
resources:tools-software:linux-drivers:input-misc:adxl345 [07 Sep 2012 10:23] – [Create an SD Card image] Michael Hennerich | resources:tools-software:linux-drivers:input-misc:adxl345 [07 Sep 2018 08:41] (current) – [Description] add adx375 link to ADI product page Alexandru Ardelean | ||
---|---|---|---|
Line 5: | Line 5: | ||
* [[adi> | * [[adi> | ||
* [[adi> | * [[adi> | ||
+ | * [[adi> | ||
Line 13: | Line 14: | ||
===== Evaluation Boards ===== | ===== Evaluation Boards ===== | ||
- | * [[adi> | + | |
- | * [[adi> | + | |
+ | * [[adi> | ||
+ | * [[adi> | ||
===== Description ===== | ===== Description ===== | ||
Line 30: | Line 33: | ||
[[adi> | [[adi> | ||
[[adi> | [[adi> | ||
+ | [[adi> | ||
+ | |||
{{youtube> | {{youtube> | ||
Line 96: | Line 101: | ||
===== Status ===== | ===== Status ===== | ||
- | ^ Source | + | ^ Source ^ Mainlined? ^ |
- | | [[git.linux.org> | + | | [[git.linux.org> |
Line 187: | Line 192: | ||
Digital Accelerometer characteristics are highly application specific and may vary between boards and models. The platform_data for the device' | Digital Accelerometer characteristics are highly application specific and may vary between boards and models. The platform_data for the device' | ||
- | <source trunk/ | + | <code c> |
+ | /* | ||
+ | | ||
+ | * | ||
+ | * Digital Accelerometer characteristics are highly application specific | ||
+ | * and may vary between boards and models. The platform_data for the | ||
+ | * device' | ||
+ | * | ||
+ | * Copyright 2009 Analog Devices Inc. | ||
+ | * | ||
+ | * Licensed under the GPL-2 or later. | ||
+ | */ | ||
- | ===== Example | + | #ifndef __LINUX_INPUT_ADXL34X_H__ |
+ | #define __LINUX_INPUT_ADXL34X_H__ | ||
+ | |||
+ | struct adxl34x_platform_data { | ||
+ | |||
+ | /* | ||
+ | * X,Y,Z Axis Offset: | ||
+ | * offer user offset adjustments in twoscompliment | ||
+ | * form with a scale factor of 15.6 mg/LSB (i.e. 0x7F = +2 g) | ||
+ | */ | ||
+ | |||
+ | s8 x_axis_offset; | ||
+ | s8 y_axis_offset; | ||
+ | s8 z_axis_offset; | ||
+ | |||
+ | /* | ||
+ | * TAP_X/Y/Z Enable: Setting TAP_X, Y, or Z Enable enables X, | ||
+ | * Y, or Z participation in Tap detection. A ' | ||
+ | * selected axis from participation in Tap detection. | ||
+ | * Setting the SUPPRESS bit suppresses Double Tap detection if | ||
+ | * acceleration greater than tap_threshold is present during the | ||
+ | * tap_latency period, i.e. after the first tap but before the | ||
+ | * opening of the second tap window. | ||
+ | */ | ||
+ | |||
+ | #define ADXL_SUPPRESS (1 << 3) | ||
+ | #define ADXL_TAP_X_EN (1 << 2) | ||
+ | #define ADXL_TAP_Y_EN (1 << 1) | ||
+ | #define ADXL_TAP_Z_EN (1 << 0) | ||
+ | |||
+ | u8 tap_axis_control; | ||
+ | |||
+ | /* | ||
+ | * tap_threshold: | ||
+ | * holds the threshold value for tap detection/ | ||
+ | * The data format is unsigned. The scale factor is 62.5 mg/LSB | ||
+ | * (i.e. 0xFF = +16 g). A zero value may result in undesirable | ||
+ | * behavior if Tap/Double Tap is enabled. | ||
+ | */ | ||
+ | |||
+ | u8 tap_threshold; | ||
+ | |||
+ | /* | ||
+ | * tap_duration: | ||
+ | * is an unsigned time value representing the maximum | ||
+ | * time that an event must be above the tap_threshold threshold | ||
+ | * to qualify as a tap event. The scale factor is 625 us/LSB. A zero | ||
+ | * value will prevent Tap/Double Tap functions from working. | ||
+ | */ | ||
+ | |||
+ | u8 tap_duration; | ||
+ | |||
+ | /* | ||
+ | * tap_latency: | ||
+ | * is an unsigned time value representing the wait time | ||
+ | * from the detection of a tap event to the opening of the time | ||
+ | * window tap_window for a possible second tap event. The scale | ||
+ | * factor is 1.25 ms/LSB. A zero value will disable the Double Tap | ||
+ | * function. | ||
+ | */ | ||
+ | |||
+ | u8 tap_latency; | ||
+ | |||
+ | /* | ||
+ | * tap_window: | ||
+ | * is an unsigned time value representing the amount | ||
+ | * of time after the expiration of tap_latency during which a second | ||
+ | * tap can begin. The scale factor is 1.25 ms/LSB. A zero value will | ||
+ | * disable the Double Tap function. | ||
+ | */ | ||
+ | |||
+ | u8 tap_window; | ||
+ | |||
+ | /* | ||
+ | * act_axis_control: | ||
+ | * X/Y/Z Enable: A ' | ||
+ | * or inactivity detection. A ' | ||
+ | * participation. If all of the axes are excluded, the function is | ||
+ | * disabled. | ||
+ | * AC/DC: A ' | ||
+ | * operation. In DC coupled operation, the current acceleration is | ||
+ | * compared with activity_threshold and inactivity_threshold directly | ||
+ | * to determine whether activity or inactivity is detected. In AC | ||
+ | * coupled operation for activity detection, the acceleration value | ||
+ | * at the start of activity detection is taken as a reference value. | ||
+ | * New samples of acceleration are then compared to this | ||
+ | * reference value and if the magnitude of the difference exceeds | ||
+ | * activity_threshold the device will trigger an activity interrupt. In | ||
+ | * AC coupled operation for inactivity detection, a reference value | ||
+ | * is used again for comparison and is updated whenever the | ||
+ | * device exceeds the inactivity threshold. Once the reference | ||
+ | * value is selected, the device compares the magnitude of the | ||
+ | * difference between the reference value and the current | ||
+ | * acceleration with inactivity_threshold. If the difference is below | ||
+ | * inactivity_threshold for a total of inactivity_time, | ||
+ | * considered inactive and the inactivity interrupt is triggered. | ||
+ | */ | ||
+ | |||
+ | #define ADXL_ACT_ACDC (1 << 7) | ||
+ | #define ADXL_ACT_X_EN (1 << 6) | ||
+ | #define ADXL_ACT_Y_EN (1 << 5) | ||
+ | #define ADXL_ACT_Z_EN (1 << 4) | ||
+ | #define ADXL_INACT_ACDC (1 << 3) | ||
+ | #define ADXL_INACT_X_EN (1 << 2) | ||
+ | #define ADXL_INACT_Y_EN (1 << 1) | ||
+ | #define ADXL_INACT_Z_EN (1 << 0) | ||
+ | |||
+ | u8 act_axis_control; | ||
+ | |||
+ | /* | ||
+ | * activity_threshold: | ||
+ | * holds the threshold value for activity detection. | ||
+ | * The data format is unsigned. The scale factor is | ||
+ | * 62.5 mg/LSB. A zero value may result in undesirable behavior if | ||
+ | * Activity interrupt is enabled. | ||
+ | */ | ||
+ | |||
+ | u8 activity_threshold; | ||
+ | |||
+ | /* | ||
+ | * inactivity_threshold: | ||
+ | * holds the threshold value for inactivity | ||
+ | * detection. The data format is unsigned. The scale | ||
+ | * factor is 62.5 mg/LSB. A zero value may result in undesirable | ||
+ | * behavior if Inactivity interrupt is enabled. | ||
+ | */ | ||
+ | |||
+ | u8 inactivity_threshold; | ||
+ | |||
+ | /* | ||
+ | * inactivity_time: | ||
+ | * is an unsigned time value representing the | ||
+ | * amount of time that acceleration must be below the value in | ||
+ | * inactivity_threshold for inactivity to be declared. The scale factor | ||
+ | * is 1 second/LSB. Unlike the other interrupt functions, which | ||
+ | * operate on unfiltered data, the inactivity function operates on the | ||
+ | * filtered output data. At least one output sample must be | ||
+ | * generated for the inactivity interrupt to be triggered. This will | ||
+ | * result in the function appearing un-responsive if the | ||
+ | * inactivity_time register is set with a value less than the time | ||
+ | * constant of the Output Data Rate. A zero value will result in an | ||
+ | * interrupt when the output data is below inactivity_threshold. | ||
+ | */ | ||
+ | |||
+ | u8 inactivity_time; | ||
+ | |||
+ | /* | ||
+ | * free_fall_threshold: | ||
+ | * holds the threshold value for Free-Fall detection. | ||
+ | * The data format is unsigned. The root-sum-square(RSS) value | ||
+ | * of all axes is calculated and compared to the value in | ||
+ | * free_fall_threshold to determine if a free fall event may be | ||
+ | * occurring. | ||
+ | * result in undesirable behavior if Free-Fall interrupt is | ||
+ | * enabled. Values between 300 and 600 mg (0x05 to 0x09) are | ||
+ | * recommended. | ||
+ | */ | ||
+ | |||
+ | u8 free_fall_threshold; | ||
+ | |||
+ | /* | ||
+ | * free_fall_time: | ||
+ | * is an unsigned time value representing the minimum | ||
+ | * time that the RSS value of all axes must be less than | ||
+ | * free_fall_threshold to generate a Free-Fall interrupt. The | ||
+ | * scale factor is 5 ms/LSB. A zero value may result in | ||
+ | * undesirable behavior if Free-Fall interrupt is enabled. | ||
+ | * Values between 100 to 350 ms (0x14 to 0x46) are recommended. | ||
+ | */ | ||
+ | |||
+ | u8 free_fall_time; | ||
+ | |||
+ | /* | ||
+ | * data_rate: | ||
+ | * Selects device bandwidth and output data rate. | ||
+ | * RATE = 3200 Hz / (2^(15 - x)). Default value is 0x0A, or 100 Hz | ||
+ | * Output Data Rate. An Output Data Rate should be selected that | ||
+ | * is appropriate for the communication protocol and frequency | ||
+ | * selected. Selecting too high of an Output Data Rate with a low | ||
+ | * communication speed will result in samples being discarded. | ||
+ | */ | ||
+ | |||
+ | u8 data_rate; | ||
+ | |||
+ | /* | ||
+ | * data_range: | ||
+ | * FULL_RES: When this bit is set with the device is | ||
+ | * in Full-Resolution Mode, where the output resolution increases | ||
+ | * with RANGE to maintain a 4 mg/LSB scale factor. When this | ||
+ | * bit is cleared the device is in 10-bit Mode and RANGE determine the | ||
+ | * maximum g-Range and scale factor. | ||
+ | */ | ||
+ | |||
+ | #define ADXL_FULL_RES (1 << 3) | ||
+ | #define ADXL_RANGE_PM_2g 0 | ||
+ | #define ADXL_RANGE_PM_4g 1 | ||
+ | #define ADXL_RANGE_PM_8g 2 | ||
+ | #define ADXL_RANGE_PM_16g 3 | ||
+ | |||
+ | u8 data_range; | ||
+ | |||
+ | /* | ||
+ | * low_power_mode: | ||
+ | * A ' | ||
+ | * power operation with somewhat higher noise. | ||
+ | */ | ||
+ | |||
+ | u8 low_power_mode; | ||
+ | |||
+ | /* | ||
+ | * power_mode: | ||
+ | * LINK: A ' | ||
+ | * enabled will delay the start of the activity function until | ||
+ | * inactivity is detected. Once activity is detected, inactivity | ||
+ | * detection will begin and prevent the detection of activity. This | ||
+ | * bit serially links the activity and inactivity functions. When ' | ||
+ | * the inactivity and activity functions are concurrent. Additional | ||
+ | * information can be found in the ADXL34x datasheet' | ||
+ | * section under Link Mode. | ||
+ | * AUTO_SLEEP: A ' | ||
+ | * when inactivity (acceleration has been below inactivity_threshold | ||
+ | * for at least inactivity_time) is detected and the LINK bit is set. | ||
+ | * A ' | ||
+ | * Sleep Bit section of the ADXL34x datasheet for more information. | ||
+ | */ | ||
+ | |||
+ | #define ADXL_LINK (1 << 5) | ||
+ | #define ADXL_AUTO_SLEEP (1 << 4) | ||
+ | |||
+ | u8 power_mode; | ||
+ | |||
+ | /* | ||
+ | * fifo_mode: | ||
+ | * BYPASS The FIFO is bypassed | ||
+ | * FIFO FIFO collects up to 32 values then stops collecting data | ||
+ | * STREAM FIFO holds the last 32 data values. Once full, the FIFO' | ||
+ | * oldest data is lost as it is replaced with newer data | ||
+ | * | ||
+ | * DEFAULT should be ADXL_FIFO_STREAM | ||
+ | */ | ||
+ | |||
+ | #define ADXL_FIFO_BYPASS 0 | ||
+ | #define ADXL_FIFO_FIFO 1 | ||
+ | #define ADXL_FIFO_STREAM 2 | ||
+ | |||
+ | u8 fifo_mode; | ||
+ | |||
+ | /* | ||
+ | * watermark: | ||
+ | * The Watermark feature can be used to reduce the interrupt load | ||
+ | * of the system. The FIFO fills up to the value stored in watermark | ||
+ | * [1..32] and then generates an interrupt. | ||
+ | * A ' | ||
+ | */ | ||
+ | |||
+ | u8 watermark; | ||
+ | |||
+ | /* | ||
+ | * When acceleration measurements are received from the ADXL34x | ||
+ | * events are sent to the event subsystem. The following settings | ||
+ | * select the event type and event code for new x, y and z axis data | ||
+ | * respectively. | ||
+ | */ | ||
+ | u32 ev_type; /* EV_ABS or EV_REL */ | ||
+ | |||
+ | u32 ev_code_x; | ||
+ | u32 ev_code_y; | ||
+ | u32 ev_code_z; | ||
+ | |||
+ | /* | ||
+ | * A valid BTN or KEY Code; use tap_axis_control to disable | ||
+ | * event reporting | ||
+ | */ | ||
+ | |||
+ | u32 ev_code_tap[3]; | ||
+ | |||
+ | /* | ||
+ | * A valid BTN or KEY Code for Free-Fall or Activity enables | ||
+ | * input event reporting. A ' | ||
+ | * Activity reporting. | ||
+ | */ | ||
+ | |||
+ | u32 ev_code_ff; | ||
+ | u32 ev_code_act_inactivity; | ||
+ | |||
+ | /* | ||
+ | * Use ADXL34x INT2 pin instead of INT1 pin for interrupt output | ||
+ | */ | ||
+ | u8 use_int2; | ||
+ | |||
+ | /* | ||
+ | * ADXL346 only ORIENTATION SENSING feature | ||
+ | * The orientation function of the ADXL346 reports both 2-D and | ||
+ | * 3-D orientation concurrently. | ||
+ | */ | ||
+ | |||
+ | #define ADXL_EN_ORIENTATION_2D 1 | ||
+ | #define ADXL_EN_ORIENTATION_3D 2 | ||
+ | #define ADXL_EN_ORIENTATION_2D_3D 3 | ||
+ | |||
+ | u8 orientation_enable; | ||
+ | |||
+ | /* | ||
+ | * The width of the deadzone region between two or more | ||
+ | * orientation positions is determined by setting the Deadzone | ||
+ | * value. The deadzone region size can be specified with a | ||
+ | * resolution of 3.6deg. The deadzone angle represents the total | ||
+ | * angle where the orientation is considered invalid. | ||
+ | */ | ||
+ | |||
+ | #define ADXL_DEADZONE_ANGLE_0p0 0 / | ||
+ | #define ADXL_DEADZONE_ANGLE_3p6 1 / | ||
+ | #define ADXL_DEADZONE_ANGLE_7p2 2 / | ||
+ | #define ADXL_DEADZONE_ANGLE_10p8 3 / | ||
+ | #define ADXL_DEADZONE_ANGLE_14p4 4 / | ||
+ | #define ADXL_DEADZONE_ANGLE_18p0 5 / | ||
+ | #define ADXL_DEADZONE_ANGLE_21p6 6 / | ||
+ | #define ADXL_DEADZONE_ANGLE_25p2 7 / | ||
+ | |||
+ | u8 deadzone_angle; | ||
+ | |||
+ | /* | ||
+ | * To eliminate most human motion such as walking or shaking, | ||
+ | * a Divisor value should be selected to effectively limit the | ||
+ | * orientation bandwidth. Set the depth of the filter used to | ||
+ | * low-pass filter the measured acceleration for stable | ||
+ | * orientation sensing | ||
+ | */ | ||
+ | |||
+ | #define ADXL_LP_FILTER_DIVISOR_2 0 | ||
+ | #define ADXL_LP_FILTER_DIVISOR_4 1 | ||
+ | #define ADXL_LP_FILTER_DIVISOR_8 2 | ||
+ | #define ADXL_LP_FILTER_DIVISOR_16 3 | ||
+ | #define ADXL_LP_FILTER_DIVISOR_32 4 | ||
+ | #define ADXL_LP_FILTER_DIVISOR_64 5 | ||
+ | #define ADXL_LP_FILTER_DIVISOR_128 6 | ||
+ | #define ADXL_LP_FILTER_DIVISOR_256 7 | ||
+ | |||
+ | u8 divisor_length; | ||
+ | |||
+ | u32 ev_codes_orient_2d[4]; | ||
+ | u32 ev_codes_orient_3d[6]; | ||
+ | }; | ||
+ | #endif | ||
+ | </ | ||
+ | |||
+ | ===== Example | ||
{{page> | {{page> | ||
Line 199: | Line 561: | ||
</ | </ | ||
- | <source trunk/ | + | <code c> |
- | <source trunk/ | + | #if defined(CONFIG_INPUT_ADXL34X) || defined(CONFIG_INPUT_ADXL34X_MODULE) |
- | <source trunk/ | + | # |
+ | static const struct adxl34x_platform_data adxl34x_info = { | ||
+ | .x_axis_offset = 0, | ||
+ | .y_axis_offset = 0, | ||
+ | .z_axis_offset = 0, | ||
+ | .tap_threshold = 0x31, | ||
+ | .tap_duration = 0x10, | ||
+ | .tap_latency = 0x60, | ||
+ | .tap_window = 0xF0, | ||
+ | .tap_axis_control = ADXL_TAP_X_EN | ADXL_TAP_Y_EN | ADXL_TAP_Z_EN, | ||
+ | .act_axis_control = 0xFF, | ||
+ | .activity_threshold = 5, | ||
+ | .inactivity_threshold = 3, | ||
+ | .inactivity_time = 4, | ||
+ | .free_fall_threshold = 0x7, | ||
+ | .free_fall_time = 0x20, | ||
+ | .data_rate = 0x8, | ||
+ | .data_range = ADXL_FULL_RES, | ||
- | ===== Example | + | .ev_type = EV_ABS, |
+ | .ev_code_x = ABS_X, /* EV_REL */ | ||
+ | .ev_code_y = ABS_Y, /* EV_REL */ | ||
+ | .ev_code_z = ABS_Z, /* EV_REL */ | ||
+ | |||
+ | .ev_code_tap = {BTN_TOUCH, BTN_TOUCH, BTN_TOUCH}, /* EV_KEY x,y,z */ | ||
+ | |||
+ | / | ||
+ | / | ||
+ | .power_mode = ADXL_AUTO_SLEEP | ADXL_LINK, | ||
+ | .fifo_mode = ADXL_FIFO_STREAM, | ||
+ | .orientation_enable = ADXL_EN_ORIENTATION_3D, | ||
+ | .deadzone_angle = ADXL_DEADZONE_ANGLE_10p8, | ||
+ | .divisor_length = ADXL_LP_FILTER_DIVISOR_16, | ||
+ | /* EV_KEY {+Z, +Y, +X, -X, -Y, -Z} */ | ||
+ | .ev_codes_orient_3d = {BTN_Z, BTN_Y, BTN_X, BTN_A, BTN_B, BTN_C}, | ||
+ | }; | ||
+ | #endif | ||
+ | </ | ||
+ | |||
+ | <code c> | ||
+ | static struct spi_board_info board_spi_board_info[] __initdata = { | ||
+ | #if defined(CONFIG_INPUT_ADXL34X_SPI) || defined(CONFIG_INPUT_ADXL34X_SPI_MODULE) | ||
+ | { | ||
+ | .modalias = " | ||
+ | .platform_data = & | ||
+ | .irq = IRQ_XYZ, | ||
+ | .max_speed_hz = 5000000, | ||
+ | .bus_num = 1, | ||
+ | .chip_select | ||
+ | .mode = SPI_MODE_3, | ||
+ | }, | ||
+ | #endif | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | <code c> | ||
+ | static int __init board_init(void) | ||
+ | { | ||
+ | [--snip--] | ||
+ | |||
+ | spi_register_board_info(board_spi_board_info, | ||
+ | |||
+ | [--snip--] | ||
+ | |||
+ | return 0; | ||
+ | } | ||
+ | arch_initcall(board_init); | ||
+ | </ | ||
+ | |||
+ | ===== Devicetree ===== | ||
+ | |||
+ | Required devicetree properties: | ||
+ | * compatible: Needs to be " | ||
+ | * reg: The chipselect number used for the device | ||
+ | * spi-max-frequency: | ||
+ | * spi-cpha: Needs to be set for the correct SPI mode | ||
+ | * spi-cpol: Needs to be set for the correct SPI mode | ||
+ | * interrupt-parent: | ||
+ | * interrupts: The interrupt associated with the INT2 pin | ||
+ | |||
+ | < | ||
+ | | ||
+ | # | ||
+ | # | ||
+ | | ||
+ | ... | ||
+ | |||
+ | | ||
+ | | ||
+ | reg = < | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | ===== Example | ||
{{page> | {{page> | ||
Line 209: | Line 668: | ||
These snippets are all from the same file. '' | These snippets are all from the same file. '' | ||
- | <source trunk/arch/ | + | <code c> |
- | <source trunk/ | + | static struct i2c_board_info __initdata board_i2c_board_info[] = { |
+ | #if defined(CONFIG_INPUT_ADXL34X_I2C) || defined(CONFIG_INPUT_ADXL34X_I2C_MODULE) | ||
+ | { | ||
+ | I2C_BOARD_INFO(" | ||
+ | .irq = IRQ_XYZ, | ||
+ | .platform_data = (void *)& | ||
+ | }, | ||
+ | #endif | ||
+ | }; | ||
+ | </code> | ||
+ | |||
+ | <code c> | ||
+ | static int __init board_init(void) | ||
+ | { | ||
+ | [--snip--] | ||
+ | |||
+ | i2c_register_board_info(0, | ||
+ | ARRAY_SIZE(board_i2c_board_info)); | ||
+ | [--snip--] | ||
+ | |||
+ | return 0; | ||
+ | } | ||
+ | arch_initcall(board_init); | ||
+ | </code> | ||
+ | |||
+ | ===== Devicetree ===== | ||
+ | |||
+ | Required devicetree properties: | ||
+ | * compatible: Needs to be " | ||
+ | * reg: The slave address of the device | ||
+ | * interrupt-parent: | ||
+ | * interrupts: The interrupt associated with the INT2 pin | ||
+ | |||
+ | < | ||
+ | | ||
+ | # | ||
+ | #size-cells = <0>; | ||
+ | | ||
+ | ... | ||
+ | |||
+ | | ||
+ | | ||
+ | reg = < | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | }; | ||
+ | </code> | ||
====== Adding Linux driver support ====== | ====== Adding Linux driver support ====== | ||
Line 217: | Line 723: | ||
"make qconfig" | "make qconfig" | ||
- | <note> | + | <WRAP round help> |
The ADXL34x Driver depends on **CONFIG_SPI** or **CONFIG_I2C** | The ADXL34x Driver depends on **CONFIG_SPI** or **CONFIG_I2C** | ||
- | </note> | + | </WRAP> |
< | < | ||
Line 318: | Line 824: | ||
</ | </ | ||
- | ===== Use the event_test | + | ===== Use the evtest |
< | < | ||
- | root:/> | + | root:/> |
Input driver version is 1.0.0 | Input driver version is 1.0.0 | ||
Input device ID: bus 0x18 vendor 0x0 product 0x159 version 0x0 | Input device ID: bus 0x18 vendor 0x0 product 0x159 version 0x0 | ||
Line 363: | Line 869: | ||
</ | </ | ||
- | <note tip> | + | <WRAP tip> |
In case you move the accelerometer and don't receive events, it's likely that something with your Interrupt is wrong.\\ | 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** | **check irq number in your platform device file** | ||
- | </note> | + | </WRAP> |
- | <note tip> | + | <WRAP tip> |
In case you get a message like: '' | In case you get a message like: '' | ||
- | </note> | + | </WRAP> |
===== Visualizing Linux Input Events using df_input example from DirectFB ===== | ===== Visualizing Linux Input Events using df_input example from DirectFB ===== | ||
Line 459: | Line 965: | ||
</ | </ | ||
- | <note tip> | + | <WRAP tip> |
**Be aware:** | **Be aware:** | ||
The ADXL34x conforms to The I2C Bus Specification, | The ADXL34x conforms to The I2C Bus Specification, | ||
Line 466: | Line 972: | ||
Very high output data rates are only possible via fast I2C (400kHz) or the SPI interface. | Very high output data rates are only possible via fast I2C (400kHz) or the SPI interface. | ||
- | </note> | + | </WRAP> |
==== Enabling / Disabling the Device ==== | ==== Enabling / Disabling the Device ==== | ||
Line 498: | Line 1004: | ||
http:// | http:// | ||
- | <note warning> | + | <WRAP alert> |
This example assumes that /dev/sdc is the SD-Card reader.\\ | This example assumes that /dev/sdc is the SD-Card reader.\\ | ||
All content will be lost! | All content will be lost! | ||
- | </note> | + | </WRAP> |
- | < | + | <WRAP box bggreen>< |
< | < | ||
Dave@HAL9000: | Dave@HAL9000: | ||
Line 515: | Line 1021: | ||
1939865600 bytes (1.9 GB) copied, 434.764 s, 4.5 MB/s | 1939865600 bytes (1.9 GB) copied, 434.764 s, 4.5 MB/s | ||
Dave@HAL9000: | Dave@HAL9000: | ||
- | </ | + | </ |
===== Compile a kernel ===== | ===== Compile a kernel ===== | ||
Line 523: | Line 1029: | ||
* On a development computer (host) | * On a development computer (host) | ||
- | <note tip> | + | <WRAP tip> |
In order to speed things up - we compile the kernel on a foreign host. | In order to speed things up - we compile the kernel on a foreign host. | ||
- | </note> | + | </WRAP> |
==== Get ARM tools and RaspberryPi kernel source ==== | ==== Get ARM tools and RaspberryPi kernel source ==== | ||
Line 531: | Line 1037: | ||
=== Create an empty directory === | === Create an empty directory === | ||
- | < | + | <WRAP box bggreen>< |
< | < | ||
Dave@HAL9000: | Dave@HAL9000: | ||
Dave@HAL9000: | Dave@HAL9000: | ||
- | </ | + | </ |
=== Get tools === | === Get tools === | ||
- | < | + | <WRAP box bggreen>< |
- | <xterm>< | + | < |
- | Dave@HAL9000: | + | Dave@HAL9000: |
Initialized empty Git repository in / | Initialized empty Git repository in / | ||
remote: Counting objects: 11148, done. | remote: Counting objects: 11148, done. | ||
Line 549: | Line 1055: | ||
Resolving deltas: 100% (6433/ | Resolving deltas: 100% (6433/ | ||
Checking out files: 100% (10692/ | Checking out files: 100% (10692/ | ||
- | </ | + | </ |
=== Get Kernel Source === | === Get Kernel Source === | ||
- | < | + | <WRAP box bggreen>< |
- | <xterm>< | + | < |
- | Dave@HAL9000: | + | Dave@HAL9000: |
Initialized empty Git repository in / | Initialized empty Git repository in / | ||
remote: Counting objects: 2287525, done. | remote: Counting objects: 2287525, done. | ||
Line 564: | Line 1070: | ||
Checking out files: 100% (37972/ | Checking out files: 100% (37972/ | ||
Dave@HAL9000: | Dave@HAL9000: | ||
- | </ | + | </ |
- | <note tip> | + | <WRAP tip> |
See here: | See here: | ||
http:// | http:// | ||
- | </note> | + | </WRAP> |
=== Download and apply patches === | === Download and apply patches === | ||
Line 576: | Line 1082: | ||
* {{: | * {{: | ||
- | < | + | <WRAP important> |
+ | This was tested with the Raspberry Pi Model B, PCB Version 2 (made in UK)\\ | ||
+ | |||
+ | **The primary and secondary I2C channels have been reversed.** | ||
+ | |||
+ | You may need to register i2c board info for Bus-0 instead of Bus-1. | ||
+ | |||
+ | <code c> | ||
+ | /* From arch/ | ||
+ | |||
+ | #ifdef CONFIG_I2C | ||
+ | i2c_register_board_info(0, | ||
+ | ARRAY_SIZE(bcm2708_i2c_board_info)); | ||
+ | #endif | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
< | < | ||
Dave@HAL9000: | Dave@HAL9000: | ||
Line 585: | Line 1109: | ||
Applying: platform: RaspberryPi: | Applying: platform: RaspberryPi: | ||
Dave@HAL9000: | Dave@HAL9000: | ||
- | </ | + | </ |
=== Add ARM toolchain to the PATH variable and set ARCH and CROSS_COMPILE === | === Add ARM toolchain to the PATH variable and set ARCH and CROSS_COMPILE === | ||
- | < | + | <WRAP box bggreen>< |
< | < | ||
Dave@HAL9000: | Dave@HAL9000: | ||
Dave@HAL9000: | Dave@HAL9000: | ||
Dave@HAL9000: | Dave@HAL9000: | ||
- | </ | + | </ |
=== Load kernel config for bcmrpi === | === Load kernel config for bcmrpi === | ||
- | < | + | <WRAP box bggreen>< |
< | < | ||
Dave@HAL9000: | Dave@HAL9000: | ||
Line 605: | Line 1129: | ||
# configuration written to .config | # configuration written to .config | ||
# | # | ||
- | </ | + | </ |
=== Now build your kernel === | === Now build your kernel === | ||
- | < | + | <WRAP box bggreen>< |
< | < | ||
Dave@HAL9000: | Dave@HAL9000: | ||
- | </ | + | </ |
=== Copy kernel image and modules to SD Card === | === Copy kernel image and modules to SD Card === | ||
- | < | + | <WRAP box bggreen>< |
< | < | ||
Dave@HAL9000: | Dave@HAL9000: | ||
Dave@HAL9000: | Dave@HAL9000: | ||
- | </ | + | </ |
==== Connect ADXL345 development Board ==== | ==== Connect ADXL345 development Board ==== | ||
Line 636: | Line 1160: | ||
=== Load the I2C Bus driver module === | === Load the I2C Bus driver module === | ||
- | < | + | <WRAP box bggreen>< |
< | < | ||
pi@raspberrypi ~ $ **sudo modprobe i2c-bcm2708** | pi@raspberrypi ~ $ **sudo modprobe i2c-bcm2708** | ||
- | </ | + | </ |
=== Check if ADXL345 was successfully probed / instantiated === | === Check if ADXL345 was successfully probed / instantiated === | ||
- | < | + | <WRAP box bggreen>< |
< | < | ||
pi@raspberrypi ~ $ **dmesg | grep ADXL** | pi@raspberrypi ~ $ **dmesg | grep ADXL** | ||
[ | [ | ||
pi@raspberrypi ~ $ | pi@raspberrypi ~ $ | ||
- | </ | + | </ |
=== Get evtest tool === | === Get evtest tool === | ||
- | < | + | <WRAP box bggreen>< |
< | < | ||
pi@raspberrypi ~ $ **sudo apt-get install evtest** | pi@raspberrypi ~ $ **sudo apt-get install evtest** | ||
- | </ | + | </ |
=== Driver test === | === Driver test === | ||
- | < | + | <WRAP box bggreen>< |
< | < | ||
pi@raspberrypi ~ $ **evtest / | pi@raspberrypi ~ $ **evtest / | ||
Line 709: | Line 1233: | ||
Event: time 1345080075.096267, | Event: time 1345080075.096267, | ||
Event: time 1345080075.096269, | Event: time 1345080075.096269, | ||
- | </ | + | </ |
- | < | + | <WRAP box bggreen>< |
< | < | ||
pi@raspberrypi ~ $ **cat / | pi@raspberrypi ~ $ **cat / | ||
Line 726: | Line 1250: | ||
**187: | **187: | ||
Err: 0 | Err: 0 | ||
- | </ | + | </ |
- | < | + | <WRAP box bggreen>< |
< | < | ||
pi@raspberrypi / | pi@raspberrypi / | ||
Line 745: | Line 1269: | ||
-rw-r--r-- 1 root root 4096 Aug 16 01:22 uevent | -rw-r--r-- 1 root root 4096 Aug 16 01:22 uevent | ||
pi@raspberrypi / | pi@raspberrypi / | ||
- | </ | + | </ |
====== More Information ====== | ====== More Information ====== |