00001 /* 00002 * Copyright (c) 2009, University of Colombo School of Computing 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 00034 /** 00035 * \file 00036 * Device drivers header file for MTS300 sensor board. 00037 * \author 00038 * Kasun Hewage <kasun.ch@gmail.com> 00039 */ 00040 00041 #ifndef __MTS300_H__ 00042 #define __MTS300_H__ 00043 00044 #include <avr/io.h> 00045 #include "contiki-conf.h" 00046 00047 #define SOUNDER_PORT PORTC 00048 #define SOUNDER_MASK _BV(2) 00049 #define SOUNDER_DDR DDRC 00050 00051 /* MTS300CA and MTS310CA, the light sensor power is controlled 00052 * by setting signal INT1(PORTE pin 5). 00053 * Both light and thermistor use the same ADC channel. 00054 */ 00055 #define LIGHT_PORT_DDR DDRE 00056 #define LIGHT_PORT PORTE 00057 #define LIGHT_PIN_MASK _BV(5) 00058 #define LIGHT_ADC_CHANNEL 1 00059 00060 /* MTS300CA and MTS310CA, the thermistor power is controlled 00061 * by setting signal INT2(PORTE pin 6). 00062 * Both light and thermistor use the same ADC channel. 00063 */ 00064 #define TEMP_PORT_DDR DDRE 00065 #define TEMP_PORT PORTE 00066 #define TEMP_PIN_MASK _BV(6) 00067 #define TEMP_ADC_CHANNEL 1 00068 00069 /* Power is controlled to the accelerometer by setting signal 00070 * PW4(PORTC pin 4), and the analog data is sampled on ADC3 and ADC4. 00071 */ 00072 #define ACCEL_PORT_DDR DDRC 00073 #define ACCEL_PORT PORTC 00074 #define ACCEL_PIN_MASK _BV(4) 00075 #define ACCELX_ADC_CHANNEL 3 00076 #define ACCELY_ADC_CHANNEL 4 00077 00078 /* Power is controlled to the magnetometer by setting signal 00079 * PW5(PORTC pin 5), and the analog data is sampled on ADC5 and ADC6. 00080 */ 00081 #define MAGNET_PORT_DDR DDRC 00082 #define MAGNET_PORT PORTC 00083 #define MAGNET_PIN_MASK _BV(5) 00084 #define MAGNETX_ADC_CHANNEL 5 00085 #define MAGNETY_ADC_CHANNEL 6 00086 00087 00088 #define MIC_PORT_DDR DDRC 00089 #define MIC_PORT PORTC 00090 #define MIC_PIN_MASK _BV(3) 00091 #define MIC_ADC_CHANNEL 2 00092 00093 void sounder_on(); 00094 void sounder_off(); 00095 00096 uint16_t get_light(); 00097 uint16_t get_temp(); 00098 00099 uint16_t get_accx(); 00100 uint16_t get_accy(); 00101 00102 uint16_t get_magx(); 00103 uint16_t get_magy(); 00104 00105 uint16_t get_mic(); 00106 00107 void mts300_init(); 00108 00109 #endif /* __MTS300_H__ */ 00110 00111 00112