]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/Common/drivers/LuminaryMicro/uart.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / Common / drivers / LuminaryMicro / uart.h
1 //*****************************************************************************\r
2 //\r
3 // uart.h - Defines and Macros for the UART.\r
4 //\r
5 // Copyright (c) 2005-2008 Luminary Micro, Inc.  All rights reserved.\r
6 // \r
7 // Software License Agreement\r
8 // \r
9 // Luminary Micro, Inc. (LMI) is supplying this software for use solely and\r
10 // exclusively on LMI's microcontroller products.\r
11 // \r
12 // The software is owned by LMI and/or its suppliers, and is protected under\r
13 // applicable copyright laws.  All rights are reserved.  You may not combine\r
14 // this software with "viral" open-source software in order to form a larger\r
15 // program.  Any use in violation of the foregoing restrictions may subject\r
16 // the user to criminal sanctions under applicable laws, as well as to civil\r
17 // liability for the breach of the terms and conditions of this license.\r
18 // \r
19 // THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED\r
20 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF\r
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.\r
22 // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR\r
23 // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.\r
24 // \r
25 // This is part of revision 2523 of the Stellaris Peripheral Driver Library.\r
26 //\r
27 //*****************************************************************************\r
28 \r
29 #ifndef __UART_H__\r
30 #define __UART_H__\r
31 \r
32 //*****************************************************************************\r
33 //\r
34 // If building with a C++ compiler, make all of the definitions in this header\r
35 // have a C binding.\r
36 //\r
37 //*****************************************************************************\r
38 #ifdef __cplusplus\r
39 extern "C"\r
40 {\r
41 #endif\r
42 \r
43 //*****************************************************************************\r
44 //\r
45 // Values that can be passed to UARTIntEnable, UARTIntDisable, and UARTIntClear\r
46 // as the ulIntFlags parameter, and returned from UARTIntStatus.\r
47 //\r
48 //*****************************************************************************\r
49 #define UART_INT_OE             0x400       // Overrun Error Interrupt Mask\r
50 #define UART_INT_BE             0x200       // Break Error Interrupt Mask\r
51 #define UART_INT_PE             0x100       // Parity Error Interrupt Mask\r
52 #define UART_INT_FE             0x080       // Framing Error Interrupt Mask\r
53 #define UART_INT_RT             0x040       // Receive Timeout Interrupt Mask\r
54 #define UART_INT_TX             0x020       // Transmit Interrupt Mask\r
55 #define UART_INT_RX             0x010       // Receive Interrupt Mask\r
56 \r
57 //*****************************************************************************\r
58 //\r
59 // Values that can be passed to UARTConfigSetExpClk as the ulConfig parameter\r
60 // and returned by UARTConfigGetExpClk in the pulConfig parameter.\r
61 // Additionally, the UART_CONFIG_PAR_* subset can be passed to\r
62 // UARTParityModeSet as the ulParity parameter, and are returned by\r
63 // UARTParityModeGet.\r
64 //\r
65 //*****************************************************************************\r
66 #define UART_CONFIG_WLEN_MASK   0x00000060  // Mask for extracting word length\r
67 #define UART_CONFIG_WLEN_8      0x00000060  // 8 bit data\r
68 #define UART_CONFIG_WLEN_7      0x00000040  // 7 bit data\r
69 #define UART_CONFIG_WLEN_6      0x00000020  // 6 bit data\r
70 #define UART_CONFIG_WLEN_5      0x00000000  // 5 bit data\r
71 #define UART_CONFIG_STOP_MASK   0x00000008  // Mask for extracting stop bits\r
72 #define UART_CONFIG_STOP_ONE    0x00000000  // One stop bit\r
73 #define UART_CONFIG_STOP_TWO    0x00000008  // Two stop bits\r
74 #define UART_CONFIG_PAR_MASK    0x00000086  // Mask for extracting parity\r
75 #define UART_CONFIG_PAR_NONE    0x00000000  // No parity\r
76 #define UART_CONFIG_PAR_EVEN    0x00000006  // Even parity\r
77 #define UART_CONFIG_PAR_ODD     0x00000002  // Odd parity\r
78 #define UART_CONFIG_PAR_ONE     0x00000086  // Parity bit is one\r
79 #define UART_CONFIG_PAR_ZERO    0x00000082  // Parity bit is zero\r
80 \r
81 //*****************************************************************************\r
82 //\r
83 // Values that can be passed to UARTFIFOLevelSet as the ulTxLevel parameter and\r
84 // returned by UARTFIFOLevelGet in the pulTxLevel.\r
85 //\r
86 //*****************************************************************************\r
87 #define UART_FIFO_TX1_8         0x00000000  // Transmit interrupt at 1/8 Full\r
88 #define UART_FIFO_TX2_8         0x00000001  // Transmit interrupt at 1/4 Full\r
89 #define UART_FIFO_TX4_8         0x00000002  // Transmit interrupt at 1/2 Full\r
90 #define UART_FIFO_TX6_8         0x00000003  // Transmit interrupt at 3/4 Full\r
91 #define UART_FIFO_TX7_8         0x00000004  // Transmit interrupt at 7/8 Full\r
92 \r
93 //*****************************************************************************\r
94 //\r
95 // Values that can be passed to UARTFIFOLevelSet as the ulRxLevel parameter and\r
96 // returned by UARTFIFOLevelGet in the pulRxLevel.\r
97 //\r
98 //*****************************************************************************\r
99 #define UART_FIFO_RX1_8         0x00000000  // Receive interrupt at 1/8 Full\r
100 #define UART_FIFO_RX2_8         0x00000008  // Receive interrupt at 1/4 Full\r
101 #define UART_FIFO_RX4_8         0x00000010  // Receive interrupt at 1/2 Full\r
102 #define UART_FIFO_RX6_8         0x00000018  // Receive interrupt at 3/4 Full\r
103 #define UART_FIFO_RX7_8         0x00000020  // Receive interrupt at 7/8 Full\r
104 \r
105 //*****************************************************************************\r
106 //\r
107 // Values that can be passed to UARTDMAEnable() and UARTDMADisable().\r
108 //\r
109 //*****************************************************************************\r
110 #define UART_DMA_ERR_RXSTOP     0x00000004  // Stop DMA receive if UART error\r
111 #define UART_DMA_TX             0x00000002  // Enable DMA for transmit\r
112 #define UART_DMA_RX             0x00000001  // Enable DMA for receive\r
113 \r
114 //*****************************************************************************\r
115 //\r
116 // API Function prototypes\r
117 //\r
118 //*****************************************************************************\r
119 extern void UARTParityModeSet(unsigned long ulBase, unsigned long ulParity);\r
120 extern unsigned long UARTParityModeGet(unsigned long ulBase);\r
121 extern void UARTFIFOLevelSet(unsigned long ulBase, unsigned long ulTxLevel,\r
122                              unsigned long ulRxLevel);\r
123 extern void UARTFIFOLevelGet(unsigned long ulBase, unsigned long *pulTxLevel,\r
124                              unsigned long *pulRxLevel);\r
125 extern void UARTConfigSetExpClk(unsigned long ulBase, unsigned long ulUARTClk,\r
126                                 unsigned long ulBaud, unsigned long ulConfig);\r
127 extern void UARTConfigGetExpClk(unsigned long ulBase, unsigned long ulUARTClk,\r
128                                 unsigned long *pulBaud,\r
129                                 unsigned long *pulConfig);\r
130 extern void UARTEnable(unsigned long ulBase);\r
131 extern void UARTDisable(unsigned long ulBase);\r
132 extern void UARTEnableSIR(unsigned long ulBase, tBoolean bLowPower);\r
133 extern void UARTDisableSIR(unsigned long ulBase);\r
134 extern tBoolean UARTCharsAvail(unsigned long ulBase);\r
135 extern tBoolean UARTSpaceAvail(unsigned long ulBase);\r
136 extern long UARTCharGetNonBlocking(unsigned long ulBase);\r
137 extern long UARTCharGet(unsigned long ulBase);\r
138 extern tBoolean UARTCharPutNonBlocking(unsigned long ulBase,\r
139                                        unsigned char ucData);\r
140 extern void UARTCharPut(unsigned long ulBase, unsigned char ucData);\r
141 extern void UARTBreakCtl(unsigned long ulBase, tBoolean bBreakState);\r
142 extern void UARTIntRegister(unsigned long ulBase, void(*pfnHandler)(void));\r
143 extern void UARTIntUnregister(unsigned long ulBase);\r
144 extern void UARTIntEnable(unsigned long ulBase, unsigned long ulIntFlags);\r
145 extern void UARTIntDisable(unsigned long ulBase, unsigned long ulIntFlags);\r
146 extern unsigned long UARTIntStatus(unsigned long ulBase, tBoolean bMasked);\r
147 extern void UARTIntClear(unsigned long ulBase, unsigned long ulIntFlags);\r
148 extern void UARTDMAEnable(unsigned long ulBase, unsigned long ulDMAFlags);\r
149 extern void UARTDMADisable(unsigned long ulBase, unsigned long ulDMAFlags);\r
150 \r
151 //*****************************************************************************\r
152 //\r
153 // Several UART APIs have been renamed, with the original function name being\r
154 // deprecated.  These defines provide backward compatibility.\r
155 //\r
156 //*****************************************************************************\r
157 #ifndef DEPRECATED\r
158 #include "sysctl.h"\r
159 #define UARTConfigSet(a, b, c)                         \\r
160         UARTConfigSetExpClk(a, SysCtlClockGet(), b, c)\r
161 #define UARTConfigGet(a, b, c)                         \\r
162         UARTConfigGetExpClk(a, SysCtlClockGet(), b, c)\r
163 #define UARTCharNonBlockingGet(a) \\r
164         UARTCharGetNonBlocking(a)\r
165 #define UARTCharNonBlockingPut(a, b) \\r
166         UARTCharPutNonBlocking(a, b)\r
167 #endif\r
168 \r
169 //*****************************************************************************\r
170 //\r
171 // Mark the end of the C bindings section for C++ compilers.\r
172 //\r
173 //*****************************************************************************\r
174 #ifdef __cplusplus\r
175 }\r
176 #endif\r
177 \r
178 #endif //  __UART_H__\r