From 75c0962363c8bdfb4444c5f8392c2a85bbd978d9 Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Tue, 9 Nov 2010 18:48:45 +0100 Subject: [PATCH] * added get_interval function to ltc4150 * fixed date command (problem with leading zeros) --- drivers/include/ltc4150.h | 1 + drivers/ltc4150.c | 4 ++++ sys/shell/ltc4150.c | 2 +- sys/shell/rtc.c | 10 +++++----- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/include/ltc4150.h b/drivers/include/ltc4150.h index b024f4b5cd..88160c8913 100644 --- a/drivers/include/ltc4150.h +++ b/drivers/include/ltc4150.h @@ -10,5 +10,6 @@ void ltc4150_stop(); double ltc4150_get_current_mA(); double ltc4150_get_total_mAh(); double ltc4150_get_avg_mA(); +int ltc4150_get_interval(); #endif /* __LTC4150_H */ diff --git a/drivers/ltc4150.c b/drivers/ltc4150.c index 6c58b3d7d3..7c50553a85 100644 --- a/drivers/ltc4150.c +++ b/drivers/ltc4150.c @@ -70,6 +70,10 @@ double ltc4150_get_avg_mA() { return (int_to_coulomb(int_count)*1000000000)/HWTIMER_TICKS_TO_US(last_int_time - start_time); } +int ltc4150_get_interval() { + return HWTIMER_TICKS_TO_US(last_int_time - start_time); +} + unsigned long ltc4150_get_intcount() { return int_count; } diff --git a/sys/shell/ltc4150.c b/sys/shell/ltc4150.c index 707878ee43..91d557592a 100644 --- a/sys/shell/ltc4150.c +++ b/sys/shell/ltc4150.c @@ -2,7 +2,7 @@ #include void _get_current_handler(char* unused) { - printf("Power usage: %.4f mA (%.4f mA avg/ %.4f mAh total)\n", ltc4150_get_current_mA(), ltc4150_get_avg_mA(), ltc4150_get_total_mAh()); + printf("Power usage: %.4f mA (%.4f mA avg/ %.4f mAh total / %i sec)\n", ltc4150_get_current_mA(), ltc4150_get_avg_mA(), ltc4150_get_total_mAh(), ltc4150_get_interval()); } void _reset_current_handler(char* unused) { diff --git a/sys/shell/rtc.c b/sys/shell/rtc.c index 44c58a65a7..25f99c089e 100644 --- a/sys/shell/rtc.c +++ b/sys/shell/rtc.c @@ -16,13 +16,13 @@ void _settime_handler(char* c) { int res; uint16_t month, epoch_year; - res = sscanf(c, "date %hu-%hu-%i %i:%i:%i", + res = sscanf(c, "date %hu-%hu-%u %u:%u:%u", &epoch_year, &month, - &(now.tm_mday), - &(now.tm_hour), - &(now.tm_min), - &(now.tm_sec)); + (unsigned int*) &(now.tm_mday), + (unsigned int*) &(now.tm_hour), + (unsigned int*) &(now.tm_min), + (unsigned int*) &(now.tm_sec)); if (res < 6) { printf("Usage: date YYYY-MM-DD hh:mm:ss\n");