Contiki 2.5
mts300.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009, University of Colombo School of Computing
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 
34 /**
35  * \file
36  * Device drivers header file for MTS300 sensor board.
37  * \author
38  * Kasun Hewage <kasun.ch@gmail.com>
39  */
40 
41 #ifndef __MTS300_H__
42 #define __MTS300_H__
43 
44 #include <avr/io.h>
45 #include "contiki-conf.h"
46 
47 #define SOUNDER_PORT PORTC
48 #define SOUNDER_MASK _BV(2)
49 #define SOUNDER_DDR DDRC
50 
51 /* MTS300CA and MTS310CA, the light sensor power is controlled
52  * by setting signal INT1(PORTE pin 5).
53  * Both light and thermistor use the same ADC channel.
54  */
55 #define LIGHT_PORT_DDR DDRE
56 #define LIGHT_PORT PORTE
57 #define LIGHT_PIN_MASK _BV(5)
58 #define LIGHT_ADC_CHANNEL 1
59 
60 /* MTS300CA and MTS310CA, the thermistor power is controlled
61  * by setting signal INT2(PORTE pin 6).
62  * Both light and thermistor use the same ADC channel.
63  */
64 #define TEMP_PORT_DDR DDRE
65 #define TEMP_PORT PORTE
66 #define TEMP_PIN_MASK _BV(6)
67 #define TEMP_ADC_CHANNEL 1
68 
69 /* Power is controlled to the accelerometer by setting signal
70  * PW4(PORTC pin 4), and the analog data is sampled on ADC3 and ADC4.
71  */
72 #define ACCEL_PORT_DDR DDRC
73 #define ACCEL_PORT PORTC
74 #define ACCEL_PIN_MASK _BV(4)
75 #define ACCELX_ADC_CHANNEL 3
76 #define ACCELY_ADC_CHANNEL 4
77 
78 /* Power is controlled to the magnetometer by setting signal
79  * PW5(PORTC pin 5), and the analog data is sampled on ADC5 and ADC6.
80  */
81 #define MAGNET_PORT_DDR DDRC
82 #define MAGNET_PORT PORTC
83 #define MAGNET_PIN_MASK _BV(5)
84 #define MAGNETX_ADC_CHANNEL 5
85 #define MAGNETY_ADC_CHANNEL 6
86 
87 
88 #define MIC_PORT_DDR DDRC
89 #define MIC_PORT PORTC
90 #define MIC_PIN_MASK _BV(3)
91 #define MIC_ADC_CHANNEL 2
92 
93 void sounder_on();
94 void sounder_off();
95 
96 uint16_t get_light();
97 uint16_t get_temp();
98 
99 uint16_t get_accx();
100 uint16_t get_accy();
101 
102 uint16_t get_magx();
103 uint16_t get_magy();
104 
105 uint16_t get_mic();
106 
107 void mts300_init();
108 
109 #endif /* __MTS300_H__ */
110 
111 
112