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  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
00030  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00031  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
00032  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00033  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00034  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00035  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00036  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00037  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00038  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  */
00040 
00041 #ifndef _UART_DRV_H_
00042 #define _UART_DRV_H_
00043 
00044 #define MSK_UART_5BIT           0x00 /* UCSRnC register */
00045 #define MSK_UART_6BIT           0x02
00046 #define MSK_UART_7BIT           0x04
00047 #define MSK_UART_8BIT           0x06
00048 #define MSK_UART_9BIT           0x06
00049 
00050 #define MSK_UART_RX_DONE        0x80 /* UCSRnA register */
00051 #define MSK_UART_TX_COMPLET     0x40
00052 #define MSK_UART_DRE            0x20
00053 
00054 #define MSK_UART_ENABLE_IT_RX   0x80
00055 #define MSK_UART_ENABLE_IT_TX   0x40
00056 #define MSK_UART_ENABLE_RX      0x10 /* UCSRnB register */
00057 #define MSK_UART_ENABLE_TX      0x08
00058 #define MSK_UART_TX_BIT9        0x01
00059 #define MSK_UART_RX_BIT9        0x02
00060 
00061 #ifdef USE_UART1
00062     #define UCSRC   (UCSR0C)
00063     #define UCSRB   (UCSR0B)
00064     #define UCSRA   (UCSR0A)
00065     #define UDR     (UDR0)
00066     #define UBRRL   (UBRR0L)
00067     #define UBRRH   (UBRR0H)
00068     #define UBRR    (UBRR0)
00069 #endif
00070 #ifdef USE_UART2
00071     #define UCSRC    (UCSR1C)
00072     #define UCSRB    (UCSR1B)
00073     #define UCSRA    (UCSR1A)
00074     #define UDR      (UDR1)
00075     #define UBRRL    (UBRR1L)
00076     #define UBRRH    (UBRR1H)
00077     #define UBRR     (UBRR1)
00078 
00079 #endif
00080 
00081 
00082 #define Uart_hw_init(config)    (UCSRC=config)
00083 #define Uart_enable()           (UCSRB|=MSK_UART_ENABLE_RX|MSK_UART_ENABLE_TX)
00084 #define Uart_tx_ready()         (UCSRA&MSK_UART_DRE)
00085 #define Uart_set_tx_busy()
00086 #define Uart_send_byte(ch)      (UDR=ch)
00087 #define Uart_rx_ready()         (UCSRA&MSK_UART_RX_DONE)
00088 #define Uart_get_byte()         (UDR)
00089 #define Uart_ack_rx_byte()
00090 
00091 #define Uart_enable_it_rx()    (UCSRB|=MSK_UART_ENABLE_IT_RX)
00092 #define Uart_enable_it_tx()    (UCSRB|=MSK_UART_ENABLE_IT_TX)
00093 #define Uart_disable_it_rx()   (UCSRB&=~MSK_UART_ENABLE_IT_RX)
00094 
00095 #endif

Generated on Wed Sep 23 09:17:02 2009 for ATMEL by  doxygen 1.5.3