[board/chronos]

* introduced battery driver
This commit is contained in:
Oliver Hahm 2010-12-17 13:38:03 +01:00
parent be71c14f04
commit 443a5efbea
3 changed files with 20 additions and 0 deletions

View File

@ -5,5 +5,6 @@ HDRS += $(TOP)/board/$(CPU)/drivers/include ;
Module board_display : display.c display1.c ;
Module board_cc110x : cc430-cc110x.c : cc110x_cc430 ;
Module board_buzzer : buzzer.c : hwtimer ;
Module battery : battery.c : adc hwtimer ;
Module display_putchar : display_putchar.c : board_display ;

View File

@ -0,0 +1,13 @@
#include <stdint.h>
#include <cc430x613x.h>
#include <cc430-adc.h>
uint16_t battery_get_voltate(void) {
uint16_t voltage;
voltage = adc12_single_conversion(REFVSEL_1, ADC12SHT0_10, ADC12INCH_11);
/* Ideally we have A11=0->AVCC=0V ... A11=4095(2^12-1)->AVCC=4V
* --> (A11/4095)*4V=AVCC --> AVCC=(A11*4)/4095 */
voltage = (voltage * 2 * 2 * 1000) / 4095;
return voltage;
}

View File

@ -0,0 +1,6 @@
#ifndef BATTERY_H
#define BATTERY_H
uint16_t battery_get_voltate(void);
#endif /* BATTERY_H */