]> git.sur5r.net Git - freertos/blob - Demo/CORTEX_AT91SAM3U256_IAR/AT91Lib/peripherals/usart/usart.h
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / CORTEX_AT91SAM3U256_IAR / 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 /// - USART_MODE_IRDA\r
72 \r
73 /// Basic asynchronous mode, i.e. 8 bits no parity.\r
74 #define USART_MODE_ASYNCHRONOUS (AT91C_US_CHRL_8_BITS | AT91C_US_PAR_NONE)\r
75 \r
76 /// IRDA mode\r
77 #define USART_MODE_IRDA         (AT91C_US_USMODE_IRDA | AT91C_US_CHRL_8_BITS | AT91C_US_PAR_NONE | AT91C_US_FILTER)\r
78 //------------------------------------------------------------------------------\r
79 \r
80 //------------------------------------------------------------------------------\r
81 //         Exported functions\r
82 //------------------------------------------------------------------------------\r
83 \r
84 extern void USART_Configure(\r
85     AT91S_USART *usart,\r
86     unsigned int mode,\r
87     unsigned int baudrate,\r
88     unsigned int masterClock);\r
89 \r
90 extern void USART_SetTransmitterEnabled(AT91S_USART *usart, unsigned char enabled);\r
91 \r
92 extern void USART_SetReceiverEnabled(AT91S_USART *usart, unsigned char enabled);\r
93 \r
94 extern void USART_Write(\r
95     AT91S_USART *usart, \r
96     unsigned short data, \r
97     volatile unsigned int timeOut);\r
98 \r
99 extern unsigned char USART_WriteBuffer(\r
100     AT91S_USART *usart,\r
101     void *buffer,\r
102     unsigned int size);\r
103 \r
104 extern unsigned short USART_Read(\r
105     AT91S_USART *usart, \r
106     volatile unsigned int timeOut);\r
107 \r
108 extern unsigned char USART_ReadBuffer(\r
109     AT91S_USART *usart,\r
110     void *buffer,\r
111     unsigned int size);\r
112 \r
113 extern unsigned char USART_IsDataAvailable(AT91S_USART *usart);\r
114 \r
115 extern void USART_SetIrdaFilter(AT91S_USART *pUsart, unsigned char filter);\r
116 \r
117 #endif //#ifndef USART_H\r
118 \r