Contiki 2.5
mems_regs.h
Go to the documentation of this file.
1 /** @file hal/micro/mems_regs.h
2  * @brief stm32w108 mems registers
3  *
4  * <!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved. -->
5  */
6 
7 #ifndef _MEMS_REGS_H_
8 #define _MEMS_REGS_H_
9 
10 //---Size of MEMs data---
11 #define MEMS_DATA_SIZE 6
12 
13 //---address of slave I want to communicate with---
14 #define kLIS3L02DQ_SLAVE_ADDR 0x38
15 
16 //-----------------------------------------------------------------------------
17 //---accelerometer register addresses---
18 #define OFFSET_X 0x16
19 #define OFFSET_Y 0x17
20 #define OFFSET_Z 0x18
21 #define GAIN_X 0x19
22 #define GAIN_Y 0x1A
23 #define GAIN_Z 0x1B
24 #define CTRL_REG1 0x20
25 #define CTRL_REG2 0x21
26 #define STATUS_REG 0x27
27 #define OUTX_L 0x28
28 #define OUTX_H 0x29
29 #define OUTY_L 0x2A
30 #define OUTY_H 0x2B
31 #define OUTZ_L 0x2C
32 #define OUTZ_H 0x2D
33 #define FF_WU_CFG 0x30
34 #define FF_WU_SRC 0x31
35 #define FF_WU_ACK 0x32
36 #define FF_WU_THS_L 0x34
37 #define FF_WU_THS_H 0x35
38 #define FF_WU_DURATION 0x36
39 #define DD_CFG 0x38
40 #define DD_SRC 0x39
41 #define DD_ACK 0x3A
42 #define DD_THSI_L 0x3C
43 #define DD_THSI_H 0x3D
44 #define DD_THSE_L 0x3E
45 #define DD_THSE_H 0x3F
46 
47 // Communication control settings
48 // I2C
49 #define REPETIR 0x80
50 // SPI
51 #define MEMS_SPI_WRITE 0x00
52 #define MEMS_SPI_READ 0x80
53 #define MEMS_SPI_MULTIPLE_BYTES 0x40
54 
55 //-----------------------------------------------------------------------------
56 //---Settings for CTRL_REG1---
57 
58 // Power Down Control (PD)
59 #define LIS_PD_OFF 0x00
60 #define LIS_PD_ON 0x40
61 
62 // Decimation Factor Control (DF)
63 #define LIS_DF_BY128 0x00
64 #define LIS_DF_BY64 0x10
65 #define LIS_DF_BY32 0x20
66 #define LIS_DF_BY8 0x30
67 
68 // Self Test
69 #define LIS_ST_NORMAL 0x00
70 #define LIS_ST_TEST 0x08
71 
72 // Enable Axis
73 #define LIS_EA_ALL 0x07
74 
75 //-----------------------------------------------------------------------------
76 //---Settings for CTRL_REG2---
77 
78 // Full Scale (FS)
79 #define LIS_FS_2G 0x00
80 #define LIS_FS_6G 0x80
81 
82 // Block Data Update (BDU)
83 #define LIS_BDU_CONTINUOUS 0x00
84 #define LIS_BDU_WAIT 0x40
85 
86 // Big/Little Endian Selection (BLE)
87 #define LIS_BLE_LE 0x00
88 #define LIS_BLE_BE 0x20
89 
90 // Data Alignment Selection DAS
91 #define LIS_DAS_12BIT 0x00
92 #define LIS_DAS_16BIT 0x01
93 
94 // Interrupt Enable
95 #define LIS_INTR_DISABLE 0x00
96 #define LIS_INTR_ENABLE 0x08
97 
98 // Data Ready Enable
99 #define LIS_DRDY_DISABLE 0x00
100 #define LIS_DRDY_ENABLE 0x04
101 
102 //-----------------------------------------------------------------------------
103 
104 #define LIS_BLE_XX LIS_BLE_BE
105 
106 
107 /* Private Functions Prototypes ----------------------------------------------*/
108 
109 //*********************i2c_read_reg***********************//
110 //----------Reads a register on the I2C target------------//
111 //------slave addr is the is the I2C target device--------//
112 //-reg_addr is the address of the register to be written--//
113 //-pBuffer is the storage destination for the read data---//
114 //-NoOfBytes is the amount of data to read----------------//
115 int8u i2c_read_reg (int8u slave_addr, int8u reg_addr, int8u *pBuffer, int8u NoOfBytes);
116 
117 //*********************i2c_write_reg**********************//
118 //----------Writes a register on the I2C target-----------//
119 //------slave addr is the is the I2C target device--------//
120 //-reg_addr is the address of the register to be written--//
121 //-reg_value is the value of the register to be written---//
122 int8u i2c_write_reg (int8u slave_addr, int8u reg_addr, int8u reg_value);
123 
124 #endif /* _MEMS_REGS_H_ */
125