Contiki 2.6
|
00001 /* 00002 * Copyright (c) 2010, Loughborough University - Computer Science 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 3. Neither the name of the Institute nor the names of its contributors 00014 * may be used to endorse or promote products derived from this software 00015 * without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 00018 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 00021 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00023 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00024 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00025 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00026 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00027 * SUCH DAMAGE. 00028 * 00029 * This file is part of the Contiki operating system. 00030 */ 00031 00032 /** 00033 * \file 00034 * Defines for the sensors on the various Sensinode models. 00035 * 00036 * Sensors will be off by default, unless turned on explicitly 00037 * in contiki-conf.h 00038 * 00039 * If you enable sensors generating interrupts, make sure you include 00040 * this file in the file containing main(). 00041 * 00042 * \author 00043 * George Oikonomou - <oikonomou@users.sourceforge.net> 00044 */ 00045 00046 #ifndef SENSINODE_SENSORS_H_ 00047 #define SENSINODE_SENSORS_H_ 00048 00049 #include "cc2430_sfr.h" 00050 #include "contiki-conf.h" 00051 #include "dev/models.h" 00052 #include "lib/sensors.h" 00053 00054 void sensinode_sensors_activate(); 00055 void sensinode_sensors_deactivate(); 00056 00057 /* ADC Sensor Types */ 00058 #define ADC_SENSOR "ADC" 00059 00060 #define ADC_SENSOR_TYPE_TEMP 0 00061 #define ADC_SENSOR_TYPE_ACC_X 1 00062 #define ADC_SENSOR_TYPE_ACC_Y 2 00063 #define ADC_SENSOR_TYPE_ACC_Z 3 00064 #define ADC_SENSOR_TYPE_VDD 4 00065 #define ADC_SENSOR_TYPE_LIGHT 5 00066 #define ADC_SENSOR_TYPE_BATTERY 6 00067 00068 /* Defines to help us control Acc and Ill individually */ 00069 #define ADC_VAL_NONE 0x00 00070 #define ADC_VAL_ALL 0x01 00071 #define ADC_VAL_LIGHT_ON 0x04 00072 #define ADC_VAL_ACC_ON 0x08 00073 #define ADC_VAL_ACC_GSEL 0x10 00074 00075 #ifdef ADC_SENSOR_CONF_ON 00076 #define ADC_SENSOR_ON ADC_SENSOR_CONF_ON 00077 #endif /* ADC_SENSOR_CONF_ON */ 00078 00079 #if ADC_SENSOR_ON 00080 extern const struct sensors_sensor adc_sensor; 00081 #endif /* ADC_SENSOR_ON */ 00082 00083 /* 00084 * Accelerometer. Available on N740 only. 00085 * This is a Freescale Semiconductor MMA7340L (3 axis, 3/11g) 00086 * X: P0_5 00087 * Y: P0_6 00088 * Z: P0_7 00089 */ 00090 #ifdef MODEL_N740 00091 #ifdef ACC_SENSOR_CONF_ON 00092 #define ACC_SENSOR_ON ACC_SENSOR_CONF_ON 00093 #endif /* ACC_SENSOR_CONF_ON */ 00094 00095 /* Accelerometer g-Select - Define for +/-11g, +/-3g Otherwise */ 00096 #if ACC_SENSOR_ON 00097 #ifdef ACC_SENSOR_CONF_GSEL 00098 #define ACC_SENSOR_GSEL ACC_SENSOR_CONF_GSEL 00099 #endif /* ACC_SENSOR_CONF_GSEL */ 00100 #endif /* ACC_SENSOR_ON */ 00101 #endif /* MODEL_N740 */ 00102 00103 /* 00104 * Buttons 00105 * N740: P1_0, P0_4 00106 * N711: P0_6, P0_7 00107 * N710: Unknown. This will mainly influence which ISRs to declare here 00108 */ 00109 #if defined(MODEL_N740) || defined(MODEL_N711) 00110 #ifdef BUTTON_SENSOR_CONF_ON 00111 #define BUTTON_SENSOR_ON BUTTON_SENSOR_CONF_ON 00112 #endif /* BUTTON_SENSOR_CONF_ON */ 00113 #endif /* defined(MODEL_FOO) */ 00114 00115 #define BUTTON_1_SENSOR "Button 1" 00116 #define BUTTON_2_SENSOR "Button 2" 00117 #define BUTTON_SENSOR BUTTON_1_SENSOR 00118 00119 #if BUTTON_SENSOR_ON 00120 extern const struct sensors_sensor button_1_sensor; 00121 extern const struct sensors_sensor button_2_sensor; 00122 #define button_sensor button_1_sensor 00123 00124 /* Port 0 ISR needed for both models */ 00125 void port_0_ISR(void) __interrupt (P0INT_VECTOR); 00126 00127 /* Only declare the Port 1 ISR for N740 */ 00128 #ifdef MODEL_N740 00129 void port_1_ISR(void) __interrupt (P1INT_VECTOR); 00130 #endif /* MODEL_N740 */ 00131 #endif /* BUTTON_SENSOR_ON */ 00132 00133 /* 00134 * Light - N710, N711, N740 00135 * N740: P0_0 00136 * N711: P0_0 00137 * N710: P?_? 00138 */ 00139 #if defined(MODEL_N740) || defined(MODEL_N711) || defined(MODEL_N710) 00140 #ifdef LIGHT_SENSOR_CONF_ON 00141 #define LIGHT_SENSOR_ON LIGHT_SENSOR_CONF_ON 00142 #endif /* LIGHT_SENSOR_CONF_ON */ 00143 #endif /* defined(MODEL_FOO) */ 00144 00145 /* 00146 * Battery - N711, N740, (N710 likely) 00147 * N740: P0_1 00148 * Unknown for other models 00149 */ 00150 #if defined(MODEL_N740) || defined(MODEL_N711) || defined(MODEL_N710) 00151 #ifdef BATTERY_SENSOR_CONF_ON 00152 #define BATTERY_SENSOR_ON BATTERY_SENSOR_CONF_ON 00153 #endif /* BATTERY_SENSOR_CONF_ON */ 00154 #endif /* defined(MODEL_FOO) */ 00155 00156 /* Temperature - Available on all cc2430 devices */ 00157 #ifdef TEMP_SENSOR_CONF_ON 00158 #define TEMP_SENSOR_ON TEMP_SENSOR_CONF_ON 00159 #endif /* TEMP_SENSOR_CONF_ON */ 00160 00161 /* Supply Voltage - Available on all cc2430 devices*/ 00162 #ifdef VDD_SENSOR_CONF_ON 00163 #define VDD_SENSOR_ON VDD_SENSOR_CONF_ON 00164 #endif /* VDD_SENSOR_CONF_ON */ 00165 00166 #endif /* SENSINODE_SENSORS_H_ */