/* Sensor routine */ #include "contiki.h" #include "lib/sensors.h" #include "dev/pir-sensor.h" #include #include "led.h" // debug const struct sensors_sensor pir_sensor; static struct timer debouncetimer; static int status(int type); static int enabled = 0; struct sensors_sensor *sensors[1]; unsigned char sensors_flags[1]; #define PIR_BIT INTF6 #define PIR_CHECK_IRQ() (EIFR & PIR_BIT) ? 0 : 1 #define PRINTF(...) printf(__VA_ARGS__) /*---------------------------------------------------------------------------*/ ISR(INT6_vect) { // leds_toggle(LEDS_YELLOW); if(PIR_CHECK_IRQ()) { if(timer_expired(&debouncetimer)) { // led1_on(); timer_set(&debouncetimer, CLOCK_SECOND / 4); sensors_changed(&pir_sensor); // led1_off(); } } } /*---------------------------------------------------------------------------*/ static int value(int type) { return (PORTE & _BV(PE6) ? 0 : 1) || !timer_expired(&debouncetimer); //return 0; } static int configure(int type, int c) { switch (type) { case SENSORS_ACTIVE: if (c) { if(!status(SENSORS_ACTIVE)) { // led1_on(); timer_set(&debouncetimer, 0); DDRE |= (0<