[board/chronos]
* introduced battery driver
This commit is contained in:
parent
be71c14f04
commit
443a5efbea
@ -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
board/chronos/drivers/battery.c
Normal file
13
board/chronos/drivers/battery.c
Normal 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;
|
||||
}
|
||||
6
board/chronos/drivers/include/battery.h
Normal file
6
board/chronos/drivers/include/battery.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef BATTERY_H
|
||||
#define BATTERY_H
|
||||
|
||||
uint16_t battery_get_voltate(void);
|
||||
|
||||
#endif /* BATTERY_H */
|
||||
Loading…
x
Reference in New Issue
Block a user