Added IRQ and SERIAL component.

This commit is contained in:
adamdunkels 2007-05-22 20:53:04 +00:00
parent f5c8869028
commit 9b6f6d6822

View file

@ -28,12 +28,12 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: energest.h,v 1.3 2007/05/15 07:54:03 adamdunkels Exp $ * $Id: energest.h,v 1.4 2007/05/22 20:53:04 adamdunkels Exp $
*/ */
/** /**
* \file * \file
* A brief description of what this file is. * Header file for the energy estimation mechanism
* \author * \author
* Adam Dunkels <adam@sics.se> * Adam Dunkels <adam@sics.se>
*/ */
@ -41,6 +41,8 @@
#ifndef __ENERGEST_H__ #ifndef __ENERGEST_H__
#define __ENERGEST_H__ #define __ENERGEST_H__
#include "rtimer-arch.h"
typedef struct { typedef struct {
/* unsigned long cummulative[2];*/ /* unsigned long cummulative[2];*/
unsigned long current; unsigned long current;
@ -49,6 +51,7 @@ typedef struct {
enum energest_type { enum energest_type {
ENERGEST_TYPE_CPU, ENERGEST_TYPE_CPU,
ENERGEST_TYPE_LPM, ENERGEST_TYPE_LPM,
ENERGEST_TYPE_IRQ,
ENERGEST_TYPE_LED_GREEN, ENERGEST_TYPE_LED_GREEN,
ENERGEST_TYPE_LED_YELLOW, ENERGEST_TYPE_LED_YELLOW,
ENERGEST_TYPE_LED_RED, ENERGEST_TYPE_LED_RED,
@ -57,21 +60,26 @@ enum energest_type {
ENERGEST_TYPE_SENSORS, ENERGEST_TYPE_SENSORS,
ENERGEST_TYPE_SERIAL,
ENERGEST_TYPE_MAX ENERGEST_TYPE_MAX
}; };
void energest_init(void); void energest_init(void);
unsigned long energest_type_time(int type); unsigned long energest_type_time(int type);
void energest_type_set(int type, unsigned long value);
#if ENERGEST_CONF_ON #if ENERGEST_CONF_ON
/*extern int energest_total_count;*/
extern energest_t energest_total_time[ENERGEST_TYPE_MAX]; extern energest_t energest_total_time[ENERGEST_TYPE_MAX];
extern unsigned short energest_current_time[ENERGEST_TYPE_MAX]; extern unsigned short energest_current_time[ENERGEST_TYPE_MAX];
#define ENERGEST_ON(type) do { \ #define ENERGEST_ON(type) do { \
energest_current_time[type] = energest_arch_now(); \ /*++energest_total_count;*/ \
energest_current_time[type] = RTIMER_NOW(); \
} while(0) } while(0)
#define ENERGEST_OFF(type) do { \ #define ENERGEST_OFF(type) do { \
energest_total_time[type].current += (unsigned long)((signed short)energest_arch_now() - \ energest_total_time[type].current += (unsigned long)((signed short)RTIMER_NOW() - \
(signed short)energest_current_time[type]); \ (signed short)energest_current_time[type]); \
} while(0) } while(0)
#else /* ENERGEST_CONF_ON */ #else /* ENERGEST_CONF_ON */