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 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00031 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00032 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND 00033 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, 00034 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00035 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00036 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00037 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00038 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00039 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00040 */ 00041 00042 /*_____ I N C L U D E S ____________________________________________________*/ 00043 #include "config.h" 00044 #include "lib_mcu/uart/uart_lib.h" 00045 00046 00047 /*_____ G L O B A L D E F I N I T I O N _________________________________*/ 00048 00049 00050 /*_____ D E F I N I T I O N ________________________________________________*/ 00051 00052 /*_____ M A C R O S ________________________________________________________*/ 00053 00054 00055 bit uart_test_hit (void) 00056 { 00057 return Uart_rx_ready(); 00058 } 00059 00060 00061 bit uart_init (void) 00062 { 00063 #ifndef UART_U2 00064 Uart_set_baudrate(BAUDRATE); 00065 Uart_hw_init(UART_CONFIG); 00066 #else 00067 Uart_set_baudrate(BAUDRATE/2); 00068 Uart_double_bdr(); 00069 Uart_hw_init(UART_CONFIG); 00070 00071 #endif 00072 Uart_enable(); 00073 return TRUE; 00074 } 00075 00076 00077 r_uart_ptchar uart_putchar (p_uart_ptchar ch) 00078 { 00079 while(!Uart_tx_ready()); 00080 Uart_set_tx_busy(); // Set Busy flag before sending (always) 00081 Uart_send_byte(ch); 00082 00083 return ch; 00084 } 00085 00086 00087 00088 00089 char uart_getchar (void) 00090 { 00091 register char c; 00092 00093 while(!Uart_rx_ready()); 00094 c = Uart_get_byte(); 00095 Uart_ack_rx_byte(); 00096 return c; 00097 } 00098 00099