refactored some ADC code into sky-sensors and made it possible to turn off sensors to save energy

This commit is contained in:
joxe 2010-02-02 20:59:45 +00:00
parent fcf60e9260
commit fd4aebdf7f
5 changed files with 152 additions and 35 deletions

View file

@ -26,14 +26,14 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: battery-sensor.c,v 1.7 2010/01/15 21:37:15 nifi Exp $
* $Id: battery-sensor.c,v 1.8 2010/02/02 20:59:45 joxe Exp $
*
* -----------------------------------------------------------------
*
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne
* Created : 2005-11-01
* Updated : $Date: 2010/01/15 21:37:15 $
* $Revision: 1.7 $
* Updated : $Date: 2010/02/02 20:59:45 $
* $Revision: 1.8 $
*/
#include "dev/battery-sensor.h"
@ -45,25 +45,11 @@ static uint8_t active;
static void
activate(void)
{
/* This assumes that some other sensor system already did setup the ADC */
/* (in the case of the sky platform it is sensors_light_init that does it) */
P6SEL |= 0x80;
P6DIR = 0xff;
P6OUT = 0x00;
/* stop converting immediately */
ADC12CTL0 &= ~ENC;
ADC12CTL1 &= ~CONSEQ_3;
/* Configure ADC12_2 to sample channel 11 (voltage) and use */
/* the Vref+ as reference (SREF_1) since it is a stable reference */
ADC12MCTL2 = (INCH_11 + SREF_1);
ADC12CTL1 |= CONSEQ_3;
ADC12CTL0 |= ENC | ADC12SC;
/* Irq_adc12_activate(&battery_sensor, 6, (INCH_11 + SREF_1)); */
sky_sensors_activate(0x80);
active = 1;
}
@ -71,6 +57,7 @@ activate(void)
static void
deactivate(void)
{
sky_sensors_deactivate(0x80);
active = 0;
}
/*---------------------------------------------------------------------------*/