MG32F10x Standard Peripherals Firmware Library

mg32f10x_uart.h
浏览该文件的文档.
1
10 /* Define to prevent recursive inclusion -------------------------------------*/
11 #ifndef __MG32F10x_UART_H
12 #define __MG32F10x_UART_H
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 /* Includes ------------------------------------------------------------------*/
19 #include "mg32f10x.h"
20
29 /* Exported types ------------------------------------------------------------*/
30
34 typedef struct
35 {
36 uint32_t UART_BaudRate;
38 uint8_t UART_WordLength;
41 uint8_t UART_StopBits;
44 uint8_t UART_Parity;
47 uint8_t UART_AutoFlowControl;
50 } UART_InitTypeDef;
51
52 /* Exported constants --------------------------------------------------------*/
53
61 #define UART_WordLength_5b UART_LCR_WLS_5BIT
62 #define UART_WordLength_6b UART_LCR_WLS_6BIT
63 #define UART_WordLength_7b UART_LCR_WLS_7BIT
64 #define UART_WordLength_8b UART_LCR_WLS_8BIT
65
73 #define UART_StopBits_One UART_LCR_SBS_1BIT
74 #define UART_StopBits_Two UART_LCR_SBS_2BIT
75 #define UART_StopBits_OnePointFive UART_LCR_SBS_2BIT
76
84 #define UART_Parity_None (0x00U)
85 #define UART_Parity_Odd (UART_LCR_PARITY_ODD)
86 #define UART_Parity_Even (UART_LCR_PARITY_EVEN)
87 #define UART_Parity_Mark (UART_LCR_PARITY_MARK)
88 #define UART_Parity_Space (UART_LCR_PARITY_SPACE)
89
97 #define UART_AutoFlowControl_None (0x00)
98 #define UART_AutoFlowControl_CTS (UART_MCR_AFCE)
99 #define UART_AutoFlowControl_RTS_CTS (UART_MCR_AFCE | UART_MCR_RTS)
100
108 #define UART_RxFIFOThreshold_1 0x00
109 #define UART_RxFIFOThreshold_4 0x01
110 #define UART_RxFIFOThreshold_8 0x02
111 #define UART_RxFIFOThreshold_14 0x03
112
120 #define UART_TxFIFOThreshold_0 0x00
121 #define UART_TxFIFOThreshold_2 0x01
122 #define UART_TxFIFOThreshold_4 0x02
123 #define UART_TxFIFOThreshold_8 0x03
124
132 #define UART_IT_RDA UART_IER_RDAIE
133 #define UART_IT_THRE UART_IER_THREIE
134 #define UART_IT_RLS UART_IER_RLSIE
135 #define UART_IT_MSI UART_IER_MSIE
136
145 #define UART_INTID_MSI UART_IIR_INTID_MSI
146 #define UART_INTID_NONE UART_IIR_INTID_NONE
147 #define UART_INTID_THRE UART_IIR_INTID_THRE
148 #define UART_INTID_RDA UART_IIR_INTID_RDA
149 #define UART_INTID_RLS UART_IIR_INTID_RLS
150 #define UART_INTID_BUSY UART_IIR_INTID_BUSY
151 #define UART_INTID_CTI UART_IIR_INTID_CTI
160 #define UART_FLAG_BUSY UART_USR_BUSY
161 #define UART_FLAG_TFNF UART_USR_TFNF
162 #define UART_FLAG_TFE UART_USR_TFE
163 #define UART_FLAG_RFNE UART_USR_RFNE
164 #define UART_FLAG_RFF UART_USR_RFF
165
173 #define UART_LINE_STATUS_DR UART_LSR_DR
174 #define UART_LINE_STATUS_OE UART_LSR_OE
175 #define UART_LINE_STATUS_PE UART_LSR_PE
176 #define UART_LINE_STATUS_FE UART_LSR_FE
177 #define UART_LINE_STATUS_BI UART_LSR_BI
178 #define UART_LINE_STATUS_THRE UART_LSR_THRE
179 #define UART_LINE_STATUS_TEMT UART_LSR_TEMT
180 #define UART_LINE_STATUS_RFE UART_LSR_RFE
181 #define UART_LINE_STATUS_ADDR_RCVD UART_LSR_ADDR_RCVD
182
190 #define UART_MODEM_STATUS_DCTS UART_MSR_DCTS
191 #define UART_MODEM_STATUS_CTS UART_MSR_CTS
192
200 /* Exported macro ------------------------------------------------------------*/
201 /* Exported functions --------------------------------------------------------*/
202
203 void UART_DeInit(UART_TypeDef* UARTx);
204 void UART_Init(UART_TypeDef* UARTx, UART_InitTypeDef* UART_InitStruct);
205 void UART_StructInit(UART_InitTypeDef* UART_InitStruct);
206 void UART_WriteData(UART_TypeDef* UARTx, uint16_t Data);
207 uint16_t UART_ReadData(UART_TypeDef* UARTx);
208 void UART_RxFIFOThresholdConfig(UART_TypeDef* UARTx, uint8_t Threshold);
209 void UART_TxFIFOThresholdConfig(UART_TypeDef* UARTx, uint8_t Threshold);
210 void UART_FIFOCmd(UART_TypeDef* UARTx, FunctionalState NewState);
211 void UART_ResetRxFIFO(UART_TypeDef* UARTx);
212 void UART_ResetTxFIFO(UART_TypeDef* UARTx);
213 void UART_ForceBreakCmd(UART_TypeDef* UARTx, FunctionalState NewState);
214 void UART_IrDACmd(UART_TypeDef* UARTx, FunctionalState NewState);
215 void UART_ProgrammableTHREModeCmd(UART_TypeDef* UARTx, FunctionalState NewState);
216 void UART_LineStatusClearModeConfig(UART_TypeDef* UARTx, uint8_t Mode);
217 void UART_ITConfig(UART_TypeDef* UARTx, uint8_t UART_IT, FunctionalState NewState);
218 uint8_t UART_GetIntID(UART_TypeDef* UARTx);
219 FlagStatus UART_GetFlagStatus(UART_TypeDef* UARTx, uint32_t UART_FLAG);
220 uint32_t UART_GetLineStatus(UART_TypeDef* UARTx);
221 uint32_t UART_GetModemStatus(UART_TypeDef* UARTx);
222 void UART_LoopBackModeCmd(UART_TypeDef* UARTx, FunctionalState NewState);
223 void UART_ModemForceRtsPinState(UART_TypeDef* UARTx, SignalState NewState);
224
233 #ifdef __cplusplus
234 }
235 #endif
236
237 #endif /* __MG32F10x_UART_H */
UART_LineStatusClearModeConfig
void UART_LineStatusClearModeConfig(UART_TypeDef *UARTx, uint8_t Mode)
Select the method for clearing the status in the LSR register.
Definition: mg32f10x_uart.c:293
UART_DeInit
void UART_DeInit(UART_TypeDef *UARTx)
Deinitializes the UARTx peripheral registers to their default reset values.
Definition: mg32f10x_uart.c:40
UART_GetFlagStatus
FlagStatus UART_GetFlagStatus(UART_TypeDef *UARTx, uint32_t UART_FLAG)
Checks whether the specified UART flag is set or not.
Definition: mg32f10x_uart.c:354
UART_GetLineStatus
uint32_t UART_GetLineStatus(UART_TypeDef *UARTx)
Get UARTx's Line status.
Definition: mg32f10x_uart.c:376
UART_TxFIFOThresholdConfig
void UART_TxFIFOThresholdConfig(UART_TypeDef *UARTx, uint8_t Threshold)
Configure UARTx's Tx FIFO trigger threshold.
Definition: mg32f10x_uart.c:175
UART_IrDACmd
void UART_IrDACmd(UART_TypeDef *UARTx, FunctionalState NewState)
Enables or disables the UARTx's IrDA SIR Mode.
Definition: mg32f10x_uart.c:251
UART_ModemForceRtsPinState
void UART_ModemForceRtsPinState(UART_TypeDef *UARTx, SignalState NewState)
Control RTS Pin State.
Definition: mg32f10x_uart.c:421
UART_InitTypeDef::UART_BaudRate
uint32_t UART_BaudRate
Definition: mg32f10x_uart.h:36
UART_ProgrammableTHREModeCmd
void UART_ProgrammableTHREModeCmd(UART_TypeDef *UARTx, FunctionalState NewState)
Enables or disables the UARTx's Programmable THRE Interrupt Mode.
Definition: mg32f10x_uart.c:270
UART_LoopBackModeCmd
void UART_LoopBackModeCmd(UART_TypeDef *UARTx, FunctionalState NewState)
Enables or disables the UARTx's LoopBack Mode.
Definition: mg32f10x_uart.c:402
UART_Init
void UART_Init(UART_TypeDef *UARTx, UART_InitTypeDef *UART_InitStruct)
Initializes the UARTx peripheral according to the specified parameters in the UART_InitStruct.
Definition: mg32f10x_uart.c:70
UART_ResetRxFIFO
void UART_ResetRxFIFO(UART_TypeDef *UARTx)
Reset the UART's Rx FIFO.
Definition: mg32f10x_uart.c:206
UART_InitTypeDef::UART_Parity
uint8_t UART_Parity
Definition: mg32f10x_uart.h:44
UART_ForceBreakCmd
void UART_ForceBreakCmd(UART_TypeDef *UARTx, FunctionalState NewState)
Force the serial out to spacing state or not.
Definition: mg32f10x_uart.c:232
UART_InitTypeDef::UART_StopBits
uint8_t UART_StopBits
Definition: mg32f10x_uart.h:41
UART_InitTypeDef::UART_AutoFlowControl
uint8_t UART_AutoFlowControl
Definition: mg32f10x_uart.h:47
UART_GetIntID
uint8_t UART_GetIntID(UART_TypeDef *UARTx)
Get UARTx's Interrupt ID.
Definition: mg32f10x_uart.c:335
UART_ResetTxFIFO
void UART_ResetTxFIFO(UART_TypeDef *UARTx)
Reset the UART's Tx FIFO.
Definition: mg32f10x_uart.c:218
UART_GetModemStatus
uint32_t UART_GetModemStatus(UART_TypeDef *UARTx)
Get UARTx's Modem Status.
Definition: mg32f10x_uart.c:388
UART_ITConfig
void UART_ITConfig(UART_TypeDef *UARTx, uint8_t UART_IT, FunctionalState NewState)
Enables or disables the UARTx's interrupts.
Definition: mg32f10x_uart.c:318
UART_TypeDef
Definition: mg32f10x.h:477
UART_InitTypeDef
UART Init Structure definition
Definition: mg32f10x_uart.h:34
UART_StructInit
void UART_StructInit(UART_InitTypeDef *UART_InitStruct)
Fills each UART_InitStruct member with its default value.
Definition: mg32f10x_uart.c:111
UART_RxFIFOThresholdConfig
void UART_RxFIFOThresholdConfig(UART_TypeDef *UARTx, uint8_t Threshold)
Configure UARTx's Rx FIFO trigger threshold.
Definition: mg32f10x_uart.c:158
UART_WriteData
void UART_WriteData(UART_TypeDef *UARTx, uint16_t Data)
Write data to THR register or Tx FIFO.
Definition: mg32f10x_uart.c:129
UART_ReadData
uint16_t UART_ReadData(UART_TypeDef *UARTx)
Read data from RBR register or Rx FIFO.
Definition: mg32f10x_uart.c:141
UART_InitTypeDef::UART_WordLength
uint8_t UART_WordLength
Definition: mg32f10x_uart.h:38
UART_FIFOCmd
void UART_FIFOCmd(UART_TypeDef *UARTx, FunctionalState NewState)
Enables or disables the UARTx's FIFO.
Definition: mg32f10x_uart.c:189