]> git.sur5r.net Git - freertos/blobdiff - Demo/CORTEX_AT91SAM3U256_IAR/AT91Lib/peripherals/usart/usart.h
Add new demo files.
[freertos] / Demo / CORTEX_AT91SAM3U256_IAR / AT91Lib / peripherals / usart / usart.h
diff --git a/Demo/CORTEX_AT91SAM3U256_IAR/AT91Lib/peripherals/usart/usart.h b/Demo/CORTEX_AT91SAM3U256_IAR/AT91Lib/peripherals/usart/usart.h
new file mode 100644 (file)
index 0000000..84a633c
--- /dev/null
@@ -0,0 +1,118 @@
+/* ----------------------------------------------------------------------------\r
+ *         ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+//------------------------------------------------------------------------------\r
+/// \dir\r
+/// !Purpose\r
+/// \r
+/// This module provides several definitions and methods for using an USART\r
+/// peripheral.\r
+///\r
+/// !Usage\r
+/// -# Enable the USART peripheral clock in the PMC.\r
+/// -# Enable the required USART PIOs (see pio.h).\r
+/// -# Configure the UART by calling USART_Configure.\r
+/// -# Enable the transmitter and/or the receiver of the USART using\r
+///    USART_SetTransmitterEnabled and USART_SetReceiverEnabled.\r
+/// -# Send data through the USART using the USART_Write and\r
+///    USART_WriteBuffer methods.\r
+/// -# Receive data from the USART using the USART_Read and\r
+///    USART_ReadBuffer functions; the availability of data can be polled\r
+///    with USART_IsDataAvailable.\r
+/// -# Disable the transmitter and/or the receiver of the USART with\r
+///    USART_SetTransmitterEnabled and USART_SetReceiverEnabled.\r
+//------------------------------------------------------------------------------\r
+\r
+#ifndef USART_H\r
+#define USART_H\r
+\r
+//------------------------------------------------------------------------------\r
+//         Headers\r
+//------------------------------------------------------------------------------\r
+\r
+#include <board.h>\r
+\r
+//------------------------------------------------------------------------------\r
+//         Definitions\r
+//------------------------------------------------------------------------------\r
+\r
+//------------------------------------------------------------------------------\r
+/// \page "USART modes"\r
+/// This page lists several common operating modes for an USART peripheral.\r
+/// \r
+/// !Modes\r
+/// - USART_MODE_ASYNCHRONOUS\r
+/// - USART_MODE_IRDA\r
+\r
+/// Basic asynchronous mode, i.e. 8 bits no parity.\r
+#define USART_MODE_ASYNCHRONOUS (AT91C_US_CHRL_8_BITS | AT91C_US_PAR_NONE)\r
+\r
+/// IRDA mode\r
+#define USART_MODE_IRDA         (AT91C_US_USMODE_IRDA | AT91C_US_CHRL_8_BITS | AT91C_US_PAR_NONE | AT91C_US_FILTER)\r
+//------------------------------------------------------------------------------\r
+\r
+//------------------------------------------------------------------------------\r
+//         Exported functions\r
+//------------------------------------------------------------------------------\r
+\r
+extern void USART_Configure(\r
+    AT91S_USART *usart,\r
+    unsigned int mode,\r
+    unsigned int baudrate,\r
+    unsigned int masterClock);\r
+\r
+extern void USART_SetTransmitterEnabled(AT91S_USART *usart, unsigned char enabled);\r
+\r
+extern void USART_SetReceiverEnabled(AT91S_USART *usart, unsigned char enabled);\r
+\r
+extern void USART_Write(\r
+    AT91S_USART *usart, \r
+    unsigned short data, \r
+    volatile unsigned int timeOut);\r
+\r
+extern unsigned char USART_WriteBuffer(\r
+    AT91S_USART *usart,\r
+    void *buffer,\r
+    unsigned int size);\r
+\r
+extern unsigned short USART_Read(\r
+    AT91S_USART *usart, \r
+    volatile unsigned int timeOut);\r
+\r
+extern unsigned char USART_ReadBuffer(\r
+    AT91S_USART *usart,\r
+    void *buffer,\r
+    unsigned int size);\r
+\r
+extern unsigned char USART_IsDataAvailable(AT91S_USART *usart);\r
+\r
+extern void USART_SetIrdaFilter(AT91S_USART *pUsart, unsigned char filter);\r
+\r
+#endif //#ifndef USART_H\r
+\r