Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
adxl34x.c File Reference
#include <linux/device.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/input/adxl34x.h>
#include <linux/module.h>
#include "adxl34x.h"

Go to the source code of this file.

Data Structures

struct  axis_triple
 
struct  adxl34x
 

Macros

#define DEVID   0x00 /* R Device ID */
 
#define THRESH_TAP   0x1D /* R/W Tap threshold */
 
#define OFSX   0x1E /* R/W X-axis offset */
 
#define OFSY   0x1F /* R/W Y-axis offset */
 
#define OFSZ   0x20 /* R/W Z-axis offset */
 
#define DUR   0x21 /* R/W Tap duration */
 
#define LATENT   0x22 /* R/W Tap latency */
 
#define WINDOW   0x23 /* R/W Tap window */
 
#define THRESH_ACT   0x24 /* R/W Activity threshold */
 
#define THRESH_INACT   0x25 /* R/W Inactivity threshold */
 
#define TIME_INACT   0x26 /* R/W Inactivity time */
 
#define ACT_INACT_CTL   0x27 /* R/W Axis enable control for activity and */
 
#define THRESH_FF   0x28 /* R/W Free-fall threshold */
 
#define TIME_FF   0x29 /* R/W Free-fall time */
 
#define TAP_AXES   0x2A /* R/W Axis control for tap/double tap */
 
#define ACT_TAP_STATUS   0x2B /* R Source of tap/double tap */
 
#define BW_RATE   0x2C /* R/W Data rate and power mode control */
 
#define POWER_CTL   0x2D /* R/W Power saving features control */
 
#define INT_ENABLE   0x2E /* R/W Interrupt enable control */
 
#define INT_MAP   0x2F /* R/W Interrupt mapping control */
 
#define INT_SOURCE   0x30 /* R Source of interrupts */
 
#define DATA_FORMAT   0x31 /* R/W Data format control */
 
#define DATAX0   0x32 /* R X-Axis Data 0 */
 
#define DATAX1   0x33 /* R X-Axis Data 1 */
 
#define DATAY0   0x34 /* R Y-Axis Data 0 */
 
#define DATAY1   0x35 /* R Y-Axis Data 1 */
 
#define DATAZ0   0x36 /* R Z-Axis Data 0 */
 
#define DATAZ1   0x37 /* R Z-Axis Data 1 */
 
#define FIFO_CTL   0x38 /* R/W FIFO control */
 
#define FIFO_STATUS   0x39 /* R FIFO status */
 
#define TAP_SIGN   0x3A /* R Sign and source for tap/double tap */
 
#define ORIENT_CONF   0x3B /* R/W Orientation configuration */
 
#define ORIENT   0x3C /* R Orientation status */
 
#define ID_ADXL345   0xE5
 
#define ID_ADXL346   0xE6
 
#define DATA_READY   (1 << 7)
 
#define SINGLE_TAP   (1 << 6)
 
#define DOUBLE_TAP   (1 << 5)
 
#define ACTIVITY   (1 << 4)
 
#define INACTIVITY   (1 << 3)
 
#define FREE_FALL   (1 << 2)
 
#define WATERMARK   (1 << 1)
 
#define OVERRUN   (1 << 0)
 
#define ACT_ACDC   (1 << 7)
 
#define ACT_X_EN   (1 << 6)
 
#define ACT_Y_EN   (1 << 5)
 
#define ACT_Z_EN   (1 << 4)
 
#define INACT_ACDC   (1 << 3)
 
#define INACT_X_EN   (1 << 2)
 
#define INACT_Y_EN   (1 << 1)
 
#define INACT_Z_EN   (1 << 0)
 
#define SUPPRESS   (1 << 3)
 
#define TAP_X_EN   (1 << 2)
 
#define TAP_Y_EN   (1 << 1)
 
#define TAP_Z_EN   (1 << 0)
 
#define ACT_X_SRC   (1 << 6)
 
#define ACT_Y_SRC   (1 << 5)
 
#define ACT_Z_SRC   (1 << 4)
 
#define ASLEEP   (1 << 3)
 
#define TAP_X_SRC   (1 << 2)
 
#define TAP_Y_SRC   (1 << 1)
 
#define TAP_Z_SRC   (1 << 0)
 
#define LOW_POWER   (1 << 4)
 
#define RATE(x)   ((x) & 0xF)
 
#define PCTL_LINK   (1 << 5)
 
