mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
added flag to enable/disable sensor event broadcast
This commit is contained in:
parent
30822b5703
commit
271968e104
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* @(#)$Id: pir-sensor.c,v 1.1 2006/06/18 07:49:33 adamdunkels Exp $
|
* @(#)$Id: pir-sensor.c,v 1.2 2006/10/09 21:08:51 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki-esb.h"
|
#include "contiki-esb.h"
|
||||||
@ -36,6 +36,7 @@
|
|||||||
const struct sensors_sensor pir_sensor;
|
const struct sensors_sensor pir_sensor;
|
||||||
|
|
||||||
static unsigned int pir;
|
static unsigned int pir;
|
||||||
|
static unsigned char flags;
|
||||||
|
|
||||||
HWCONF_PIN(PIR, 1, 3);
|
HWCONF_PIN(PIR, 1, 3);
|
||||||
HWCONF_IRQ(PIR, 1, 3);
|
HWCONF_IRQ(PIR, 1, 3);
|
||||||
@ -46,7 +47,9 @@ irq(void)
|
|||||||
{
|
{
|
||||||
if(PIR_CHECK_IRQ()) {
|
if(PIR_CHECK_IRQ()) {
|
||||||
++pir;
|
++pir;
|
||||||
sensors_changed(&pir_sensor);
|
if(flags & PIR_ENABLE_EVENT) {
|
||||||
|
sensors_changed(&pir_sensor);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -55,6 +58,7 @@ irq(void)
|
|||||||
static void
|
static void
|
||||||
init(void)
|
init(void)
|
||||||
{
|
{
|
||||||
|
flags = PIR_ENABLE_EVENT;
|
||||||
pir = 0;
|
pir = 0;
|
||||||
PIR_SELECT();
|
PIR_SELECT();
|
||||||
PIR_MAKE_INPUT();
|
PIR_MAKE_INPUT();
|
||||||
@ -89,13 +93,18 @@ value(int type)
|
|||||||
static int
|
static int
|
||||||
configure(int type, void *c)
|
configure(int type, void *c)
|
||||||
{
|
{
|
||||||
return 0;
|
if(c) {
|
||||||
|
flags |= type & 0xff;
|
||||||
|
} else {
|
||||||
|
flags &= ~type & 0xff;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void *
|
static void *
|
||||||
status(int type)
|
status(int type)
|
||||||
{
|
{
|
||||||
return NULL;
|
return (void *) (((int) (flags & type)) & 0xff);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
SENSORS_SENSOR(pir_sensor, PIR_SENSOR,
|
SENSORS_SENSOR(pir_sensor, PIR_SENSOR,
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* @(#)$Id: pir-sensor.h,v 1.1 2006/06/18 07:49:33 adamdunkels Exp $
|
* @(#)$Id: pir-sensor.h,v 1.2 2006/10/09 21:08:51 nifi Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef __PIR_SENSOR_H__
|
#ifndef __PIR_SENSOR_H__
|
||||||
#define __PIR_SENSOR_H__
|
#define __PIR_SENSOR_H__
|
||||||
@ -39,4 +39,6 @@ extern const struct sensors_sensor pir_sensor;
|
|||||||
|
|
||||||
#define PIR_SENSOR "PIR"
|
#define PIR_SENSOR "PIR"
|
||||||
|
|
||||||
|
#define PIR_ENABLE_EVENT 1
|
||||||
|
|
||||||
#endif /* __PIR_SENSOR_H__ */
|
#endif /* __PIR_SENSOR_H__ */
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* @(#)$Id: vib-sensor.c,v 1.1 2006/06/18 07:49:33 adamdunkels Exp $
|
* @(#)$Id: vib-sensor.c,v 1.2 2006/10/09 21:08:51 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki-esb.h"
|
#include "contiki-esb.h"
|
||||||
@ -36,6 +36,7 @@
|
|||||||
const struct sensors_sensor vib_sensor;
|
const struct sensors_sensor vib_sensor;
|
||||||
|
|
||||||
static unsigned int vib;
|
static unsigned int vib;
|
||||||
|
static unsigned char flags;
|
||||||
|
|
||||||
HWCONF_PIN(VIB, 1, 4);
|
HWCONF_PIN(VIB, 1, 4);
|
||||||
HWCONF_IRQ(VIB, 1, 4);
|
HWCONF_IRQ(VIB, 1, 4);
|
||||||
@ -46,7 +47,9 @@ irq(void)
|
|||||||
{
|
{
|
||||||
if(VIB_CHECK_IRQ()) {
|
if(VIB_CHECK_IRQ()) {
|
||||||
++vib;
|
++vib;
|
||||||
sensors_changed(&vib_sensor);
|
if(flags & VIB_ENABLE_EVENT) {
|
||||||
|
sensors_changed(&vib_sensor);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -89,13 +92,18 @@ value(int type)
|
|||||||
static int
|
static int
|
||||||
configure(int type, void *c)
|
configure(int type, void *c)
|
||||||
{
|
{
|
||||||
return 0;
|
if(c) {
|
||||||
|
flags |= type & 0xff;
|
||||||
|
} else {
|
||||||
|
flags &= ~type & 0xff;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void *
|
static void *
|
||||||
status(int type)
|
status(int type)
|
||||||
{
|
{
|
||||||
return NULL;
|
return (void *) (((int) (flags & type)) & 0xff);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
SENSORS_SENSOR(vib_sensor, VIB_SENSOR,
|
SENSORS_SENSOR(vib_sensor, VIB_SENSOR,
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* @(#)$Id: vib-sensor.h,v 1.1 2006/06/18 07:49:33 adamdunkels Exp $
|
* @(#)$Id: vib-sensor.h,v 1.2 2006/10/09 21:08:51 nifi Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef __VIB_SENSOR_H__
|
#ifndef __VIB_SENSOR_H__
|
||||||
#define __VIB_SENSOR_H__
|
#define __VIB_SENSOR_H__
|
||||||
@ -39,4 +39,6 @@ extern const struct sensors_sensor vib_sensor;
|
|||||||
|
|
||||||
#define VIB_SENSOR "Vibration"
|
#define VIB_SENSOR "Vibration"
|
||||||
|
|
||||||
|
#define VIB_ENABLE_EVENT 1
|
||||||
|
|
||||||
#endif /* __VIB_SENSOR_H__ */
|
#endif /* __VIB_SENSOR_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user