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