2 ******************************************************************************
\r
3 * @file stm32f7xx_hal_usart_ex.h
\r
4 * @author MCD Application Team
\r
6 * @date 24-March-2015
\r
7 * @brief Header file of USART HAL Extension module.
\r
8 ******************************************************************************
\r
11 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
\r
13 * Redistribution and use in source and binary forms, with or without modification,
\r
14 * are permitted provided that the following conditions are met:
\r
15 * 1. Redistributions of source code must retain the above copyright notice,
\r
16 * this list of conditions and the following disclaimer.
\r
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
18 * this list of conditions and the following disclaimer in the documentation
\r
19 * and/or other materials provided with the distribution.
\r
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
\r
21 * may be used to endorse or promote products derived from this software
\r
22 * without specific prior written permission.
\r
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
\r
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
\r
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
\r
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
\r
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
35 ******************************************************************************
\r
38 /* Define to prevent recursive inclusion -------------------------------------*/
\r
39 #ifndef __STM32F7xx_HAL_USART_EX_H
\r
40 #define __STM32F7xx_HAL_USART_EX_H
\r
46 /* Includes ------------------------------------------------------------------*/
\r
47 #include "stm32f7xx_hal_def.h"
\r
49 /** @addtogroup STM32F7xx_HAL_Driver
\r
53 /** @addtogroup USARTEx
\r
57 /* Exported types ------------------------------------------------------------*/
\r
58 /* Exported constants --------------------------------------------------------*/
\r
59 /** @defgroup USARTEx_Exported_Constants USARTEx Exported Constants
\r
63 /** @defgroup USARTEx_Word_Length USARTEx Word Length
\r
66 #define USART_WORDLENGTH_7B ((uint32_t)USART_CR1_M_1)
\r
67 #define USART_WORDLENGTH_8B ((uint32_t)0x00000000)
\r
68 #define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M_0)
\r
77 /* Exported functions --------------------------------------------------------*/
\r
79 /* Private macros ------------------------------------------------------------*/
\r
80 /** @defgroup USARTEx_Private_Macros USARTEx Private Macros
\r
84 /** @brief Computes the USART mask to apply to retrieve the received data
\r
85 * according to the word length and to the parity bits activation.
\r
86 * If PCE = 1, the parity bit is not included in the data extracted
\r
87 * by the reception API().
\r
88 * This masking operation is not carried out in the case of
\r
90 * @param __HANDLE__: specifies the USART Handle
\r
93 #define __HAL_USART_MASK_COMPUTATION(__HANDLE__) \
\r
95 if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_9B) \
\r
97 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
\r
99 (__HANDLE__)->Mask = 0x01FF ; \
\r
103 (__HANDLE__)->Mask = 0x00FF ; \
\r
106 else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_8B) \
\r
108 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
\r
110 (__HANDLE__)->Mask = 0x00FF ; \
\r
114 (__HANDLE__)->Mask = 0x007F ; \
\r
117 else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_7B) \
\r
119 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
\r
121 (__HANDLE__)->Mask = 0x007F ; \
\r
125 (__HANDLE__)->Mask = 0x003F ; \
\r
130 #define IS_USART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == USART_WORDLENGTH_7B) || \
\r
131 ((__LENGTH__) == USART_WORDLENGTH_8B) || \
\r
132 ((__LENGTH__) == USART_WORDLENGTH_9B))
\r
137 /* Exported functions --------------------------------------------------------*/
\r
138 /* Initialization/de-initialization methods **********************************/
\r
139 /* IO operation methods *******************************************************/
\r
140 /* Peripheral Control methods ************************************************/
\r
141 /* Peripheral State methods **************************************************/
\r
156 #endif /* __STM32F7xx_HAL_USART_EX_H */
\r
158 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r