2006-06-18 00:41:10 +02:00
|
|
|
/*
|
2010-01-14 14:29:56 +01:00
|
|
|
* Copyright (c) 2009, Swedish Institute of Computer Science
|
2007-11-17 19:01:00 +01:00
|
|
|
* All rights reserved.
|
2006-06-18 00:41:10 +02:00
|
|
|
*
|
2007-11-17 19:01:00 +01:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the Institute nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
2006-06-18 00:41:10 +02:00
|
|
|
*
|
2007-11-17 19:01:00 +01:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
2006-06-18 00:41:10 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Contiki operating system.
|
|
|
|
*
|
2010-02-23 19:27:04 +01:00
|
|
|
* @(#)$Id: sensors.h,v 1.9 2010/02/23 18:27:04 adamdunkels Exp $
|
2006-06-18 00:41:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SENSORS_H__
|
|
|
|
#define __SENSORS_H__
|
|
|
|
|
|
|
|
#include "contiki.h"
|
|
|
|
|
2010-01-14 14:29:56 +01:00
|
|
|
/* some constants for the configure API */
|
|
|
|
#define SENSORS_HW_INIT 128 /* internal - used only for initialization */
|
|
|
|
#define SENSORS_ACTIVE 129 /* ACTIVE => 0 -> turn off, 1 -> turn on */
|
|
|
|
#define SENSORS_READY 130 /* read only */
|
|
|
|
|
2010-01-14 21:13:34 +01:00
|
|
|
#define SENSORS_ACTIVATE(sensor) (sensor).configure(SENSORS_ACTIVE, 1)
|
|
|
|
#define SENSORS_DEACTIVATE(sensor) (sensor).configure(SENSORS_ACTIVE, 0)
|
2010-01-14 14:29:56 +01:00
|
|
|
|
|
|
|
#define SENSORS_SENSOR(name, type, value, configure, status) \
|
|
|
|
const struct sensors_sensor name = { type, value, configure, status }
|
2006-06-18 00:41:10 +02:00
|
|
|
|
|
|
|
#define SENSORS_NUM (sizeof(sensors) / sizeof(struct sensors_sensor *))
|
|
|
|
|
|
|
|
#define SENSORS(...) \
|
|
|
|
const struct sensors_sensor *sensors[] = {__VA_ARGS__, NULL}; \
|
2010-02-23 19:27:04 +01:00
|
|
|
unsigned char sensors_flags[SENSORS_NUM]
|
2006-06-18 00:41:10 +02:00
|
|
|
|
|
|
|
struct sensors_sensor {
|
|
|
|
char * type;
|
2010-01-14 16:33:27 +01:00
|
|
|
int (* value) (int type);
|
|
|
|
int (* configure) (int type, int value);
|
|
|
|
int (* status) (int type);
|
2006-06-18 00:41:10 +02:00
|
|
|
};
|
|
|
|
|
2011-09-23 15:49:00 +02:00
|
|
|
const struct sensors_sensor *sensors_find(const char *type);
|
|
|
|
const struct sensors_sensor *sensors_next(const struct sensors_sensor *s);
|
|
|
|
const struct sensors_sensor *sensors_first(void);
|
2006-06-18 00:41:10 +02:00
|
|
|
|
|
|
|
void sensors_changed(const struct sensors_sensor *s);
|
|
|
|
|
|
|
|
extern process_event_t sensors_event;
|
|
|
|
|
|
|
|
PROCESS_NAME(sensors_process);
|
|
|
|
|
|
|
|
#endif /* __SENSORS_H__ */
|