minor code cleanup

This commit is contained in:
Niclas Finne 2011-12-19 18:03:55 +01:00
parent 8e1e12dfd3
commit 8aaa9d14b7
5 changed files with 28 additions and 40 deletions

View file

@ -26,14 +26,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: acc-sensor.c,v 1.6 2010/01/14 20:01:18 nifi Exp $
*
* -----------------------------------------------------------------
*
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
* Created : 2005-11-01
* Updated : $Date: 2010/01/14 20:01:18 $
* $Revision: 1.6 $
*/
#include "dev/acc-sensor.h"
@ -101,15 +97,15 @@ value(int type)
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int c)
configure(int type, int value)
{
switch(type) {
case SENSORS_ACTIVE:
if (c) {
if(type == SENSORS_ACTIVE) {
if(value) {
activate();
} else {
deactivate();
}
return 1;
}
return 0;
}
@ -121,9 +117,10 @@ status(int type)
case SENSORS_ACTIVE:
case SENSORS_READY:
return active;
}
default:
return 0;
}
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(acc_sensor, ACC_SENSOR,
value, configure, status);

View file

@ -26,14 +26,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: acc-sensor.h,v 1.1 2009/01/15 21:06:02 adamdunkels Exp $
*
* -----------------------------------------------------------------
*
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
* Created : 2005-11-01
* Updated : $Date: 2009/01/15 21:06:02 $
* $Revision: 1.1 $
*/
#ifndef __ACC_SENSOR_H__

View file

@ -51,13 +51,11 @@ interrupt(PORT2_VECTOR)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);
if(BUTTON_CHECK_IRQ()) {
if(timer_expired(&debouncetimer)) {
if(BUTTON_CHECK_IRQ() && timer_expired(&debouncetimer)) {
timer_set(&debouncetimer, CLOCK_SECOND / 4);
sensors_changed(&button_sensor);
LPM4_EXIT;
}
}
P2IFG = 0x00;
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
@ -69,11 +67,14 @@ value(int type)
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int c)
configure(int type, int value)
{
switch (type) {
case SENSORS_ACTIVE:
if (c) {
if(type == SENSORS_ACTIVE) {
if(value == 0) {
/* Deactivate button sensor */
BUTTON_DISABLE_IRQ();
} else {
/* Activate button sensor */
if(!status(SENSORS_ACTIVE)) {
timer_set(&debouncetimer, 0);
BUTTON_IRQ_EDGE_SELECTD();
@ -83,8 +84,6 @@ configure(int type, int c)
BUTTON_ENABLE_IRQ();
}
} else {
BUTTON_DISABLE_IRQ();
}
return 1;
}
@ -98,9 +97,10 @@ status(int type)
case SENSORS_ACTIVE:
case SENSORS_READY:
return BUTTON_IRQ_ENABLED();
}
default:
return 0;
}
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(button_sensor, BUTTON_SENSOR,
value, configure, status);

View file

@ -26,15 +26,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ext-sensor.c,v 1.3 2010/02/13 11:20:48 joxe Exp $
*
* -----------------------------------------------------------------
*
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne, Marcus Lundén,
* Jesper Karlsson
* Created : 2005-11-01
* Updated : $Date: 2010/02/13 11:20:48 $
* $Revision: 1.3 $
*/
#include "contiki.h"
@ -69,9 +65,10 @@ status(int type)
case SENSORS_ACTIVE:
case SENSORS_READY:
return active;
}
default:
return 0;
}
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int c)
@ -97,9 +94,11 @@ configure(int type, int c)
sky_sensors_deactivate(0x0F);
active = 0;
}
}
return 1;
default:
return 0;
}
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(ext_sensor, "Ext",
value, configure, status);

View file

@ -26,14 +26,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ext-sensor.h,v 1.2 2010/02/13 11:20:48 joxe Exp $
*
* -----------------------------------------------------------------
*
* Author : Marcus Lundén
* Created : 2005-11-01
* Updated : $Date: 2010/02/13 11:20:48 $
* $Revision: 1.2 $
*/
#ifndef __EXT_SENSOR_H__