Line No. | Rev | Author | Line |
---|---|---|---|
1 | 6 | kaklik | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
||
3 | <title>Procyon AVRlib: lis3l02.h Source File</title> |
||
4 | <link href="dox.css" rel="stylesheet" type="text/css"> |
||
5 | </head><body> |
||
6 | <!-- Generated by Doxygen 1.4.2 --> |
||
7 | <div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div> |
||
8 | <h1>lis3l02.h</h1><a href="lis3l02_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file lis3l02.h \brief ST LIS3L02 3-axis I2C Accelerometer Library. */</span> |
||
9 | 00002 <span class="comment">//*****************************************************************************</span> |
||
10 | 00003 <span class="comment">//</span> |
||
11 | 00004 <span class="comment">// File Name : 'lis3l02.h'</span> |
||
12 | 00005 <span class="comment">// Title : ST LIS3L02 3-axis I2C Accelerometer Library</span> |
||
13 | 00006 <span class="comment">// Author : Pascal Stang - Copyright (C) 2004</span> |
||
14 | 00007 <span class="comment">// Created : 2004.10.23</span> |
||
15 | 00008 <span class="comment">// Revised : 2004.12.14</span> |
||
16 | 00009 <span class="comment">// Version : 0.1</span> |
||
17 | 00010 <span class="comment">// Target MCU : Atmel AVR Series</span> |
||
18 | 00011 <span class="comment">// Editor Tabs : 4</span> |
||
19 | 00012 <span class="comment">//</span> |
||
20 | 00013 <span class="comment">// NOTE: This code is currently below version 1.0, and therefore is considered</span> |
||
21 | 00014 <span class="comment">// to be lacking in some functionality or documentation, or may not be fully</span> |
||
22 | 00015 <span class="comment">// tested. Nonetheless, you can expect most functions to work.</span> |
||
23 | 00016 <span class="comment">//</span><span class="comment"></span> |
||
24 | 00017 <span class="comment">/// \ingroup driver_hw</span> |
||
25 | 00018 <span class="comment">/// \defgroup lis3l02 ST LIS3L02 3-axis I2C Accelerometer Library (lis3l02.c)</span> |
||
26 | 00019 <span class="comment">/// \code #include "lis3l02.h" \endcode</span> |
||
27 | 00020 <span class="comment">/// \par Overview</span> |
||
28 | 00021 <span class="comment">/// This library provides an interface to the ST LIS3L02 integrated 3-axis</span> |
||
29 | 00022 <span class="comment">/// accelerometer. The LIS3L02 has a built-in A/D converter to capture analog</span> |
||
30 | 00023 <span class="comment">/// acceleration data and make it available over an I2C interface.</span> |
||
31 | 00024 <span class="comment"></span><span class="comment">//</span> |
||
32 | 00025 <span class="comment">// This code is distributed under the GNU Public License</span> |
||
33 | 00026 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span> |
||
34 | 00027 <span class="comment">//</span> |
||
35 | 00028 <span class="comment">//*****************************************************************************</span> |
||
36 | 00029 |
||
37 | 00030 <span class="preprocessor">#ifndef LIS3L02_H</span> |
||
38 | 00031 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_H</span> |
||
39 | 00032 <span class="preprocessor"></span> |
||
40 | 00033 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span> |
||
41 | 00034 |
||
42 | 00035 <span class="comment">// constants/macros/typdefs</span> |
||
43 | <a name="l00036"></a><a class="code" href="lis3l02_8h.html#a0">00036</a> <span class="preprocessor">#define LIS3L02_I2C_ADDR 0x3A </span><span class="comment">///< Base I2C address of LIS3L02 device</span> |
||
44 | 00037 <span class="comment"></span> |
||
45 | 00038 <span class="comment">// LIS3L02 register address defines</span> |
||
46 | <a name="l00039"></a><a class="code" href="lis3l02_8h.html#a1">00039</a> <span class="preprocessor">#define LIS3L02_REG_OFFSETX 0x16 </span><span class="comment">///< LIS3L02 X-axis digital offset trim</span> |
||
47 | <a name="l00040"></a><a class="code" href="lis3l02_8h.html#a2">00040</a> <span class="comment"></span>#define LIS3L02_REG_OFFSETY 0x17 <span class="comment">///< LIS3L02 Y-axis digital offset trim</span> |
||
48 | <a name="l00041"></a><a class="code" href="lis3l02_8h.html#a3">00041</a> <span class="comment"></span>#define LIS3L02_REG_OFFSETZ 0x18 <span class="comment">///< LIS3L02 Z-axis digital offset trim</span> |
||
49 | <a name="l00042"></a><a class="code" href="lis3l02_8h.html#a4">00042</a> <span class="comment"></span>#define LIS3L02_REG_GAINX 0x19 <span class="comment">///< LIS3L02 X-axis digital gain trim</span> |
||
50 | <a name="l00043"></a><a class="code" href="lis3l02_8h.html#a5">00043</a> <span class="comment"></span>#define LIS3L02_REG_GAINY 0x1A <span class="comment">///< LIS3L02 Y-axis digital gain trim</span> |
||
51 | <a name="l00044"></a><a class="code" href="lis3l02_8h.html#a6">00044</a> <span class="comment"></span>#define LIS3L02_REG_GAINZ 0x1B <span class="comment">///< LIS3L02 Z-axis digital gain trim</span> |
||
52 | <a name="l00045"></a><a class="code" href="lis3l02_8h.html#a7">00045</a> <span class="comment"></span>#define LIS3L02_REG_CTRLREG1 0x20 <span class="comment">///< LIS3L02 interface/operation control</span> |
||
53 | <a name="l00046"></a><a class="code" href="lis3l02_8h.html#a8">00046</a> <span class="comment"></span>#define LIS3L02_REG_CTRLREG2 0x21 <span class="comment">///< LIS3L02 interface/operation control</span> |
||
54 | <a name="l00047"></a><a class="code" href="lis3l02_8h.html#a9">00047</a> <span class="comment"></span>#define LIS3L02_REG_WAKEUPCFG 0x23 <span class="comment">///< LIS3L02 interrupt/wakeup config</span> |
||
55 | <a name="l00048"></a><a class="code" href="lis3l02_8h.html#a10">00048</a> <span class="comment"></span>#define LIS3L02_REG_WAKEUPSRC 0x24 <span class="comment">///< LIS3L02 interrupt/wakeup source indicator</span> |
||
56 | <a name="l00049"></a><a class="code" href="lis3l02_8h.html#a11">00049</a> <span class="comment"></span>#define LIS3L02_REG_WAKEUPACK 0x25 <span class="comment">///< LIS3L02 wakeup source clear</span> |
||
57 | <a name="l00050"></a><a class="code" href="lis3l02_8h.html#a12">00050</a> <span class="comment"></span>#define LIS3L02_REG_STATUS 0x27 <span class="comment">///< LIS3L02 Accelerometer Status</span> |
||
58 | <a name="l00051"></a><a class="code" href="lis3l02_8h.html#a13">00051</a> <span class="comment"></span>#define LIS3L02_REG_OUTXL 0x28 <span class="comment">///< LIS3L02 Accelerometer X Output Low-byte</span> |
||
59 | <a name="l00052"></a><a class="code" href="lis3l02_8h.html#a14">00052</a> <span class="comment"></span>#define LIS3L02_REG_OUTXH 0x29 <span class="comment">///< LIS3L02 Accelerometer X Output High-byte</span> |
||
60 | <a name="l00053"></a><a class="code" href="lis3l02_8h.html#a15">00053</a> <span class="comment"></span>#define LIS3L02_REG_OUTYL 0x2A <span class="comment">///< LIS3L02 Accelerometer Y Output Low-byte</span> |
||
61 | <a name="l00054"></a><a class="code" href="lis3l02_8h.html#a16">00054</a> <span class="comment"></span>#define LIS3L02_REG_OUTYH 0x2B <span class="comment">///< LIS3L02 Accelerometer Y Output High-byte</span> |
||
62 | <a name="l00055"></a><a class="code" href="lis3l02_8h.html#a17">00055</a> <span class="comment"></span>#define LIS3L02_REG_OUTZL 0x2C <span class="comment">///< LIS3L02 Accelerometer Z Output Low-byte</span> |
||
63 | <a name="l00056"></a><a class="code" href="lis3l02_8h.html#a18">00056</a> <span class="comment"></span>#define LIS3L02_REG_OUTZH 0x2D <span class="comment">///< LIS3L02 Accelerometer Z Output High-byte</span> |
||
64 | <a name="l00057"></a><a class="code" href="lis3l02_8h.html#a19">00057</a> <span class="comment"></span>#define LIS3L02_REG_THSL 0x2E <span class="comment">///< LIS3L02 Accelerometer Threshold Low-byte</span> |
||
65 | <a name="l00058"></a><a class="code" href="lis3l02_8h.html#a20">00058</a> <span class="comment"></span>#define LIS3L02_REG_THSH 0x2F <span class="comment">///< LIS3L02 Accelerometer Threshold High-byte</span> |
||
66 | <a name="l00059"></a><a class="code" href="lis3l02_8h.html#a21">00059</a> <span class="comment"></span>#define LIS3L02_REG_MULTIREAD 0x80 <span class="comment">///< LIS3L02 Mutliple Read Bit</span> |
||
67 | 00060 <span class="comment"></span> |
||
68 | 00061 <span class="comment">// LIS3L02 control register 1 bit defines</span> |
||
69 | <a name="l00062"></a><a class="code" href="lis3l02_8h.html#a22">00062</a> <span class="preprocessor">#define LIS3L02_CTRLREG1_XEN 0x01 </span><span class="comment">///< LIS3L02 CtrlReg1 X-axis Enable</span> |
||
70 | <a name="l00063"></a><a class="code" href="lis3l02_8h.html#a23">00063</a> <span class="comment"></span>#define LIS3L02_CTRLREG1_YEN 0x02 <span class="comment">///< LIS3L02 CtrlReg1 Y-axis Enable</span> |
||
71 | <a name="l00064"></a><a class="code" href="lis3l02_8h.html#a24">00064</a> <span class="comment"></span>#define LIS3L02_CTRLREG1_ZEN 0x04 <span class="comment">///< LIS3L02 CtrlReg1 Z-axis Enable</span> |
||
72 | <a name="l00065"></a><a class="code" href="lis3l02_8h.html#a25">00065</a> <span class="comment"></span>#define LIS3L02_CTRLREG1_ST 0x08 <span class="comment">///< LIS3L02 CtrlReg1 Self-Test Enable</span> |
||
73 | <a name="l00066"></a><a class="code" href="lis3l02_8h.html#a26">00066</a> <span class="comment"></span>#define LIS3L02_CTRLREG1_DF0 0x10 <span class="comment">///< LIS3L02 CtrlReg1 Decimation Factor 0</span> |
||
74 | <a name="l00067"></a><a class="code" href="lis3l02_8h.html#a27">00067</a> <span class="comment"></span>#define LIS3L02_CTRLREG1_DF1 0x20 <span class="comment">///< LIS3L02 CtrlReg1 Decimation Factor 0</span> |
||
75 | <a name="l00068"></a><a class="code" href="lis3l02_8h.html#a28">00068</a> <span class="comment"></span>#define LIS3L02_CTRLREG1_PD0 0x40 <span class="comment">///< LIS3L02 CtrlReg1 Power-down Control 0</span> |
||
76 | <a name="l00069"></a><a class="code" href="lis3l02_8h.html#a29">00069</a> <span class="comment"></span>#define LIS3L02_CTRLREG1_PD1 0x80 <span class="comment">///< LIS3L02 CtrlReg1 Power-down Control 1</span> |
||
77 | 00070 <span class="comment"></span> |
||
78 | 00071 <span class="comment">// LIS3L02 control register 2 bit defines</span> |
||
79 | <a name="l00072"></a><a class="code" href="lis3l02_8h.html#a30">00072</a> <span class="preprocessor">#define LIS3L02_CTRLREG2_DAS 0x01 </span><span class="comment">///< LIS3L02 CtrlReg2 Data Alignment Selection</span> |
||
80 | <a name="l00073"></a><a class="code" href="lis3l02_8h.html#a31">00073</a> <span class="comment"></span>#define LIS3L02_CTRLREG2_SIM 0x02 <span class="comment">///< LIS3L02 CtrlReg2 SPI Mode Select</span> |
||
81 | <a name="l00074"></a><a class="code" href="lis3l02_8h.html#a32">00074</a> <span class="comment"></span>#define LIS3L02_CTRLREG2_DRDY 0x04 <span class="comment">///< LIS3L02 CtrlReg2 Enable Data-Ready generation</span> |
||
82 | <a name="l00075"></a><a class="code" href="lis3l02_8h.html#a33">00075</a> <span class="comment"></span>#define LIS3L02_CTRLREG2_IEN 0x08 <span class="comment">///< LIS3L02 CtrlReg2 Interrupt Enable</span> |
||
83 | <a name="l00076"></a><a class="code" href="lis3l02_8h.html#a34">00076</a> <span class="comment"></span>#define LIS3L02_CTRLREG2_BOOT 0x10 <span class="comment">///< LIS3L02 CtrlReg2 Reboot from memory</span> |
||
84 | <a name="l00077"></a><a class="code" href="lis3l02_8h.html#a35">00077</a> <span class="comment"></span>#define LIS3L02_CTRLREG2_FS 0x80 <span class="comment">///< LIS3L02 CtrlReg2 Full-scale Select (0=2g, 1=6g)</span> |
||
85 | 00078 <span class="comment"></span> |
||
86 | 00079 <span class="comment">// LIS3L02 WAKEUPCFG register bit defines</span> |
||
87 | <a name="l00080"></a><a class="code" href="lis3l02_8h.html#a36">00080</a> <span class="preprocessor">#define LIS3L02_WAKEUPCFG_MXL 0x01 </span><span class="comment">///< LIS3L02 WAKEUPCFG Mask X Low Interrupt</span> |
||
88 | <a name="l00081"></a><a class="code" href="lis3l02_8h.html#a37">00081</a> <span class="comment"></span>#define LIS3L02_WAKEUPCFG_MXH 0x02 <span class="comment">///< LIS3L02 WAKEUPCFG Mask X High Interrupt</span> |
||
89 | <a name="l00082"></a><a class="code" href="lis3l02_8h.html#a38">00082</a> <span class="comment"></span>#define LIS3L02_WAKEUPCFG_MYL 0x04 <span class="comment">///< LIS3L02 WAKEUPCFG Mask Y Low Interrupt</span> |
||
90 | <a name="l00083"></a><a class="code" href="lis3l02_8h.html#a39">00083</a> <span class="comment"></span>#define LIS3L02_WAKEUPCFG_MYH 0x08 <span class="comment">///< LIS3L02 WAKEUPCFG Mask Y High Interrupt</span> |
||
91 | <a name="l00084"></a><a class="code" href="lis3l02_8h.html#a40">00084</a> <span class="comment"></span>#define LIS3L02_WAKEUPCFG_MZL 0x10 <span class="comment">///< LIS3L02 WAKEUPCFG Mask Z Low Interrupt</span> |
||
92 | <a name="l00085"></a><a class="code" href="lis3l02_8h.html#a41">00085</a> <span class="comment"></span>#define LIS3L02_WAKEUPCFG_MZH 0x20 <span class="comment">///< LIS3L02 WAKEUPCFG Mask Z High Interrupt</span> |
||
93 | <a name="l00086"></a><a class="code" href="lis3l02_8h.html#a42">00086</a> <span class="comment"></span>#define LIS3L02_WAKEUPCFG_LIR 0x40 <span class="comment">///< LIS3L02 WAKEUPCFG Latch Intr Request</span> |
||
94 | 00087 <span class="comment"></span> |
||
95 | 00088 <span class="comment">// LIS3L02 WAKEUPSRC register bit defines</span> |
||
96 | <a name="l00089"></a><a class="code" href="lis3l02_8h.html#a43">00089</a> <span class="preprocessor">#define LIS3L02_WAKEUPSRC_XL 0x01 </span><span class="comment">///< LIS3L02 WAKEUPSRC X Low Interrupt</span> |
||
97 | <a name="l00090"></a><a class="code" href="lis3l02_8h.html#a44">00090</a> <span class="comment"></span>#define LIS3L02_WAKEUPSRC_XH 0x02 <span class="comment">///< LIS3L02 WAKEUPSRC X High Interrupt</span> |
||
98 | <a name="l00091"></a><a class="code" href="lis3l02_8h.html#a45">00091</a> <span class="comment"></span>#define LIS3L02_WAKEUPSRC_YL 0x04 <span class="comment">///< LIS3L02 WAKEUPSRC Y Low Interrupt</span> |
||
99 | <a name="l00092"></a><a class="code" href="lis3l02_8h.html#a46">00092</a> <span class="comment"></span>#define LIS3L02_WAKEUPSRC_YH 0x08 <span class="comment">///< LIS3L02 WAKEUPSRC Y High Interrupt</span> |
||
100 | <a name="l00093"></a><a class="code" href="lis3l02_8h.html#a47">00093</a> <span class="comment"></span>#define LIS3L02_WAKEUPSRC_ZL 0x10 <span class="comment">///< LIS3L02 WAKEUPSRC Z Low Interrupt</span> |
||
101 | <a name="l00094"></a><a class="code" href="lis3l02_8h.html#a48">00094</a> <span class="comment"></span>#define LIS3L02_WAKEUPSRC_ZH 0x20 <span class="comment">///< LIS3L02 WAKEUPSRC Z High Interrupt</span> |
||
102 | <a name="l00095"></a><a class="code" href="lis3l02_8h.html#a49">00095</a> <span class="comment"></span>#define LIS3L02_WAKEUPSRC_IA 0x40 <span class="comment">///< LIS3L02 WAKEUPSRC Interrupt Active</span> |
||
103 | 00096 <span class="comment"></span> |
||
104 | 00097 <span class="comment">// LIS3L02 WAKEUPSRC register bit defines</span> |
||
105 | <a name="l00098"></a><a class="code" href="lis3l02_8h.html#a50">00098</a> <span class="preprocessor">#define LIS3L02_STATUS_XDA 0x01 </span><span class="comment">///< LIS3L02 STATUS X New Data Available</span> |
||
106 | <a name="l00099"></a><a class="code" href="lis3l02_8h.html#a51">00099</a> <span class="comment"></span>#define LIS3L02_STATUS_YDA 0x02 <span class="comment">///< LIS3L02 STATUS Y New Data Available</span> |
||
107 | <a name="l00100"></a><a class="code" href="lis3l02_8h.html#a52">00100</a> <span class="comment"></span>#define LIS3L02_STATUS_ZDA 0x04 <span class="comment">///< LIS3L02 STATUS Z New Data Available</span> |
||
108 | <a name="l00101"></a><a class="code" href="lis3l02_8h.html#a53">00101</a> <span class="comment"></span>#define LIS3L02_STATUS_ZYXDA 0x08 <span class="comment">///< LIS3L02 STATUS XYZ New Data Available</span> |
||
109 | <a name="l00102"></a><a class="code" href="lis3l02_8h.html#a54">00102</a> <span class="comment"></span>#define LIS3L02_STATUS_XOR 0x10 <span class="comment">///< LIS3L02 STATUS X-axis Data Overrun</span> |
||
110 | <a name="l00103"></a><a class="code" href="lis3l02_8h.html#a55">00103</a> <span class="comment"></span>#define LIS3L02_STATUS_YOR 0x20 <span class="comment">///< LIS3L02 STATUS Y-axis Data Overrun</span> |
||
111 | <a name="l00104"></a><a class="code" href="lis3l02_8h.html#a56">00104</a> <span class="comment"></span>#define LIS3L02_STATUS_ZOR 0x40 <span class="comment">///< LIS3L02 STATUS Z-axis Data Overrun</span> |
||
112 | <a name="l00105"></a><a class="code" href="lis3l02_8h.html#a57">00105</a> <span class="comment"></span>#define LIS3L02_STATUS_ZYXOR 0x80 <span class="comment">///< LIS3L02 STATUS XYZ-axis Data Overrun</span> |
||
113 | 00106 <span class="comment"></span> |
||
114 | 00107 <span class="comment">// functions</span> |
||
115 | 00108 <span class="comment"></span> |
||
116 | 00109 <span class="comment">//! Initialize the LIS3L02 chip.</span> |
||
117 | 00110 <span class="comment">/// returns:</span> |
||
118 | 00111 <span class="comment">/// 0 if successful, </span> |
||
119 | 00112 <span class="comment">/// non-zero if unsuccessful (chip not present).</span> |
||
120 | 00113 <span class="comment"></span>u08 <a class="code" href="lis3l02_8c.html#a0">lis3l02Init</a>(<span class="keywordtype">void</span>); |
||
121 | 00114 <span class="comment"></span> |
||
122 | 00115 <span class="comment">//! Reset the LIS3L02 chip.</span> |
||
123 | 00116 <span class="comment"></span>u08 <a class="code" href="lis3l02_8c.html#a1">lis3l02Reset</a>(<span class="keywordtype">void</span>); |
||
124 | 00117 <span class="comment"></span> |
||
125 | 00118 <span class="comment">//! Read a LIS3L02 register.</span> |
||
126 | 00119 <span class="comment"></span>u08 <a class="code" href="lis3l02_8c.html#a2">lis3l02ReadReg</a>(u08 reg); |
||
127 | 00120 <span class="comment"></span> |
||
128 | 00121 <span class="comment">//! Write a LIS3L02 register.</span> |
||
129 | 00122 <span class="comment"></span>u08 <a class="code" href="lis3l02_8c.html#a3">lis3l02WriteReg</a>(u08 reg, u08 data); |
||
130 | 00123 <span class="comment"></span> |
||
131 | 00124 <span class="comment">//! Get an acceleration reading from the LIS3L02 sensor.</span> |
||
132 | 00125 <span class="comment"></span>s16 <a class="code" href="lis3l02_8c.html#a4">lis3l02GetAccel</a>(u08 chxyz); |
||
133 | 00126 |
||
134 | 00127 <span class="preprocessor">#endif</span> |
||
135 | </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by |
||
136 | <a href="http://www.doxygen.org/index.html"> |
||
137 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address> |
||
138 | </body> |
||
139 | </html> |
Powered by WebSVN v2.8.3