Contiki-Inga 3.x
gyro-sensor.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, TU Braunschweig.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 /**
31  * \file
32  * Gyroscope sensor definition
33  * \author
34  * Ulf Kulau <kulau@ibr.cs.tu-bs.de>
35  * Enrico Joerns <e.joerns@tu-bs.de>
36  */
37 
38 /**
39  * \addtogroup inga_sensors
40  * @{
41  */
42 
43 /**
44  * \defgroup inga_gyro_driver Gyroscope Sensor
45  *
46  * This sensor interface allows to control the gyroscope of the INGA sensor platform.
47  *
48  * @note This interface provides only a subset of the full sensor features.
49  * If you require extended configuration, consider using the underlying sensor driver.
50  *
51  * \section cfg_sensor Configure sensor
52  * <code> acc_sensor.configure(type, value) </code>
53  *
54  * The sensor interface allows to configure:
55  * - Sensitivity (\ref GYRO_CONF_SENSITIVITY)
56  * - Data rate (\ref GYRO_CONF_DATA_RATE)
57  *
58  * Details of the different configurations are given in
59  * the documentation of respective config.
60  *
61  * \section query_measure Query measurements
62  * <code>acc_sensor.value(channel)</code>
63  *
64  * The sensor provides 7 data channels.
65  * - 3 provide dps values
66  * - 3 provide unprocessed raw values
67  * - 1 provides temperature value
68  *
69  * @note Measurement values are updated only if one channel
70  * is read twice. I.e. reading x,y, and z channel
71  * will provide values from a single measurement.
72  * If then one of these channels is read again, a new
73  * measurement is initated.
74  *
75  * \section usage Example Usage
76  *
77 \code
78 #include <sensors.h>
79 [...]
80 struct sensors_sensor gyrosensor = find_sensor("Gyro");
81 ACTIVATE_SENSOR(gyrosensor);
82 gyrosensor.configure(GYRO_CONF_SENSITIVITY, GYRO_250DPS);
83 [...]
84 int x = gyrosensor.value(GYRO_X);
85 int y = gyrosensor.value(GYRO_Y);
86 int z = gyrosensor.value(GYRO_Z);
87 \endcode
88  *
89  * @{
90  */
91 
92 #ifndef __GYRO_SENSOR_H__
93 #define __GYRO_SENSOR_H__
94 
95 #include "lib/sensors.h"
96 
97 extern const struct sensors_sensor gyro_sensor;
98 
99 #define GYRO_SENSOR "Gyro"
100 
101 /**
102  * \name Data Output Channels
103  * GYRO_X/Y/Z provide values for the respective axis in degree pre seconds (dps).
104  * GYRO_X/Y/Z_RAW provide raw output values.
105  * @{ */
106 #define GYRO_X 0
107 #define GYRO_Y 1
108 #define GYRO_Z 2
109 #define GYRO_X_RAW 3
110 #define GYRO_Y_RAW 4
111 #define GYRO_Z_RAW 5
112 #define GYRO_TEMP 6
113 /** @} */
114 
115 /**
116  * \name Configuration Types
117  *
118  * Sensor specific configuration types.
119  * @{ */
120 /** Configures the sensitivity.
121  * The sensor can operate at three different sensitivity levels (+/-250,+/-500,+/-2000 [dps]).
122  * Possible values can be found in \ref sens_val "SENSITIVITY Values"
123  */
124 #define GYRO_CONF_SENSITIVITY 10
125 /** Configures the output data rate.
126  * The sensor can operate at different update rates (100,200,400,800 [Hz]).
127  * Allowed values can be found in \ref rate_val "DATA_RATE Values"
128  */
129 #define GYRO_CONF_DATA_RATE 20
130 /** @} */
131 
132 
133 /**
134  * \name SENSITIVITY Values
135  * \anchor sens_val
136  * \see GYRO_CONF_SENSITIVITY
137  * @{ */
138 #define GYRO_250DPS 250
139 #define GYRO_500DPS 500
140 #define GYRO_2000DPS 2000
141 /** @} */
142 
143 
144 /**
145  * \name DATA_RATE Values.
146  * \anchor rate_val
147  * \see GYRO_CONF_DATA_RATE
148  * @{
149  */
150 #define GYRO_100HZ 100
151 #define GYRO_200HZ 200
152 #define GYRO_400HZ 400
153 #define GYRO_800HZ 800
154 /** @} */
155 
156 #endif /* __GYRO-SENSOR_H__ */
157 
158 /** @} */ // inga_gyro_driver
159 /** @} */ // inga_sensors