Contiki 2.6

uart_intr.c

Go to the documentation of this file.
00001 /**
00002  * \file
00003  *
00004  *   uart write routines
00005  *
00006  * \author
00007  * 
00008  *   Anthony "Asterisk" Ambuehl
00009  *
00010  *   interrupt routines which must be in HOME bank.  handles received data from UART.
00011  *
00012  */
00013 #include <stdlib.h>
00014 #include <string.h>
00015 
00016 #include "cc2430_sfr.h"
00017 
00018 #include "dev/leds.h"
00019 #include "dev/uart0.h"
00020 #include "dev/uart1.h"
00021 #include "sys/energest.h"
00022 
00023 #if UART_ZERO_ENABLE
00024 static int (*uart0_input_handler)(unsigned char c);
00025 #endif
00026 #if UART_ONE_ENABLE
00027 static int (*uart1_input_handler)(unsigned char c);
00028 #endif
00029 
00030 #if UART_ZERO_ENABLE
00031 /*---------------------------------------------------------------------------*/
00032 void
00033 uart0_set_input(int (*input)(unsigned char c))
00034 {
00035   uart0_input_handler = input;
00036 }
00037 
00038 /*---------------------------------------------------------------------------*/
00039 void
00040 uart0_rx_ISR(void) __interrupt (URX0_VECTOR)
00041 {
00042   ENERGEST_ON(ENERGEST_TYPE_IRQ);
00043   TCON_URX0IF = 0;
00044   if(uart0_input_handler != NULL) {
00045     uart0_input_handler(U0BUF);
00046   }
00047   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
00048 }
00049 /*---------------------------------------------------------------------------*/
00050 void
00051 uart0_tx_ISR( void ) __interrupt (UTX0_VECTOR)
00052 {
00053 }
00054 #endif /* UART_ZERO_ENABLE */
00055 #if UART_ONE_ENABLE
00056 /*---------------------------------------------------------------------------*/
00057 void
00058 uart1_set_input(int (*input)(unsigned char c))
00059 {
00060   uart1_input_handler = input;
00061 }
00062 /*---------------------------------------------------------------------------*/
00063 #if UART_ONE_CONF_WITH_INPUT
00064 void
00065 uart1_rx_ISR(void) __interrupt (URX1_VECTOR)
00066 {
00067   ENERGEST_ON(ENERGEST_TYPE_IRQ);
00068   TCON_URX1IF = 0;
00069   if(uart1_input_handler != NULL) {
00070     uart1_input_handler(U1BUF);
00071   }
00072   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
00073 }
00074 /*---------------------------------------------------------------------------*/
00075 void
00076 uart1_tx_ISR( void ) __interrupt (UTX1_VECTOR)
00077 {
00078 }
00079 /*---------------------------------------------------------------------------*/
00080 #endif /* UART_ONE_CONF_WITH_INPUT */
00081 #endif /* UART_ONE_ENABLE */