00001 00038 /* 00039 serial.h - Contains definitions and function prototypes for the RS232 serial port 00040 author(s): pkv 00041 00042 Directions: 00043 Call the initialization function for the serial port you wish to use. Then, use 00044 either the provided functions or the stdio functions (fprintf, etc) to read and 00045 write characters to the serial ports. 00046 00047 UART Mapping: 00048 usb_*() -> UART0 00049 xbee_*() -> UART1 00050 00051 Options: (Add the following defines to your code to configure this library) 00052 #define USB_BAUD { 115200 | 9600 } <= pick ONE value from in here 00053 #define XBEE_BAUD { 115200 | 9600 } <= pick ONE value from in here 00054 #define USE_STDIO 00055 00056 Note: If you enable USE_STDIO, the first init function that is called will 00057 automatically be linked to stdin, stdout, and stderr. To use the baud rate 00058 commands, add something like the following to your code: 00059 00060 #define FOO_BAUD 9600 00061 00062 **UNLESS YOU KNOW WHAT YOU ARE DOING, PLEASE DO NOT CHANGE THIS FILE** 00063 Many, many other people use this file in their code. If you change it, you will 00064 probably break all of their nice code. You should not need to change anything in 00065 here, except to accomodate new hardware. 00066 */ 00067 00068 #ifndef _SERIAL_H 00069 #define _SERIAL_H 00070 00071 #include <inttypes.h> 00072 #include <avr/pgmspace.h> 00073 00083 // if no baud rate is defined for usb, default is set here 00084 #ifndef USB_BAUD 00085 00086 #define USB_BAUD 115200 00087 #endif 00088 00090 void usb_init(void); 00092 int usb_putc(char c); 00094 int usb_getc(void); 00096 int usb_getc_nb(char *c); 00098 int usb_puts(char *s); 00100 void usb_puts_P (PGM_P s); 00102 int usb_puti(int value); 00104 uint8_t hex_digit (uint8_t value); 00106 void usb_puth16 (uint16_t value); 00108 void usb_puth8(uint8_t value); 00110 static inline void usb_puth (uint16_t value) { usb_puth16 (value); }; 00111 00112 //end addtogroup 00114 00124 // if no baud rate is defined for usb, default is set here 00125 00126 // if no baud rate is defined for xbee, default is set here 00127 #ifndef XBEE_BAUD 00128 00129 #define XBEE_BAUD 9600 00130 #endif 00131 00133 void xbee_init(void); 00135 int xbee_putc(char c); 00137 int xbee_getc(void); 00139 int xbee_getc_nb(char *c); 00140 00141 00142 //end addtogroup 00144 00145 #endif 00146