#define PCTL_AUTO_SLEEP   (1 << 4)
 
#define PCTL_MEASURE   (1 << 3)
 
#define PCTL_SLEEP   (1 << 2)
 
#define PCTL_WAKEUP(x)   ((x) & 0x3)
 
#define SELF_TEST   (1 << 7)
 
#define SPI   (1 << 6)
 
#define INT_INVERT   (1 << 5)
 
#define FULL_RES   (1 << 3)
 
#define JUSTIFY   (1 << 2)
 
#define RANGE(x)   ((x) & 0x3)
 
#define RANGE_PM_2g   0
 
#define RANGE_PM_4g   1
 
#define RANGE_PM_8g   2
 
#define RANGE_PM_16g   3
 
#define ADXL_FULLRES_MAX_VAL   4096
 
#define ADXL_FIXEDRES_MAX_VAL   512
 
#define FIFO_MODE(x)   (((x) & 0x3) << 6)
 
#define FIFO_BYPASS   0
 
#define FIFO_FIFO   1
 
#define FIFO_STREAM   2
 
#define FIFO_TRIGGER   3
 
#define TRIGGER   (1 << 5)
 
#define SAMPLES(x)   ((x) & 0x1F)
 
#define FIFO_TRIG   (1 << 7)
 
#define ENTRIES(x)   ((x) & 0x3F)
 
#define XSIGN   (1 << 6)
 
#define YSIGN   (1 << 5)
 
#define ZSIGN   (1 << 4)
 
#define XTAP   (1 << 3)
 
#define YTAP   (1 << 2)
 
#define ZTAP   (1 << 1)
 
#define ORIENT_DEADZONE(x)   (((x) & 0x7) << 4)
 
#define ORIENT_DIVISOR(x)   ((x) & 0x7)
 
#define ADXL346_2D_VALID   (1 << 6)
 
#define ADXL346_2D_ORIENT(x)   (((x) & 0x3) >> 4)
 
#define ADXL346_3D_VALID   (1 << 3)
 
#define ADXL346_3D_ORIENT(x)   ((x) & 0x7)
 
#define ADXL346_2D_PORTRAIT_POS   0 /* +X */
 
#define ADXL346_2D_PORTRAIT_NEG   1 /* -X */
 
#define ADXL346_2D_LANDSCAPE_POS   2 /* +Y */
 
#define ADXL346_2D_LANDSCAPE_NEG   3 /* -Y */
 
#define ADXL346_3D_FRONT   3 /* +X */
 
#define ADXL346_3D_BACK   4 /* -X */
 
#define ADXL346_3D_RIGHT   2 /* +Y */
 
#define ADXL346_3D_LEFT   5 /* -Y */
 
#define ADXL346_3D_TOP   1 /* +Z */
 
#define ADXL346_3D_BOTTOM   6 /* -Z */
 
#define ADXL_X_AXIS   0
 
#define ADXL_Y_AXIS   1
 
#define ADXL_Z_AXIS   2
 
#define AC_READ(ac, reg)   ((ac)->bops->read((ac)->dev, reg))
 
#define AC_WRITE(ac, reg, val)   ((ac)->bops->write((ac)->dev, reg, val))
 

Functions

void adxl34x_suspend (struct adxl34x *ac)
 
 EXPORT_SYMBOL_GPL (adxl34x_suspend)
 
void adxl34x_resume (struct adxl34x *ac)
 
 EXPORT_SYMBOL_GPL (adxl34x_resume)
 
struct adxl34xadxl34x_probe (struct device *dev, int irq, bool fifo_delay_default, const struct adxl34x_bus_ops *bops)
 
 EXPORT_SYMBOL_GPL (adxl34x_probe)
 
int adxl34x_remove (struct adxl34x *ac)
 
 EXPORT_SYMBOL_GPL (adxl34x_remove)
 
 MODULE_AUTHOR ("Michael Hennerich <[email protected]>")
 
 MODULE_DESCRIPTION ("ADXL345/346 Three-Axis Digital Accelerometer Driver")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

#define AC_READ (   ac,
  reg 
)    ((ac)->bops->read((ac)->dev, reg))

Definition at line 182 of file adxl34x.c.

#define AC_WRITE (   ac,
  reg,
  val 
)    ((ac)->bops->write((ac)->dev, reg, val))

Definition at line 183 of file adxl34x.c.

