uart_drv.h

Go to the documentation of this file.
00001 /*This file is prepared for Doxygen automatic documentation generation.*/
00013 
00014 /* Copyright (c) 2009 Atmel Corporation. All rights reserved.
00015  *
00016  * Redistribution and use in source and binary forms, with or without
00017  * modification, are permitted provided that the following conditions are met:
00018  *
00019  * 1. Redistributions of source code must retain the above copyright notice,
00020  * this list of conditions and the following disclaimer.
00021  *
00022  * 2. Redistributions in binary form must reproduce the above copyright notice,
00023  * this list of conditions and the following disclaimer in the documentation
00024  * and/or other materials provided with the distribution.
00025  *
00026  * 3. The name of Atmel may not be used to endorse or promote products derived
00027  * from this software without specific prior written permission.
00028  *
00029  * 4. This software may only be redistributed and used in connection with an Atmel
00030  * AVR product.
00031  *
00032  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
00033  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00034  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
00035  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00036  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00037  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00038  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00039  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00040  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00041  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00042  */
00043 
00044 #ifndef _UART_DRV_H_
00045 #define _UART_DRV_H_
00046 
00047 #define MSK_UART_5BIT           0x00 /* UCSRnC register */
00048 #define MSK_UART_6BIT           0x02
00049 #define MSK_UART_7BIT           0x04
00050 #define MSK_UART_8BIT           0x06
00051 #define MSK_UART_9BIT           0x06
00052 
00053 #define MSK_UART_RX_DONE        0x80 /* UCSRnA register */
00054 #define MSK_UART_TX_COMPLET     0x40
00055 #define MSK_UART_DRE            0x20
00056 
00057 #define MSK_UART_ENABLE_IT_RX   0x80
00058 #define MSK_UART_ENABLE_IT_TX   0x40
00059 #define MSK_UART_ENABLE_RX      0x10 /* UCSRnB register */
00060 #define MSK_UART_ENABLE_TX      0x08
00061 #define MSK_UART_TX_BIT9        0x01
00062 #define MSK_UART_RX_BIT9        0x02
00063 
00064 #ifdef USE_UART1
00065     #define UCSRC   (UCSR0C)
00066     #define UCSRB   (UCSR0B)
00067     #define UCSRA   (UCSR0A)
00068     #define UDR     (UDR0)
00069     #define UBRRL   (UBRR0L)
00070     #define UBRRH   (UBRR0H)
00071     #define UBRR    (UBRR0)
00072 #endif
00073 #ifdef USE_UART2
00074     #define UCSRC    (UCSR1C)
00075     #define UCSRB    (UCSR1B)
00076     #define UCSRA    (UCSR1A)
00077     #define UDR      (UDR1)
00078     #define UBRRL    (UBRR1L)
00079     #define UBRRH    (UBRR1H)
00080     #define UBRR     (UBRR1)
00081 
00082 #endif
00083 
00084 
00085 #define Uart_hw_init(config)    (UCSRC=config)
00086 #define Uart_enable()           (UCSRB|=MSK_UART_ENABLE_RX|MSK_UART_ENABLE_TX)
00087 #define Uart_tx_ready()         (UCSRA&MSK_UART_DRE)
00088 #define Uart_set_tx_busy()
00089 #define Uart_send_byte(ch)      (UDR=ch)
00090 #define Uart_rx_ready()         (UCSRA&MSK_UART_RX_DONE)
00091 #define Uart_get_byte()         (UDR)
00092 #define Uart_ack_rx_byte()
00093 
00094 #define Uart_enable_it_rx()    (UCSRB|=MSK_UART_ENABLE_IT_RX)
00095 #define Uart_enable_it_tx()    (UCSRB|=MSK_UART_ENABLE_IT_TX)
00096 #define Uart_disable_it_rx()   (UCSRB&=~MSK_UART_ENABLE_IT_RX)
00097 
00098 #endif

Generated on Fri Sep 11 15:02:35 2009 for ATMEL by  doxygen 1.5.3