uart_lib.c

Go to the documentation of this file.
00001 /*C**************************************************************************
00002 * $RCSfile: uart_lib.c,v $
00003 *----------------------------------------------------------------------------
00004 * Copyright (c) 2003 Atmel.
00005 *----------------------------------------------------------------------------
00006 * RELEASE:      $Name: mc100_bldc_sinus_1_0_0 $
00007 * REVISION:     $Revision: 1.1 $
00008 * FILE_CVSID:   $Id: uart_lib.c,v 1.1 2008/09/16 15:49:06 raubree Exp $
00009 *----------------------------------------------------------------------------
00010 * PURPOSE:
00011 * This file provides a minimal VT100 terminal access through UART
00012 * and compatibility with Custom I/O support
00013 *****************************************************************************/
00014 
00015 /*_____ I N C L U D E S ____________________________________________________*/
00016 
00017 #ifdef __ICCAVR__ // IAR C Compiler
00018 #include "config.h"
00019 #endif
00020 
00021 #ifdef __GNUC__  // GNU C Compiler
00022 #include "config_for_gcc.h"
00023 #include <avr/io.h>
00024 #endif
00025 
00026 #include "uart_lib.h"
00027 
00028 
00029 /*_____ G L O B A L    D E F I N I T I O N _________________________________*/
00030 
00031 
00032 /*_____ D E F I N I T I O N ________________________________________________*/
00033 
00034 /*_____ M A C R O S ________________________________________________________*/
00035 
00036 
00037 bit uart_test_hit (void)
00038 {
00039 return Uart_rx_ready();
00040 }
00041 
00042 
00043 bit uart_init (void)
00044 {
00045 #ifndef UART_U2
00046   Uart_set_baudrate(BAUDRATE);
00047   Uart_hw_init(UART_CONFIG);
00048 #else
00049   Uart_set_baudrate(BAUDRATE/2);
00050   Uart_double_bdr();
00051   Uart_hw_init(UART_CONFIG);
00052 
00053 #endif
00054   Uart_enable();
00055   return TRUE;
00056 }
00057 
00058 
00059 r_uart_ptchar uart_putchar (p_uart_ptchar ch)
00060 {
00061   while(!Uart_tx_ready());
00062   Uart_set_tx_busy(); // Set Busy flag before sending (always)
00063   Uart_send_byte(ch);
00064     
00065   return ch;
00066 }
00067 
00068 
00069 
00070 
00071 r_uart_gtchar uart_getchar (void)
00072 {
00073   register char c;
00074 
00075   while(!Uart_rx_ready());
00076   c = Uart_get_byte();
00077   Uart_ack_rx_byte();
00078   return c;
00079 }
00080 
00081 

Generated on Tue Sep 16 18:11:19 2008 for Atmel BLDC Sinusoidal on ATAVRMC100 by  doxygen 1.5.3