Skip to content

Commit

Permalink
[board/chronos]
Browse files Browse the repository at this point in the history
* introduced battery driver
  • Loading branch information
OlegHahm committed Dec 17, 2010
1 parent c608fe4 commit 27afca6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions chronos/drivers/Jamfile
Expand Up @@ -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 ;
13 changes: 13 additions & 0 deletions chronos/drivers/battery.c
@@ -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;
}
6 changes: 6 additions & 0 deletions chronos/drivers/include/battery.h
@@ -0,0 +1,6 @@
#ifndef BATTERY_H
#define BATTERY_H

uint16_t battery_get_voltate(void);

#endif /* BATTERY_H */

0 comments on commit 27afca6

Please sign in to comment.