diff --git a/platform/esb/dev/pir-sensor.c b/platform/esb/dev/pir-sensor.c index 4a42c7dbc..94b44aeb2 100644 --- a/platform/esb/dev/pir-sensor.c +++ b/platform/esb/dev/pir-sensor.c @@ -28,7 +28,7 @@ * * 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" @@ -36,6 +36,7 @@ const struct sensors_sensor pir_sensor; static unsigned int pir; +static unsigned char flags; HWCONF_PIN(PIR, 1, 3); HWCONF_IRQ(PIR, 1, 3); @@ -46,7 +47,9 @@ irq(void) { if(PIR_CHECK_IRQ()) { ++pir; - sensors_changed(&pir_sensor); + if(flags & PIR_ENABLE_EVENT) { + sensors_changed(&pir_sensor); + } return 1; } return 0; @@ -55,6 +58,7 @@ irq(void) static void init(void) { + flags = PIR_ENABLE_EVENT; pir = 0; PIR_SELECT(); PIR_MAKE_INPUT(); @@ -89,13 +93,18 @@ value(int type) static int configure(int type, void *c) { - return 0; + if(c) { + flags |= type & 0xff; + } else { + flags &= ~type & 0xff; + } + return 1; } /*---------------------------------------------------------------------------*/ static void * status(int type) { - return NULL; + return (void *) (((int) (flags & type)) & 0xff); } /*---------------------------------------------------------------------------*/ SENSORS_SENSOR(pir_sensor, PIR_SENSOR, diff --git a/platform/esb/dev/pir-sensor.h b/platform/esb/dev/pir-sensor.h index 6fb1cf2a9..b9a339018 100644 --- a/platform/esb/dev/pir-sensor.h +++ b/platform/esb/dev/pir-sensor.h @@ -28,7 +28,7 @@ * * 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__ #define __PIR_SENSOR_H__ @@ -39,4 +39,6 @@ extern const struct sensors_sensor pir_sensor; #define PIR_SENSOR "PIR" +#define PIR_ENABLE_EVENT 1 + #endif /* __PIR_SENSOR_H__ */ diff --git a/platform/esb/dev/vib-sensor.c b/platform/esb/dev/vib-sensor.c index 8a4cad64e..3ed9a5011 100644 --- a/platform/esb/dev/vib-sensor.c +++ b/platform/esb/dev/vib-sensor.c @@ -28,7 +28,7 @@ * * 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" @@ -36,6 +36,7 @@ const struct sensors_sensor vib_sensor; static unsigned int vib; +static unsigned char flags; HWCONF_PIN(VIB, 1, 4); HWCONF_IRQ(VIB, 1, 4); @@ -46,7 +47,9 @@ irq(void) { if(VIB_CHECK_IRQ()) { ++vib; - sensors_changed(&vib_sensor); + if(flags & VIB_ENABLE_EVENT) { + sensors_changed(&vib_sensor); + } return 1; } return 0; @@ -89,13 +92,18 @@ value(int type) static int configure(int type, void *c) { - return 0; + if(c) { + flags |= type & 0xff; + } else { + flags &= ~type & 0xff; + } + return 1; } /*---------------------------------------------------------------------------*/ static void * status(int type) { - return NULL; + return (void *) (((int) (flags & type)) & 0xff); } /*---------------------------------------------------------------------------*/ SENSORS_SENSOR(vib_sensor, VIB_SENSOR, diff --git a/platform/esb/dev/vib-sensor.h b/platform/esb/dev/vib-sensor.h index fff8cb620..4dc0cc21d 100644 --- a/platform/esb/dev/vib-sensor.h +++ b/platform/esb/dev/vib-sensor.h @@ -28,7 +28,7 @@ * * 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__ #define __VIB_SENSOR_H__ @@ -39,4 +39,6 @@ extern const struct sensors_sensor vib_sensor; #define VIB_SENSOR "Vibration" +#define VIB_ENABLE_EVENT 1 + #endif /* __VIB_SENSOR_H__ */