Contiki 2.5
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  * @(#)$Id: rs232.h,v 1.1 2006/08/21 12:11:19 fros4943 Exp $
32  */
33 
34 /** \addtogroup esb
35  * @{ */
36 
37 /**
38  * \defgroup esbrs232 ESB RS232
39  *
40  * @{
41  */
42 
43 /**
44  * \file
45  * Header file for MSP430 RS232 driver.
46  * \author Adam Dunkels <adam@sics.se>
47  *
48  */
49 #ifndef __RS232_H__
50 #define __RS232_H__
51 
52 
53 #define RS232_19200 1
54 #define RS232_38400 2
55 #define RS232_57600 3
56 #define RS232_115200 4
57 
58 /**
59  * \brief Initialize the RS232 module
60  *
61  * This function is called from the boot up code to
62  * initalize the RS232 module.
63  */
64 void rs232_init(void);
65 
66 /**
67  * \brief Set an input handler for incoming RS232 data
68  * \param f A pointer to a byte input handler
69  *
70  * This function sets the input handler for incoming RS232
71  * data. The input handler function is called for every
72  * incoming data byte. The function is called from the
73  * RS232 interrupt handler, so care must be taken when
74  * implementing the input handler to avoid race
75  * conditions.
76  *
77  * The return value of the input handler affects the sleep
78  * mode of the CPU: if the input handler returns non-zero
79  * (true), the CPU is awakened to let other processing
80  * take place. If the input handler returns zero, the CPU
81  * is kept sleeping.
82  */
83 void rs232_set_input(int (* f)(unsigned char));
84 
85 /**
86  * \brief Configure the speed of the RS232 hardware
87  * \param speed The speed
88  *
89  * This function configures the speed of the RS232
90  * hardware. The allowed parameters are RS232_19200,
91  * RS232_38400, RS232_57600, and RS232_115200.
92  */
93 void rs232_set_speed(unsigned char speed);
94 
95 /**
96  * \brief Print a text string on RS232
97  * \param str A pointer to the string that is to be printed
98  *
99  * This function prints a string to RS232. The string must
100  * be terminated by a null byte. The RS232 module must be
101  * correctly initalized and configured for this function
102  * to work.
103  */
104 void rs232_print(char *text);
105 
106 /**
107  * \brief Print a character on RS232
108  * \param c The character to be printed
109  *
110  * This function prints a character to RS232. The RS232
111  * module must be correctly initalized and configured for
112  * this function to work.
113  */
114 void rs232_send(char c);
115 
116 #endif /* __RS232_H__ */
117 
118 /** @} */ /** @} */