Contiki-Inga 3.x
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
platform
cc2530dk
dev
button-sensor.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011, George Oikonomou - <oikonomou@users.sourceforge.net>
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
* Override core/dev/button-sensor.h
35
*
36
* \author
37
* George Oikonomou - <oikonomou@users.sourceforge.net>
38
*/
39
40
#ifndef BUTTON_SENSOR_H_
41
#define BUTTON_SENSOR_H_
42
43
#include "contiki-conf.h"
44
#include "lib/sensors.h"
45
46
#define BUTTON_SENSOR "Button"
47
48
/*
49
* SmartRF Buttons
50
* B1: P0_1, B2: Not Connected
51
*
52
* USB Dongle Buttons
53
* B1: P1_2
54
* B2: P1_3
55
*
56
*/
57
#if MODELS_CONF_CC2531_USB_STICK
58
#define BUTTON1_PORT 1
59
#define BUTTON1_PIN 2
60
#define BUTTON2_PORT 1
61
#define BUTTON2_PIN 3
62
#else
63
#define BUTTON1_PORT 0
64
#define BUTTON1_PIN 1
65
#endif
66
67
#ifdef BUTTON_SENSOR_CONF_ON
68
#define BUTTON_SENSOR_ON BUTTON_SENSOR_CONF_ON
69
#endif
/* BUTTON_SENSOR_CONF_ON */
70
71
#define button_sensor button_1_sensor
72
extern
const
struct
sensors_sensor
button_1_sensor;
73
extern
const
struct
sensors_sensor
button_2_sensor;
74
75
#if BUTTON_SENSOR_ON
76
#if MODELS_CONF_CC2531_USB_STICK
77
/* USB Dongle */
78
/* Buttons: P1_2 & P1_3 - Port 1 ISR needed */
79
void
port_1_isr(
void
) __interrupt(P1INT_VECTOR);
80
#define BUTTON_SENSOR_ACTIVATE() do { \
81
button_1_sensor.configure(SENSORS_ACTIVE, 1); \
82
button_2_sensor.configure(SENSORS_ACTIVE, 1); \
83
} while(0)
84
85
#else
/* MODELS_CONF_CC2531_USB_STICK */
86
/* SmartRF */
87
/* Button 1: P0_1 - Port 0 ISR needed */
88
void
port_0_isr(
void
) __interrupt(P0INT_VECTOR);
89
#define BUTTON_SENSOR_ACTIVATE() button_sensor.configure(SENSORS_ACTIVE, 1)
90
#endif
/* MODELS_CONF_CC2531_USB_STICK */
91
92
#else
/* BUTTON_SENSOR_ON */
93
#define BUTTON_SENSOR_ACTIVATE()
94
#endif
/* BUTTON_SENSOR_ON */
95
96
/* Define macros for buttons */
97
#define BUTTON_READ(b) PORT_READ(BUTTON##b##_PORT, BUTTON##b##_PIN)
98
#define BUTTON_FUNC_GPIO(b) PORT_FUNC_GPIO(BUTTON##b##_PORT, BUTTON##b##_PIN)
99
#define BUTTON_DIR_INPUT(b) PORT_DIR_INPUT(BUTTON##b##_PORT, BUTTON##b##_PIN)
100
#define BUTTON_IRQ_ENABLED(b) PORT_IRQ_ENABLED(BUTTON##b##_PORT, BUTTON##b##_PIN)
101
#define BUTTON_IRQ_CHECK(b) PORT_IRQ_CHECK(BUTTON##b##_PORT, BUTTON##b##_PIN)
102
#define BUTTON_IRQ_ENABLE(b) PORT_IRQ_ENABLE(BUTTON##b##_PORT, BUTTON##b##_PIN)
103
#define BUTTON_IRQ_DISABLE(b) PORT_IRQ_DISABLE(BUTTON##b##_PORT, BUTTON##b##_PIN)
104
#define BUTTON_IRQ_FLAG_OFF(b) PORT_IRQ_FLAG_OFF(BUTTON##b##_PORT, BUTTON##b##_PIN)
105
#define BUTTON_IRQ_ON_PRESS(b) PORT_IRQ_EDGE_RISE(BUTTON##b##_PORT, BUTTON##b##_PIN)
106
#define BUTTON_IRQ_ON_RELEASE(b) PORT_IRQ_EDGE_FALL(BUTTON##b##_PORT, BUTTON##b##_PIN)
107
108
#endif
/* BUTTON_SENSOR_H_ */
Generated on Thu Apr 24 2014 16:26:11 for Contiki-Inga 3.x by
1.8.3.1