Contiki 2.5
gyro-sensor.c
1 /* GYROSCOPE sensor interface
2  * Author : Georg von Zengen
3  * Created : 2011/10/17
4  */
5 #include "contiki.h"
6 #include "lib/sensors.h"
8 #include "dev/gyro-sensor.h"
9 const struct sensors_sensor gyro_sensor;
10 uint8_t gyro_state=0;
11 /*---------------------------------------------------------------------------*/
12 static int
13 value(int type)
14 {
15  switch(type) {
16  case X_AS:
17  return l3g4200d_get_x_angle();
18 
19  case Y_AS:
20  return l3g4200d_get_z_angle();
21 
22  case Z_AS:
23  return l3g4200d_get_y_angle();
24 
25  case TEMP_AS: //only for relative temperature measurements
26  return (int16_t) l3g4200d_get_temp();
27  }
28  return 0;
29 }
30 /*---------------------------------------------------------------------------*/
31 static int
32 status(int type)
33 {
34  return gyro_state;
35 }
36 /*---------------------------------------------------------------------------*/
37 static int
38 configure(int type, int c)
39 {
40  gyro_state=1;
41  return l3g4200d_init();
42 }
43 /*---------------------------------------------------------------------------*/
44 SENSORS_SENSOR(gyro_sensor, "GYROSCOPE", value, configure, status);