📄 lis3l02_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Procyon AVRlib: lis3l02.h Source File</title><link href="dox.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.2 --><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></div><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>00002 <span class="comment">//*****************************************************************************</span>00003 <span class="comment">//</span>00004 <span class="comment">// File Name : 'lis3l02.h'</span>00005 <span class="comment">// Title : ST LIS3L02 3-axis I2C Accelerometer Library</span>00006 <span class="comment">// Author : Pascal Stang - Copyright (C) 2004</span>00007 <span class="comment">// Created : 2004.10.23</span>00008 <span class="comment">// Revised : 2004.12.14</span>00009 <span class="comment">// Version : 0.1</span>00010 <span class="comment">// Target MCU : Atmel AVR Series</span>00011 <span class="comment">// Editor Tabs : 4</span>00012 <span class="comment">//</span>00013 <span class="comment">// NOTE: This code is currently below version 1.0, and therefore is considered</span>00014 <span class="comment">// to be lacking in some functionality or documentation, or may not be fully</span>00015 <span class="comment">// tested. Nonetheless, you can expect most functions to work.</span>00016 <span class="comment">//</span><span class="comment"></span>00017 <span class="comment">/// \ingroup driver_hw</span>00018 <span class="comment">/// \defgroup lis3l02 ST LIS3L02 3-axis I2C Accelerometer Library (lis3l02.c)</span>00019 <span class="comment">/// \code #include "lis3l02.h" \endcode</span>00020 <span class="comment">/// \par Overview</span>00021 <span class="comment">/// This library provides an interface to the ST LIS3L02 integrated 3-axis</span>00022 <span class="comment">/// accelerometer. The LIS3L02 has a built-in A/D converter to capture analog</span>00023 <span class="comment">/// acceleration data and make it available over an I2C interface.</span>00024 <span class="comment"></span><span class="comment">//</span>00025 <span class="comment">// This code is distributed under the GNU Public License</span>00026 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span>00027 <span class="comment">//</span>00028 <span class="comment">//*****************************************************************************</span>00029 00030 <span class="preprocessor">#ifndef LIS3L02_H</span>00031 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_H</span>00032 <span class="preprocessor"></span>00033 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span>00034 00035 <span class="comment">// constants/macros/typdefs</span>00036 <span class="preprocessor">#define LIS3L02_I2C_ADDR 0x3A //< Base I2C address of LIS3L02 device</span>00037 <span class="preprocessor"></span>00038 <span class="comment">// LIS3L02 register address defines</span>00039 <span class="preprocessor">#define LIS3L02_REG_OFFSETX 0x16 //< LIS3L02 X-axis digital offset trim</span>00040 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_OFFSETY 0x17 //< LIS3L02 Y-axis digital offset trim</span>00041 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_OFFSETZ 0x18 //< LIS3L02 Z-axis digital offset trim</span>00042 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_GAINX 0x19 //< LIS3L02 X-axis digital gain trim</span>00043 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_GAINY 0x1A //< LIS3L02 Y-axis digital gain trim</span>00044 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_GAINZ 0x1B //< LIS3L02 Z-axis digital gain trim</span>00045 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_CTRLREG1 0x20 //< LIS3L02 interface/operation control</span>00046 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_CTRLREG2 0x21 //< LIS3L02 interface/operation control</span>00047 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_WAKEUPCFG 0x23 //< LIS3L02 interrupt/wakeup config</span>00048 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_WAKEUPSRC 0x24 //< LIS3L02 interrupt/wakeup source indicator</span>00049 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_WAKEUPACK 0x25 //< LIS3L02 wakeup source clear</span>00050 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_STATUS 0x27 //< LIS3L02 Accelerometer Status</span>00051 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_OUTXL 0x28 //< LIS3L02 Accelerometer X Output Low-byte</span>00052 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_OUTXH 0x29 //< LIS3L02 Accelerometer X Output High-byte</span>00053 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_OUTYL 0x2A //< LIS3L02 Accelerometer Y Output Low-byte</span>00054 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_OUTYH 0x2B //< LIS3L02 Accelerometer Y Output High-byte</span>00055 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_OUTZL 0x2C //< LIS3L02 Accelerometer Z Output Low-byte</span>00056 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_OUTZH 0x2D //< LIS3L02 Accelerometer Z Output High-byte</span>00057 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_THSL 0x2E //< LIS3L02 Accelerometer Threshold Low-byte</span>00058 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_THSH 0x2F //< LIS3L02 Accelerometer Threshold High-byte</span>00059 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_REG_MULTIREAD 0x80 //< LIS3L02 Mutliple Read Bit</span>00060 <span class="preprocessor"></span>00061 <span class="comment">// LIS3L02 control register 1 bit defines</span>00062 <span class="preprocessor">#define LIS3L02_CTRLREG1_XEN 0x01 //< LIS3L02 CtrlReg1 X-axis Enable</span>00063 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_CTRLREG1_YEN 0x02 //< LIS3L02 CtrlReg1 Y-axis Enable</span>00064 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_CTRLREG1_ZEN 0x04 //< LIS3L02 CtrlReg1 Z-axis Enable</span>00065 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_CTRLREG1_ST 0x08 //< LIS3L02 CtrlReg1 Self-Test Enable</span>00066 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_CTRLREG1_DF0 0x10 //< LIS3L02 CtrlReg1 Decimation Factor 0</span>00067 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_CTRLREG1_DF1 0x20 //< LIS3L02 CtrlReg1 Decimation Factor 0</span>00068 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_CTRLREG1_PD0 0x40 //< LIS3L02 CtrlReg1 Power-down Control 0</span>00069 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_CTRLREG1_PD1 0x80 //< LIS3L02 CtrlReg1 Power-down Control 1</span>00070 <span class="preprocessor"></span>00071 <span class="comment">// LIS3L02 control register 2 bit defines</span>00072 <span class="preprocessor">#define LIS3L02_CTRLREG2_DAS 0x01 //< LIS3L02 CtrlReg2 Data Alignment Selection</span>00073 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_CTRLREG2_SIM 0x02 //< LIS3L02 CtrlReg2 SPI Mode Select</span>00074 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_CTRLREG2_DRDY 0x04 //< LIS3L02 CtrlReg2 Enable Data-Ready generation</span>00075 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_CTRLREG2_IEN 0x08 //< LIS3L02 CtrlReg2 Interrupt Enable</span>00076 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_CTRLREG2_BOOT 0x10 //< LIS3L02 CtrlReg2 Reboot from memory</span>00077 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_CTRLREG2_FS 0x80 //< LIS3L02 CtrlReg2 Full-scale Select (0=2g, 1=6g)</span>00078 <span class="preprocessor"></span>00079 <span class="comment">// LIS3L02 WAKEUPCFG register bit defines</span>00080 <span class="preprocessor">#define LIS3L02_WAKEUPCFG_MXL 0x01 //< LIS3L02 WAKEUPCFG Mask X Low Interrupt</span>00081 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_WAKEUPCFG_MXH 0x02 //< LIS3L02 WAKEUPCFG Mask X High Interrupt</span>00082 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_WAKEUPCFG_MYL 0x04 //< LIS3L02 WAKEUPCFG Mask Y Low Interrupt</span>00083 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_WAKEUPCFG_MYH 0x08 //< LIS3L02 WAKEUPCFG Mask Y High Interrupt</span>00084 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_WAKEUPCFG_MZL 0x10 //< LIS3L02 WAKEUPCFG Mask Z Low Interrupt</span>00085 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_WAKEUPCFG_MZH 0x20 //< LIS3L02 WAKEUPCFG Mask Z High Interrupt</span>00086 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_WAKEUPCFG_LIR 0x40 //< LIS3L02 WAKEUPCFG Latch Intr Request</span>00087 <span class="preprocessor"></span>00088 <span class="comment">// LIS3L02 WAKEUPSRC register bit defines</span>00089 <span class="preprocessor">#define LIS3L02_WAKEUPSRC_XL 0x01 //< LIS3L02 WAKEUPSRC X Low Interrupt</span>00090 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_WAKEUPSRC_XH 0x02 //< LIS3L02 WAKEUPSRC X High Interrupt</span>00091 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_WAKEUPSRC_YL 0x04 //< LIS3L02 WAKEUPSRC Y Low Interrupt</span>00092 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_WAKEUPSRC_YH 0x08 //< LIS3L02 WAKEUPSRC Y High Interrupt</span>00093 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_WAKEUPSRC_ZL 0x10 //< LIS3L02 WAKEUPSRC Z Low Interrupt</span>00094 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_WAKEUPSRC_ZH 0x20 //< LIS3L02 WAKEUPSRC Z High Interrupt</span>00095 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_WAKEUPSRC_IA 0x40 //< LIS3L02 WAKEUPSRC Interrupt Active</span>00096 <span class="preprocessor"></span>00097 <span class="comment">// LIS3L02 WAKEUPSRC register bit defines</span>00098 <span class="preprocessor">#define LIS3L02_STATUS_XDA 0x01 //< LIS3L02 STATUS X New Data Available</span>00099 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_STATUS_YDA 0x02 //< LIS3L02 STATUS Y New Data Available</span>00100 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_STATUS_ZDA 0x04 //< LIS3L02 STATUS Z New Data Available</span>00101 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_STATUS_ZYXDA 0x08 //< LIS3L02 STATUS XYZ New Data Available</span>00102 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_STATUS_XOR 0x10 //< LIS3L02 STATUS X-axis Data Overrun</span>00103 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_STATUS_YOR 0x20 //< LIS3L02 STATUS Y-axis Data Overrun</span>00104 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_STATUS_ZOR 0x40 //< LIS3L02 STATUS Z-axis Data Overrun</span>00105 <span class="preprocessor"></span><span class="preprocessor">#define LIS3L02_STATUS_ZYXOR 0x80 //< LIS3L02 STATUS XYZ-axis Data Overrun</span>00106 <span class="preprocessor"></span>00107 <span class="comment">// functions</span>00108 <span class="comment"></span>00109 <span class="comment">//! Initialize the LIS3L02 chip.</span>00110 <span class="comment">/// returns:</span>00111 <span class="comment">/// 0 if successful, </span>00112 <span class="comment">/// non-zero if unsuccessful (chip not present).</span>00113 <span class="comment"></span>u08 <a class="code" href="lis3l02_8c.html#a0">lis3l02Init</a>(<span class="keywordtype">void</span>);00114 <span class="comment"></span>00115 <span class="comment">//! Reset the LIS3L02 chip.</span>00116 <span class="comment"></span>u08 <a class="code" href="lis3l02_8c.html#a1">lis3l02Reset</a>(<span class="keywordtype">void</span>);00117 <span class="comment"></span>00118 <span class="comment">//! Read a LIS3L02 register.</span>00119 <span class="comment"></span>u08 <a class="code" href="lis3l02_8c.html#a2">lis3l02ReadReg</a>(u08 reg);00120 <span class="comment"></span>00121 <span class="comment">//! Write a LIS3L02 register.</span>00122 <span class="comment"></span>u08 <a class="code" href="lis3l02_8c.html#a3">lis3l02WriteReg</a>(u08 reg, u08 data);00123 <span class="comment"></span>00124 <span class="comment">//! Get an acceleration reading from the LIS3L02 sensor.</span>00125 <span class="comment"></span>s16 <a class="code" href="lis3l02_8c.html#a4">lis3l02GetAccel</a>(u08 chxyz);00126 00127 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Aug 22 04:29:27 2005 for Procyon AVRlib by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -