MG32L003 Standard Peripherals Firmware Library
mg32l003_uart.h
Go to the documentation of this file.
1 
10 /* Define to prevent recursive inclusion -------------------------------------*/
11 #ifndef __MG32L003_UART_H
12 #define __MG32L003_UART_H
13 
14 #ifdef __cplusplus
15  extern "C" {
16 #endif
17 
18 /* Includes ------------------------------------------------------------------*/
19 #include "mg32l003.h"
20 
29 /* Exported types ------------------------------------------------------------*/
30 
34 typedef struct
35 {
36  uint32_t UART_BandDouble;
39  uint32_t UART_BaudRateMode;
42  uint32_t UART_BaudRate;
44  uint8_t UART_WordLength;
47 
48 /* Exported constants --------------------------------------------------------*/
49 
54 #define IS_UART_ALL_PERIPH(PERIPH) (((PERIPH) == UART1) || \
55  ((PERIPH) == UART2))
56 
60 #define UART_WordLength_8b ((uint32_t)(0x01U << 6))
61 #define UART_WordLength_9b ((uint32_t)(0x03U << 6))
62 
70 #define UART_BandDouble_Enable ((uint32_t)UART_SCON_DBAUD)
71 #define UART_BandDouble_Disable ((uint32_t)0x00)
72 
80 #define UART_BaudRateMode_Self ((uint32_t)UART_BAUDCR_SELF_BRG)
81 #define UART_BaudRateMode_Tim ((uint32_t)0x00)
82 
90 #define UART_Parity_None ((uint8_t)0x00)
91 #define UART_Parity_Odd ((uint8_t)0x01)
92 #define UART_Parity_Even ((uint8_t)0x02)
93 
101 #define UART_IT_FE UART_SCON_FEEN
102 #define UART_IT_TI UART_SCON_TIEN
103 #define UART_IT_RI UART_SCON_RIEN
104 
112 #define UART_FLAG_FE UART_INTSR_FE
113 #define UART_FLAG_TI UART_INTSR_TI
114 #define UART_FLAG_RI UART_INTSR_RI
115 
124 /* Exported macro ------------------------------------------------------------*/
125 /* Exported functions --------------------------------------------------------*/
126 
127 void UART_DeInit(UART_TypeDef* UARTx);
128 void UART_Init(UART_TypeDef* UARTx, UART_InitTypeDef* UART_InitStruct);
129 void UART_StructInit(UART_InitTypeDef* UART_InitStruct);
130 void UART_Cmd(UART_TypeDef* UARTx, FunctionalState NewState);
131 void UART_WriteData(UART_TypeDef* UARTx, uint8_t Data);
132 uint8_t UART_ReadData(UART_TypeDef* UARTx);
133 void UART_WriteDataParity(UART_TypeDef* UARTx, uint8_t Data, uint8_t Parity);
134 uint8_t UART_ReadDataParity(UART_TypeDef* UARTx, uint8_t *Data, uint8_t Parity);
135 void UART_MultideviceCmd(UART_TypeDef* UARTx, FunctionalState NewState);
136 void UART_SetAddress(UART_TypeDef* UARTx, uint8_t UART_Address);
137 void UART_SetAddressMask(UART_TypeDef* UARTx, uint8_t UART_AddressMask);
138 void UART_IrDACmd(UART_TypeDef* UARTx, FunctionalState NewState);
139 void UART_ITConfig(UART_TypeDef* UARTx, uint8_t UART_IT, FunctionalState NewState);
140 FlagStatus UART_GetFlagStatus(UART_TypeDef* UARTx, uint32_t UART_FLAG);
141 void UART_ClearFlag(UART_TypeDef* UARTx, uint32_t UART_FLAG);
142 
143 
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 #endif /* __MG32L003_UART_H */
uint32_t UART_BaudRateMode
Definition: mg32l003_uart.h:39
void UART_DeInit(UART_TypeDef *UARTx)
Deinitializes the UARTx peripheral registers to their default reset values.
Definition: mg32l003_uart.c:60
void UART_ClearFlag(UART_TypeDef *UARTx, uint32_t UART_FLAG)
Clear the specified UART flag.
Definition: mg32l003_uart.c:400
FlagStatus UART_GetFlagStatus(UART_TypeDef *UARTx, uint32_t UART_FLAG)
Checks whether the specified UART flag is set or not.
Definition: mg32l003_uart.c:369
void UART_SetAddressMask(UART_TypeDef *UARTx, uint8_t UART_AddressMask)
Sets the address mask of the UART node.
Definition: mg32l003_uart.c:348
void UART_IrDACmd(UART_TypeDef *UARTx, FunctionalState NewState)
Enables or disables the UARTx's IrDA Mode.
Definition: mg32l003_uart.c:260
uint32_t UART_BandDouble
Definition: mg32l003_uart.h:36
void UART_WriteData(UART_TypeDef *UARTx, uint8_t Data)
Write data to SBUF register.
Definition: mg32l003_uart.c:160
void UART_SetAddress(UART_TypeDef *UARTx, uint8_t UART_Address)
Sets the address of the UART node.
Definition: mg32l003_uart.c:331
uint32_t UART_BaudRate
Definition: mg32l003_uart.h:42
void UART_Cmd(UART_TypeDef *UARTx, FunctionalState NewState)
Enables or disables the specified UART peripheral.
Definition: mg32l003_uart.c:135
void UART_Init(UART_TypeDef *UARTx, UART_InitTypeDef *UART_InitStruct)
Initializes the UARTx peripheral according to the specified parameters in the UART_InitStruct.
Definition: mg32l003_uart.c:88
void UART_WriteDataParity(UART_TypeDef *UARTx, uint8_t Data, uint8_t Parity)
Write data and parity to SBUF register.
Definition: mg32l003_uart.c:195
void UART_ITConfig(UART_TypeDef *UARTx, uint8_t UART_IT, FunctionalState NewState)
Enables or disables the UARTx's interrupts.
Definition: mg32l003_uart.c:287
uint8_t UART_ReadData(UART_TypeDef *UARTx)
Read data from SBUF register.
Definition: mg32l003_uart.c:175
void UART_MultideviceCmd(UART_TypeDef *UARTx, FunctionalState NewState)
Enables or disables the UARTx's Multidevice function.
Definition: mg32l003_uart.c:308
Definition: mg32l003.h:350
UART Init Structure definition.
Definition: mg32l003_uart.h:34
void UART_StructInit(UART_InitTypeDef *UART_InitStruct)
Fills each UART_InitStruct member with its default value.
Definition: mg32l003_uart.c:117
uint8_t UART_ReadDataParity(UART_TypeDef *UARTx, uint8_t *Data, uint8_t Parity)
Read data and parity check result from SBUF register.
Definition: mg32l003_uart.c:224
uint8_t UART_WordLength
Definition: mg32l003_uart.h:44