[board msba2]

* fixed header guards

[drivers ltc4150]
* added joule conversion
This commit is contained in:
Oliver Hahm 2011-03-04 16:46:20 +01:00
parent d96783a66e
commit 3622d83ea9
8 changed files with 19 additions and 6 deletions

View File

@ -24,8 +24,8 @@ and the mailinglist (subscription via web site)
scatterweb@lists.spline.inf.fu-berlin.de
*******************************************************************************/
#ifndef __BOARD_H
#define __BOARD_H
#ifndef __MSBA2_COMMON_H
#define __MSBA2_COMMON_H
/**
* @ingroup msb_a2
@ -48,4 +48,4 @@ and the mailinglist (subscription via web site)
#define VICIntEnClear VICIntEnClr
/** @} */
#endif // __BOARD_H
#endif // __MSBA2_COMMON_H

View File

@ -2,6 +2,7 @@
#define __BOARD_H
#include <msba2_common.h>
#include <bitarithm.h>
#define LED_RED_PIN (BIT25)
#define LED_GREEN_PIN (BIT26)

View File

@ -9,6 +9,7 @@ void ltc4150_stop();
double ltc4150_get_current_mA();
double ltc4150_get_total_mAh();
double ltc4150_get_total_Joule(void);
double ltc4150_get_avg_mA();
int ltc4150_get_interval();
long ltc4150_get_intcount(void);

View File

@ -46,6 +46,7 @@ and the mailinglist (subscription via web site)
#define _GFH (double)32.631375
#define _R_SENSE (double)0.330
#define SUPPLY_VOLTAGE (5)
void ltc4150_disable_int(void);
void ltc4150_enable_int(void);

View File

@ -54,6 +54,10 @@ static double __attribute__((__no_instrument_function__)) coulomb_to_mA(double c
return (coulomb * 1000) / 3600;
}
static double mAh_to_Joule(double mAh) {
return (SUPPLY_VOLTAGE * mAh * 3600);
}
uint32_t ltc4150_get_last_int_duration_us() {
return HWTIMER_TICKS_TO_US(last_int_duration);
}
@ -66,6 +70,10 @@ double __attribute__((__no_instrument_function__)) ltc4150_get_total_mAh() {
return coulomb_to_mA(int_to_coulomb(int_count));
}
double ltc4150_get_total_Joule(void) {
return mAh_to_Joule(ltc4150_get_total_mAh());
}
double ltc4150_get_avg_mA() {
return (int_to_coulomb(int_count)*1000000000)/HWTIMER_TICKS_TO_US(last_int_time - start_time);
}

View File

@ -34,7 +34,6 @@ int main(void) {
shell_init(&shell, NULL, shell_readc, shell_putchar);
shell_run(&shell);
return 0;
}

View File

@ -7,6 +7,8 @@
int main(void)
{
sht11_val_t sht11_val;
double mAh = 0;
uint8_t success = 0;
puts("");
@ -18,11 +20,12 @@ int main(void)
while (1) {
success = sht11_read_sensor(&sht11_val, HUMIDITY|TEMPERATURE);
mAh = ltc4150_get_total_mAh();
if (!success) {
printf("error;error;error\n");
}
else {
printf("%.2f;%.2f;%.2f\n", sht11_val.temperature, sht11_val.relhum, sht11_val.relhum_temp);
printf("%.2f;%.2f;%.2f;%.2f\n", sht11_val.temperature, sht11_val.relhum, sht11_val.relhum_temp, mAh);
}
LED_RED_TOGGLE;
swtimer_usleep(60 * 1000*1000);

View File

@ -1,5 +1,5 @@
SubDir TOP projects test_cc110x_ng ;
Module test_cc110x_ng : main.c : cc110x_ng shell shell_commands transceiver ps rtc posix_io uart0 auto_init swtimer config ;
Module test_cc110x_ng : main.c : cc110x_ng shell shell_commands transceiver ps rtc posix_io uart0 auto_init swtimer config ltc4150 ;
UseModule test_cc110x_ng ;