root / trunk / code / projects / libdragonfly / serial.h @ 203
History | View | Annotate | Download (2.76 KB)
1 |
/**
|
---|---|
2 |
* @file serial.h
|
3 |
* @brief Contains declarations for serial input and output
|
4 |
*
|
5 |
* Contains definitions for serial input and output.
|
6 |
*
|
7 |
* @author Colony Project, CMU Robotics Club
|
8 |
* Based on Tom Lauwer's Firefly Library
|
9 |
*
|
10 |
**/
|
11 |
|
12 |
/*
|
13 |
serial.h - Contains definitions and function prototypes for the RS232 serial port
|
14 |
author(s): pkv
|
15 |
|
16 |
Directions:
|
17 |
Call the initialization function for the serial port you wish to use. Then, use
|
18 |
either the provided functions or the stdio functions (fprintf, etc) to read and
|
19 |
write characters to the serial ports.
|
20 |
|
21 |
UART Mapping:
|
22 |
usb_*() -> UART0
|
23 |
xbee_*() -> UART1
|
24 |
|
25 |
Options: (Add the following defines to your code to configure this library)
|
26 |
#define USB_BAUD { 115200 | 9600 } <= pick ONE value from in here
|
27 |
#define XBEE_BAUD { 115200 | 9600 } <= pick ONE value from in here
|
28 |
#define USE_STDIO
|
29 |
|
30 |
Note: If you enable USE_STDIO, the first init function that is called will
|
31 |
automatically be linked to stdin, stdout, and stderr. To use the baud rate
|
32 |
commands, add something like the following to your code:
|
33 |
|
34 |
#define FOO_BAUD 9600
|
35 |
|
36 |
**UNLESS YOU KNOW WHAT YOU ARE DOING, PLEASE DO NOT CHANGE THIS FILE**
|
37 |
Many, many other people use this file in their code. If you change it, you will
|
38 |
probably break all of their nice code. You should not need to change anything in
|
39 |
here, except to accomodate new hardware.
|
40 |
*/
|
41 |
|
42 |
#ifndef _SERIAL_H
|
43 |
#define _SERIAL_H
|
44 |
|
45 |
/**
|
46 |
* @defgroup usb USB Input / Output
|
47 |
* @brief Functions for USB input / output
|
48 |
*
|
49 |
* Low level functions for USB input and output.
|
50 |
*
|
51 |
* @{
|
52 |
**/
|
53 |
|
54 |
// if no baud rate is defined for usb, default is set here
|
55 |
#ifndef USB_BAUD
|
56 |
/** @brief the USB baud rate **/
|
57 |
#define USB_BAUD 115200 |
58 |
#endif
|
59 |
|
60 |
/** @brief Initialize the USB **/
|
61 |
void usb_init(void); |
62 |
/** @brief Print a character to USB **/
|
63 |
int usb_putc(char c); |
64 |
/** @brief Read a character from USB **/
|
65 |
int usb_getc(void); |
66 |
/** @brief Read a character from USB without blocking **/
|
67 |
int usb_getc_nb(char *c); |
68 |
/** @brief Print a string to USB **/
|
69 |
int usb_puts(char *s); |
70 |
/** @brief Print an integer to USB **/
|
71 |
int usb_puti(int value); |
72 |
|
73 |
/** @} **/ //end addtogroup |
74 |
|
75 |
/**
|
76 |
* @defgroup xbee XBee Input / Output
|
77 |
* @brief Functions for XBee input / output
|
78 |
*
|
79 |
* Low level functions for XBee input and output.
|
80 |
*
|
81 |
* @{
|
82 |
**/
|
83 |
|
84 |
// if no baud rate is defined for usb, default is set here
|
85 |
|
86 |
// if no baud rate is defined for xbee, default is set here
|
87 |
#ifndef XBEE_BAUD
|
88 |
/** @brief the XBee baud rate **/
|
89 |
#define XBEE_BAUD 9600 |
90 |
#endif
|
91 |
|
92 |
/** @brief Initialize the XBee **/
|
93 |
void xbee_init(void); |
94 |
/** @brief Print a character to the XBee **/
|
95 |
int xbee_putc(char c); |
96 |
/** @brief Read a character from the XBee **/
|
97 |
int xbee_getc(void); |
98 |
/** @brief Read a character from the XBee without blocking **/
|
99 |
int xbee_getc_nb(char *c); |
100 |
|
101 |
/** @} **/ //end addtogroup |
102 |
|
103 |
#endif
|
104 |
|