The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_NUCLEO_F030R8/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_usart_ex.h@143:86740a56073b, 2017-05-26 (annotated)
- Committer:
- AnnaBridge
- Date:
- Fri May 26 12:30:20 2017 +0100
- Revision:
- 143:86740a56073b
- Parent:
- 134:ad3be0349dc5
Release 143 of the mbed library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 85:024bf7f99721 | 1 | /** |
bogdanm | 85:024bf7f99721 | 2 | ****************************************************************************** |
bogdanm | 85:024bf7f99721 | 3 | * @file stm32f0xx_hal_usart_ex.h |
bogdanm | 85:024bf7f99721 | 4 | * @author MCD Application Team |
<> | 134:ad3be0349dc5 | 5 | * @version V1.5.0 |
<> | 134:ad3be0349dc5 | 6 | * @date 04-November-2016 |
<> | 134:ad3be0349dc5 | 7 | * @brief Header file of USART HAL Extended module. |
bogdanm | 85:024bf7f99721 | 8 | ****************************************************************************** |
bogdanm | 85:024bf7f99721 | 9 | * @attention |
Kojto | 108:34e6b704fe68 | 10 | * |
Kojto | 122:f9eeca106725 | 11 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
bogdanm | 85:024bf7f99721 | 12 | * |
bogdanm | 85:024bf7f99721 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 85:024bf7f99721 | 14 | * are permitted provided that the following conditions are met: |
bogdanm | 85:024bf7f99721 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
bogdanm | 85:024bf7f99721 | 16 | * this list of conditions and the following disclaimer. |
bogdanm | 85:024bf7f99721 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bogdanm | 85:024bf7f99721 | 18 | * this list of conditions and the following disclaimer in the documentation |
bogdanm | 85:024bf7f99721 | 19 | * and/or other materials provided with the distribution. |
bogdanm | 85:024bf7f99721 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bogdanm | 85:024bf7f99721 | 21 | * may be used to endorse or promote products derived from this software |
bogdanm | 85:024bf7f99721 | 22 | * without specific prior written permission. |
bogdanm | 85:024bf7f99721 | 23 | * |
bogdanm | 85:024bf7f99721 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bogdanm | 85:024bf7f99721 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bogdanm | 85:024bf7f99721 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 85:024bf7f99721 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bogdanm | 85:024bf7f99721 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bogdanm | 85:024bf7f99721 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bogdanm | 85:024bf7f99721 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bogdanm | 85:024bf7f99721 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bogdanm | 85:024bf7f99721 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bogdanm | 85:024bf7f99721 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 85:024bf7f99721 | 34 | * |
Kojto | 108:34e6b704fe68 | 35 | ****************************************************************************** |
bogdanm | 85:024bf7f99721 | 36 | */ |
bogdanm | 85:024bf7f99721 | 37 | |
bogdanm | 85:024bf7f99721 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
bogdanm | 85:024bf7f99721 | 39 | #ifndef __STM32F0xx_HAL_USART_EX_H |
bogdanm | 85:024bf7f99721 | 40 | #define __STM32F0xx_HAL_USART_EX_H |
bogdanm | 85:024bf7f99721 | 41 | |
bogdanm | 85:024bf7f99721 | 42 | #ifdef __cplusplus |
bogdanm | 85:024bf7f99721 | 43 | extern "C" { |
bogdanm | 85:024bf7f99721 | 44 | #endif |
bogdanm | 85:024bf7f99721 | 45 | |
bogdanm | 85:024bf7f99721 | 46 | /* Includes ------------------------------------------------------------------*/ |
bogdanm | 85:024bf7f99721 | 47 | #include "stm32f0xx_hal_def.h" |
bogdanm | 85:024bf7f99721 | 48 | |
bogdanm | 85:024bf7f99721 | 49 | /** @addtogroup STM32F0xx_HAL_Driver |
bogdanm | 85:024bf7f99721 | 50 | * @{ |
bogdanm | 85:024bf7f99721 | 51 | */ |
bogdanm | 85:024bf7f99721 | 52 | |
<> | 134:ad3be0349dc5 | 53 | /** @addtogroup USARTEx |
bogdanm | 85:024bf7f99721 | 54 | * @{ |
<> | 134:ad3be0349dc5 | 55 | */ |
bogdanm | 85:024bf7f99721 | 56 | |
bogdanm | 85:024bf7f99721 | 57 | /* Exported types ------------------------------------------------------------*/ |
bogdanm | 85:024bf7f99721 | 58 | /* Exported constants --------------------------------------------------------*/ |
bogdanm | 92:4fc01daae5a5 | 59 | /** @defgroup USARTEx_Exported_Constants USARTEx Exported Constants |
bogdanm | 85:024bf7f99721 | 60 | * @{ |
bogdanm | 85:024bf7f99721 | 61 | */ |
Kojto | 108:34e6b704fe68 | 62 | |
bogdanm | 92:4fc01daae5a5 | 63 | /** @defgroup USARTEx_Word_Length USARTEx Word Length |
bogdanm | 85:024bf7f99721 | 64 | * @{ |
bogdanm | 85:024bf7f99721 | 65 | */ |
Kojto | 93:e188a91d3eaa | 66 | #if defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \ |
Kojto | 93:e188a91d3eaa | 67 | defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \ |
Kojto | 93:e188a91d3eaa | 68 | defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) |
Kojto | 108:34e6b704fe68 | 69 | #define USART_WORDLENGTH_7B ((uint32_t)USART_CR1_M1) /*!< 7-bit long USART frame */ |
<> | 134:ad3be0349dc5 | 70 | #define USART_WORDLENGTH_8B (0x00000000U) /*!< 8-bit long USART frame */ |
Kojto | 108:34e6b704fe68 | 71 | #define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M0) /*!< 9-bit long USART frame */ |
bogdanm | 85:024bf7f99721 | 72 | #else |
<> | 134:ad3be0349dc5 | 73 | #define USART_WORDLENGTH_8B (0x00000000U) /*!< 8-bit long USART frame */ |
Kojto | 108:34e6b704fe68 | 74 | #define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M) /*!< 9-bit long USART frame */ |
Kojto | 93:e188a91d3eaa | 75 | #endif /* defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || defined (STM32F070xB) || \ |
bogdanm | 92:4fc01daae5a5 | 76 | defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \ |
Kojto | 93:e188a91d3eaa | 77 | defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) */ |
bogdanm | 85:024bf7f99721 | 78 | /** |
bogdanm | 85:024bf7f99721 | 79 | * @} |
bogdanm | 85:024bf7f99721 | 80 | */ |
Kojto | 108:34e6b704fe68 | 81 | |
Kojto | 108:34e6b704fe68 | 82 | /** @defgroup USART_Request_Parameters USARTEx Request Parameters |
Kojto | 108:34e6b704fe68 | 83 | * @{ |
Kojto | 108:34e6b704fe68 | 84 | */ |
<> | 134:ad3be0349dc5 | 85 | #define USART_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */ |
Kojto | 108:34e6b704fe68 | 86 | #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) |
Kojto | 108:34e6b704fe68 | 87 | #define USART_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */ |
Kojto | 108:34e6b704fe68 | 88 | #else |
Kojto | 108:34e6b704fe68 | 89 | #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */ |
Kojto | 108:34e6b704fe68 | 90 | /** |
Kojto | 108:34e6b704fe68 | 91 | * @} |
Kojto | 108:34e6b704fe68 | 92 | */ |
Kojto | 108:34e6b704fe68 | 93 | |
Kojto | 108:34e6b704fe68 | 94 | /** @defgroup USART_Flags USART Flags |
Kojto | 108:34e6b704fe68 | 95 | * Elements values convention: 0xXXXX |
Kojto | 108:34e6b704fe68 | 96 | * - 0xXXXX : Flag mask in the ISR register |
Kojto | 108:34e6b704fe68 | 97 | * @{ |
Kojto | 108:34e6b704fe68 | 98 | */ |
Kojto | 108:34e6b704fe68 | 99 | #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) |
<> | 134:ad3be0349dc5 | 100 | #define USART_FLAG_REACK (0x00400000U) /*!< USART receive enable acknowledge flag */ |
<> | 134:ad3be0349dc5 | 101 | #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */ |
<> | 134:ad3be0349dc5 | 102 | #define USART_FLAG_TEACK (0x00200000U) /*!< USART transmit enable acknowledge flag */ |
<> | 134:ad3be0349dc5 | 103 | #define USART_FLAG_BUSY (0x00010000U) /*!< USART busy flag */ |
<> | 134:ad3be0349dc5 | 104 | #define USART_FLAG_CTS (0x00000400U) /*!< USART clear to send flag */ |
<> | 134:ad3be0349dc5 | 105 | #define USART_FLAG_CTSIF (0x00000200U) /*!< USART clear to send interrupt flag */ |
<> | 134:ad3be0349dc5 | 106 | #define USART_FLAG_TXE (0x00000080U) /*!< USART transmit data register empty */ |
<> | 134:ad3be0349dc5 | 107 | #define USART_FLAG_TC (0x00000040U) /*!< USART transmission complete */ |
<> | 134:ad3be0349dc5 | 108 | #define USART_FLAG_RXNE (0x00000020U) /*!< USART read data register not empty */ |
<> | 134:ad3be0349dc5 | 109 | #define USART_FLAG_IDLE (0x00000010U) /*!< USART idle flag */ |
<> | 134:ad3be0349dc5 | 110 | #define USART_FLAG_ORE (0x00000008U) /*!< USART overrun error */ |
<> | 134:ad3be0349dc5 | 111 | #define USART_FLAG_NE (0x00000004U) /*!< USART noise error */ |
<> | 134:ad3be0349dc5 | 112 | #define USART_FLAG_FE (0x00000002U) /*!< USART frame error */ |
<> | 134:ad3be0349dc5 | 113 | #define USART_FLAG_PE (0x00000001U) /*!< USART parity error */ |
bogdanm | 85:024bf7f99721 | 114 | /** |
bogdanm | 85:024bf7f99721 | 115 | * @} |
Kojto | 108:34e6b704fe68 | 116 | */ |
Kojto | 108:34e6b704fe68 | 117 | |
Kojto | 108:34e6b704fe68 | 118 | /** |
Kojto | 108:34e6b704fe68 | 119 | * @} |
Kojto | 108:34e6b704fe68 | 120 | */ |
Kojto | 108:34e6b704fe68 | 121 | |
Kojto | 108:34e6b704fe68 | 122 | /* Exported macros ------------------------------------------------------------*/ |
Kojto | 108:34e6b704fe68 | 123 | /** @defgroup USARTEx_Exported_Macros USARTEx Exported Macros |
Kojto | 108:34e6b704fe68 | 124 | * @{ |
Kojto | 108:34e6b704fe68 | 125 | */ |
bogdanm | 85:024bf7f99721 | 126 | |
Kojto | 108:34e6b704fe68 | 127 | /** @brief Flush the USART Data registers. |
Kojto | 108:34e6b704fe68 | 128 | * @param __HANDLE__: specifies the USART Handle. |
Kojto | 108:34e6b704fe68 | 129 | * @retval None |
Kojto | 108:34e6b704fe68 | 130 | */ |
Kojto | 108:34e6b704fe68 | 131 | #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) |
Kojto | 108:34e6b704fe68 | 132 | #define __HAL_USART_FLUSH_DRREGISTER(__HANDLE__) \ |
Kojto | 108:34e6b704fe68 | 133 | do{ \ |
Kojto | 108:34e6b704fe68 | 134 | SET_BIT((__HANDLE__)->Instance->RQR, USART_RXDATA_FLUSH_REQUEST); \ |
Kojto | 108:34e6b704fe68 | 135 | SET_BIT((__HANDLE__)->Instance->RQR, USART_TXDATA_FLUSH_REQUEST); \ |
Kojto | 108:34e6b704fe68 | 136 | } while(0) |
Kojto | 108:34e6b704fe68 | 137 | #else |
Kojto | 108:34e6b704fe68 | 138 | #define __HAL_USART_FLUSH_DRREGISTER(__HANDLE__) \ |
Kojto | 108:34e6b704fe68 | 139 | do{ \ |
Kojto | 108:34e6b704fe68 | 140 | SET_BIT((__HANDLE__)->Instance->RQR, USART_RXDATA_FLUSH_REQUEST); \ |
Kojto | 108:34e6b704fe68 | 141 | } while(0) |
Kojto | 108:34e6b704fe68 | 142 | #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */ |
Kojto | 108:34e6b704fe68 | 143 | |
Kojto | 108:34e6b704fe68 | 144 | /** |
Kojto | 108:34e6b704fe68 | 145 | * @} |
Kojto | 108:34e6b704fe68 | 146 | */ |
Kojto | 108:34e6b704fe68 | 147 | |
Kojto | 108:34e6b704fe68 | 148 | /* Private macros ------------------------------------------------------------*/ |
Kojto | 108:34e6b704fe68 | 149 | /** @defgroup USARTEx_Private_Macros USARTEx Private Macros |
bogdanm | 85:024bf7f99721 | 150 | * @{ |
bogdanm | 85:024bf7f99721 | 151 | */ |
bogdanm | 85:024bf7f99721 | 152 | |
<> | 134:ad3be0349dc5 | 153 | /** @brief Report the USART clock source. |
<> | 134:ad3be0349dc5 | 154 | * @param __HANDLE__: specifies the USART Handle. |
<> | 134:ad3be0349dc5 | 155 | * @param __CLOCKSOURCE__: output variable. |
bogdanm | 85:024bf7f99721 | 156 | * @retval the USART clocking source, written in __CLOCKSOURCE__. |
bogdanm | 85:024bf7f99721 | 157 | */ |
bogdanm | 85:024bf7f99721 | 158 | #if defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F038xx) |
Kojto | 108:34e6b704fe68 | 159 | #define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ |
bogdanm | 85:024bf7f99721 | 160 | do { \ |
bogdanm | 85:024bf7f99721 | 161 | switch(__HAL_RCC_GET_USART1_SOURCE()) \ |
bogdanm | 85:024bf7f99721 | 162 | { \ |
bogdanm | 85:024bf7f99721 | 163 | case RCC_USART1CLKSOURCE_PCLK1: \ |
bogdanm | 85:024bf7f99721 | 164 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 85:024bf7f99721 | 165 | break; \ |
bogdanm | 85:024bf7f99721 | 166 | case RCC_USART1CLKSOURCE_HSI: \ |
bogdanm | 85:024bf7f99721 | 167 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \ |
bogdanm | 85:024bf7f99721 | 168 | break; \ |
bogdanm | 85:024bf7f99721 | 169 | case RCC_USART1CLKSOURCE_SYSCLK: \ |
bogdanm | 85:024bf7f99721 | 170 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \ |
bogdanm | 85:024bf7f99721 | 171 | break; \ |
bogdanm | 85:024bf7f99721 | 172 | case RCC_USART1CLKSOURCE_LSE: \ |
bogdanm | 85:024bf7f99721 | 173 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \ |
bogdanm | 85:024bf7f99721 | 174 | break; \ |
bogdanm | 85:024bf7f99721 | 175 | default: \ |
bogdanm | 85:024bf7f99721 | 176 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
bogdanm | 85:024bf7f99721 | 177 | break; \ |
bogdanm | 85:024bf7f99721 | 178 | } \ |
bogdanm | 85:024bf7f99721 | 179 | } while(0) |
Kojto | 93:e188a91d3eaa | 180 | #elif defined (STM32F030x8) || defined (STM32F070x6) || \ |
bogdanm | 85:024bf7f99721 | 181 | defined (STM32F042x6) || defined (STM32F048xx) || \ |
bogdanm | 85:024bf7f99721 | 182 | defined (STM32F051x8) || defined (STM32F058xx) |
Kojto | 108:34e6b704fe68 | 183 | #define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ |
bogdanm | 85:024bf7f99721 | 184 | do { \ |
bogdanm | 85:024bf7f99721 | 185 | if((__HANDLE__)->Instance == USART1) \ |
bogdanm | 85:024bf7f99721 | 186 | { \ |
bogdanm | 85:024bf7f99721 | 187 | switch(__HAL_RCC_GET_USART1_SOURCE()) \ |
bogdanm | 85:024bf7f99721 | 188 | { \ |
bogdanm | 85:024bf7f99721 | 189 | case RCC_USART1CLKSOURCE_PCLK1: \ |
bogdanm | 85:024bf7f99721 | 190 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 85:024bf7f99721 | 191 | break; \ |
bogdanm | 85:024bf7f99721 | 192 | case RCC_USART1CLKSOURCE_HSI: \ |
bogdanm | 85:024bf7f99721 | 193 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \ |
bogdanm | 85:024bf7f99721 | 194 | break; \ |
bogdanm | 85:024bf7f99721 | 195 | case RCC_USART1CLKSOURCE_SYSCLK: \ |
bogdanm | 85:024bf7f99721 | 196 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \ |
bogdanm | 85:024bf7f99721 | 197 | break; \ |
bogdanm | 85:024bf7f99721 | 198 | case RCC_USART1CLKSOURCE_LSE: \ |
bogdanm | 85:024bf7f99721 | 199 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \ |
bogdanm | 85:024bf7f99721 | 200 | break; \ |
bogdanm | 85:024bf7f99721 | 201 | default: \ |
bogdanm | 85:024bf7f99721 | 202 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
bogdanm | 85:024bf7f99721 | 203 | break; \ |
bogdanm | 85:024bf7f99721 | 204 | } \ |
bogdanm | 85:024bf7f99721 | 205 | } \ |
bogdanm | 85:024bf7f99721 | 206 | else if((__HANDLE__)->Instance == USART2) \ |
bogdanm | 85:024bf7f99721 | 207 | { \ |
bogdanm | 85:024bf7f99721 | 208 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 85:024bf7f99721 | 209 | } \ |
bogdanm | 85:024bf7f99721 | 210 | else \ |
bogdanm | 85:024bf7f99721 | 211 | { \ |
bogdanm | 85:024bf7f99721 | 212 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
bogdanm | 85:024bf7f99721 | 213 | } \ |
Kojto | 108:34e6b704fe68 | 214 | } while(0) |
Kojto | 93:e188a91d3eaa | 215 | #elif defined (STM32F070xB) |
Kojto | 108:34e6b704fe68 | 216 | #define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ |
Kojto | 93:e188a91d3eaa | 217 | do { \ |
Kojto | 93:e188a91d3eaa | 218 | if((__HANDLE__)->Instance == USART1) \ |
Kojto | 93:e188a91d3eaa | 219 | { \ |
Kojto | 93:e188a91d3eaa | 220 | switch(__HAL_RCC_GET_USART1_SOURCE()) \ |
Kojto | 93:e188a91d3eaa | 221 | { \ |
Kojto | 93:e188a91d3eaa | 222 | case RCC_USART1CLKSOURCE_PCLK1: \ |
Kojto | 93:e188a91d3eaa | 223 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
Kojto | 93:e188a91d3eaa | 224 | break; \ |
Kojto | 93:e188a91d3eaa | 225 | case RCC_USART1CLKSOURCE_HSI: \ |
Kojto | 93:e188a91d3eaa | 226 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \ |
Kojto | 93:e188a91d3eaa | 227 | break; \ |
Kojto | 93:e188a91d3eaa | 228 | case RCC_USART1CLKSOURCE_SYSCLK: \ |
Kojto | 93:e188a91d3eaa | 229 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \ |
Kojto | 93:e188a91d3eaa | 230 | break; \ |
Kojto | 93:e188a91d3eaa | 231 | case RCC_USART1CLKSOURCE_LSE: \ |
Kojto | 93:e188a91d3eaa | 232 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \ |
Kojto | 93:e188a91d3eaa | 233 | break; \ |
Kojto | 93:e188a91d3eaa | 234 | default: \ |
Kojto | 93:e188a91d3eaa | 235 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
Kojto | 93:e188a91d3eaa | 236 | break; \ |
Kojto | 93:e188a91d3eaa | 237 | } \ |
Kojto | 93:e188a91d3eaa | 238 | } \ |
Kojto | 93:e188a91d3eaa | 239 | else if((__HANDLE__)->Instance == USART2) \ |
Kojto | 93:e188a91d3eaa | 240 | { \ |
Kojto | 93:e188a91d3eaa | 241 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
Kojto | 93:e188a91d3eaa | 242 | } \ |
Kojto | 93:e188a91d3eaa | 243 | else if((__HANDLE__)->Instance == USART3) \ |
Kojto | 93:e188a91d3eaa | 244 | { \ |
Kojto | 93:e188a91d3eaa | 245 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
Kojto | 93:e188a91d3eaa | 246 | } \ |
Kojto | 93:e188a91d3eaa | 247 | else if((__HANDLE__)->Instance == USART4) \ |
Kojto | 93:e188a91d3eaa | 248 | { \ |
Kojto | 93:e188a91d3eaa | 249 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
Kojto | 93:e188a91d3eaa | 250 | } \ |
Kojto | 93:e188a91d3eaa | 251 | else \ |
Kojto | 93:e188a91d3eaa | 252 | { \ |
Kojto | 93:e188a91d3eaa | 253 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
Kojto | 93:e188a91d3eaa | 254 | } \ |
Kojto | 108:34e6b704fe68 | 255 | } while(0) |
bogdanm | 85:024bf7f99721 | 256 | #elif defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) |
Kojto | 108:34e6b704fe68 | 257 | #define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ |
bogdanm | 85:024bf7f99721 | 258 | do { \ |
bogdanm | 85:024bf7f99721 | 259 | if((__HANDLE__)->Instance == USART1) \ |
bogdanm | 85:024bf7f99721 | 260 | { \ |
bogdanm | 85:024bf7f99721 | 261 | switch(__HAL_RCC_GET_USART1_SOURCE()) \ |
bogdanm | 85:024bf7f99721 | 262 | { \ |
bogdanm | 85:024bf7f99721 | 263 | case RCC_USART1CLKSOURCE_PCLK1: \ |
bogdanm | 85:024bf7f99721 | 264 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 85:024bf7f99721 | 265 | break; \ |
bogdanm | 85:024bf7f99721 | 266 | case RCC_USART1CLKSOURCE_HSI: \ |
bogdanm | 85:024bf7f99721 | 267 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \ |
bogdanm | 85:024bf7f99721 | 268 | break; \ |
bogdanm | 85:024bf7f99721 | 269 | case RCC_USART1CLKSOURCE_SYSCLK: \ |
bogdanm | 85:024bf7f99721 | 270 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \ |
bogdanm | 85:024bf7f99721 | 271 | break; \ |
bogdanm | 85:024bf7f99721 | 272 | case RCC_USART1CLKSOURCE_LSE: \ |
bogdanm | 85:024bf7f99721 | 273 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \ |
bogdanm | 85:024bf7f99721 | 274 | break; \ |
bogdanm | 85:024bf7f99721 | 275 | default: \ |
bogdanm | 85:024bf7f99721 | 276 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
bogdanm | 85:024bf7f99721 | 277 | break; \ |
bogdanm | 85:024bf7f99721 | 278 | } \ |
bogdanm | 85:024bf7f99721 | 279 | } \ |
bogdanm | 85:024bf7f99721 | 280 | else if((__HANDLE__)->Instance == USART2) \ |
bogdanm | 85:024bf7f99721 | 281 | { \ |
bogdanm | 85:024bf7f99721 | 282 | switch(__HAL_RCC_GET_USART2_SOURCE()) \ |
bogdanm | 85:024bf7f99721 | 283 | { \ |
bogdanm | 85:024bf7f99721 | 284 | case RCC_USART2CLKSOURCE_PCLK1: \ |
bogdanm | 85:024bf7f99721 | 285 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 85:024bf7f99721 | 286 | break; \ |
bogdanm | 85:024bf7f99721 | 287 | case RCC_USART2CLKSOURCE_HSI: \ |
bogdanm | 85:024bf7f99721 | 288 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \ |
bogdanm | 85:024bf7f99721 | 289 | break; \ |
bogdanm | 85:024bf7f99721 | 290 | case RCC_USART2CLKSOURCE_SYSCLK: \ |
bogdanm | 85:024bf7f99721 | 291 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \ |
bogdanm | 85:024bf7f99721 | 292 | break; \ |
bogdanm | 85:024bf7f99721 | 293 | case RCC_USART2CLKSOURCE_LSE: \ |
bogdanm | 85:024bf7f99721 | 294 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \ |
bogdanm | 85:024bf7f99721 | 295 | break; \ |
bogdanm | 85:024bf7f99721 | 296 | default: \ |
bogdanm | 85:024bf7f99721 | 297 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
bogdanm | 85:024bf7f99721 | 298 | break; \ |
bogdanm | 85:024bf7f99721 | 299 | } \ |
bogdanm | 85:024bf7f99721 | 300 | } \ |
bogdanm | 85:024bf7f99721 | 301 | else if((__HANDLE__)->Instance == USART3) \ |
bogdanm | 85:024bf7f99721 | 302 | { \ |
bogdanm | 85:024bf7f99721 | 303 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 85:024bf7f99721 | 304 | } \ |
bogdanm | 85:024bf7f99721 | 305 | else if((__HANDLE__)->Instance == USART4) \ |
bogdanm | 85:024bf7f99721 | 306 | { \ |
bogdanm | 85:024bf7f99721 | 307 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 85:024bf7f99721 | 308 | } \ |
bogdanm | 85:024bf7f99721 | 309 | else \ |
bogdanm | 85:024bf7f99721 | 310 | { \ |
bogdanm | 85:024bf7f99721 | 311 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
bogdanm | 85:024bf7f99721 | 312 | } \ |
Kojto | 108:34e6b704fe68 | 313 | } while(0) |
bogdanm | 92:4fc01daae5a5 | 314 | #elif defined(STM32F091xC) || defined (STM32F098xx) |
Kojto | 108:34e6b704fe68 | 315 | #define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ |
bogdanm | 92:4fc01daae5a5 | 316 | do { \ |
bogdanm | 92:4fc01daae5a5 | 317 | if((__HANDLE__)->Instance == USART1) \ |
bogdanm | 92:4fc01daae5a5 | 318 | { \ |
bogdanm | 92:4fc01daae5a5 | 319 | switch(__HAL_RCC_GET_USART1_SOURCE()) \ |
bogdanm | 92:4fc01daae5a5 | 320 | { \ |
bogdanm | 92:4fc01daae5a5 | 321 | case RCC_USART1CLKSOURCE_PCLK1: \ |
bogdanm | 92:4fc01daae5a5 | 322 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 92:4fc01daae5a5 | 323 | break; \ |
bogdanm | 92:4fc01daae5a5 | 324 | case RCC_USART1CLKSOURCE_HSI: \ |
bogdanm | 92:4fc01daae5a5 | 325 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \ |
bogdanm | 92:4fc01daae5a5 | 326 | break; \ |
bogdanm | 92:4fc01daae5a5 | 327 | case RCC_USART1CLKSOURCE_SYSCLK: \ |
bogdanm | 92:4fc01daae5a5 | 328 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \ |
bogdanm | 92:4fc01daae5a5 | 329 | break; \ |
bogdanm | 92:4fc01daae5a5 | 330 | case RCC_USART1CLKSOURCE_LSE: \ |
bogdanm | 92:4fc01daae5a5 | 331 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \ |
bogdanm | 92:4fc01daae5a5 | 332 | break; \ |
bogdanm | 92:4fc01daae5a5 | 333 | default: \ |
bogdanm | 92:4fc01daae5a5 | 334 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
bogdanm | 92:4fc01daae5a5 | 335 | break; \ |
bogdanm | 92:4fc01daae5a5 | 336 | } \ |
bogdanm | 92:4fc01daae5a5 | 337 | } \ |
bogdanm | 92:4fc01daae5a5 | 338 | else if((__HANDLE__)->Instance == USART2) \ |
bogdanm | 92:4fc01daae5a5 | 339 | { \ |
bogdanm | 92:4fc01daae5a5 | 340 | switch(__HAL_RCC_GET_USART2_SOURCE()) \ |
bogdanm | 92:4fc01daae5a5 | 341 | { \ |
bogdanm | 92:4fc01daae5a5 | 342 | case RCC_USART2CLKSOURCE_PCLK1: \ |
bogdanm | 92:4fc01daae5a5 | 343 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 92:4fc01daae5a5 | 344 | break; \ |
bogdanm | 92:4fc01daae5a5 | 345 | case RCC_USART2CLKSOURCE_HSI: \ |
bogdanm | 92:4fc01daae5a5 | 346 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \ |
bogdanm | 92:4fc01daae5a5 | 347 | break; \ |
bogdanm | 92:4fc01daae5a5 | 348 | case RCC_USART2CLKSOURCE_SYSCLK: \ |
bogdanm | 92:4fc01daae5a5 | 349 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \ |
bogdanm | 92:4fc01daae5a5 | 350 | break; \ |
bogdanm | 92:4fc01daae5a5 | 351 | case RCC_USART2CLKSOURCE_LSE: \ |
bogdanm | 92:4fc01daae5a5 | 352 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \ |
bogdanm | 92:4fc01daae5a5 | 353 | break; \ |
bogdanm | 92:4fc01daae5a5 | 354 | default: \ |
bogdanm | 92:4fc01daae5a5 | 355 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
bogdanm | 92:4fc01daae5a5 | 356 | break; \ |
bogdanm | 92:4fc01daae5a5 | 357 | } \ |
bogdanm | 92:4fc01daae5a5 | 358 | } \ |
bogdanm | 92:4fc01daae5a5 | 359 | else if((__HANDLE__)->Instance == USART3) \ |
bogdanm | 92:4fc01daae5a5 | 360 | { \ |
bogdanm | 92:4fc01daae5a5 | 361 | switch(__HAL_RCC_GET_USART3_SOURCE()) \ |
bogdanm | 92:4fc01daae5a5 | 362 | { \ |
bogdanm | 92:4fc01daae5a5 | 363 | case RCC_USART3CLKSOURCE_PCLK1: \ |
bogdanm | 92:4fc01daae5a5 | 364 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 92:4fc01daae5a5 | 365 | break; \ |
bogdanm | 92:4fc01daae5a5 | 366 | case RCC_USART3CLKSOURCE_HSI: \ |
bogdanm | 92:4fc01daae5a5 | 367 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \ |
bogdanm | 92:4fc01daae5a5 | 368 | break; \ |
bogdanm | 92:4fc01daae5a5 | 369 | case RCC_USART3CLKSOURCE_SYSCLK: \ |
bogdanm | 92:4fc01daae5a5 | 370 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \ |
bogdanm | 92:4fc01daae5a5 | 371 | break; \ |
bogdanm | 92:4fc01daae5a5 | 372 | case RCC_USART3CLKSOURCE_LSE: \ |
bogdanm | 92:4fc01daae5a5 | 373 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \ |
bogdanm | 92:4fc01daae5a5 | 374 | break; \ |
bogdanm | 92:4fc01daae5a5 | 375 | default: \ |
bogdanm | 92:4fc01daae5a5 | 376 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
bogdanm | 92:4fc01daae5a5 | 377 | break; \ |
bogdanm | 92:4fc01daae5a5 | 378 | } \ |
bogdanm | 92:4fc01daae5a5 | 379 | } \ |
bogdanm | 92:4fc01daae5a5 | 380 | else if((__HANDLE__)->Instance == USART4) \ |
bogdanm | 92:4fc01daae5a5 | 381 | { \ |
bogdanm | 92:4fc01daae5a5 | 382 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 92:4fc01daae5a5 | 383 | } \ |
bogdanm | 92:4fc01daae5a5 | 384 | else if((__HANDLE__)->Instance == USART5) \ |
bogdanm | 92:4fc01daae5a5 | 385 | { \ |
bogdanm | 92:4fc01daae5a5 | 386 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 92:4fc01daae5a5 | 387 | } \ |
bogdanm | 92:4fc01daae5a5 | 388 | else if((__HANDLE__)->Instance == USART6) \ |
bogdanm | 92:4fc01daae5a5 | 389 | { \ |
bogdanm | 92:4fc01daae5a5 | 390 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 92:4fc01daae5a5 | 391 | } \ |
bogdanm | 92:4fc01daae5a5 | 392 | else if((__HANDLE__)->Instance == USART7) \ |
bogdanm | 92:4fc01daae5a5 | 393 | { \ |
bogdanm | 92:4fc01daae5a5 | 394 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 92:4fc01daae5a5 | 395 | } \ |
bogdanm | 92:4fc01daae5a5 | 396 | else if((__HANDLE__)->Instance == USART8) \ |
bogdanm | 92:4fc01daae5a5 | 397 | { \ |
bogdanm | 92:4fc01daae5a5 | 398 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
bogdanm | 92:4fc01daae5a5 | 399 | } \ |
bogdanm | 92:4fc01daae5a5 | 400 | else \ |
bogdanm | 92:4fc01daae5a5 | 401 | { \ |
bogdanm | 92:4fc01daae5a5 | 402 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
bogdanm | 92:4fc01daae5a5 | 403 | } \ |
Kojto | 93:e188a91d3eaa | 404 | } while(0) |
Kojto | 93:e188a91d3eaa | 405 | #elif defined(STM32F030xC) |
Kojto | 108:34e6b704fe68 | 406 | #define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ |
Kojto | 93:e188a91d3eaa | 407 | do { \ |
Kojto | 93:e188a91d3eaa | 408 | if((__HANDLE__)->Instance == USART1) \ |
Kojto | 93:e188a91d3eaa | 409 | { \ |
Kojto | 93:e188a91d3eaa | 410 | switch(__HAL_RCC_GET_USART1_SOURCE()) \ |
Kojto | 93:e188a91d3eaa | 411 | { \ |
Kojto | 93:e188a91d3eaa | 412 | case RCC_USART1CLKSOURCE_PCLK1: \ |
Kojto | 93:e188a91d3eaa | 413 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
Kojto | 93:e188a91d3eaa | 414 | break; \ |
Kojto | 93:e188a91d3eaa | 415 | case RCC_USART1CLKSOURCE_HSI: \ |
Kojto | 93:e188a91d3eaa | 416 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \ |
Kojto | 93:e188a91d3eaa | 417 | break; \ |
Kojto | 93:e188a91d3eaa | 418 | case RCC_USART1CLKSOURCE_SYSCLK: \ |
Kojto | 93:e188a91d3eaa | 419 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \ |
Kojto | 93:e188a91d3eaa | 420 | break; \ |
Kojto | 93:e188a91d3eaa | 421 | case RCC_USART1CLKSOURCE_LSE: \ |
Kojto | 93:e188a91d3eaa | 422 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \ |
Kojto | 93:e188a91d3eaa | 423 | break; \ |
Kojto | 93:e188a91d3eaa | 424 | default: \ |
Kojto | 93:e188a91d3eaa | 425 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
Kojto | 93:e188a91d3eaa | 426 | break; \ |
Kojto | 93:e188a91d3eaa | 427 | } \ |
Kojto | 93:e188a91d3eaa | 428 | } \ |
Kojto | 93:e188a91d3eaa | 429 | else if((__HANDLE__)->Instance == USART2) \ |
Kojto | 93:e188a91d3eaa | 430 | { \ |
Kojto | 93:e188a91d3eaa | 431 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
Kojto | 93:e188a91d3eaa | 432 | } \ |
Kojto | 93:e188a91d3eaa | 433 | else if((__HANDLE__)->Instance == USART3) \ |
Kojto | 93:e188a91d3eaa | 434 | { \ |
Kojto | 93:e188a91d3eaa | 435 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
Kojto | 93:e188a91d3eaa | 436 | } \ |
Kojto | 93:e188a91d3eaa | 437 | else if((__HANDLE__)->Instance == USART4) \ |
Kojto | 93:e188a91d3eaa | 438 | { \ |
Kojto | 93:e188a91d3eaa | 439 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
Kojto | 93:e188a91d3eaa | 440 | } \ |
Kojto | 93:e188a91d3eaa | 441 | else if((__HANDLE__)->Instance == USART5) \ |
Kojto | 93:e188a91d3eaa | 442 | { \ |
Kojto | 93:e188a91d3eaa | 443 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
Kojto | 93:e188a91d3eaa | 444 | } \ |
Kojto | 93:e188a91d3eaa | 445 | else if((__HANDLE__)->Instance == USART6) \ |
Kojto | 93:e188a91d3eaa | 446 | { \ |
Kojto | 93:e188a91d3eaa | 447 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \ |
Kojto | 93:e188a91d3eaa | 448 | } \ |
Kojto | 93:e188a91d3eaa | 449 | else \ |
Kojto | 93:e188a91d3eaa | 450 | { \ |
Kojto | 93:e188a91d3eaa | 451 | (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ |
Kojto | 93:e188a91d3eaa | 452 | } \ |
Kojto | 108:34e6b704fe68 | 453 | } while(0) |
bogdanm | 85:024bf7f99721 | 454 | #endif /* defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F038xx) */ |
bogdanm | 85:024bf7f99721 | 455 | |
Kojto | 108:34e6b704fe68 | 456 | |
Kojto | 108:34e6b704fe68 | 457 | /** @brief Compute the USART mask to apply to retrieve the received data |
bogdanm | 85:024bf7f99721 | 458 | * according to the word length and to the parity bits activation. |
Kojto | 108:34e6b704fe68 | 459 | * @note If PCE = 1, the parity bit is not included in the data extracted |
bogdanm | 85:024bf7f99721 | 460 | * by the reception API(). |
bogdanm | 85:024bf7f99721 | 461 | * This masking operation is not carried out in the case of |
Kojto | 108:34e6b704fe68 | 462 | * DMA transfers. |
Kojto | 108:34e6b704fe68 | 463 | * @param __HANDLE__: specifies the USART Handle. |
Kojto | 108:34e6b704fe68 | 464 | * @retval None, the mask to apply to USART RDR register is stored in (__HANDLE__)->Mask field. |
Kojto | 108:34e6b704fe68 | 465 | */ |
Kojto | 93:e188a91d3eaa | 466 | #if defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \ |
Kojto | 93:e188a91d3eaa | 467 | defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \ |
Kojto | 93:e188a91d3eaa | 468 | defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) |
Kojto | 108:34e6b704fe68 | 469 | #define USART_MASK_COMPUTATION(__HANDLE__) \ |
bogdanm | 85:024bf7f99721 | 470 | do { \ |
bogdanm | 85:024bf7f99721 | 471 | if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_9B) \ |
bogdanm | 85:024bf7f99721 | 472 | { \ |
bogdanm | 85:024bf7f99721 | 473 | if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \ |
bogdanm | 85:024bf7f99721 | 474 | { \ |
<> | 134:ad3be0349dc5 | 475 | (__HANDLE__)->Mask = 0x01FFU; \ |
bogdanm | 85:024bf7f99721 | 476 | } \ |
bogdanm | 85:024bf7f99721 | 477 | else \ |
bogdanm | 85:024bf7f99721 | 478 | { \ |
<> | 134:ad3be0349dc5 | 479 | (__HANDLE__)->Mask = 0x00FFU; \ |
bogdanm | 85:024bf7f99721 | 480 | } \ |
bogdanm | 85:024bf7f99721 | 481 | } \ |
bogdanm | 85:024bf7f99721 | 482 | else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_8B) \ |
bogdanm | 85:024bf7f99721 | 483 | { \ |
bogdanm | 85:024bf7f99721 | 484 | if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \ |
bogdanm | 85:024bf7f99721 | 485 | { \ |
<> | 134:ad3be0349dc5 | 486 | (__HANDLE__)->Mask = 0x00FFU; \ |
bogdanm | 85:024bf7f99721 | 487 | } \ |
bogdanm | 85:024bf7f99721 | 488 | else \ |
bogdanm | 85:024bf7f99721 | 489 | { \ |
<> | 134:ad3be0349dc5 | 490 | (__HANDLE__)->Mask = 0x007FU; \ |
bogdanm | 85:024bf7f99721 | 491 | } \ |
bogdanm | 85:024bf7f99721 | 492 | } \ |
bogdanm | 85:024bf7f99721 | 493 | else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_7B) \ |
bogdanm | 85:024bf7f99721 | 494 | { \ |
bogdanm | 85:024bf7f99721 | 495 | if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \ |
bogdanm | 85:024bf7f99721 | 496 | { \ |
<> | 134:ad3be0349dc5 | 497 | (__HANDLE__)->Mask = 0x007FU; \ |
bogdanm | 85:024bf7f99721 | 498 | } \ |
bogdanm | 85:024bf7f99721 | 499 | else \ |
bogdanm | 85:024bf7f99721 | 500 | { \ |
<> | 134:ad3be0349dc5 | 501 | (__HANDLE__)->Mask = 0x003FU; \ |
bogdanm | 85:024bf7f99721 | 502 | } \ |
bogdanm | 85:024bf7f99721 | 503 | } \ |
Kojto | 108:34e6b704fe68 | 504 | } while(0) |
bogdanm | 85:024bf7f99721 | 505 | #else |
Kojto | 108:34e6b704fe68 | 506 | #define USART_MASK_COMPUTATION(__HANDLE__) \ |
bogdanm | 85:024bf7f99721 | 507 | do { \ |
bogdanm | 85:024bf7f99721 | 508 | if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_9B) \ |
bogdanm | 85:024bf7f99721 | 509 | { \ |
bogdanm | 85:024bf7f99721 | 510 | if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \ |
bogdanm | 85:024bf7f99721 | 511 | { \ |
<> | 134:ad3be0349dc5 | 512 | (__HANDLE__)->Mask = 0x01FFU; \ |
bogdanm | 85:024bf7f99721 | 513 | } \ |
bogdanm | 85:024bf7f99721 | 514 | else \ |
bogdanm | 85:024bf7f99721 | 515 | { \ |
<> | 134:ad3be0349dc5 | 516 | (__HANDLE__)->Mask = 0x00FFU; \ |
bogdanm | 85:024bf7f99721 | 517 | } \ |
bogdanm | 85:024bf7f99721 | 518 | } \ |
bogdanm | 85:024bf7f99721 | 519 | else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_8B) \ |
bogdanm | 85:024bf7f99721 | 520 | { \ |
bogdanm | 85:024bf7f99721 | 521 | if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \ |
bogdanm | 85:024bf7f99721 | 522 | { \ |
<> | 134:ad3be0349dc5 | 523 | (__HANDLE__)->Mask = 0x00FFU; \ |
bogdanm | 85:024bf7f99721 | 524 | } \ |
bogdanm | 85:024bf7f99721 | 525 | else \ |
bogdanm | 85:024bf7f99721 | 526 | { \ |
<> | 134:ad3be0349dc5 | 527 | (__HANDLE__)->Mask = 0x007FU; \ |
bogdanm | 85:024bf7f99721 | 528 | } \ |
bogdanm | 85:024bf7f99721 | 529 | } \ |
Kojto | 108:34e6b704fe68 | 530 | } while(0) |
Kojto | 93:e188a91d3eaa | 531 | #endif /* defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \ |
Kojto | 93:e188a91d3eaa | 532 | defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \ |
Kojto | 93:e188a91d3eaa | 533 | defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) */ |
Kojto | 108:34e6b704fe68 | 534 | |
Kojto | 108:34e6b704fe68 | 535 | |
Kojto | 108:34e6b704fe68 | 536 | /** |
Kojto | 108:34e6b704fe68 | 537 | * @brief Ensure that USART frame length is valid. |
Kojto | 108:34e6b704fe68 | 538 | * @param __LENGTH__: USART frame length. |
Kojto | 108:34e6b704fe68 | 539 | * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid) |
Kojto | 108:34e6b704fe68 | 540 | */ |
Kojto | 108:34e6b704fe68 | 541 | #if defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \ |
Kojto | 108:34e6b704fe68 | 542 | defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \ |
Kojto | 108:34e6b704fe68 | 543 | defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) |
Kojto | 108:34e6b704fe68 | 544 | #define IS_USART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == USART_WORDLENGTH_7B) || \ |
Kojto | 108:34e6b704fe68 | 545 | ((__LENGTH__) == USART_WORDLENGTH_8B) || \ |
Kojto | 108:34e6b704fe68 | 546 | ((__LENGTH__) == USART_WORDLENGTH_9B)) |
Kojto | 108:34e6b704fe68 | 547 | #else |
Kojto | 108:34e6b704fe68 | 548 | #define IS_USART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == USART_WORDLENGTH_8B) || \ |
Kojto | 108:34e6b704fe68 | 549 | ((__LENGTH__) == USART_WORDLENGTH_9B)) |
Kojto | 108:34e6b704fe68 | 550 | #endif /* defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || defined (STM32F070xB) || \ |
Kojto | 108:34e6b704fe68 | 551 | defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \ |
Kojto | 108:34e6b704fe68 | 552 | defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) */ |
Kojto | 108:34e6b704fe68 | 553 | |
Kojto | 108:34e6b704fe68 | 554 | /** |
Kojto | 108:34e6b704fe68 | 555 | * @brief Ensure that USART request parameter is valid. |
Kojto | 108:34e6b704fe68 | 556 | * @param __PARAM__: USART request parameter. |
Kojto | 108:34e6b704fe68 | 557 | * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid) |
Kojto | 108:34e6b704fe68 | 558 | */ |
Kojto | 108:34e6b704fe68 | 559 | #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) |
Kojto | 108:34e6b704fe68 | 560 | #define IS_USART_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == USART_RXDATA_FLUSH_REQUEST) || \ |
Kojto | 108:34e6b704fe68 | 561 | ((__PARAM__) == USART_TXDATA_FLUSH_REQUEST)) |
Kojto | 108:34e6b704fe68 | 562 | #else |
Kojto | 108:34e6b704fe68 | 563 | #define IS_USART_REQUEST_PARAMETER(__PARAM__) ((__PARAM__) == USART_RXDATA_FLUSH_REQUEST) |
Kojto | 108:34e6b704fe68 | 564 | #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */ |
Kojto | 108:34e6b704fe68 | 565 | |
bogdanm | 85:024bf7f99721 | 566 | /** |
bogdanm | 85:024bf7f99721 | 567 | * @} |
bogdanm | 85:024bf7f99721 | 568 | */ |
bogdanm | 85:024bf7f99721 | 569 | |
bogdanm | 85:024bf7f99721 | 570 | /* Exported functions --------------------------------------------------------*/ |
bogdanm | 85:024bf7f99721 | 571 | |
bogdanm | 85:024bf7f99721 | 572 | /** |
bogdanm | 85:024bf7f99721 | 573 | * @} |
Kojto | 108:34e6b704fe68 | 574 | */ |
bogdanm | 85:024bf7f99721 | 575 | |
bogdanm | 85:024bf7f99721 | 576 | /** |
bogdanm | 85:024bf7f99721 | 577 | * @} |
Kojto | 108:34e6b704fe68 | 578 | */ |
Kojto | 108:34e6b704fe68 | 579 | |
bogdanm | 85:024bf7f99721 | 580 | #ifdef __cplusplus |
bogdanm | 85:024bf7f99721 | 581 | } |
bogdanm | 85:024bf7f99721 | 582 | #endif |
bogdanm | 85:024bf7f99721 | 583 | |
bogdanm | 85:024bf7f99721 | 584 | #endif /* __STM32F0xx_HAL_USART_EX_H */ |
bogdanm | 85:024bf7f99721 | 585 | |
bogdanm | 85:024bf7f99721 | 586 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
bogdanm | 92:4fc01daae5a5 | 587 |