Contiki-Inga 3.x
rs232.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005, Swedish Institute of Computer Science
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  */
32 
33 /** \addtogroup esb
34  * @{ */
35 
36 /**
37  * \defgroup esbrs232 ESB RS232
38  *
39  * @{
40  */
41 
42 /**
43  * \file
44  * Header file for MSP430 RS232 driver.
45  * \author Adam Dunkels <adam@sics.se>
46  *
47  */
48 #ifndef RS232_H_
49 #define RS232_H_
50 
51 
52 #define RS232_19200 1
53 #define RS232_38400 2
54 #define RS232_57600 3
55 #define RS232_115200 4
56 
57 /**
58  * \brief Initialize the RS232 module
59  *
60  * This function is called from the boot up code to
61  * initalize the RS232 module.
62  */
63 void rs232_init(void);
64 
65 /**
66  * \brief Set an input handler for incoming RS232 data
67  * \param f A pointer to a byte input handler
68  *
69  * This function sets the input handler for incoming RS232
70  * data. The input handler function is called for every
71  * incoming data byte. The function is called from the
72  * RS232 interrupt handler, so care must be taken when
73  * implementing the input handler to avoid race
74  * conditions.
75  *
76  * The return value of the input handler affects the sleep
77  * mode of the CPU: if the input handler returns non-zero
78  * (true), the CPU is awakened to let other processing
79  * take place. If the input handler returns zero, the CPU
80  * is kept sleeping.
81  */
82 void rs232_set_input(int (* f)(unsigned char));
83 
84 /**
85  * \brief Configure the speed of the RS232 hardware
86  * \param speed The speed
87  *
88  * This function configures the speed of the RS232
89  * hardware. The allowed parameters are RS232_19200,
90  * RS232_38400, RS232_57600, and RS232_115200.
91  */
92 void rs232_set_speed(unsigned char speed);
93 
94 /**
95  * \brief Print a text string on RS232
96  * \param str A pointer to the string that is to be printed
97  *
98  * This function prints a string to RS232. The string must
99  * be terminated by a null byte. The RS232 module must be
100  * correctly initalized and configured for this function
101  * to work.
102  */
103 void rs232_print(char *text);
104 
105 /**
106  * \brief Print a character on RS232
107  * \param c The character to be printed
108  *
109  * This function prints a character to RS232. The RS232
110  * module must be correctly initalized and configured for
111  * this function to work.
112  */
113 void rs232_send(char c);
114 
115 #endif /* RS232_H_ */
116 
117 /** @} */ /** @} */