Rev 304 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
196 | killagreg | 1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** |
1 | ingob | 2 | * File Name : 91x_uart.h |
3 | * Author : MCD Application Team |
||
196 | killagreg | 4 | * Version : V2.1 |
5 | * Date : 12/22/2008 |
||
1 | ingob | 6 | * Description : This file contains all the functions prototypes for the |
196 | killagreg | 7 | * UART firmware library. |
1 | ingob | 8 | ******************************************************************************** |
9 | * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
||
10 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. |
||
11 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, |
||
12 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE |
||
13 | * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING |
||
14 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
||
15 | *******************************************************************************/ |
||
16 | |||
17 | /* Define to prevent recursive inclusion -------------------------------------*/ |
||
18 | #ifndef __91x_UART_H |
||
19 | #define __91x_UART_H |
||
20 | |||
21 | /* Includes ------------------------------------------------------------------*/ |
||
22 | #include <91x_map.h> |
||
23 | |||
24 | /* Exported types ------------------------------------------------------------*/ |
||
25 | /* UART FIFO Level enumeration */ |
||
26 | typedef enum |
||
27 | { |
||
28 | UART_FIFOLevel_1_8 = 0x0000, /* FIFO size 16 bytes, FIFO level 2 bytes */ |
||
29 | UART_FIFOLevel_1_4 = 0x0001, /* FIFO size 16 bytes, FIFO level 4 bytes */ |
||
30 | UART_FIFOLevel_1_2 = 0x0002, /* FIFO size 16 bytes, FIFO level 8 bytes */ |
||
31 | UART_FIFOLevel_3_4 = 0x0003, /* FIFO size 16 bytes, FIFO level 12 bytes */ |
||
32 | UART_FIFOLevel_7_8 = 0x0004 /* FIFO size 16 bytes, FIFO level 14 bytes */ |
||
33 | }UART_FIFOLevel; |
||
34 | |||
35 | /* UART Init Structure definition */ |
||
36 | typedef struct |
||
37 | { |
||
38 | u16 UART_WordLength; |
||
39 | u16 UART_StopBits; |
||
40 | u16 UART_Parity; |
||
41 | u32 UART_BaudRate; |
||
42 | u16 UART_HardwareFlowControl; |
||
43 | u16 UART_Mode; |
||
44 | u16 UART_FIFO; |
||
45 | UART_FIFOLevel UART_TxFIFOLevel; |
||
46 | UART_FIFOLevel UART_RxFIFOLevel; |
||
47 | }UART_InitTypeDef; |
||
48 | |||
49 | |||
50 | /* UART RTS enumeration */ |
||
51 | typedef enum |
||
52 | { |
||
53 | LowLevel = 0, |
||
54 | HighLevel |
||
55 | }UART_LevelTypeDef; |
||
56 | |||
57 | /* Exported constants --------------------------------------------------------*/ |
||
58 | /* UART Data Length */ |
||
59 | #define UART_WordLength_5D 0x0000 /* 5 bits Data */ |
||
60 | #define UART_WordLength_6D 0x0020 /* 6 bits Data */ |
||
61 | #define UART_WordLength_7D 0x0040 /* 7 bits Data */ |
||
62 | #define UART_WordLength_8D 0x0060 /* 8 bits Data */ |
||
63 | |||
64 | /* UART Stop Bits */ |
||
65 | #define UART_StopBits_1 0xFFF7 /* Disable two stop bit is transmitted |
||
66 | at the end of frame */ |
||
67 | #define UART_StopBits_2 0x0008 /* Enable Two stop bits are transmitted |
||
68 | at the end of frame */ |
||
69 | /* UART Parity */ |
||
70 | #define UART_Parity_No 0x0000 /* Parity Disable */ |
||
71 | #define UART_Parity_Even 0x0006 /* Even Parity */ |
||
72 | #define UART_Parity_Odd 0x0002 /* Odd Parity */ |
||
73 | #define UART_Parity_OddStick 0x0082 /* 1 is transmitted as bit parity */ |
||
74 | #define UART_Parity_EvenStick 0x0086 /* 0 is transmitted as bit parity */ |
||
75 | |||
76 | /* UART Hardware Flow Control */ |
||
77 | #define UART_HardwareFlowControl_None 0x0000 /* HFC Disable */ |
||
78 | #define UART_HardwareFlowControl_RTS 0x4000 /* RTS Enable */ |
||
79 | #define UART_HardwareFlowControl_CTS 0x8000 /* CTS Enable */ |
||
80 | #define UART_HardwareFlowControl_RTS_CTS 0xC000 /* CTS and RTS Enable */ |
||
81 | |||
82 | /* UART Mode */ |
||
83 | #define UART_Mode_Rx 0x0200 /* UART Rx Enabled */ |
||
84 | #define UART_Mode_Tx 0x0100 /* UART Tx Enbled */ |
||
85 | #define UART_Mode_Tx_Rx 0x0300 /* UART Tx and Rx Enabled */ |
||
86 | |||
87 | /* UART FIFO */ |
||
88 | #define UART_FIFO_Disable 0xFFEF /* FIFOs Disable */ |
||
89 | #define UART_FIFO_Enable 0x0010 /* FIFOs Enable */ |
||
90 | |||
91 | /* UART Interrupt definition */ |
||
92 | #define UART_IT_OverrunError 0x0400 /* Overrun Error interrupt mask */ |
||
93 | #define UART_IT_BreakError 0x0200 /* Break Error interrupt mask */ |
||
94 | #define UART_IT_ParityError 0x0100 /* Parity Error interrupt mask */ |
||
95 | #define UART_IT_FrameError 0x0080 /* Frame Error interrupt mask */ |
||
96 | #define UART_IT_ReceiveTimeOut 0x0040 /* Receive Time Out interrupt mask */ |
||
97 | #define UART_IT_Transmit 0x0020 /* Transmit interrupt mask */ |
||
98 | #define UART_IT_Receive 0x0010 /* Receive interrupt mask */ |
||
99 | #define UART_IT_DSR 0x0008 /* DSR interrupt mask */ |
||
100 | #define UART_IT_DCD 0x0004 /* DCD interrupt mask */ |
||
101 | #define UART_IT_CTS 0x0002 /* CTS interrupt mask */ |
||
102 | #define UART_IT_RI 0x0001 /* RI interrupt mask */ |
||
103 | |||
104 | /* UART DMA On Error */ |
||
105 | #define UART_DMAOnError_Enable 0xFFFB /* DMA receive request enabled |
||
106 | when the UART error interrupt |
||
107 | is asserted. */ |
||
108 | #define UART_DMAOnError_Disable 0x0004 /* DMA receive request disabled |
||
109 | when the UART error interrupt |
||
110 | is asserted. */ |
||
111 | /* UART DMA Request */ |
||
112 | #define UART_DMAReq_Tx 0x02 /* Transmit DMA Enable */ |
||
113 | #define UART_DMAReq_Rx 0x01 /* Receive DMA Enable */ |
||
114 | |||
115 | /* UART FLAG */ |
||
116 | #define UART_FLAG_OverrunError 0x23 /* Overrun error flag */ |
||
117 | #define UART_FLAG_Break 0x22 /* break error flag */ |
||
118 | #define UART_FLAG_ParityError 0x21 /* parity error flag */ |
||
119 | #define UART_FLAG_FrameError 0x20 /* frame error flag */ |
||
120 | #define UART_FLAG_RI 0x48 /* RI flag */ |
||
121 | #define UART_FLAG_TxFIFOEmpty 0x47 /* Transmit FIFO Empty flag */ |
||
122 | #define UART_FLAG_RxFIFOFull 0x46 /* Receive FIFO Full flag */ |
||
123 | #define UART_FLAG_TxFIFOFull 0x45 /* Transmit FIFO Full flag */ |
||
124 | #define UART_FLAG_RxFIFOEmpty 0x44 /* Receive FIFO Empty flag */ |
||
125 | #define UART_FLAG_Busy 0x43 /* UART Busy flag */ |
||
126 | #define UART_FLAG_DCD 0x42 /* DCD flag */ |
||
127 | #define UART_FLAG_DSR 0x41 /* DSR flag */ |
||
128 | #define UART_FLAG_CTS 0x40 /* CTS flag */ |
||
129 | #define UART_RawIT_OverrunError 0x6A /* Overrun Error Raw IT flag */ |
||
130 | #define UART_RawIT_BreakError 0x69 /* Break Error Raw IT flag */ |
||
131 | #define UART_RawIT_ParityError 0x68 /* Parity Error Raw IT flag */ |
||
132 | #define UART_RawIT_FrameError 0x67 /* Frame Error Raw IT flag */ |
||
133 | #define UART_RawIT_ReceiveTimeOut 0x66 /* ReceiveTimeOut Raw IT flag */ |
||
134 | #define UART_RawIT_Transmit 0x65 /* Transmit Raw IT flag */ |
||
135 | #define UART_RawIT_Receive 0x64 /* Receive Raw IT flag */ |
||
136 | #define UART_RawIT_DSR 0x63 /* DSR Raw IT flag */ |
||
137 | #define UART_RawIT_DCD 0x62 /* DCD Raw IT flag */ |
||
138 | #define UART_RawIT_CTS 0x61 /* CTS Raw IT flag */ |
||
139 | #define UART_RawIT_RI 0x60 /* RI Raw IT flag */ |
||
140 | |||
141 | /*IrDAx select*/ |
||
142 | #define IrDA0 0x01 /*IrDA0 select*/ |
||
143 | #define IrDA1 0x02 /*IrDA0 select*/ |
||
144 | #define IrDA2 0x03 /*IrDA0 select*/ |
||
145 | |||
146 | /* Exported macro ------------------------------------------------------------*/ |
||
147 | /* Exported functions ------------------------------------------------------- */ |
||
148 | void UART_DeInit(UART_TypeDef* UARTx); |
||
149 | void UART_Init(UART_TypeDef* UARTx, UART_InitTypeDef* UART_InitStruct); |
||
150 | void UART_StructInit(UART_InitTypeDef* UART_InitStruct); |
||
151 | void UART_Cmd(UART_TypeDef* UARTx, FunctionalState NewState); |
||
152 | void UART_ITConfig(UART_TypeDef* UARTx, u16 UART_IT, FunctionalState NewState); |
||
153 | void UART_DMAConfig(UART_TypeDef* UARTx, u16 UART_DMAOnError); |
||
154 | void UART_DMACmd(UART_TypeDef* UARTx, u8 UART_DMAReq, FunctionalState NewState); |
||
155 | void UART_LoopBackConfig(UART_TypeDef* UARTx, FunctionalState NewState); |
||
156 | FlagStatus UART_GetFlagStatus(UART_TypeDef* UARTx, u16 UART_FLAG); |
||
157 | void UART_ClearFlag(UART_TypeDef* UARTx); |
||
158 | void UART_ClearITPendingBit(UART_TypeDef* UARTx, u16 UART_IT); |
||
159 | void UART_IrDALowPowerConfig(u8 IrDAx, FunctionalState NewState); |
||
160 | void UART_IrDACmd(u8 IrDAx, FunctionalState NewState); |
||
161 | void UART_IrDASetCounter(u8 IrDAx, u32 IrDA_Counter); |
||
162 | void UART_SendData(UART_TypeDef* UARTx, u8 Data); |
||
163 | u8 UART_ReceiveData(UART_TypeDef* UARTx); |
||
164 | void UART_SendBreak(UART_TypeDef* UARTx); |
||
165 | void UART_DTRConfig(UART_LevelTypeDef LevelState); |
||
166 | void UART_RTSConfig(UART_LevelTypeDef LevelState); |
||
167 | ITStatus UART_GetITStatus(UART_TypeDef* UARTx, u16 UART_IT); |
||
168 | |||
169 | #endif /* __91x_UART_H */ |
||
170 | |||
196 | killagreg | 171 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ |