add pir sensor, sensor events

This commit is contained in:
harald42 2013-02-13 15:07:49 +01:00 committed by harald
parent a1152fd96e
commit 32ab451fff
4 changed files with 22 additions and 11 deletions

View file

@ -4,13 +4,17 @@ CONTIKI_CORE=contiki-main
CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o
CONTIKI_TARGET_SOURCEFILES += contiki-main.c params.c node-id.c CONTIKI_TARGET_SOURCEFILES += contiki-main.c params.c node-id.c
#Needed for slip #Needed for slip
CONTIKI_TARGET_SOURCEFILES += temperature-sensor.c adc.c button-sensor.c sensors.c slip_uart0.c slip.c CONTIKI_TARGET_SOURCEFILES += temperature-sensor.c adc.c led.c sensors.c slip_uart0.c slip.c
#Needed for Button
CONTIKI_TARGET_SOURCEFILES += button-sensor.c
#Needed for DHT11 humidity sensor #Needed for DHT11 humidity sensor
CONTIKI_TARGET_SOURCEFILES += dht11.c CONTIKI_TARGET_SOURCEFILES += dht11.c
#Needed for DS18S20 temperature sensor #Needed for DS18S20 temperature sensor
CONTIKI_TARGET_SOURCEFILES += ds1820.c CONTIKI_TARGET_SOURCEFILES += ds1820.c
#Needed for Battery test #Needed for Battery test
CONTIKI_TARGET_SOURCEFILES += battery-sensor.c CONTIKI_TARGET_SOURCEFILES += battery-sensor.c
#Needed for PIR
CONTIKI_TARGET_SOURCEFILES += pir-sensor.c
CONTIKIAVR=$(CONTIKI)/cpu/avr CONTIKIAVR=$(CONTIKI)/cpu/avr
CONTIKIBOARD=. CONTIKIBOARD=.
BOOTLOADER_START = 0x1F000 BOOTLOADER_START = 0x1F000

View file

@ -146,7 +146,7 @@ typedef unsigned short uip_stats_t;
#define RIMEADDR_CONF_SIZE 8 #define RIMEADDR_CONF_SIZE 8
#define UIP_CONF_ICMP6 1 #define UIP_CONF_ICMP6 1
#define UIP_CONF_UDP 1 #define UIP_CONF_UDP 1
#define UIP_CONF_TCP 1 #define UIP_CONF_TCP 0
#define NETSTACK_CONF_NETWORK sicslowpan_driver #define NETSTACK_CONF_NETWORK sicslowpan_driver
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06 #define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
#else #else

View file

@ -144,6 +144,11 @@ FUSES ={.low = 0xF6, .high = 0x98, .extended = 0xfd,};
FUSES ={.low = 0xC2, .high = 0x99, .extended = 0xfe,}; FUSES ={.low = 0xC2, .high = 0x99, .extended = 0xfe,};
#endif #endif
#include "lib/sensors.h"
#include "dev/button-sensor.h"
#include "dev/pir-sensor.h"
SENSORS(&button_sensor, &pir_sensor);
uint8_t uint8_t
rng_get_uint8(void) { rng_get_uint8(void) {
#if 1 #if 1
@ -315,6 +320,8 @@ uint8_t i;
process_start(&raven_lcd_process, NULL); process_start(&raven_lcd_process, NULL);
#endif #endif
process_start(&sensors_process, NULL);
/* Autostart other processes */ /* Autostart other processes */
autostart_start(autostart_processes); autostart_start(autostart_processes);

View file

@ -14,12 +14,12 @@ static int enabled = 0;
struct sensors_sensor *sensors[1]; struct sensors_sensor *sensors[1];
unsigned char sensors_flags[1]; unsigned char sensors_flags[1];
#define BUTTON_BIT INTF6 #define BUTTON_BIT INTF5
#define BUTTON_CHECK_IRQ() (EIFR & BUTTON_BIT) ? 0 : 1 #define BUTTON_CHECK_IRQ() (EIFR & BUTTON_BIT) ? 0 : 1
#define PRINTF(...) printf(__VA_ARGS__) #define PRINTF(...) printf(__VA_ARGS__)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
ISR(INT6_vect) ISR(INT5_vect)
{ {
// leds_toggle(LEDS_YELLOW); // leds_toggle(LEDS_YELLOW);
@ -39,7 +39,7 @@ ISR(INT6_vect)
static int static int
value(int type) value(int type)
{ {
return (PORTE & _BV(PE6) ? 0 : 1) || !timer_expired(&debouncetimer); return (PORTE & _BV(PE5) ? 0 : 1) || !timer_expired(&debouncetimer);
//return 0; //return 0;
} }
@ -54,10 +54,10 @@ configure(int type, int c)
led1_on(); led1_on();
timer_set(&debouncetimer, 0); timer_set(&debouncetimer, 0);
PRINTF("Setup sensor started\n"); PRINTF("Setup sensor started\n");
DDRE |= (0<<DDE6); // Set pin as input DDRE |= (0<<DDE5); // Set pin as input
PORTE |= (1<<PORTE6); // Set port PORTE bint 6 with pullup resistor PORTE |= (1<<PORTE5); // Set port PORTE bint 5 with pullup resistor
EICRB |= (2<<ISC60); // For falling edge EICRB |= (2<<ISC50); // For falling edge
EIMSK |= (1<<INT6); // Set int EIMSK |= (1<<INT5); // Set int
enabled = 1; enabled = 1;
sei(); sei();
led1_off(); led1_off();
@ -65,7 +65,7 @@ configure(int type, int c)
PRINTF("Sensor EIMSK set\n"); PRINTF("Sensor EIMSK set\n");
} else { } else {
enabled = 0; enabled = 0;
EIMSK &= ~(1<<INT6); // clear int EIMSK &= ~(1<<INT5); // clear int
PRINTF("Setup sensor failed\n"); PRINTF("Setup sensor failed\n");
} }
return 1; return 1;
@ -79,7 +79,7 @@ status(int type)
switch (type) { switch (type) {
case SENSORS_ACTIVE: case SENSORS_ACTIVE:
case SENSORS_READY: case SENSORS_READY:
return enabled;//(EIMSK & (1<<INT6) ? 0 : 1);//BUTTON_IRQ_ENABLED(); return enabled;//(EIMSK & (1<<INT5) ? 0 : 1);//BUTTON_IRQ_ENABLED();
} }
return 0; return 0;
} }