Contiki 2.5
mems_regs.h
1 /******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
2 * File Name : mems_regs.h
3 * Author : MCD Application Team
4 * Version : V1.0
5 * Date : January 2010
6 * Description : stm32w108 mems registers
7 ********************************************************************************
8 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 *******************************************************************************/
15 
16 #ifndef _MEMS_REGS_H_
17 #define _MEMS_REGS_H_
18 
19 /* Private include ------------------------------------------------------------*/
20 
21 /* Private define ------------------------------------------------------------*/
22 
23 //---Size of MEMs data---
24 #define MEMS_DATA_SIZE 6
25 
26 //---address of slave I want to communicate with---
27 #define kLIS3L02DQ_SLAVE_ADDR 0x38
28 
29 //-----------------------------------------------------------------------------
30 //---accelerometer register addresses---
31 #define OFFSET_X 0x16
32 #define OFFSET_Y 0x17
33 #define OFFSET_Z 0x18
34 #define GAIN_X 0x19
35 #define GAIN_Y 0x1A
36 #define GAIN_Z 0x1B
37 #define CTRL_REG1 0x20
38 #define CTRL_REG2 0x21
39 #define STATUS_REG 0x27
40 #define OUTX_L 0x28
41 #define OUTX_H 0x29
42 #define OUTY_L 0x2A
43 #define OUTY_H 0x2B
44 #define OUTZ_L 0x2C
45 #define OUTZ_H 0x2D
46 #define FF_WU_CFG 0x30
47 #define FF_WU_SRC 0x31
48 #define FF_WU_ACK 0x32
49 #define FF_WU_THS_L 0x34
50 #define FF_WU_THS_H 0x35
51 #define FF_WU_DURATION 0x36
52 #define DD_CFG 0x38
53 #define DD_SRC 0x39
54 #define DD_ACK 0x3A
55 #define DD_THSI_L 0x3C
56 #define DD_THSI_H 0x3D
57 #define DD_THSE_L 0x3E
58 #define DD_THSE_H 0x3F
59 
60 // Communication control settings
61 // I2C
62 #define REPETIR 0x80
63 // SPI
64 #define MEMS_SPI_WRITE 0x00
65 #define MEMS_SPI_READ 0x80
66 #define MEMS_SPI_MULTIPLE_BYTES 0x40
67 
68 //-----------------------------------------------------------------------------
69 //---Settings for CTRL_REG1---
70 
71 // Power Down Control (PD)
72 #define LIS_PD_OFF 0x00
73 #define LIS_PD_ON 0x40
74 
75 // Decimation Factor Control (DF)
76 #define LIS_DF_BY128 0x00
77 #define LIS_DF_BY64 0x10
78 #define LIS_DF_BY32 0x20
79 #define LIS_DF_BY8 0x30
80 
81 // Self Test
82 #define LIS_ST_NORMAL 0x00
83 #define LIS_ST_TEST 0x08
84 
85 // Enable Axis
86 #define LIS_EA_ALL 0x07
87 
88 //-----------------------------------------------------------------------------
89 //---Settings for CTRL_REG2---
90 
91 // Full Scale (FS)
92 #define LIS_FS_2G 0x00
93 #define LIS_FS_6G 0x80
94 
95 // Block Data Update (BDU)
96 #define LIS_BDU_CONTINUOUS 0x00
97 #define LIS_BDU_WAIT 0x40
98 
99 // Big/Little Endian Selection (BLE)
100 #define LIS_BLE_LE 0x00
101 #define LIS_BLE_BE 0x20
102 
103 // Data Alignment Selection DAS
104 #define LIS_DAS_12BIT 0x00
105 #define LIS_DAS_16BIT 0x01
106 
107 // Interrupt Enable
108 #define LIS_INTR_DISABLE 0x00
109 #define LIS_INTR_ENABLE 0x08
110 
111 // Data Ready Enable
112 #define LIS_DRDY_DISABLE 0x00
113 #define LIS_DRDY_ENABLE 0x04
114 
115 //-----------------------------------------------------------------------------
116 
117 #define LIS_BLE_XX LIS_BLE_BE
118 
119 
120 /* Private Functions Prototypes ----------------------------------------------*/
121 
122 //*********************i2c_read_reg***********************//
123 //----------Reads a register on the I2C target------------//
124 //------slave addr is the is the I2C target device--------//
125 //-reg_addr is the address of the register to be written--//
126 //-pBuffer is the storage destination for the read data---//
127 //-NoOfBytes is the amount of data to read----------------//
128 int8u i2c_read_reg (int8u slave_addr, int8u reg_addr, int8u *pBuffer, int8u NoOfBytes);
129 
130 //*********************i2c_write_reg**********************//
131 //----------Writes a register on the I2C target-----------//
132 //------slave addr is the is the I2C target device--------//
133 //-reg_addr is the address of the register to be written--//
134 //-reg_value is the value of the register to be written---//
135 int8u i2c_write_reg (int8u slave_addr, int8u reg_addr, int8u reg_value);
136 
137 #endif /* _MEMS_REGS_H_ */
138 
139 /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/