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_sensorless_0_1_0 $
00007 * REVISION:     $Revision: 1.20.4.5 $
00008 * FILE_CVSID:   $Id: uart_lib.c,v 1.20.4.5 2006/05/05 16:56:15 rletendu 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 #include "config.h"
00017 #include "lib_mcu/uart/uart_lib.h"
00018 
00019 
00020 /*_____ G L O B A L    D E F I N I T I O N _________________________________*/
00021 
00022 
00023 /*_____ D E F I N I T I O N ________________________________________________*/
00024 
00025 /*_____ M A C R O S ________________________________________________________*/
00026 
00027 
00028 bit uart_test_hit (void)
00029 {
00030 return Uart_rx_ready();
00031 }
00032 
00033 
00034 bit uart_init (void)
00035 {
00036 #ifndef UART_U2
00037   Uart_set_baudrate(BAUDRATE);
00038   Uart_hw_init(UART_CONFIG);
00039 #else
00040   Uart_set_baudrate(BAUDRATE/2);
00041   Uart_double_bdr();
00042   Uart_hw_init(UART_CONFIG);
00043 
00044 #endif
00045   Uart_enable();
00046   return TRUE;
00047 }
00048 
00049 
00050 r_uart_ptchar uart_putchar (p_uart_ptchar ch)
00051 {
00052   while(!Uart_tx_ready());
00053   Uart_set_tx_busy(); // Set Busy flag before sending (always)
00054   Uart_send_byte(ch);
00055     
00056   return ch;
00057 }
00058 
00059 
00060 
00061 
00062 char uart_getchar (void)
00063 {
00064   register char c;
00065 
00066   while(!Uart_rx_ready());
00067   c = Uart_get_byte();
00068   Uart_ack_rx_byte();
00069   return c;
00070 }
00071 
00072 

Generated on Wed Jul 12 16:55:10 2006 for Atmel BLDC Sensorless on ATAVRMC100 by  doxygen 1.4.7