Contiki 2.5
gyro-l3g4200d.h
Go to the documentation of this file.
1 /* Copyright (c) 2010, Ulf Kulau
2  *
3  * Permission is hereby granted, free of charge, to any person
4  * obtaining a copy of this software and associated documentation
5  * files (the "Software"), to deal in the Software without
6  * restriction, including without limitation the rights to use,
7  * copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following
10  * conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 /**
26  * \addtogroup Device Interfaces
27  * @{
28  *
29  * \defgroup L3G4200D_interface ST L3G4200D 3-axis Gyroscope interface
30  *
31  * <p>
32  * </p>
33  *
34  *
35  * @{
36  *
37  */
38 
39 /**
40  * \file
41  * ST L3G4200D 3-axis Gyroscope interface definitions
42  * \author
43  * Ulf Kulau <kulau@ibr.cs.tu-bs.de>
44  */
45 
46 #ifndef GYROL3G4200D_H_
47 #define GYROL3G4200D_H_
48 
49 #include "../drv/i2c-drv.h"
50 #include <util/delay.h>
51 
52 /*Pressure Sensor BMP085 device address*/
53 #define L3G4200D_DEV_ADDR_R 0xD3
54 #define L3G4200D_DEV_ADDR_W 0xD2
55 
56 #define L3G4000D_WHO_I_AM_REG 0x0F
57 #define L3G4000D_CTRL_REG1 0x20
58 #define L3G4000D_CTRL_REG2 0x21
59 #define L3G4000D_CTRL_REG3 0x22
60 #define L3G4000D_CTRL_REG4 0x23
61 #define L3G4000D_CTRL_REG5 0x24
62 
63 #define L3G4000D_REFERENCE 0x25
64 
65 #define L3G4000D_OUT_TEMP 0x26
66 
67 #define L3G4000D_STATUS_REG 0x27
68 
69 #define L3G4000D_OUT_X_L 0x28
70 #define L3G4000D_OUT_X_H 0x29
71 #define L3G4000D_OUT_Y_L 0x2A
72 #define L3G4000D_OUT_Y_H 0x2B
73 #define L3G4000D_OUT_Z_L 0x2C
74 #define L3G4000D_OUT_Z_H 0x2D
75 
76 typedef struct {
77  uint16_t angle_x_value;
78  uint16_t angle_y_value;
79  uint16_t angle_z_value;
80 } angle_data_t;
81 
82 int8_t l3g4200d_init(void);
83 angle_data_t l3g4200d_get_angle(void);
84 uint16_t l3g4200d_get_x_angle(void);
85 uint16_t l3g4200d_get_y_angle(void);
86 uint16_t l3g4200d_get_z_angle(void);
87 int8_t l3g4200d_get_temp(void);
88 uint16_t l3g4200d_read16bit(uint8_t addr);
89 uint8_t l3g4200d_read8bit(uint8_t addr);
90 void l3g4200d_write8bit(uint8_t addr, uint8_t data);
91 #endif /* GYROL3G4200D_H_ */