Contiki 3.x
button-sensor.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
3  * Copyright (c) 2015, Zolertia - http://www.zolertia.com
4  * Copyright (c) 2015, University of Bristol - http://www.bristol.ac.uk
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the copyright holder nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31  * OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 /*---------------------------------------------------------------------------*/
34 /**
35  * \addtogroup zoul-sensors
36  * @{
37  *
38  * \defgroup zoul-button-sensor Zoul User Button Driver
39  *
40  * Driver for the Zoul user button
41  *
42  * The user button (on Zoul-based platforms like the RE-Mote and the Firefly)
43  * will generate a sensors_changed event on press as well as on release.
44  *
45  * Unlike many other platforms, the user button has the ability to
46  * generate events when the user keeps the button pressed. The user can
47  * configure the button driver with a timer interval in clock ticks. When the
48  * button is kept pressed, the driver will then generate a broadcast event
49  * each time the interval passes. For example the driver can be configured to
50  * generate an event every second while the button is kept pressed. This
51  * functionality can be enabled through the configure() function, by passing
52  * BUTTON_SENSOR_CONFIG_TYPE_INTERVAL as the type argument.
53  * @{
54  *
55  * \file
56  * Header file for the Zoul User Button Driver
57  */
58 /*---------------------------------------------------------------------------*/
59 #ifndef BUTTON_SENSOR_H_
60 #define BUTTON_SENSOR_H_
61 /*---------------------------------------------------------------------------*/
62 #include "lib/sensors.h"
63 /*---------------------------------------------------------------------------*/
64 #define BUTTON_SENSOR "Button"
65 
66 extern const struct sensors_sensor button_sensor;
67 /*---------------------------------------------------------------------------*/
68 extern process_event_t button_press_duration_exceeded;
69 /*---------------------------------------------------------------------------*/
70 #define BUTTON_SENSOR_CONFIG_TYPE_INTERVAL 0x0100
71 
72 #define BUTTON_SENSOR_VALUE_TYPE_LEVEL 0
73 #define BUTTON_SENSOR_VALUE_TYPE_PRESS_DURATION 1
74 
75 #define BUTTON_SENSOR_PRESSED_LEVEL 0
76 #define BUTTON_SENSOR_RELEASED_LEVEL 8
77 /*---------------------------------------------------------------------------*/
78 #endif /* BUTTON_SENSOR_H_ */
79 /*---------------------------------------------------------------------------*/
80 /**
81  * @}
82  * @}
83  */
const struct sensors_sensor button_sensor
Copyright (c) 2014, Analog Devices, Inc.
Definition: button-sensor.c:5