Contiki 2.6
|
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 "cc253x.h" 00014 00015 #include "dev/uart0.h" 00016 #include "dev/uart1.h" 00017 #include "sys/energest.h" 00018 #include "dev/leds.h" 00019 00020 #if UART0_ENABLE 00021 static int (*uart0_input_handler)(unsigned char c); 00022 #endif 00023 #if UART1_ENABLE 00024 static int (*uart1_input_handler)(unsigned char c); 00025 #endif 00026 00027 #if UART0_ENABLE 00028 /*---------------------------------------------------------------------------*/ 00029 void 00030 uart0_set_input(int (*input)(unsigned char c)) 00031 { 00032 uart0_input_handler = input; 00033 } 00034 /*---------------------------------------------------------------------------*/ 00035 #if UART0_CONF_WITH_INPUT 00036 void 00037 uart0_rx_isr(void) __interrupt (URX0_VECTOR) 00038 { 00039 ENERGEST_ON(ENERGEST_TYPE_IRQ); 00040 leds_toggle(LEDS_YELLOW); 00041 URX0IF = 0; 00042 if(uart0_input_handler != NULL) { 00043 uart0_input_handler(U0DBUF); 00044 } 00045 ENERGEST_OFF(ENERGEST_TYPE_IRQ); 00046 } 00047 #endif 00048 #endif /* UART0_ENABLE */ 00049 #if UART1_ENABLE 00050 /*---------------------------------------------------------------------------*/ 00051 void 00052 uart1_set_input(int (*input)(unsigned char c)) 00053 { 00054 uart1_input_handler = input; 00055 } 00056 /*---------------------------------------------------------------------------*/ 00057 #if UART_ONE_CONF_WITH_INPUT 00058 void 00059 uart1_rx_isr(void) __interrupt (URX1_VECTOR) 00060 { 00061 ENERGEST_ON(ENERGEST_TYPE_IRQ); 00062 URX1IF = 0; 00063 if(uart1_input_handler != NULL) { 00064 uart1_input_handler(U1DBUF); 00065 } 00066 ENERGEST_OFF(ENERGEST_TYPE_IRQ); 00067 } 00068 /*---------------------------------------------------------------------------*/ 00069 #endif /* UART_ONE_CONF_WITH_INPUT */ 00070 #endif /* UART1_ENABLE */