mems_regs.h

00001 /******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
00002 * File Name          : mems_regs.h
00003 * Author             : MCD Application Team
00004 * Version            : V1.0
00005 * Date               : January 2010
00006 * Description        : stm32w108 mems registers 
00007 ********************************************************************************
00008 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00009 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
00010 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
00011 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
00012 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
00013 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00014 *******************************************************************************/
00015 
00016 #ifndef _MEMS_REGS_H_
00017 #define _MEMS_REGS_H_
00018 
00019 /* Private include ------------------------------------------------------------*/
00020 
00021 /* Private define ------------------------------------------------------------*/
00022 
00023 //---Size of MEMs data---
00024 #define MEMS_DATA_SIZE 6
00025 
00026 //---address of slave I want to communicate with---
00027 #define kLIS3L02DQ_SLAVE_ADDR    0x38
00028 
00029 //-----------------------------------------------------------------------------
00030 //---accelerometer register addresses---
00031 #define OFFSET_X         0x16
00032 #define OFFSET_Y         0x17
00033 #define OFFSET_Z         0x18
00034 #define GAIN_X           0x19
00035 #define GAIN_Y           0x1A
00036 #define GAIN_Z           0x1B
00037 #define CTRL_REG1        0x20
00038 #define CTRL_REG2        0x21
00039 #define STATUS_REG       0x27
00040 #define OUTX_L           0x28
00041 #define OUTX_H           0x29
00042 #define OUTY_L           0x2A
00043 #define OUTY_H           0x2B
00044 #define OUTZ_L           0x2C
00045 #define OUTZ_H           0x2D
00046 #define FF_WU_CFG        0x30
00047 #define FF_WU_SRC        0x31
00048 #define FF_WU_ACK        0x32
00049 #define FF_WU_THS_L      0x34
00050 #define FF_WU_THS_H      0x35
00051 #define FF_WU_DURATION   0x36
00052 #define DD_CFG           0x38
00053 #define DD_SRC           0x39
00054 #define DD_ACK           0x3A
00055 #define DD_THSI_L        0x3C
00056 #define DD_THSI_H        0x3D
00057 #define DD_THSE_L        0x3E
00058 #define DD_THSE_H        0x3F
00059 
00060 // Communication control settings
00061 // I2C
00062 #define REPETIR          0x80
00063 // SPI
00064 #define MEMS_SPI_WRITE   0x00
00065 #define MEMS_SPI_READ    0x80
00066 #define MEMS_SPI_MULTIPLE_BYTES 0x40
00067 
00068 //-----------------------------------------------------------------------------
00069 //---Settings for CTRL_REG1---
00070 
00071 // Power Down Control (PD)
00072 #define LIS_PD_OFF 0x00
00073 #define LIS_PD_ON  0x40
00074 
00075 // Decimation Factor Control (DF)
00076 #define LIS_DF_BY128 0x00
00077 #define LIS_DF_BY64  0x10
00078 #define LIS_DF_BY32  0x20
00079 #define LIS_DF_BY8   0x30
00080 
00081 // Self Test
00082 #define LIS_ST_NORMAL 0x00
00083 #define LIS_ST_TEST   0x08
00084 
00085 // Enable Axis
00086 #define LIS_EA_ALL    0x07
00087 
00088 //-----------------------------------------------------------------------------
00089 //---Settings for CTRL_REG2---
00090 
00091 // Full Scale (FS)
00092 #define LIS_FS_2G 0x00
00093 #define LIS_FS_6G 0x80
00094 
00095 // Block Data Update (BDU)
00096 #define LIS_BDU_CONTINUOUS 0x00
00097 #define LIS_BDU_WAIT       0x40
00098 
00099 // Big/Little Endian Selection (BLE)
00100 #define LIS_BLE_LE 0x00
00101 #define LIS_BLE_BE 0x20
00102 
00103 // Data Alignment Selection DAS
00104 #define LIS_DAS_12BIT 0x00
00105 #define LIS_DAS_16BIT 0x01
00106 
00107 // Interrupt Enable
00108 #define LIS_INTR_DISABLE 0x00
00109 #define LIS_INTR_ENABLE  0x08
00110 
00111 // Data Ready Enable
00112 #define LIS_DRDY_DISABLE 0x00
00113 #define LIS_DRDY_ENABLE  0x04
00114 
00115 //-----------------------------------------------------------------------------
00116 
00117 #define LIS_BLE_XX LIS_BLE_BE
00118 
00119 
00120 /* Private Functions Prototypes ----------------------------------------------*/
00121 
00122 //*********************i2c_read_reg***********************//
00123 //----------Reads a register on the I2C target------------//
00124 //------slave addr is the is the I2C target device--------//
00125 //-reg_addr is the address of the register to be written--//
00126 //-pBuffer is the storage destination for the read data---//
00127 //-NoOfBytes is the amount of data to read----------------//
00128 int8u i2c_read_reg (int8u slave_addr, int8u reg_addr, int8u *pBuffer, int8u NoOfBytes);
00129 
00130 //*********************i2c_write_reg**********************//
00131 //----------Writes a register on the I2C target-----------//
00132 //------slave addr is the is the I2C target device--------//
00133 //-reg_addr is the address of the register to be written--//
00134 //-reg_value is the value of the register to be written---//
00135 int8u i2c_write_reg (int8u slave_addr, int8u reg_addr, int8u reg_value);
00136 
00137 #endif /* _MEMS_REGS_H_ */
00138 
00139 /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/

Generated on Mon Apr 11 14:23:40 2011 for Contiki 2.5 by  doxygen 1.6.1