Contiki 2.5
rs232.h
1 /*
2  * Copyright (c) 2007, Takahide Matsutsuka.
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
11  * copyright notice, this list of conditions and the following
12  * disclaimer in the documentation and/or other materials provided
13  * with the distribution.
14  * 3. The name of the author may not be used to endorse or promote
15  * products derived from this software without specific prior
16  * written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * $Id: rs232.h,v 1.4 2007/09/29 03:58:38 matsutsuka Exp $
31  *
32  */
33 /*
34  * \file
35  * This is RS-232C process based on polling.
36  * \author
37  * Takahide Matsutsuka <markn@markn.org>
38  */
39 
40 #ifndef __RS232_H__
41 #define __RS232_H__
42 
43 /*
44  * Implement the following methods for each platform.
45  */
46 
47 /*
48  * An architecture-depend implementation of RS-232C initialization.
49  */
50 void rs232_arch_init(unsigned long ubr);
51 
52 /*
53  * An architecture-depend implementation of RS-232C polling.
54  * @return character, stat == zero if no input.
55  */
56 unsigned char rs232_arch_poll(unsigned char* stat);
57 
58 /*
59  * An architecture-depend implementation of RS-232C writing a byte.
60  */
61 void rs232_arch_writeb(unsigned char ch);
62 
63 PROCESS_NAME(rs232_process);
64 
65 /*
66  * if you want to use simple serial communication,
67  * define RS232_CONF_CALLBACK as serial_input_byte.
68  * The default is SLIP.
69  */
70 #ifdef RS232_CONF_CALLBACK
71 #define RS232_CALLBACK RS232_CONF_CALLBACK
72 #else /* RS232_CONF_CALLBACK */
73 #define RS232_CALLBACK slip_input_byte
74 #endif /* RS232_CONF_CALLBACK */
75 
76 #ifdef RS232_CONF_BUFISZE
77 #define RS232_BUFSIZE RS232_CONF_BUFISZE
78 #else /* RS232_CONF_BUFISZE */
79 #define RS232_BUFSIZE 64
80 #endif /* RS232_CONF_BUFISZE */
81 
82 #ifdef RS232_CONF_BAUD_RATE
83 #define RS232_BAUD_RATE RS232_CONF_BAUD_RATE
84 #else /* RS232_CONF_BAUD_RATE */
85 #define RS232_BAUD_RATE 9600
86 #endif /* RS232_CONF_BAUD_RATE */
87 
88 #endif /* __RS232_H__ */