Easily configure B2 on the cc2531 USB stick as a General-Purpose or Reset button

This commit is contained in:
George Oikonomou 2012-04-30 11:26:04 +01:00
parent cc76c649b1
commit fea95ae088
2 changed files with 11 additions and 0 deletions

View file

@ -102,6 +102,12 @@
#ifndef BUTTON_SENSOR_CONF_ON
#define BUTTON_SENSOR_CONF_ON 1 /* Buttons */
#endif
/* B2 on the cc2531 USB stick can be a reset button or a general-purpose one */
#ifndef CC2531_CONF_B2_REBOOTS
#define CC2531_CONF_B2_REBOOTS 0 /* General Purpose by default */
#endif
/* ADC - Turning this off will disable everything below */
#ifndef ADC_SENSOR_CONF_ON
#define ADC_SENSOR_CONF_ON 1

View file

@ -34,6 +34,7 @@
*/
#include "dev/port.h"
#include "dev/button-sensor.h"
#include "dev/watchdog.h"
/*---------------------------------------------------------------------------*/
static __data struct timer debouncetimer;
/*---------------------------------------------------------------------------*/
@ -150,7 +151,11 @@ port_1_isr(void) __interrupt(P1INT_VECTOR)
if(BUTTON_IRQ_CHECK(2)) {
if(timer_expired(&debouncetimer)) {
timer_set(&debouncetimer, CLOCK_SECOND / 8);
#if CC2531_CONF_B2_REBOOTS
watchdog_reboot();
#else /* General Purpose */
sensors_changed(&button_2_sensor);
#endif
}
}