Changed the return value of the inpt handler function to int so that it can wake up the CPU from LPM

This commit is contained in:
adamdunkels 2008-01-08 08:04:09 +00:00
parent 7f05b8a5ef
commit e16b7ffcf0
2 changed files with 12 additions and 9 deletions

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)$Id: uart1.c,v 1.3 2007/09/06 11:45:08 nvt-se Exp $ * @(#)$Id: uart1.c,v 1.4 2008/01/08 08:04:09 adamdunkels Exp $
*/ */
/* /*
@ -40,11 +40,13 @@
#include "lib/energest.h" #include "lib/energest.h"
#include "dev/uart1.h" #include "dev/uart1.h"
static void (*uart1_input_handler)(unsigned char c); #include "dev/leds.h"
static int (*uart1_input_handler)(unsigned char c);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
uart1_set_input(void (*input)(unsigned char c)) uart1_set_input(int (*input)(unsigned char c))
{ {
uart1_input_handler = input; uart1_input_handler = input;
} }
@ -53,7 +55,7 @@ void
uart1_writeb(unsigned char c) uart1_writeb(unsigned char c)
{ {
/* Loop until the transmission buffer is available. */ /* Loop until the transmission buffer is available. */
while ((IFG2 & UTXIFG1) == 0); while((IFG2 & UTXIFG1) == 0);
/* Transmit the data. */ /* Transmit the data. */
TXBUF1 = c; TXBUF1 = c;
@ -126,9 +128,10 @@ uart1_interrupt(void)
volatile unsigned dummy; volatile unsigned dummy;
dummy = RXBUF1; /* Clear error flags by forcing a dummy read. */ dummy = RXBUF1; /* Clear error flags by forcing a dummy read. */
} else { } else {
if (uart1_input_handler != NULL) { if(uart1_input_handler != NULL) {
uart1_input_handler(RXBUF1); if(uart1_input_handler(RXBUF1)) {
LPM4_EXIT; LPM4_EXIT;
}
} }
} }
ENERGEST_OFF(ENERGEST_TYPE_IRQ); ENERGEST_OFF(ENERGEST_TYPE_IRQ);

View File

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: uart1.h,v 1.2 2007/09/06 11:45:08 nvt-se Exp $ * $Id: uart1.h,v 1.3 2008/01/08 08:04:09 adamdunkels Exp $
*/ */
/** /**
@ -45,7 +45,7 @@
#define UART1_BAUD2UBR(baud) ((MSP430_CPU_SPEED)/(baud)) #define UART1_BAUD2UBR(baud) ((MSP430_CPU_SPEED)/(baud))
void uart1_set_input(void (*input)(unsigned char c)); void uart1_set_input(int (*input)(unsigned char c));
void uart1_writeb(unsigned char c); void uart1_writeb(unsigned char c);
void uart1_init(unsigned long ubr); void uart1_init(unsigned long ubr);