add pir sensor, sensor events
This commit is contained in:
parent
a1152fd96e
commit
32ab451fff
|
@ -4,13 +4,17 @@ CONTIKI_CORE=contiki-main
|
|||
CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o
|
||||
CONTIKI_TARGET_SOURCEFILES += contiki-main.c params.c node-id.c
|
||||
#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
|
||||
CONTIKI_TARGET_SOURCEFILES += dht11.c
|
||||
#Needed for DS18S20 temperature sensor
|
||||
CONTIKI_TARGET_SOURCEFILES += ds1820.c
|
||||
#Needed for Battery test
|
||||
CONTIKI_TARGET_SOURCEFILES += battery-sensor.c
|
||||
#Needed for PIR
|
||||
CONTIKI_TARGET_SOURCEFILES += pir-sensor.c
|
||||
CONTIKIAVR=$(CONTIKI)/cpu/avr
|
||||
CONTIKIBOARD=.
|
||||
BOOTLOADER_START = 0x1F000
|
||||
|
|
|
@ -146,7 +146,7 @@ typedef unsigned short uip_stats_t;
|
|||
#define RIMEADDR_CONF_SIZE 8
|
||||
#define UIP_CONF_ICMP6 1
|
||||
#define UIP_CONF_UDP 1
|
||||
#define UIP_CONF_TCP 1
|
||||
#define UIP_CONF_TCP 0
|
||||
#define NETSTACK_CONF_NETWORK sicslowpan_driver
|
||||
#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
|
||||
#else
|
||||
|
|
|
@ -144,6 +144,11 @@ FUSES ={.low = 0xF6, .high = 0x98, .extended = 0xfd,};
|
|||
FUSES ={.low = 0xC2, .high = 0x99, .extended = 0xfe,};
|
||||
#endif
|
||||
|
||||
#include "lib/sensors.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/pir-sensor.h"
|
||||
SENSORS(&button_sensor, &pir_sensor);
|
||||
|
||||
uint8_t
|
||||
rng_get_uint8(void) {
|
||||
#if 1
|
||||
|
@ -315,6 +320,8 @@ uint8_t i;
|
|||
process_start(&raven_lcd_process, NULL);
|
||||
#endif
|
||||
|
||||
process_start(&sensors_process, NULL);
|
||||
|
||||
/* Autostart other processes */
|
||||
autostart_start(autostart_processes);
|
||||
|
||||
|
|
|
@ -14,12 +14,12 @@ static int enabled = 0;
|
|||
struct sensors_sensor *sensors[1];
|
||||
unsigned char sensors_flags[1];
|
||||
|
||||
#define BUTTON_BIT INTF6
|
||||
#define BUTTON_BIT INTF5
|
||||
#define BUTTON_CHECK_IRQ() (EIFR & BUTTON_BIT) ? 0 : 1
|
||||
|
||||
#define PRINTF(...) printf(__VA_ARGS__)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
ISR(INT6_vect)
|
||||
ISR(INT5_vect)
|
||||
{
|
||||
|
||||
// leds_toggle(LEDS_YELLOW);
|
||||
|
@ -39,7 +39,7 @@ ISR(INT6_vect)
|
|||
static int
|
||||
value(int type)
|
||||
{
|
||||
return (PORTE & _BV(PE6) ? 0 : 1) || !timer_expired(&debouncetimer);
|
||||
return (PORTE & _BV(PE5) ? 0 : 1) || !timer_expired(&debouncetimer);
|
||||
//return 0;
|
||||
}
|
||||
|
||||
|
@ -54,10 +54,10 @@ configure(int type, int c)
|
|||
led1_on();
|
||||
timer_set(&debouncetimer, 0);
|
||||
PRINTF("Setup sensor started\n");
|
||||
DDRE |= (0<<DDE6); // Set pin as input
|
||||
PORTE |= (1<<PORTE6); // Set port PORTE bint 6 with pullup resistor
|
||||
EICRB |= (2<<ISC60); // For falling edge
|
||||
EIMSK |= (1<<INT6); // Set int
|
||||
DDRE |= (0<<DDE5); // Set pin as input
|
||||
PORTE |= (1<<PORTE5); // Set port PORTE bint 5 with pullup resistor
|
||||
EICRB |= (2<<ISC50); // For falling edge
|
||||
EIMSK |= (1<<INT5); // Set int
|
||||
enabled = 1;
|
||||
sei();
|
||||
led1_off();
|
||||
|
@ -65,7 +65,7 @@ configure(int type, int c)
|
|||
PRINTF("Sensor EIMSK set\n");
|
||||
} else {
|
||||
enabled = 0;
|
||||
EIMSK &= ~(1<<INT6); // clear int
|
||||
EIMSK &= ~(1<<INT5); // clear int
|
||||
PRINTF("Setup sensor failed\n");
|
||||
}
|
||||
return 1;
|
||||
|
@ -79,7 +79,7 @@ status(int type)
|
|||
switch (type) {
|
||||
case SENSORS_ACTIVE:
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue