uart_drv.h

Go to the documentation of this file.
00001 /*H**************************************************************************
00002 * $RCSfile: uart_drv.h,v $
00003 *----------------------------------------------------------------------------
00004 * Copyright (c) 2003 Atmel.
00005 *----------------------------------------------------------------------------
00006 * RELEASE:      $Name: mc100_bldc_sensorless_0_1_0 $
00007 * REVISION:     $Revision: 1.1.2.3 $
00008 * FILE_CVSID:   $Id: uart_drv.h,v 1.1.2.3 2006/03/14 18:03:53 rletendu Exp $
00009 *----------------------------------------------------------------------------
00010 * PURPOSE:
00011 * Provide Uart driver
00012 *****************************************************************************/
00013 
00014 #ifndef _UART_DRV_H_
00015 #define _UART_DRV_H_
00016 
00017 #define MSK_UART_5BIT           0x00 /* UCSRnC register */
00018 #define MSK_UART_6BIT           0x02
00019 #define MSK_UART_7BIT           0x04
00020 #define MSK_UART_8BIT           0x06
00021 #define MSK_UART_9BIT           0x06
00022 
00023 #define MSK_UART_RX_DONE        0x80 /* UCSRnA register */
00024 #define MSK_UART_TX_COMPLET     0x40
00025 #define MSK_UART_DRE            0x20
00026 
00027 #define MSK_UART_ENABLE_IT_RX   0x80
00028 #define MSK_UART_ENABLE_IT_TX   0x40
00029 #define MSK_UART_ENABLE_RX      0x10 /* UCSRnB register */
00030 #define MSK_UART_ENABLE_TX      0x08
00031 #define MSK_UART_TX_BIT9        0x01
00032 #define MSK_UART_RX_BIT9        0x02
00033 
00034 #ifdef USE_UART1
00035     #define UCSRC   (UCSR0C)
00036     #define UCSRB   (UCSR0B)
00037     #define UCSRA   (UCSR0A)
00038     #define UDR     (UDR0)
00039     #define UBRRL   (UBRR0L)
00040     #define UBRRH   (UBRR0H)
00041     #define UBRR    (UBRR0)
00042 #endif
00043 #ifdef USE_UART2
00044     #define UCSRC    (UCSR1C)
00045     #define UCSRB    (UCSR1B)
00046     #define UCSRA    (UCSR1A)
00047     #define UDR      (UDR1)
00048     #define UBRRL    (UBRR1L)
00049     #define UBRRH    (UBRR1H)
00050     #define UBRR     (UBRR1)
00051 
00052 #endif
00053 
00054 
00055 #define Uart_hw_init(config)    (UCSRC=config)
00056 /*#define Uart_set_baudrate(bdr)  ( UBRRH = (Uchar)((((Uint32)FOSC*1000L)/((Uint32)bdr*16)-1)>>8),\
00057                                   UBRRL = (Uchar)(((Uint32)FOSC*1000 )/((Uint32)bdr*16)-1)    )*/
00058 #define Uart_enable()           (UCSRB|=MSK_UART_ENABLE_RX|MSK_UART_ENABLE_TX)
00059 #define Uart_tx_ready()         (UCSRA&MSK_UART_DRE)
00060 #define Uart_set_tx_busy()
00061 #define Uart_send_byte(ch)      (UDR=ch)
00062 #define Uart_rx_ready()         (UCSRA&MSK_UART_RX_DONE)
00063 #define Uart_get_byte()         (UDR)
00064 #define Uart_ack_rx_byte()
00065 
00066 #define Uart_enable_it_rx()    (UCSRB|=MSK_UART_ENABLE_IT_RX)
00067 #define Uart_enable_it_tx()    (UCSRB|=MSK_UART_ENABLE_IT_TX)
00068 #define Uart_disable_it_rx()   (UCSRB&=~MSK_UART_ENABLE_IT_RX)
00069 
00070 #endif

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