#define ACT_ACDC   (1 << 7)

Definition at line 75 of file adxl34x.c.

#define ACT_INACT_CTL   0x27 /* R/W Axis enable control for activity and */

Definition at line 35 of file adxl34x.c.

#define ACT_TAP_STATUS   0x2B /* R Source of tap/double tap */

Definition at line 40 of file adxl34x.c.

#define ACT_X_EN   (1 << 6)

Definition at line 76 of file adxl34x.c.

#define ACT_X_SRC   (1 << 6)

Definition at line 91 of file adxl34x.c.

#define ACT_Y_EN   (1 << 5)

Definition at line 77 of file adxl34x.c.

#define ACT_Y_SRC   (1 << 5)

Definition at line 92 of file adxl34x.c.

#define ACT_Z_EN   (1 << 4)

Definition at line 78 of file adxl34x.c.

#define ACT_Z_SRC   (1 << 4)

Definition at line 93 of file adxl34x.c.

#define ACTIVITY   (1 << 4)

Definition at line 68 of file adxl34x.c.

#define ADXL346_2D_LANDSCAPE_NEG   3 /* -Y */

Definition at line 167 of file adxl34x.c.

#define ADXL346_2D_LANDSCAPE_POS   2 /* +Y */

Definition at line 166 of file adxl34x.c.

#define ADXL346_2D_ORIENT (   x)    (((x) & 0x3) >> 4)

Definition at line 161 of file adxl34x.c.

#define ADXL346_2D_PORTRAIT_NEG   1 /* -X */

Definition at line 165 of file adxl34x.c.

#define ADXL346_2D_PORTRAIT_POS   0 /* +X */

Definition at line 164 of file adxl34x.c.

#define ADXL346_2D_VALID   (1 << 6)

Definition at line 160 of file adxl34x.c.

#define ADXL346_3D_BACK   4 /* -X */

Definition at line 170 of file adxl34x.c.

#define ADXL346_3D_BOTTOM   6 /* -Z */

Definition at line 174 of file adxl34x.c.

#define ADXL346_3D_FRONT   3 /* +X */

Definition at line 169 of file adxl34x.c.

#define ADXL346_3D_LEFT   5 /* -Y */

Definition at line 172 of file adxl34x.c.

#define ADXL346_3D_ORIENT (   x)    ((x) & 0x7)

Definition at line 163 of file adxl34x.c.

#define ADXL346_3D_RIGHT   2 /* +Y */

Definition at line 171 of file adxl34x.c.

#define ADXL346_3D_TOP   1 /* +Z */

Definition at line 173 of file adxl34x.c.

#define ADXL346_3D_VALID   (1 << 3)

Definition at line 162 of file adxl34x.c.

#define ADXL_FIXEDRES_MAX_VAL   512

Definition at line 132 of file adxl34x.c.

#define ADXL_FULLRES_MAX_VAL   4096

Definition at line 126 of file adxl34x.c.

#define ADXL_X_AXIS   0

Definition at line 178 of file adxl34x.c.

#define ADXL_Y_AXIS   1

Definition at line 179 of file adxl34x.c.

#define ADXL_Z_AXIS   2

Definition at line 180 of file adxl34x.c.

#define ASLEEP   (1 << 3)

Definition at line 94 of file adxl34x.c.

#define BW_RATE   0x2C /* R/W Data rate and power mode control */

Definition at line 41 of file adxl34x.c.

#define DATA_FORMAT   0x31 /* R/W Data format control */

Definition at line 46 of file adxl34x.c.

#define DATA_READY   (1 << 7)

Definition at line 65 of file adxl34x.c.

#define DATAX0   0x32 /* R X-Axis Data 0 */

Definition at line 47 of file adxl34x.c.

#define DATAX1   0x33 /* R X-Axis Data 1 */

Definition at line 48 of file adxl34x.c.

#define DATAY0   0x34 /* R Y-Axis Data 0 */

Definition at line 49 of file adxl34x.c.

#define DATAY1   0x35 /* R Y-Axis Data 1 */

Definition at line 50 of file adxl34x.c.

#define DATAZ0   0x36 /* R Z-Axis Data 0 */

Definition at line 51 of file adxl34x.c.

#define DATAZ1   0x37 /* R Z-Axis Data 1 */

Definition at line 52 of file adxl34x.c.

#define DEVID   0x00 /* R Device ID */

