minor code cleanup
This commit is contained in:
parent
8e1e12dfd3
commit
8aaa9d14b7
5 changed files with 28 additions and 40 deletions
|
@ -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,8 +117,9 @@ status(int type)
|
|||
case SENSORS_ACTIVE:
|
||||
case SENSORS_READY:
|
||||
return active;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(acc_sensor, ACC_SENSOR,
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -51,12 +51,10 @@ interrupt(PORT2_VECTOR)
|
|||
{
|
||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||
|
||||
if(BUTTON_CHECK_IRQ()) {
|
||||
if(timer_expired(&debouncetimer)) {
|
||||
timer_set(&debouncetimer, CLOCK_SECOND / 4);
|
||||
sensors_changed(&button_sensor);
|
||||
LPM4_EXIT;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@ -94,12 +93,13 @@ configure(int type, int c)
|
|||
static int
|
||||
status(int type)
|
||||
{
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case SENSORS_ACTIVE:
|
||||
case SENSORS_READY:
|
||||
return BUTTON_IRQ_ENABLED();
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(button_sensor, BUTTON_SENSOR,
|
||||
|
|
|
@ -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"
|
||||
|
@ -66,11 +62,12 @@ static int
|
|||
status(int type)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSORS_ACTIVE:
|
||||
case SENSORS_READY:
|
||||
return active;
|
||||
case SENSORS_ACTIVE:
|
||||
case SENSORS_READY:
|
||||
return active;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
|
@ -97,8 +94,10 @@ configure(int type, int c)
|
|||
sky_sensors_deactivate(0x0F);
|
||||
active = 0;
|
||||
}
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(ext_sensor, "Ext",
|
||||
|
|
|
@ -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__
|
||||
|
|
Loading…
Reference in a new issue