1 /* ----------------------------------------------------------------------------
\r
2 * ATMEL Microcontroller Software Support
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2008, Atmel Corporation
\r
6 * All rights reserved.
\r
8 * Redistribution and use in source and binary forms, with or without
\r
9 * modification, are permitted provided that the following conditions are met:
\r
11 * - Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the disclaimer below.
\r
14 * Atmel's name may not be used to endorse or promote products derived from
\r
15 * this software without specific prior written permission.
\r
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
\r
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
\r
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 * ----------------------------------------------------------------------------
\r
30 //------------------------------------------------------------------------------
\r
34 /// This module provides several definitions and methods for using an USART
\r
38 /// -# Enable the USART peripheral clock in the PMC.
\r
39 /// -# Enable the required USART PIOs (see pio.h).
\r
40 /// -# Configure the UART by calling USART_Configure.
\r
41 /// -# Enable the transmitter and/or the receiver of the USART using
\r
42 /// USART_SetTransmitterEnabled and USART_SetReceiverEnabled.
\r
43 /// -# Send data through the USART using the USART_Write and
\r
44 /// USART_WriteBuffer methods.
\r
45 /// -# Receive data from the USART using the USART_Read and
\r
46 /// USART_ReadBuffer functions; the availability of data can be polled
\r
47 /// with USART_IsDataAvailable.
\r
48 /// -# Disable the transmitter and/or the receiver of the USART with
\r
49 /// USART_SetTransmitterEnabled and USART_SetReceiverEnabled.
\r
50 //------------------------------------------------------------------------------
\r
55 //------------------------------------------------------------------------------
\r
57 //------------------------------------------------------------------------------
\r
61 //------------------------------------------------------------------------------
\r
63 //------------------------------------------------------------------------------
\r
65 //------------------------------------------------------------------------------
\r
66 /// \page "USART modes"
\r
67 /// This page lists several common operating modes for an USART peripheral.
\r
70 /// - USART_MODE_ASYNCHRONOUS
\r
72 /// Basic asynchronous mode, i.e. 8 bits no parity.
\r
73 #define USART_MODE_ASYNCHRONOUS (AT91C_US_CHRL_8_BITS | AT91C_US_PAR_NONE)
\r
74 //------------------------------------------------------------------------------
\r
76 //------------------------------------------------------------------------------
\r
77 // Exported functions
\r
78 //------------------------------------------------------------------------------
\r
80 extern void USART_Configure(
\r
83 unsigned int baudrate,
\r
84 unsigned int masterClock);
\r
86 extern void USART_SetTransmitterEnabled(AT91S_USART *usart, unsigned char enabled);
\r
88 extern void USART_SetReceiverEnabled(AT91S_USART *usart, unsigned char enabled);
\r
90 extern void USART_Write(
\r
91 AT91S_USART *usart,
\r
92 unsigned short data,
\r
93 volatile unsigned int timeOut);
\r
95 extern unsigned char USART_WriteBuffer(
\r
100 extern unsigned short USART_Read(
\r
101 AT91S_USART *usart,
\r
102 volatile unsigned int timeOut);
\r
104 extern unsigned char USART_ReadBuffer(
\r
105 AT91S_USART *usart,
\r
107 unsigned int size);
\r
109 extern unsigned char USART_IsDataAvailable(AT91S_USART *usart);
\r
111 #endif //#ifndef USART_H
\r