00001 /*This file is prepared for Doxygen automatic documentation generation.*/ 00014 00015 /* Copyright (c) 2009 Atmel Corporation. All rights reserved. 00016 * 00017 * Redistribution and use in source and binary forms, with or without 00018 * modification, are permitted provided that the following conditions are met: 00019 * 00020 * 1. Redistributions of source code must retain the above copyright notice, 00021 * this list of conditions and the following disclaimer. 00022 * 00023 * 2. Redistributions in binary form must reproduce the above copyright notice, 00024 * this list of conditions and the following disclaimer in the documentation 00025 * and/or other materials provided with the distribution. 00026 * 00027 * 3. The name of Atmel may not be used to endorse or promote products derived 00028 * from this software without specific prior written permission. 00029 * 00030 * 4. This software may only be redistributed and used in connection with an Atmel 00031 * AVR product. 00032 * 00033 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00034 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00035 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND 00036 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, 00037 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00038 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00039 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00040 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00041 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00042 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00043 */ 00044 00045 /*_____ I N C L U D E S ____________________________________________________*/ 00046 #include "config.h" 00047 #include "lib_mcu/uart/uart_lib.h" 00048 00049 00050 /*_____ G L O B A L D E F I N I T I O N _________________________________*/ 00051 00052 00053 /*_____ D E F I N I T I O N ________________________________________________*/ 00054 00055 /*_____ M A C R O S ________________________________________________________*/ 00056 00057 00058 bit uart_test_hit (void) 00059 { 00060 return Uart_rx_ready(); 00061 } 00062 00063 00064 bit uart_init (void) 00065 { 00066 #ifndef UART_U2 00067 Uart_set_baudrate(BAUDRATE); 00068 Uart_hw_init(UART_CONFIG); 00069 #else 00070 Uart_set_baudrate(BAUDRATE/2); 00071 Uart_double_bdr(); 00072 Uart_hw_init(UART_CONFIG); 00073 00074 #endif 00075 Uart_enable(); 00076 return TRUE; 00077 } 00078 00079 00080 r_uart_ptchar uart_putchar (p_uart_ptchar ch) 00081 { 00082 while(!Uart_tx_ready()); 00083 Uart_set_tx_busy(); // Set Busy flag before sending (always) 00084 Uart_send_byte(ch); 00085 00086 return ch; 00087 } 00088 00089 00090 00091 00092 char uart_getchar (void) 00093 { 00094 register char c; 00095 00096 while(!Uart_rx_ready()); 00097 c = Uart_get_byte(); 00098 Uart_ack_rx_byte(); 00099 return c; 00100 } 00101 00102