L4 HAL Drivers
Embed:
(wiki syntax)
Show/hide line numbers
stm32l4xx_hal_usart_ex.h
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal_usart_ex.h 00004 * @author MCD Application Team 00005 * @version V1.1.0 00006 * @date 16-September-2015 00007 * @brief Header file of USART HAL Extended module. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 /* Define to prevent recursive inclusion -------------------------------------*/ 00039 #ifndef __STM32L4xx_HAL_USART_EX_H 00040 #define __STM32L4xx_HAL_USART_EX_H 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 /* Includes ------------------------------------------------------------------*/ 00047 #include "stm32l4xx_hal_def.h" 00048 00049 /** @addtogroup STM32L4xx_HAL_Driver 00050 * @{ 00051 */ 00052 00053 /** @addtogroup USARTEx 00054 * @{ 00055 */ 00056 00057 /* Exported types ------------------------------------------------------------*/ 00058 /* Exported constants --------------------------------------------------------*/ 00059 /** @defgroup USARTEx_Exported_Constants USARTEx Exported Constants 00060 * @{ 00061 */ 00062 00063 /** @defgroup USARTEx_Word_Length USARTEx Word Length 00064 * @{ 00065 */ 00066 #define USART_WORDLENGTH_7B ((uint32_t)USART_CR1_M1) /*!< 7-bit long USART frame */ 00067 #define USART_WORDLENGTH_8B ((uint32_t)0x00000000) /*!< 8-bit long USART frame */ 00068 #define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M0) /*!< 9-bit long USART frame */ 00069 /** 00070 * @} 00071 */ 00072 00073 /** 00074 * @} 00075 */ 00076 00077 /* Exported functions --------------------------------------------------------*/ 00078 00079 /* Private macros ------------------------------------------------------------*/ 00080 /** @defgroup USARTEx_Private_Macros USARTEx Private Macros 00081 * @{ 00082 */ 00083 00084 /** @brief Compute the USART mask to apply to retrieve the received data 00085 * according to the word length and to the parity bits activation. 00086 * @note If PCE = 1, the parity bit is not included in the data extracted 00087 * by the reception API(). 00088 * This masking operation is not carried out in the case of 00089 * DMA transfers. 00090 * @param __HANDLE__: specifies the USART Handle. 00091 * @retval None, the mask to apply to USART RDR register is stored in (__HANDLE__)->Mask field. 00092 */ 00093 #define USART_MASK_COMPUTATION(__HANDLE__) \ 00094 do { \ 00095 if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_9B) \ 00096 { \ 00097 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \ 00098 { \ 00099 (__HANDLE__)->Mask = 0x01FF ; \ 00100 } \ 00101 else \ 00102 { \ 00103 (__HANDLE__)->Mask = 0x00FF ; \ 00104 } \ 00105 } \ 00106 else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_8B) \ 00107 { \ 00108 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \ 00109 { \ 00110 (__HANDLE__)->Mask = 0x00FF ; \ 00111 } \ 00112 else \ 00113 { \ 00114 (__HANDLE__)->Mask = 0x007F ; \ 00115 } \ 00116 } \ 00117 else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_7B) \ 00118 { \ 00119 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \ 00120 { \ 00121 (__HANDLE__)->Mask = 0x007F ; \ 00122 } \ 00123 else \ 00124 { \ 00125 (__HANDLE__)->Mask = 0x003F ; \ 00126 } \ 00127 } \ 00128 } while(0) 00129 00130 /** 00131 * @brief Ensure that USART frame length is valid. 00132 * @param __LENGTH__: USART frame length. 00133 * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid) 00134 */ 00135 #define IS_USART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == USART_WORDLENGTH_7B) || \ 00136 ((__LENGTH__) == USART_WORDLENGTH_8B) || \ 00137 ((__LENGTH__) == USART_WORDLENGTH_9B)) 00138 00139 /** 00140 * @} 00141 */ 00142 00143 /* Exported functions --------------------------------------------------------*/ 00144 00145 /** 00146 * @} 00147 */ 00148 00149 /** 00150 * @} 00151 */ 00152 00153 #ifdef __cplusplus 00154 } 00155 #endif 00156 00157 #endif /* __STM32L4xx_HAL_USART_EX_H */ 00158 00159 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00160
Generated on Tue Jul 12 2022 10:58:11 by 1.7.2