mirror of
https://github.com/oliverschmidt/contiki.git
synced 2025-01-03 11:30:53 +00:00
Made scalar values explicitly unsigned long. Preliminary support for cummulative estimates (larger than 32 bits)
This commit is contained in:
parent
af997a93e0
commit
5c79330b41
@ -28,7 +28,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: energest.c,v 1.1 2007/03/19 00:30:13 adamdunkels Exp $
|
||||
* $Id: energest.c,v 1.2 2007/05/15 07:54:03 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -39,6 +39,7 @@
|
||||
*/
|
||||
|
||||
#include "lib/energest.h"
|
||||
#include "contiki-conf.h"
|
||||
|
||||
#if ENERGEST_CONF_ON
|
||||
|
||||
@ -51,17 +52,17 @@ energest_init(void)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < ENERGEST_TYPE_MAX; ++i) {
|
||||
energest_total_time[i] = 0;
|
||||
energest_total_time[i].current = 0;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
energest_t
|
||||
unsigned long
|
||||
energest_type_time(int type)
|
||||
{
|
||||
return energest_total_time[type];
|
||||
return energest_total_time[type].current;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#else /* ENERGEST_CONF_ON */
|
||||
void energest_init(void) {}
|
||||
energest_t energest_type_time(int type) { return 0; }
|
||||
unsigned long energest_type_time(int type) { return 0; }
|
||||
#endif /* ENERGEST_CONF_ON */
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: energest.h,v 1.2 2007/03/25 09:20:53 oliverschmidt Exp $
|
||||
* $Id: energest.h,v 1.3 2007/05/15 07:54:03 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -41,16 +41,14 @@
|
||||
#ifndef __ENERGEST_H__
|
||||
#define __ENERGEST_H__
|
||||
|
||||
typedef unsigned long energest_t;
|
||||
typedef struct {
|
||||
/* unsigned long cummulative[2];*/
|
||||
unsigned long current;
|
||||
} energest_t;
|
||||
|
||||
enum energest_type {
|
||||
ENERGEST_TYPE_NONE,
|
||||
|
||||
ENERGEST_TYPE_CPU,
|
||||
ENERGEST_TYPE_LPM1,
|
||||
ENERGEST_TYPE_LPM2,
|
||||
ENERGEST_TYPE_LPM3,
|
||||
ENERGEST_TYPE_LPM4,
|
||||
ENERGEST_TYPE_LPM,
|
||||
ENERGEST_TYPE_LED_GREEN,
|
||||
ENERGEST_TYPE_LED_YELLOW,
|
||||
ENERGEST_TYPE_LED_RED,
|
||||
@ -63,25 +61,25 @@ enum energest_type {
|
||||
};
|
||||
|
||||
void energest_init(void);
|
||||
energest_t energest_type_time(int type);
|
||||
unsigned long energest_type_time(int type);
|
||||
|
||||
#if ENERGEST_CONF_ON
|
||||
extern energest_t energest_total_time[ENERGEST_TYPE_MAX];
|
||||
extern energest_t energest_current_time[ENERGEST_TYPE_MAX];
|
||||
extern unsigned short energest_current_time[ENERGEST_TYPE_MAX];
|
||||
|
||||
#define ENERGEST_ON(type) do { \
|
||||
energest_current_time[type] = energest_arch_now(); \
|
||||
} while(0)
|
||||
#define ENERGEST_OFF(type) do { \
|
||||
energest_total_time[type] += energest_arch_now() - \
|
||||
energest_current_time[type]; \
|
||||
energest_total_time[type].current += (unsigned long)((signed short)energest_arch_now() - \
|
||||
(signed short)energest_current_time[type]); \
|
||||
} while(0)
|
||||
#else /* ENERGEST_CONF_ON */
|
||||
#define ENERGEST_ON(type) do { } while(0)
|
||||
#define ENERGEST_OFF(type) do { } while(0)
|
||||
#endif /* ENERGEST_CONF_ON */
|
||||
|
||||
energest_t energest_arch_current_estimate(void);
|
||||
energest_t energest_arch_now(void);
|
||||
unsigned long energest_arch_current_estimate(void);
|
||||
unsigned short energest_arch_now(void);
|
||||
|
||||
#endif /* __ENERGEST_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user