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 <stdlib.h>
14 #include <string.h>
15 
16 #include "cc2430_sfr.h"
17 
18 #include "dev/leds.h"
19 #include "dev/uart0.h"
20 #include "dev/uart1.h"
21 #include "sys/energest.h"
22 
23 #if UART_ZERO_ENABLE
24 static int (* uart0_input_handler)(unsigned char c);
25 #endif
26 #if UART_ONE_ENABLE
27 static int (* uart1_input_handler)(unsigned char c);
28 #endif
29 
30 #if UART_ZERO_ENABLE
31 /*---------------------------------------------------------------------------*/
32 void
33 uart0_set_input(int (* input)(unsigned char c))
34 {
35  uart0_input_handler = input;
36 }
37 
38 /*---------------------------------------------------------------------------*/
39 #pragma save
40 #if CC_CONF_OPTIMIZE_STACK_SIZE
41 #pragma exclude bits
42 #endif
43 void
44 uart0_rx_ISR(void) __interrupt(URX0_VECTOR)
45 {
46  ENERGEST_ON(ENERGEST_TYPE_IRQ);
47  TCON_URX0IF = 0;
48  if(uart0_input_handler != NULL) {
49  uart0_input_handler(U0BUF);
50  }
51  ENERGEST_OFF(ENERGEST_TYPE_IRQ);
52 }
53 /*---------------------------------------------------------------------------*/
54 void
55 uart0_tx_ISR(void) __interrupt(UTX0_VECTOR)
56 {
57 }
58 #pragma restore
59 #endif /* UART_ZERO_ENABLE */
60 #if UART_ONE_ENABLE
61 /*---------------------------------------------------------------------------*/
62 void
63 uart1_set_input(int (* input)(unsigned char c))
64 {
65  uart1_input_handler = input;
66 }
67 /*---------------------------------------------------------------------------*/
68 #if UART_ONE_CONF_WITH_INPUT
69 #pragma save
70 #if CC_CONF_OPTIMIZE_STACK_SIZE
71 #pragma exclude bits
72 #endif
73 void
74 uart1_rx_ISR(void) __interrupt(URX1_VECTOR)
75 {
76  ENERGEST_ON(ENERGEST_TYPE_IRQ);
77  TCON_URX1IF = 0;
78  if(uart1_input_handler != NULL) {
79  uart1_input_handler(U1BUF);
80  }
81  ENERGEST_OFF(ENERGEST_TYPE_IRQ);
82 }
83 /*---------------------------------------------------------------------------*/
84 void
85 uart1_tx_ISR(void) __interrupt(UTX1_VECTOR)
86 {
87 }
88 #pragma restore
89 /*---------------------------------------------------------------------------*/
90 #endif /* UART_ONE_CONF_WITH_INPUT */
91 #endif /* UART_ONE_ENABLE */
CC2430 registers header file for CC2430.
#define NULL
The null pointer.
Header file for the energy estimation mechanism