root / trunk / code / projects / libdragonfly / serial.h @ 907
History | View | Annotate | Download (3.86 KB)
1 | 8 | bcoltin | /**
|
---|---|---|---|
2 | 241 | bcoltin | * Copyright (c) 2007 Colony Project
|
3 | *
|
||
4 | * Permission is hereby granted, free of charge, to any person
|
||
5 | * obtaining a copy of this software and associated documentation
|
||
6 | * files (the "Software"), to deal in the Software without
|
||
7 | * restriction, including without limitation the rights to use,
|
||
8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
9 | * copies of the Software, and to permit persons to whom the
|
||
10 | * Software is furnished to do so, subject to the following
|
||
11 | * conditions:
|
||
12 | *
|
||
13 | * The above copyright notice and this permission notice shall be
|
||
14 | * included in all copies or substantial portions of the Software.
|
||
15 | *
|
||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||
18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||
19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||
20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||
21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||
22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||
23 | * OTHER DEALINGS IN THE SOFTWARE.
|
||
24 | **/
|
||
25 | |||
26 | |||
27 | /**
|
||
28 | 8 | bcoltin | * @file serial.h
|
29 | * @brief Contains declarations for serial input and output
|
||
30 | *
|
||
31 | * Contains definitions for serial input and output.
|
||
32 | *
|
||
33 | * @author Colony Project, CMU Robotics Club
|
||
34 | * Based on Tom Lauwer's Firefly Library
|
||
35 | *
|
||
36 | **/
|
||
37 | |||
38 | /*
|
||
39 | 380 | jknichel | serial.h - Contains definitions and function prototypes for the RS232 serial port
|
40 | 8 | bcoltin | author(s): pkv
|
41 | |||
42 | Directions:
|
||
43 | Call the initialization function for the serial port you wish to use. Then, use
|
||
44 | either the provided functions or the stdio functions (fprintf, etc) to read and
|
||
45 | write characters to the serial ports.
|
||
46 | |||
47 | UART Mapping:
|
||
48 | 380 | jknichel | usb_*() -> UART0
|
49 | xbee_*() -> UART1
|
||
50 | 8 | bcoltin | |
51 | Options: (Add the following defines to your code to configure this library)
|
||
52 | 380 | jknichel | #define USB_BAUD { 115200 | 9600 } <= pick ONE value from in here
|
53 | #define XBEE_BAUD { 115200 | 9600 } <= pick ONE value from in here
|
||
54 | #define USE_STDIO
|
||
55 | 8 | bcoltin | |
56 | Note: If you enable USE_STDIO, the first init function that is called will
|
||
57 | automatically be linked to stdin, stdout, and stderr. To use the baud rate
|
||
58 | commands, add something like the following to your code:
|
||
59 | |||
60 | #define FOO_BAUD 9600
|
||
61 | |||
62 | **UNLESS YOU KNOW WHAT YOU ARE DOING, PLEASE DO NOT CHANGE THIS FILE**
|
||
63 | Many, many other people use this file in their code. If you change it, you will
|
||
64 | probably break all of their nice code. You should not need to change anything in
|
||
65 | here, except to accomodate new hardware.
|
||
66 | */
|
||
67 | |||
68 | #ifndef _SERIAL_H
|
||
69 | #define _SERIAL_H
|
||
70 | |||
71 | /**
|
||
72 | * @defgroup usb USB Input / Output
|
||
73 | * @brief Functions for USB input / output
|
||
74 | *
|
||
75 | * Low level functions for USB input and output.
|
||
76 | *
|
||
77 | * @{
|
||
78 | **/
|
||
79 | |||
80 | // if no baud rate is defined for usb, default is set here
|
||
81 | #ifndef USB_BAUD
|
||
82 | /** @brief the USB baud rate **/
|
||
83 | #define USB_BAUD 115200 |
||
84 | #endif
|
||
85 | |||
86 | /** @brief Initialize the USB **/
|
||
87 | void usb_init(void); |
||
88 | /** @brief Print a character to USB **/
|
||
89 | int usb_putc(char c); |
||
90 | /** @brief Read a character from USB **/
|
||
91 | int usb_getc(void); |
||
92 | /** @brief Read a character from USB without blocking **/
|
||
93 | int usb_getc_nb(char *c); |
||
94 | /** @brief Print a string to USB **/
|
||
95 | int usb_puts(char *s); |
||
96 | /** @brief Print an integer to USB **/
|
||
97 | int usb_puti(int value); |
||
98 | |||
99 | /** @} **/ //end addtogroup |
||
100 | |||
101 | /**
|
||
102 | * @defgroup xbee XBee Input / Output
|
||
103 | * @brief Functions for XBee input / output
|
||
104 | *
|
||
105 | * Low level functions for XBee input and output.
|
||
106 | *
|
||
107 | * @{
|
||
108 | **/
|
||
109 | |||
110 | // if no baud rate is defined for usb, default is set here
|
||
111 | |||
112 | // if no baud rate is defined for xbee, default is set here
|
||
113 | #ifndef XBEE_BAUD
|
||
114 | /** @brief the XBee baud rate **/
|
||
115 | #define XBEE_BAUD 9600 |
||
116 | #endif
|
||
117 | |||
118 | /** @brief Initialize the XBee **/
|
||
119 | void xbee_init(void); |
||
120 | /** @brief Print a character to the XBee **/
|
||
121 | int xbee_putc(char c); |
||
122 | /** @brief Read a character from the XBee **/
|
||
123 | int xbee_getc(void); |
||
124 | /** @brief Read a character from the XBee without blocking **/
|
||
125 | int xbee_getc_nb(char *c); |
||
126 | |||
127 | /** @} **/ //end addtogroup |
||
128 | |||
129 | #endif
|