Definition at line 24 of file adxl34x.c.

#define DOUBLE_TAP   (1 << 5)

Definition at line 67 of file adxl34x.c.

#define DUR   0x21 /* R/W Tap duration */

Definition at line 29 of file adxl34x.c.

#define ENTRIES (   x)    ((x) & 0x3F)

Definition at line 145 of file adxl34x.c.

#define FIFO_BYPASS   0

Definition at line 136 of file adxl34x.c.

#define FIFO_CTL   0x38 /* R/W FIFO control */

Definition at line 53 of file adxl34x.c.

#define FIFO_FIFO   1

Definition at line 137 of file adxl34x.c.

#define FIFO_MODE (   x)    (((x) & 0x3) << 6)

Definition at line 135 of file adxl34x.c.

#define FIFO_STATUS   0x39 /* R FIFO status */

Definition at line 54 of file adxl34x.c.

#define FIFO_STREAM   2

Definition at line 138 of file adxl34x.c.

#define FIFO_TRIG   (1 << 7)

Definition at line 144 of file adxl34x.c.

#define FIFO_TRIGGER   3

Definition at line 139 of file adxl34x.c.

#define FREE_FALL   (1 << 2)

Definition at line 70 of file adxl34x.c.

#define FULL_RES   (1 << 3)

Definition at line 114 of file adxl34x.c.

#define ID_ADXL345   0xE5

Definition at line 61 of file adxl34x.c.

#define ID_ADXL346   0xE6

Definition at line 62 of file adxl34x.c.

#define INACT_ACDC   (1 << 3)

Definition at line 79 of file adxl34x.c.

#define INACT_X_EN   (1 << 2)

Definition at line 80 of file adxl34x.c.

#define INACT_Y_EN   (1 << 1)

Definition at line 81 of file adxl34x.c.

#define INACT_Z_EN   (1 << 0)

Definition at line 82 of file adxl34x.c.

#define INACTIVITY   (1 << 3)

Definition at line 69 of file adxl34x.c.

#define INT_ENABLE   0x2E /* R/W Interrupt enable control */

Definition at line 43 of file adxl34x.c.

#define INT_INVERT   (1 << 5)

Definition at line 113 of file adxl34x.c.

#define INT_MAP   0x2F /* R/W Interrupt mapping control */

Definition at line 44 of file adxl34x.c.

#define INT_SOURCE   0x30 /* R Source of interrupts */

Definition at line 45 of file adxl34x.c.

#define JUSTIFY   (1 << 2)

Definition at line 115 of file adxl34x.c.

#define LATENT   0x22 /* R/W Tap latency */

Definition at line 30 of file adxl34x.c.

#define LOW_POWER   (1 << 4)

Definition at line 100 of file adxl34x.c.

#define OFSX   0x1E /* R/W X-axis offset */

Definition at line 26 of file adxl34x.c.

#define OFSY   0x1F /* R/W Y-axis offset */

Definition at line 27 of file adxl34x.c.

#define OFSZ   0x20 /* R/W Z-axis offset */

Definition at line 28 of file adxl34x.c.

#define ORIENT   0x3C /* R Orientation status */

Definition at line 58 of file adxl34x.c.

#define ORIENT_CONF   0x3B /* R/W Orientation configuration */

Definition at line 57 of file adxl34x.c.

#define ORIENT_DEADZONE (   x)    (((x) & 0x7) << 4)

Definition at line 156 of file adxl34x.c.

#define ORIENT_DIVISOR (   x)    ((x) & 0x7)

Definition at line 157 of file adxl34x.c.

#define OVERRUN   (1 << 0)

Definition at line 72 of file adxl34x.c.

#define PCTL_AUTO_SLEEP   (1 << 4)

Definition at line 105 of file adxl34x.c.

#define PCTL_LINK   (1 << 5)

Definition at line 104 of file adxl34x.c.

#define PCTL_MEASURE   (1 << 3)

Definition at line 106 of file adxl34x.c.

#define PCTL_SLEEP   (1 << 2)

Definition at line 107 of file adxl34x.c.

#define PCTL_WAKEUP (   x)    ((x) & 0x3)

Definition at line 108 of file adxl34x.c.

#define POWER_CTL   0x2D /* R/W Power saving features control */

Definition at line 42 of file adxl34x.c.

#define RANGE (   x)    ((x) & 0x3)

Definition at line 116 of file adxl34x.c.

