uart_lib.c

Go to the documentation of this file.
00001 /*C**************************************************************************
00002 * NAME:         uart_lib.c
00003 *----------------------------------------------------------------------------
00004 * Copyright (c) 2006 Atmel.
00005 *----------------------------------------------------------------------------
00006 * RELEASE:      at90usb162-cdc-1_0_1
00007 * REVISION:     1.20.4.5
00008 *----------------------------------------------------------------------------
00009 * PURPOSE:
00010 * This file provides a minimal VT100 terminal access through UART
00011 * and compatibility with Custom I/O support
00012 *****************************************************************************/
00013 
00014 /*_____ I N C L U D E S ____________________________________________________*/
00015 #include "config.h"
00016 #include "lib_mcu/uart/uart_lib.h"
00017 
00018 
00019 /*_____ G L O B A L    D E F I N I T I O N _________________________________*/
00020 
00021 
00022 /*_____ D E F I N I T I O N ________________________________________________*/
00023 
00024 /*_____ M A C R O S ________________________________________________________*/
00025 
00026 
00027 bit uart_test_hit (void)
00028 {
00029 return Uart_rx_ready();
00030 }
00031 
00032 
00033 bit uart_init (void)
00034 {
00035 #ifndef UART_U2
00036   Uart_set_baudrate(BAUDRATE);
00037   Uart_hw_init(UART_CONFIG);
00038 #else
00039   Uart_set_baudrate(BAUDRATE/2);
00040   Uart_double_bdr();
00041   Uart_hw_init(UART_CONFIG);
00042 
00043 #endif
00044   Uart_enable();
00045   return TRUE;
00046 }
00047 
00048 
00049 r_uart_ptchar uart_putchar (p_uart_ptchar ch)
00050 {
00051   while(!Uart_tx_ready());
00052   Uart_set_tx_busy(); // Set Busy flag before sending (always)
00053   Uart_send_byte(ch);
00054    
00055   return ch;
00056 }
00057 
00058 
00059 
00060 
00061 char uart_getchar (void)
00062 {
00063   register char c;
00064 
00065   while(!Uart_rx_ready());
00066   c = Uart_get_byte();
00067   Uart_ack_rx_byte();
00068   return c;
00069 }
00070 
00071 

Generated on Fri Jun 15 14:15:32 2007 for Atmel by  doxygen 1.5.1-p1