Contiki-NG
Loading...
Searching...
No Matches
reed-sensor.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, Zolertia <http://www.zolertia.com>
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 * Header file for the reed sensor
34 *
35 * The Reed sensor allows to be used either by polling the sensor status or by
36 * setting up a timer on the background ticking every REED_CHECK_PERIOD, posting
37 * a reed_sensor_event_changed event, informing the application about a change
38 * in the sensor status (basically open or closed). To enable each mode
39 * (default is polling) call the configure() function with REED_SENSOR_MODE
40 * using REED_SENSOR_EVENT_MODE or REED_SENSOR_POLL_MODE, after having
41 * initialized the device using SENSORS_ACTIVATE(reed_sensor).
42 *
43 * \file
44 * Reed sensor header file
45 * \author
46 * Antonio Lignan <alinan@zolertia.com>
47 */
48#include "lib/sensors.h"
49
50#ifndef REED_SENSOR_H_
51#define REED_SENSOR_H_
52/* -------------------------------------------------------------------------- */
53#define REED_SENSOR_ERROR -1
54#define REED_SENSOR_SUCCESS 0x00
55#define REED_SENSOR_VAL 0x01
56/* -------------------------------------------------------------------------- */
57#define REED_OPEN 0x00
58#define REED_CLOSED 0x01
59/* -------------------------------------------------------------------------- */
60#define REED_SENSOR_MODE 0x01
61#define REED_SENSOR_EVENT_MODE 0x0A
62#define REED_SENSOR_EVENT_POLL 0x0B
63/* -------------------------------------------------------------------------- */
64#define REED_PORT_DIR P4DIR
65#define REED_PORT_SEL P4SEL
66#define REED_PORT_REN P4REN
67#define REED_PORT_READ P4IN
68#define REED_PORT_PRES P4OUT
69#define REED_READ_PIN (1 << 2)
70/* -------------------------------------------------------------------------- */
71#define REED_SENSOR "Reed Sensor"
72/* -------------------------------------------------------------------------- */
73extern const struct sensors_sensor reed_sensor;
74extern process_event_t reed_sensor_event_changed;
75/* -------------------------------------------------------------------------- */
76#endif /* ifndef REED_SENSOR_H_ */