Contiki 3.x
sensinode-sensors.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, Loughborough University - Computer Science
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  * This file is part of the Contiki operating system.
30  */
31 
32 /**
33  * \file
34  * Defines for the sensors on the various Sensinode models.
35  *
36  * Sensors will be off by default, unless turned on explicitly
37  * in contiki-conf.h
38  *
39  * If you enable sensors generating interrupts, make sure you include
40  * this file in the file containing main().
41  *
42  * \author
43  * George Oikonomou - <oikonomou@users.sourceforge.net>
44  */
45 
46 #ifndef SENSINODE_SENSORS_H_
47 #define SENSINODE_SENSORS_H_
48 
49 #include "cc2430_sfr.h"
50 #include "contiki-conf.h"
51 #include "dev/models.h"
52 #include "lib/sensors.h"
53 
54 void sensinode_sensors_activate();
55 void sensinode_sensors_deactivate();
56 
57 /* ADC Sensor Types */
58 #define ADC_SENSOR "ADC"
59 
60 #define ADC_SENSOR_TYPE_TEMP 0
61 #define ADC_SENSOR_TYPE_ACC_X 1
62 #define ADC_SENSOR_TYPE_ACC_Y 2
63 #define ADC_SENSOR_TYPE_ACC_Z 3
64 #define ADC_SENSOR_TYPE_VDD 4
65 #define ADC_SENSOR_TYPE_LIGHT 5
66 #define ADC_SENSOR_TYPE_BATTERY 6
67 
68 /* Defines to help us control Acc and Ill individually */
69 #define ADC_VAL_NONE 0x00
70 #define ADC_VAL_ALL 0x01
71 #define ADC_VAL_LIGHT_ON 0x04
72 #define ADC_VAL_ACC_ON 0x08
73 #define ADC_VAL_ACC_GSEL 0x10
74 
75 #ifdef ADC_SENSOR_CONF_ON
76 #define ADC_SENSOR_ON ADC_SENSOR_CONF_ON
77 #endif /* ADC_SENSOR_CONF_ON */
78 
79 #if ADC_SENSOR_ON
80 extern const struct sensors_sensor adc_sensor;
81 #endif /* ADC_SENSOR_ON */
82 
83 /*
84  * Accelerometer. Available on N740 only.
85  * This is a Freescale Semiconductor MMA7340L (3 axis, 3/11g)
86  * X: P0_5
87  * Y: P0_6
88  * Z: P0_7
89  */
90 #ifdef MODEL_N740
91 #ifdef ACC_SENSOR_CONF_ON
92 #define ACC_SENSOR_ON ACC_SENSOR_CONF_ON
93 #endif /* ACC_SENSOR_CONF_ON */
94 
95 /* Accelerometer g-Select - Define for +/-11g, +/-3g Otherwise */
96 #if ACC_SENSOR_ON
97 #ifdef ACC_SENSOR_CONF_GSEL
98 #define ACC_SENSOR_GSEL ACC_SENSOR_CONF_GSEL
99 #endif /* ACC_SENSOR_CONF_GSEL */
100 #endif /* ACC_SENSOR_ON */
101 #endif /* MODEL_N740 */
102 
103 /*
104  * Buttons
105  * N740: P1_0, P0_4
106  * N711: P0_6, P0_7
107  * N710: Unknown. This will mainly influence which ISRs to declare here
108  */
109 #if defined(MODEL_N740) || defined(MODEL_N711)
110 #ifdef BUTTON_SENSOR_CONF_ON
111 #define BUTTON_SENSOR_ON BUTTON_SENSOR_CONF_ON
112 #endif /* BUTTON_SENSOR_CONF_ON */
113 #endif /* defined(MODEL_FOO) */
114 
115 #define BUTTON_1_SENSOR "Button 1"
116 #define BUTTON_2_SENSOR "Button 2"
117 #define BUTTON_SENSOR BUTTON_1_SENSOR
118 
119 #if BUTTON_SENSOR_ON
120 extern const struct sensors_sensor button_1_sensor;
121 extern const struct sensors_sensor button_2_sensor;
122 #define button_sensor button_1_sensor
123 
124 /* Port 0 ISR needed for both models */
125 void port_0_ISR(void) __interrupt (P0INT_VECTOR);
126 
127 /* Only declare the Port 1 ISR for N740 */
128 #ifdef MODEL_N740
129 void port_1_ISR(void) __interrupt (P1INT_VECTOR);
130 #endif /* MODEL_N740 */
131 #endif /* BUTTON_SENSOR_ON */
132 
133 /*
134  * Light - N710, N711, N740
135  * N740: P0_0
136  * N711: P0_0
137  * N710: P?_?
138  */
139 #if defined(MODEL_N740) || defined(MODEL_N711) || defined(MODEL_N710)
140 #ifdef LIGHT_SENSOR_CONF_ON
141 #define LIGHT_SENSOR_ON LIGHT_SENSOR_CONF_ON
142 #endif /* LIGHT_SENSOR_CONF_ON */
143 #endif /* defined(MODEL_FOO) */
144 
145 /*
146  * Battery - N711, N740, (N710 likely)
147  * N740: P0_1
148  * Unknown for other models
149  */
150 #if defined(MODEL_N740) || defined(MODEL_N711) || defined(MODEL_N710)
151 #ifdef BATTERY_SENSOR_CONF_ON
152 #define BATTERY_SENSOR_ON BATTERY_SENSOR_CONF_ON
153 #endif /* BATTERY_SENSOR_CONF_ON */
154 #endif /* defined(MODEL_FOO) */
155 
156 /* Temperature - Available on all cc2430 devices */
157 #ifdef TEMP_SENSOR_CONF_ON
158 #define TEMP_SENSOR_ON TEMP_SENSOR_CONF_ON
159 #endif /* TEMP_SENSOR_CONF_ON */
160 
161 /* Supply Voltage - Available on all cc2430 devices*/
162 #ifdef VDD_SENSOR_CONF_ON
163 #define VDD_SENSOR_ON VDD_SENSOR_CONF_ON
164 #endif /* VDD_SENSOR_CONF_ON */
165 
166 #endif /* SENSINODE_SENSORS_H_ */
CC2430 registers header file for CC2430.