Contiki 3.x
uart-intr.c
Go to the documentation of this file.
1 /**
2  * \file
3  *
4  * uart write routines
5  *
6  * \author
7  *
8  * Anthony "Asterisk" Ambuehl
9  *
10  * interrupt routines which must be in HOME bank. handles received data from UART.
11  *
12  */
13 #include "cc253x.h"
14 
15 #include "dev/uart0.h"
16 #include "dev/uart1.h"
17 #include "sys/energest.h"
18 
19 #if UART0_ENABLE
20 static int (* uart0_input_handler)(unsigned char c);
21 #endif
22 #if UART1_ENABLE
23 static int (* uart1_input_handler)(unsigned char c);
24 #endif
25 
26 #if UART0_ENABLE
27 /*---------------------------------------------------------------------------*/
28 void
29 uart0_set_input(int (* input)(unsigned char c))
30 {
31  uart0_input_handler = input;
32 }
33 /*---------------------------------------------------------------------------*/
34 #if UART0_CONF_WITH_INPUT
35 /* avoid referencing bits since we're not using them */
36 #pragma save
37 #if CC_CONF_OPTIMIZE_STACK_SIZE
38 #pragma exclude bits
39 #endif
40 void
41 uart0_rx_isr(void) __interrupt(URX0_VECTOR)
42 {
43  ENERGEST_ON(ENERGEST_TYPE_IRQ);
44  URX0IF = 0;
45  if(uart0_input_handler != NULL) {
46  uart0_input_handler(U0DBUF);
47  }
48  ENERGEST_OFF(ENERGEST_TYPE_IRQ);
49 }
50 #pragma restore
51 #endif
52 #endif /* UART0_ENABLE */
53 #if UART1_ENABLE
54 /*---------------------------------------------------------------------------*/
55 void
56 uart1_set_input(int (* input)(unsigned char c))
57 {
58  uart1_input_handler = input;
59 }
60 /*---------------------------------------------------------------------------*/
61 #if UART_ONE_CONF_WITH_INPUT
62 /* avoid referencing bits since we're not using them */
63 #pragma save
64 #if CC_CONF_OPTIMIZE_STACK_SIZE
65 #pragma exclude bits
66 #endif
67 void
68 uart1_rx_isr(void) __interrupt(URX1_VECTOR)
69 {
70  ENERGEST_ON(ENERGEST_TYPE_IRQ);
71  URX1IF = 0;
72  if(uart1_input_handler != NULL) {
73  uart1_input_handler(U1DBUF);
74  }
75  ENERGEST_OFF(ENERGEST_TYPE_IRQ);
76 }
77 #pragma restore
78 /*---------------------------------------------------------------------------*/
79 #endif /* UART_ONE_CONF_WITH_INPUT */
80 #endif /* UART1_ENABLE */
#define NULL
The null pointer.
Definitions for TI/Chipcon cc2530, cc2531 and cc2533 SFR registers.
Header file for the energy estimation mechanism