#define RANGE_PM_16g   3

Definition at line 120 of file adxl34x.c.

#define RANGE_PM_2g   0

Definition at line 117 of file adxl34x.c.

#define RANGE_PM_4g   1

Definition at line 118 of file adxl34x.c.

#define RANGE_PM_8g   2

Definition at line 119 of file adxl34x.c.

#define RATE (   x)    ((x) & 0xF)

Definition at line 101 of file adxl34x.c.

#define SAMPLES (   x)    ((x) & 0x1F)

Definition at line 141 of file adxl34x.c.

#define SELF_TEST   (1 << 7)

Definition at line 111 of file adxl34x.c.

#define SINGLE_TAP   (1 << 6)

Definition at line 66 of file adxl34x.c.

#define SPI   (1 << 6)

Definition at line 112 of file adxl34x.c.

#define SUPPRESS   (1 << 3)

Definition at line 85 of file adxl34x.c.

#define TAP_AXES   0x2A /* R/W Axis control for tap/double tap */

Definition at line 39 of file adxl34x.c.

#define TAP_SIGN   0x3A /* R Sign and source for tap/double tap */

Definition at line 55 of file adxl34x.c.

#define TAP_X_EN   (1 << 2)

Definition at line 86 of file adxl34x.c.

#define TAP_X_SRC   (1 << 2)

Definition at line 95 of file adxl34x.c.

#define TAP_Y_EN   (1 << 1)

Definition at line 87 of file adxl34x.c.

#define TAP_Y_SRC   (1 << 1)

Definition at line 96 of file adxl34x.c.

#define TAP_Z_EN   (1 << 0)

Definition at line 88 of file adxl34x.c.

#define TAP_Z_SRC   (1 << 0)

Definition at line 97 of file adxl34x.c.

#define THRESH_ACT   0x24 /* R/W Activity threshold */

Definition at line 32 of file adxl34x.c.

#define THRESH_FF   0x28 /* R/W Free-fall threshold */

Definition at line 37 of file adxl34x.c.

#define THRESH_INACT   0x25 /* R/W Inactivity threshold */

Definition at line 33 of file adxl34x.c.

#define THRESH_TAP   0x1D /* R/W Tap threshold */

Definition at line 25 of file adxl34x.c.

#define TIME_FF   0x29 /* R/W Free-fall time */

Definition at line 38 of file adxl34x.c.

#define TIME_INACT   0x26 /* R/W Inactivity time */

Definition at line 34 of file adxl34x.c.

#define TRIGGER   (1 << 5)

Definition at line 140 of file adxl34x.c.

#define WATERMARK   (1 << 1)

Definition at line 71 of file adxl34x.c.

#define WINDOW   0x23 /* R/W Tap window */

Definition at line 31 of file adxl34x.c.

#define XSIGN   (1 << 6)

Definition at line 148 of file adxl34x.c.

#define XTAP   (1 << 3)

Definition at line 151 of file adxl34x.c.

#define YSIGN   (1 << 5)

Definition at line 149 of file adxl34x.c.

#define YTAP   (1 << 2)

Definition at line 152 of file adxl34x.c.

#define ZSIGN   (1 << 4)

Definition at line 150 of file adxl34x.c.

#define ZTAP   (1 << 1)

Definition at line 153 of file adxl34x.c.

Function Documentation

struct adxl34x* adxl34x_probe ( struct device dev,
int  irq,
bool  fifo_delay_default,
const struct adxl34x_bus_ops bops 
)
read

Definition at line 692 of file adxl34x.c.

int adxl34x_remove ( struct adxl34x ac)

Definition at line 901 of file adxl34x.c.

void adxl34x_resume ( struct adxl34x ac)

Definition at line 429 of file adxl34x.c.

void adxl34x_suspend ( struct adxl34x ac)

Definition at line 416 of file adxl34x.c.

EXPORT_SYMBOL_GPL ( adxl34x_suspend  )
EXPORT_SYMBOL_GPL ( adxl34x_resume  )
EXPORT_SYMBOL_GPL ( adxl34x_probe  )
EXPORT_SYMBOL_GPL ( adxl34x_remove  )
MODULE_AUTHOR ( "Michael Hennerich <[email protected]>"  )
MODULE_DESCRIPTION ( "ADXL345/346 Three-Axis Digital Accelerometer Driver"  )
MODULE_LICENSE ( "GPL"  )