stm32f4xx_usart.h
Go to the documentation of this file.
1 
29 /* Define to prevent recursive inclusion -------------------------------------*/
30 #ifndef __STM32F4xx_USART_H
31 #define __STM32F4xx_USART_H
32 
33 #ifdef __cplusplus
34  extern "C" {
35 #endif
36 
37 /* Includes ------------------------------------------------------------------*/
38 #include "stm32f4xx.h"
39 
48 /* Exported types ------------------------------------------------------------*/
49 
54 typedef struct
55 {
56  uint32_t USART_BaudRate;
62  uint16_t USART_WordLength;
65  uint16_t USART_StopBits;
68  uint16_t USART_Parity;
75  uint16_t USART_Mode;
82 
87 typedef struct
88 {
89 
90  uint16_t USART_Clock;
93  uint16_t USART_CPOL;
96  uint16_t USART_CPHA;
99  uint16_t USART_LastBit;
103 
104 /* Exported constants --------------------------------------------------------*/
105 
110 #define IS_USART_ALL_PERIPH(PERIPH) (((PERIPH) == USART1) || \
111  ((PERIPH) == USART2) || \
112  ((PERIPH) == USART3) || \
113  ((PERIPH) == UART4) || \
114  ((PERIPH) == UART5) || \
115  ((PERIPH) == USART6) || \
116  ((PERIPH) == UART7) || \
117  ((PERIPH) == UART8))
118 
119 #define IS_USART_1236_PERIPH(PERIPH) (((PERIPH) == USART1) || \
120  ((PERIPH) == USART2) || \
121  ((PERIPH) == USART3) || \
122  ((PERIPH) == USART6))
123 
128 #define USART_WordLength_8b ((uint16_t)0x0000)
129 #define USART_WordLength_9b ((uint16_t)0x1000)
130 
131 #define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WordLength_8b) || \
132  ((LENGTH) == USART_WordLength_9b))
133 
141 #define USART_StopBits_1 ((uint16_t)0x0000)
142 #define USART_StopBits_0_5 ((uint16_t)0x1000)
143 #define USART_StopBits_2 ((uint16_t)0x2000)
144 #define USART_StopBits_1_5 ((uint16_t)0x3000)
145 #define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_StopBits_1) || \
146  ((STOPBITS) == USART_StopBits_0_5) || \
147  ((STOPBITS) == USART_StopBits_2) || \
148  ((STOPBITS) == USART_StopBits_1_5))
149 
157 #define USART_Parity_No ((uint16_t)0x0000)
158 #define USART_Parity_Even ((uint16_t)0x0400)
159 #define USART_Parity_Odd ((uint16_t)0x0600)
160 #define IS_USART_PARITY(PARITY) (((PARITY) == USART_Parity_No) || \
161  ((PARITY) == USART_Parity_Even) || \
162  ((PARITY) == USART_Parity_Odd))
163 
171 #define USART_Mode_Rx ((uint16_t)0x0004)
172 #define USART_Mode_Tx ((uint16_t)0x0008)
173 #define IS_USART_MODE(MODE) ((((MODE) & (uint16_t)0xFFF3) == 0x00) && ((MODE) != (uint16_t)0x00))
174 
181 #define USART_HardwareFlowControl_None ((uint16_t)0x0000)
182 #define USART_HardwareFlowControl_RTS ((uint16_t)0x0100)
183 #define USART_HardwareFlowControl_CTS ((uint16_t)0x0200)
184 #define USART_HardwareFlowControl_RTS_CTS ((uint16_t)0x0300)
185 #define IS_USART_HARDWARE_FLOW_CONTROL(CONTROL)\
186  (((CONTROL) == USART_HardwareFlowControl_None) || \
187  ((CONTROL) == USART_HardwareFlowControl_RTS) || \
188  ((CONTROL) == USART_HardwareFlowControl_CTS) || \
189  ((CONTROL) == USART_HardwareFlowControl_RTS_CTS))
190 
197 #define USART_Clock_Disable ((uint16_t)0x0000)
198 #define USART_Clock_Enable ((uint16_t)0x0800)
199 #define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_Clock_Disable) || \
200  ((CLOCK) == USART_Clock_Enable))
201 
209 #define USART_CPOL_Low ((uint16_t)0x0000)
210 #define USART_CPOL_High ((uint16_t)0x0400)
211 #define IS_USART_CPOL(CPOL) (((CPOL) == USART_CPOL_Low) || ((CPOL) == USART_CPOL_High))
212 
221 #define USART_CPHA_1Edge ((uint16_t)0x0000)
222 #define USART_CPHA_2Edge ((uint16_t)0x0200)
223 #define IS_USART_CPHA(CPHA) (((CPHA) == USART_CPHA_1Edge) || ((CPHA) == USART_CPHA_2Edge))
224 
233 #define USART_LastBit_Disable ((uint16_t)0x0000)
234 #define USART_LastBit_Enable ((uint16_t)0x0100)
235 #define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LastBit_Disable) || \
236  ((LASTBIT) == USART_LastBit_Enable))
237 
245 #define USART_IT_PE ((uint16_t)0x0028)
246 #define USART_IT_TXE ((uint16_t)0x0727)
247 #define USART_IT_TC ((uint16_t)0x0626)
248 #define USART_IT_RXNE ((uint16_t)0x0525)
249 #define USART_IT_ORE_RX ((uint16_t)0x0325) /* In case interrupt is generated if the RXNEIE bit is set */
250 #define USART_IT_IDLE ((uint16_t)0x0424)
251 #define USART_IT_LBD ((uint16_t)0x0846)
252 #define USART_IT_CTS ((uint16_t)0x096A)
253 #define USART_IT_ERR ((uint16_t)0x0060)
254 #define USART_IT_ORE_ER ((uint16_t)0x0360) /* In case interrupt is generated if the EIE bit is set */
255 #define USART_IT_NE ((uint16_t)0x0260)
256 #define USART_IT_FE ((uint16_t)0x0160)
257 
261 #define USART_IT_ORE USART_IT_ORE_ER
262 
266 #define IS_USART_CONFIG_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \
267  ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
268  ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \
269  ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ERR))
270 #define IS_USART_GET_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \
271  ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
272  ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \
273  ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ORE) || \
274  ((IT) == USART_IT_ORE_RX) || ((IT) == USART_IT_ORE_ER) || \
275  ((IT) == USART_IT_NE) || ((IT) == USART_IT_FE))
276 #define IS_USART_CLEAR_IT(IT) (((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
277  ((IT) == USART_IT_LBD) || ((IT) == USART_IT_CTS))
278 
286 #define USART_DMAReq_Tx ((uint16_t)0x0080)
287 #define USART_DMAReq_Rx ((uint16_t)0x0040)
288 #define IS_USART_DMAREQ(DMAREQ) ((((DMAREQ) & (uint16_t)0xFF3F) == 0x00) && ((DMAREQ) != (uint16_t)0x00))
289 
298 #define USART_WakeUp_IdleLine ((uint16_t)0x0000)
299 #define USART_WakeUp_AddressMark ((uint16_t)0x0800)
300 #define IS_USART_WAKEUP(WAKEUP) (((WAKEUP) == USART_WakeUp_IdleLine) || \
301  ((WAKEUP) == USART_WakeUp_AddressMark))
302 
310 #define USART_LINBreakDetectLength_10b ((uint16_t)0x0000)
311 #define USART_LINBreakDetectLength_11b ((uint16_t)0x0020)
312 #define IS_USART_LIN_BREAK_DETECT_LENGTH(LENGTH) \
313  (((LENGTH) == USART_LINBreakDetectLength_10b) || \
314  ((LENGTH) == USART_LINBreakDetectLength_11b))
315 
323 #define USART_IrDAMode_LowPower ((uint16_t)0x0004)
324 #define USART_IrDAMode_Normal ((uint16_t)0x0000)
325 #define IS_USART_IRDA_MODE(MODE) (((MODE) == USART_IrDAMode_LowPower) || \
326  ((MODE) == USART_IrDAMode_Normal))
327 
335 #define USART_FLAG_CTS ((uint16_t)0x0200)
336 #define USART_FLAG_LBD ((uint16_t)0x0100)
337 #define USART_FLAG_TXE ((uint16_t)0x0080)
338 #define USART_FLAG_TC ((uint16_t)0x0040)
339 #define USART_FLAG_RXNE ((uint16_t)0x0020)
340 #define USART_FLAG_IDLE ((uint16_t)0x0010)
341 #define USART_FLAG_ORE ((uint16_t)0x0008)
342 #define USART_FLAG_NE ((uint16_t)0x0004)
343 #define USART_FLAG_FE ((uint16_t)0x0002)
344 #define USART_FLAG_PE ((uint16_t)0x0001)
345 #define IS_USART_FLAG(FLAG) (((FLAG) == USART_FLAG_PE) || ((FLAG) == USART_FLAG_TXE) || \
346  ((FLAG) == USART_FLAG_TC) || ((FLAG) == USART_FLAG_RXNE) || \
347  ((FLAG) == USART_FLAG_IDLE) || ((FLAG) == USART_FLAG_LBD) || \
348  ((FLAG) == USART_FLAG_CTS) || ((FLAG) == USART_FLAG_ORE) || \
349  ((FLAG) == USART_FLAG_NE) || ((FLAG) == USART_FLAG_FE))
350 
351 #define IS_USART_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFC9F) == 0x00) && ((FLAG) != (uint16_t)0x00))
352 
353 #define IS_USART_BAUDRATE(BAUDRATE) (((BAUDRATE) > 0) && ((BAUDRATE) < 7500001))
354 #define IS_USART_ADDRESS(ADDRESS) ((ADDRESS) <= 0xF)
355 #define IS_USART_DATA(DATA) ((DATA) <= 0x1FF)
356 
365 /* Exported macro ------------------------------------------------------------*/
366 /* Exported functions --------------------------------------------------------*/
367 
368 /* Function used to set the USART configuration to the default reset state ***/
369 void USART_DeInit(USART_TypeDef* USARTx);
370 
371 /* Initialization and Configuration functions *********************************/
372 void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct);
373 void USART_StructInit(USART_InitTypeDef* USART_InitStruct);
374 void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct);
375 void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct);
376 void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState);
377 void USART_SetPrescaler(USART_TypeDef* USARTx, uint8_t USART_Prescaler);
379 void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState);
380 
381 /* Data transfers functions ***************************************************/
382 void USART_SendData(USART_TypeDef* USARTx, uint16_t Data);
383 uint16_t USART_ReceiveData(USART_TypeDef* USARTx);
384 
385 /* Multi-Processor Communication functions ************************************/
386 void USART_SetAddress(USART_TypeDef* USARTx, uint8_t USART_Address);
387 void USART_WakeUpConfig(USART_TypeDef* USARTx, uint16_t USART_WakeUp);
389 
390 /* LIN mode functions *********************************************************/
391 void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, uint16_t USART_LINBreakDetectLength);
392 void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState);
393 void USART_SendBreak(USART_TypeDef* USARTx);
394 
395 /* Half-duplex mode function **************************************************/
396 void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState);
397 
398 /* Smartcard mode functions ***************************************************/
399 void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState);
401 void USART_SetGuardTime(USART_TypeDef* USARTx, uint8_t USART_GuardTime);
402 
403 /* IrDA mode functions ********************************************************/
404 void USART_IrDAConfig(USART_TypeDef* USARTx, uint16_t USART_IrDAMode);
405 void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState);
406 
407 /* DMA transfers management functions *****************************************/
408 void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState);
409 
410 /* Interrupts and flags management functions **********************************/
411 void USART_ITConfig(USART_TypeDef* USARTx, uint16_t USART_IT, FunctionalState NewState);
412 FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG);
413 void USART_ClearFlag(USART_TypeDef* USARTx, uint16_t USART_FLAG);
414 ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint16_t USART_IT);
415 void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint16_t USART_IT);
416 
417 #ifdef __cplusplus
418 }
419 #endif
420 
421 #endif /* __STM32F4xx_USART_H */
422 
431 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
FlagStatus
Definition: stm32f4xx.h:706
void USART_ClearFlag(USART_TypeDef *USARTx, uint16_t USART_FLAG)
Clears the USARTx&#39;s pending flags.
FunctionalState
Definition: stm32f4xx.h:708
void USART_WakeUpConfig(USART_TypeDef *USARTx, uint16_t USART_WakeUp)
Selects the USART WakeUp method.
uint16_t USART_HardwareFlowControl
Universal Synchronous Asynchronous Receiver Transmitter.
Definition: stm32f4xx.h:1710
void USART_DeInit(USART_TypeDef *USARTx)
Deinitializes the USARTx peripheral registers to their default reset values.
CMSIS Cortex-M4 Device Peripheral Access Layer Header File. This file contains all the peripheral reg...
FlagStatus USART_GetFlagStatus(USART_TypeDef *USARTx, uint16_t USART_FLAG)
Checks whether the specified USART flag is set or not.
void USART_SendBreak(USART_TypeDef *USARTx)
Transmits break characters.
void USART_ITConfig(USART_TypeDef *USARTx, uint16_t USART_IT, FunctionalState NewState)
Enables or disables the specified USART interrupts.
void USART_OverSampling8Cmd(USART_TypeDef *USARTx, FunctionalState NewState)
Enables or disables the USART&#39;s 8x oversampling mode.
enum FlagStatus ITStatus
void USART_IrDAConfig(USART_TypeDef *USARTx, uint16_t USART_IrDAMode)
Configures the USART&#39;s IrDA interface.
uint16_t USART_ReceiveData(USART_TypeDef *USARTx)
Returns the most recent received data by the USARTx peripheral.
void USART_DMACmd(USART_TypeDef *USARTx, uint16_t USART_DMAReq, FunctionalState NewState)
Enables or disables the USART&#39;s DMA interface.
void USART_OneBitMethodCmd(USART_TypeDef *USARTx, FunctionalState NewState)
Enables or disables the USART&#39;s one bit sampling method.
USART Clock Init Structure definition.
void USART_ReceiverWakeUpCmd(USART_TypeDef *USARTx, FunctionalState NewState)
Determines if the USART is in mute mode or not.
void USART_ClearITPendingBit(USART_TypeDef *USARTx, uint16_t USART_IT)
Clears the USARTx&#39;s interrupt pending bits.
void USART_SetPrescaler(USART_TypeDef *USARTx, uint8_t USART_Prescaler)
Sets the system clock prescaler.
void USART_StructInit(USART_InitTypeDef *USART_InitStruct)
Fills each USART_InitStruct member with its default value.
uint16_t USART_WordLength
void USART_HalfDuplexCmd(USART_TypeDef *USARTx, FunctionalState NewState)
Enables or disables the USART&#39;s Half Duplex communication.
void USART_Init(USART_TypeDef *USARTx, USART_InitTypeDef *USART_InitStruct)
Initializes the USARTx peripheral according to the specified parameters in the USART_InitStruct ...
void USART_LINCmd(USART_TypeDef *USARTx, FunctionalState NewState)
Enables or disables the USART&#39;s LIN mode.
void USART_Cmd(USART_TypeDef *USARTx, FunctionalState NewState)
Enables or disables the specified USART peripheral.
void USART_SmartCardNACKCmd(USART_TypeDef *USARTx, FunctionalState NewState)
Enables or disables NACK transmission.
void USART_LINBreakDetectLengthConfig(USART_TypeDef *USARTx, uint16_t USART_LINBreakDetectLength)
Sets the USART LIN Break detection length.
ITStatus USART_GetITStatus(USART_TypeDef *USARTx, uint16_t USART_IT)
Checks whether the specified USART interrupt has occurred or not.
void USART_ClockInit(USART_TypeDef *USARTx, USART_ClockInitTypeDef *USART_ClockInitStruct)
Initializes the USARTx peripheral Clock according to the specified parameters in the USART_ClockInitS...
USART Init Structure definition.
void USART_SetAddress(USART_TypeDef *USARTx, uint8_t USART_Address)
Sets the address of the USART node.
void USART_IrDACmd(USART_TypeDef *USARTx, FunctionalState NewState)
Enables or disables the USART&#39;s IrDA interface.
void USART_ClockStructInit(USART_ClockInitTypeDef *USART_ClockInitStruct)
Fills each USART_ClockInitStruct member with its default value.
void USART_SmartCardCmd(USART_TypeDef *USARTx, FunctionalState NewState)
Enables or disables the USART&#39;s Smart Card mode.
void USART_SetGuardTime(USART_TypeDef *USARTx, uint8_t USART_GuardTime)
Sets the specified USART guard time.
void USART_SendData(USART_TypeDef *USARTx, uint16_t Data)
Transmits single data through the USARTx peripheral.


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:26