Contiki-Inga 3.x
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
platform
wismote
dev
ext-sensor.c
1
/*
2
* Copyright (c) 2006, Swedish Institute of 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
* -----------------------------------------------------------------
30
*
31
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne, Marcus Lundén,
32
* Jesper Karlsson
33
* Created : 2005-11-01
34
*/
35
36
#include "contiki.h"
37
#include "dev/ext-sensor.h"
38
#include "dev/sky-sensors.h"
39
40
const
struct
sensors_sensor
ext_sensor;
41
static
uint8_t active;
42
/*---------------------------------------------------------------------------*/
43
static
int
44
value
(
int
type
)
45
{
46
/* ADC0 corresponds to the port under the logo, ADC1 to the port over the logo,
47
ADC2 and ADC3 corresponds to port on the JCreate bottom expansion port)
48
switch(type) {
49
case ADC0:
50
return ADC12MEM6;
51
case ADC1:
52
return ADC12MEM7;
53
case ADC2:
54
return ADC12MEM8;
55
case ADC3:
56
return ADC12MEM9;
57
}*/
58
return
0;
59
}
60
/*---------------------------------------------------------------------------*/
61
static
int
62
status
(
int
type
)
63
{
64
switch
(type) {
65
case
SENSORS_ACTIVE
:
66
case
SENSORS_READY
:
67
return
active;
68
default
:
69
return
0;
70
}
71
}
72
/*---------------------------------------------------------------------------*/
73
static
int
74
configure
(
int
type,
int
c)
75
{
76
switch
(type) {
77
case
SENSORS_ACTIVE
:
78
if
(c) {
79
if
(!
status
(
SENSORS_ACTIVE
)) {
80
/* SREF_1 is Vref+
81
/* MemReg6 == P6.0/A0 == port "under" logo
82
ADC12MCTL6 = (INCH_0 + SREF_0);
83
/* MemReg7 == P6.1/A1 == port "over" logo
84
ADC12MCTL7 = (INCH_1 + SREF_0);
85
/* MemReg8 == P6.2/A2, bottom expansion port
86
ADC12MCTL8 = (INCH_2 + SREF_0);
87
/* MemReg9 == P6.1/A3, bottom expansion port, End Of (ADC-)Sequence
88
ADC12MCTL9 = (INCH_3 + SREF_0);
89
*/
90
sky_sensors_activate(0x0F);
91
active = 1;
92
}
93
}
else
{
94
sky_sensors_deactivate(0x0F);
95
active = 0;
96
}
97
return
1;
98
default
:
99
return
0;
100
}
101
}
102
/*---------------------------------------------------------------------------*/
103
SENSORS_SENSOR
(ext_sensor,
"Ext"
,
104
value
,
configure
,
status
);
Generated on Thu Apr 24 2014 16:26:16 for Contiki-Inga 3.x by
1.8.3.1