]> git.sur5r.net Git - freertos/blob - Demo/Common/drivers/Atmel/at91lib/peripherals/usart/usart.h
Atmel provided hardware specifics.
[freertos] / Demo / Common / drivers / Atmel / at91lib / peripherals / usart / usart.h
1 /* ----------------------------------------------------------------------------\r
2  *         ATMEL Microcontroller Software Support \r
3  * ----------------------------------------------------------------------------\r
4  * Copyright (c) 2008, Atmel Corporation\r
5  *\r
6  * All rights reserved.\r
7  *\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
10  *\r
11  * - Redistributions of source code must retain the above copyright notice,\r
12  * this list of conditions and the disclaimer below.\r
13  *\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
16  *\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
28  */\r
29 \r
30 //------------------------------------------------------------------------------\r
31 /// \dir\r
32 /// !Purpose\r
33 /// \r
34 /// This module provides several definitions and methods for using an USART\r
35 /// peripheral.\r
36 ///\r
37 /// !Usage\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
51 \r
52 #ifndef USART_H\r
53 #define USART_H\r
54 \r
55 //------------------------------------------------------------------------------\r
56 //         Headers\r
57 //------------------------------------------------------------------------------\r
58 \r
59 #include <board.h>\r
60 \r
61 //------------------------------------------------------------------------------\r
62 //         Definitions\r
63 //------------------------------------------------------------------------------\r
64 \r
65 //------------------------------------------------------------------------------\r
66 /// \page "USART modes"\r
67 /// This page lists several common operating modes for an USART peripheral.\r
68 /// \r
69 /// !Modes\r
70 /// - USART_MODE_ASYNCHRONOUS\r
71 \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
75 \r
76 //------------------------------------------------------------------------------\r
77 //         Exported functions\r
78 //------------------------------------------------------------------------------\r
79 \r
80 extern void USART_Configure(\r
81     AT91S_USART *usart,\r
82     unsigned int mode,\r
83     unsigned int baudrate,\r
84     unsigned int masterClock);\r
85 \r
86 extern void USART_SetTransmitterEnabled(AT91S_USART *usart, unsigned char enabled);\r
87 \r
88 extern void USART_SetReceiverEnabled(AT91S_USART *usart, unsigned char enabled);\r
89 \r
90 extern void USART_Write(\r
91     AT91S_USART *usart, \r
92     unsigned short data, \r
93     volatile unsigned int timeOut);\r
94 \r
95 extern unsigned char USART_WriteBuffer(\r
96     AT91S_USART *usart,\r
97     void *buffer,\r
98     unsigned int size);\r
99 \r
100 extern unsigned short USART_Read(\r
101     AT91S_USART *usart, \r
102     volatile unsigned int timeOut);\r
103 \r
104 extern unsigned char USART_ReadBuffer(\r
105     AT91S_USART *usart,\r
106     void *buffer,\r
107     unsigned int size);\r
108 \r
109 extern unsigned char USART_IsDataAvailable(AT91S_USART *usart);\r
110 \r
111 #endif //#ifndef USART_H\r
112 \r