Added energy estimation

This commit is contained in:
adamdunkels 2007-05-22 21:07:51 +00:00
parent b32a9b9be5
commit f33844bd9c
2 changed files with 20 additions and 4 deletions

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* @(#)$Id: rs232.c,v 1.1 2006/06/18 07:49:33 adamdunkels Exp $
* @(#)$Id: rs232.c,v 1.2 2007/05/22 21:07:51 adamdunkels Exp $
*/
/** \addtogroup esbrs232
@ -55,6 +55,7 @@ static int (* input_handler)(unsigned char) = NULL;
interrupt(UART1RX_VECTOR)
rs232_rx_usart1(void)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);
/* Check status register for receive errors. - before reading RXBUF since
it clears the error and interrupt flags */
if(!(URCTL1 & RXERR) && input_handler != NULL) {
@ -66,6 +67,7 @@ interrupt(UART1RX_VECTOR)
/* Else read out the char to clear the I-flags, etc. */
RXBUF1;
}
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
/*---------------------------------------------------------------------------*/
/**
@ -91,11 +93,15 @@ rs232_init(void)
void
rs232_send(char c)
{
ENERGEST_ON(ENERGEST_TYPE_SERIAL);
/* Loop until the transmission buffer is available. */
while ((IFG2 & UTXIFG1) == 0);
while((IFG2 & UTXIFG1) == 0) {
}
/* Transmit the data. */
TXBUF1 = c;
ENERGEST_OFF(ENERGEST_TYPE_SERIAL);
}
/*---------------------------------------------------------------------------*/
void

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* @(#)$Id: tr1001-gcr.c,v 1.7 2007/03/19 00:35:23 adamdunkels Exp $
* @(#)$Id: tr1001-gcr.c,v 1.8 2007/05/22 21:08:04 adamdunkels Exp $
*/
/**
* \addtogroup esb
@ -76,6 +76,14 @@ static unsigned short packets_err;
static unsigned short packets_ok;
#endif /* TR1001_STATISTICS */
/*const struct radio_driver tr1001_driver =
{
tr1001_send,
tr1001_read,
tr1001_set_receiver,
tr1001_on,
tr1001_off,
};*/
/*
* The buffer which holds incoming data.
@ -142,7 +150,7 @@ static struct process *poll_process;
#define LOG(...)
#endif
#define GCRLOG(...) /* printf(__VA_ARGS__) */
#define GCRLOG(...) /* printf(__VA_ARGS__)*/
/*---------------------------------------------------------------------------*/
#if TR1001_STATISTICS
@ -386,10 +394,12 @@ tr1001_init(struct process *p)
interrupt (UART0RX_VECTOR)
tr1001_rxhandler(void)
{
ENERGEST_ON(ENERGEST_TYPE_IRQ);
tr1001_default_rxhandler_pt(RXBUF0);
if(tr1001_rxstate == RXSTATE_FULL) {
LPM_AWAKE();
}
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
/*---------------------------------------------------------------------------*/
static void