mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
92:4fc01daae5a5
Child:
123:b0220dba8be7
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 86:04dd9b1680ae 1 /**
bogdanm 86:04dd9b1680ae 2 ******************************************************************************
bogdanm 86:04dd9b1680ae 3 * @file stm32f3xx_hal_irda_ex.h
bogdanm 86:04dd9b1680ae 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.2.1
Kojto 122:f9eeca106725 6 * @date 29-April-2015
Kojto 122:f9eeca106725 7 * @brief Header file of IRDA HAL Extension module.
bogdanm 86:04dd9b1680ae 8 ******************************************************************************
bogdanm 86:04dd9b1680ae 9 * @attention
Kojto 122:f9eeca106725 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
bogdanm 86:04dd9b1680ae 12 *
bogdanm 86:04dd9b1680ae 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 86:04dd9b1680ae 14 * are permitted provided that the following conditions are met:
bogdanm 86:04dd9b1680ae 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 86:04dd9b1680ae 16 * this list of conditions and the following disclaimer.
bogdanm 86:04dd9b1680ae 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 86:04dd9b1680ae 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 86:04dd9b1680ae 19 * and/or other materials provided with the distribution.
bogdanm 86:04dd9b1680ae 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 86:04dd9b1680ae 21 * may be used to endorse or promote products derived from this software
bogdanm 86:04dd9b1680ae 22 * without specific prior written permission.
bogdanm 86:04dd9b1680ae 23 *
bogdanm 86:04dd9b1680ae 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 86:04dd9b1680ae 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 86:04dd9b1680ae 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 86:04dd9b1680ae 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 86:04dd9b1680ae 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 86:04dd9b1680ae 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 86:04dd9b1680ae 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 86:04dd9b1680ae 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 86:04dd9b1680ae 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 86:04dd9b1680ae 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 86:04dd9b1680ae 34 *
Kojto 122:f9eeca106725 35 ******************************************************************************
bogdanm 86:04dd9b1680ae 36 */
bogdanm 86:04dd9b1680ae 37
bogdanm 86:04dd9b1680ae 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 86:04dd9b1680ae 39 #ifndef __STM32F3xx_HAL_IRDA_EX_H
bogdanm 86:04dd9b1680ae 40 #define __STM32F3xx_HAL_IRDA_EX_H
bogdanm 86:04dd9b1680ae 41
bogdanm 86:04dd9b1680ae 42 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 43 extern "C" {
bogdanm 86:04dd9b1680ae 44 #endif
bogdanm 86:04dd9b1680ae 45
bogdanm 86:04dd9b1680ae 46 /* Includes ------------------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 47 #include "stm32f3xx_hal_def.h"
bogdanm 86:04dd9b1680ae 48
bogdanm 86:04dd9b1680ae 49 /** @addtogroup STM32F3xx_HAL_Driver
bogdanm 86:04dd9b1680ae 50 * @{
bogdanm 86:04dd9b1680ae 51 */
bogdanm 86:04dd9b1680ae 52
Kojto 122:f9eeca106725 53 /** @defgroup IRDAEx IRDAEx
Kojto 122:f9eeca106725 54 * @brief IRDA Extension HAL module driver.
bogdanm 86:04dd9b1680ae 55 * @{
Kojto 122:f9eeca106725 56 */
bogdanm 86:04dd9b1680ae 57
bogdanm 86:04dd9b1680ae 58 /* Exported types ------------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 59 /* Exported constants --------------------------------------------------------*/
Kojto 122:f9eeca106725 60 /** @defgroup IRDAEx_Exported_Constants IRDAEx Exported Constants
bogdanm 86:04dd9b1680ae 61 * @{
bogdanm 86:04dd9b1680ae 62 */
Kojto 122:f9eeca106725 63
Kojto 122:f9eeca106725 64 /** @defgroup IRDAEx_Word_Length IRDA Word Length
bogdanm 86:04dd9b1680ae 65 * @{
bogdanm 86:04dd9b1680ae 66 */
bogdanm 92:4fc01daae5a5 67 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
bogdanm 92:4fc01daae5a5 68 defined(STM32F334x8) || \
bogdanm 92:4fc01daae5a5 69 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
Kojto 122:f9eeca106725 70 #define IRDA_WORDLENGTH_7B ((uint32_t)USART_CR1_M1) /*!< 7-bit long frame */
Kojto 122:f9eeca106725 71 #define IRDA_WORDLENGTH_8B ((uint32_t)0x00000000) /*!< 8-bit long frame */
Kojto 122:f9eeca106725 72 #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M0) /*!< 9-bit long frame */
bogdanm 86:04dd9b1680ae 73 #else
Kojto 122:f9eeca106725 74 #define IRDA_WORDLENGTH_8B ((uint32_t)0x00000000) /*!< 8-bit long frame */
Kojto 122:f9eeca106725 75 #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M) /*!< 9-bit long frame */
bogdanm 92:4fc01daae5a5 76 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
bogdanm 92:4fc01daae5a5 77 /* STM32F334x8 || */
bogdanm 92:4fc01daae5a5 78 /* STM32F301x8 || STM32F302x8 || STM32F318xx */
bogdanm 86:04dd9b1680ae 79 /**
bogdanm 86:04dd9b1680ae 80 * @}
bogdanm 86:04dd9b1680ae 81 */
Kojto 122:f9eeca106725 82
bogdanm 86:04dd9b1680ae 83 /**
bogdanm 86:04dd9b1680ae 84 * @}
bogdanm 86:04dd9b1680ae 85 */
bogdanm 86:04dd9b1680ae 86
bogdanm 92:4fc01daae5a5 87 /* Exported macros -----------------------------------------------------------*/
Kojto 122:f9eeca106725 88 /* Exported functions --------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 89
Kojto 122:f9eeca106725 90 /* Private macros ------------------------------------------------------------*/
Kojto 122:f9eeca106725 91
Kojto 122:f9eeca106725 92 /** @defgroup IRDAEx_Private_Macros IRDAEx Private Macros
bogdanm 86:04dd9b1680ae 93 * @{
bogdanm 86:04dd9b1680ae 94 */
Kojto 122:f9eeca106725 95
Kojto 122:f9eeca106725 96 /** @brief Report the IRDA clock source.
Kojto 122:f9eeca106725 97 * @param __HANDLE__: specifies the IRDA Handle.
Kojto 122:f9eeca106725 98 * @param __CLOCKSOURCE__: output variable.
bogdanm 86:04dd9b1680ae 99 * @retval IRDA clocking source, written in __CLOCKSOURCE__.
bogdanm 86:04dd9b1680ae 100 */
bogdanm 92:4fc01daae5a5 101 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
bogdanm 92:4fc01daae5a5 102 defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx)
Kojto 122:f9eeca106725 103 #define IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
bogdanm 86:04dd9b1680ae 104 do { \
bogdanm 86:04dd9b1680ae 105 if((__HANDLE__)->Instance == USART1) \
bogdanm 86:04dd9b1680ae 106 { \
bogdanm 86:04dd9b1680ae 107 switch(__HAL_RCC_GET_USART1_SOURCE()) \
bogdanm 86:04dd9b1680ae 108 { \
bogdanm 86:04dd9b1680ae 109 case RCC_USART1CLKSOURCE_PCLK2: \
bogdanm 86:04dd9b1680ae 110 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK2; \
bogdanm 86:04dd9b1680ae 111 break; \
bogdanm 86:04dd9b1680ae 112 case RCC_USART1CLKSOURCE_HSI: \
bogdanm 86:04dd9b1680ae 113 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
bogdanm 86:04dd9b1680ae 114 break; \
bogdanm 86:04dd9b1680ae 115 case RCC_USART1CLKSOURCE_SYSCLK: \
bogdanm 86:04dd9b1680ae 116 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
bogdanm 86:04dd9b1680ae 117 break; \
bogdanm 86:04dd9b1680ae 118 case RCC_USART1CLKSOURCE_LSE: \
bogdanm 86:04dd9b1680ae 119 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
bogdanm 86:04dd9b1680ae 120 break; \
Kojto 122:f9eeca106725 121 default: \
Kojto 122:f9eeca106725 122 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 123 break; \
bogdanm 86:04dd9b1680ae 124 } \
bogdanm 86:04dd9b1680ae 125 } \
bogdanm 86:04dd9b1680ae 126 else if((__HANDLE__)->Instance == USART2) \
bogdanm 86:04dd9b1680ae 127 { \
bogdanm 86:04dd9b1680ae 128 switch(__HAL_RCC_GET_USART2_SOURCE()) \
bogdanm 86:04dd9b1680ae 129 { \
bogdanm 86:04dd9b1680ae 130 case RCC_USART2CLKSOURCE_PCLK1: \
bogdanm 86:04dd9b1680ae 131 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
bogdanm 86:04dd9b1680ae 132 break; \
bogdanm 86:04dd9b1680ae 133 case RCC_USART2CLKSOURCE_HSI: \
bogdanm 86:04dd9b1680ae 134 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
bogdanm 86:04dd9b1680ae 135 break; \
bogdanm 86:04dd9b1680ae 136 case RCC_USART2CLKSOURCE_SYSCLK: \
bogdanm 86:04dd9b1680ae 137 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
bogdanm 86:04dd9b1680ae 138 break; \
bogdanm 86:04dd9b1680ae 139 case RCC_USART2CLKSOURCE_LSE: \
bogdanm 86:04dd9b1680ae 140 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
bogdanm 86:04dd9b1680ae 141 break; \
Kojto 122:f9eeca106725 142 default: \
Kojto 122:f9eeca106725 143 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 144 break; \
bogdanm 86:04dd9b1680ae 145 } \
bogdanm 86:04dd9b1680ae 146 } \
bogdanm 86:04dd9b1680ae 147 else if((__HANDLE__)->Instance == USART3) \
bogdanm 86:04dd9b1680ae 148 { \
bogdanm 86:04dd9b1680ae 149 switch(__HAL_RCC_GET_USART3_SOURCE()) \
bogdanm 86:04dd9b1680ae 150 { \
bogdanm 86:04dd9b1680ae 151 case RCC_USART3CLKSOURCE_PCLK1: \
bogdanm 86:04dd9b1680ae 152 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
bogdanm 86:04dd9b1680ae 153 break; \
bogdanm 86:04dd9b1680ae 154 case RCC_USART3CLKSOURCE_HSI: \
bogdanm 86:04dd9b1680ae 155 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
bogdanm 86:04dd9b1680ae 156 break; \
bogdanm 86:04dd9b1680ae 157 case RCC_USART3CLKSOURCE_SYSCLK: \
bogdanm 86:04dd9b1680ae 158 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
bogdanm 86:04dd9b1680ae 159 break; \
bogdanm 86:04dd9b1680ae 160 case RCC_USART3CLKSOURCE_LSE: \
bogdanm 86:04dd9b1680ae 161 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
bogdanm 86:04dd9b1680ae 162 break; \
Kojto 122:f9eeca106725 163 default: \
Kojto 122:f9eeca106725 164 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 165 break; \
bogdanm 86:04dd9b1680ae 166 } \
bogdanm 86:04dd9b1680ae 167 } \
bogdanm 86:04dd9b1680ae 168 else if((__HANDLE__)->Instance == UART4) \
bogdanm 86:04dd9b1680ae 169 { \
bogdanm 86:04dd9b1680ae 170 switch(__HAL_RCC_GET_UART4_SOURCE()) \
bogdanm 86:04dd9b1680ae 171 { \
bogdanm 86:04dd9b1680ae 172 case RCC_UART4CLKSOURCE_PCLK1: \
bogdanm 86:04dd9b1680ae 173 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
bogdanm 86:04dd9b1680ae 174 break; \
bogdanm 86:04dd9b1680ae 175 case RCC_UART4CLKSOURCE_HSI: \
bogdanm 86:04dd9b1680ae 176 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
bogdanm 86:04dd9b1680ae 177 break; \
bogdanm 86:04dd9b1680ae 178 case RCC_UART4CLKSOURCE_SYSCLK: \
bogdanm 86:04dd9b1680ae 179 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
bogdanm 86:04dd9b1680ae 180 break; \
bogdanm 86:04dd9b1680ae 181 case RCC_UART4CLKSOURCE_LSE: \
bogdanm 86:04dd9b1680ae 182 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
bogdanm 86:04dd9b1680ae 183 break; \
Kojto 122:f9eeca106725 184 default: \
Kojto 122:f9eeca106725 185 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 186 break; \
bogdanm 86:04dd9b1680ae 187 } \
bogdanm 86:04dd9b1680ae 188 } \
bogdanm 86:04dd9b1680ae 189 else if ((__HANDLE__)->Instance == UART5) \
bogdanm 86:04dd9b1680ae 190 { \
bogdanm 86:04dd9b1680ae 191 switch(__HAL_RCC_GET_UART5_SOURCE()) \
bogdanm 86:04dd9b1680ae 192 { \
bogdanm 86:04dd9b1680ae 193 case RCC_UART5CLKSOURCE_PCLK1: \
bogdanm 86:04dd9b1680ae 194 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
bogdanm 86:04dd9b1680ae 195 break; \
bogdanm 86:04dd9b1680ae 196 case RCC_UART5CLKSOURCE_HSI: \
bogdanm 86:04dd9b1680ae 197 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
bogdanm 86:04dd9b1680ae 198 break; \
bogdanm 86:04dd9b1680ae 199 case RCC_UART5CLKSOURCE_SYSCLK: \
bogdanm 86:04dd9b1680ae 200 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
bogdanm 86:04dd9b1680ae 201 break; \
bogdanm 86:04dd9b1680ae 202 case RCC_UART5CLKSOURCE_LSE: \
bogdanm 86:04dd9b1680ae 203 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
bogdanm 86:04dd9b1680ae 204 break; \
Kojto 122:f9eeca106725 205 default: \
Kojto 122:f9eeca106725 206 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 207 break; \
bogdanm 86:04dd9b1680ae 208 } \
bogdanm 86:04dd9b1680ae 209 } \
Kojto 122:f9eeca106725 210 else \
Kojto 122:f9eeca106725 211 { \
Kojto 122:f9eeca106725 212 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 213 } \
bogdanm 86:04dd9b1680ae 214 } while(0)
Kojto 122:f9eeca106725 215 #elif defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
Kojto 122:f9eeca106725 216 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
Kojto 122:f9eeca106725 217 #define IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
bogdanm 86:04dd9b1680ae 218 do { \
bogdanm 86:04dd9b1680ae 219 if((__HANDLE__)->Instance == USART1) \
bogdanm 86:04dd9b1680ae 220 { \
bogdanm 86:04dd9b1680ae 221 switch(__HAL_RCC_GET_USART1_SOURCE()) \
bogdanm 86:04dd9b1680ae 222 { \
bogdanm 86:04dd9b1680ae 223 case RCC_USART1CLKSOURCE_PCLK1: \
bogdanm 86:04dd9b1680ae 224 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
bogdanm 86:04dd9b1680ae 225 break; \
bogdanm 86:04dd9b1680ae 226 case RCC_USART1CLKSOURCE_HSI: \
bogdanm 86:04dd9b1680ae 227 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
bogdanm 86:04dd9b1680ae 228 break; \
bogdanm 86:04dd9b1680ae 229 case RCC_USART1CLKSOURCE_SYSCLK: \
bogdanm 86:04dd9b1680ae 230 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
bogdanm 86:04dd9b1680ae 231 break; \
bogdanm 86:04dd9b1680ae 232 case RCC_USART1CLKSOURCE_LSE: \
bogdanm 86:04dd9b1680ae 233 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
bogdanm 86:04dd9b1680ae 234 break; \
Kojto 122:f9eeca106725 235 default: \
Kojto 122:f9eeca106725 236 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 237 break; \
Kojto 122:f9eeca106725 238 } \
Kojto 122:f9eeca106725 239 } \
Kojto 122:f9eeca106725 240 else if((__HANDLE__)->Instance == USART2) \
Kojto 122:f9eeca106725 241 { \
Kojto 122:f9eeca106725 242 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
Kojto 122:f9eeca106725 243 } \
Kojto 122:f9eeca106725 244 else if((__HANDLE__)->Instance == USART3) \
Kojto 122:f9eeca106725 245 { \
Kojto 122:f9eeca106725 246 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
Kojto 122:f9eeca106725 247 } \
Kojto 122:f9eeca106725 248 else \
Kojto 122:f9eeca106725 249 { \
Kojto 122:f9eeca106725 250 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 251 } \
Kojto 122:f9eeca106725 252 } while(0)
Kojto 122:f9eeca106725 253 #else
Kojto 122:f9eeca106725 254 #define IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 122:f9eeca106725 255 do { \
Kojto 122:f9eeca106725 256 if((__HANDLE__)->Instance == USART1) \
Kojto 122:f9eeca106725 257 { \
Kojto 122:f9eeca106725 258 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 122:f9eeca106725 259 { \
Kojto 122:f9eeca106725 260 case RCC_USART1CLKSOURCE_PCLK2: \
Kojto 122:f9eeca106725 261 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK2; \
Kojto 122:f9eeca106725 262 break; \
Kojto 122:f9eeca106725 263 case RCC_USART1CLKSOURCE_HSI: \
Kojto 122:f9eeca106725 264 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
Kojto 122:f9eeca106725 265 break; \
Kojto 122:f9eeca106725 266 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 122:f9eeca106725 267 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
Kojto 122:f9eeca106725 268 break; \
Kojto 122:f9eeca106725 269 case RCC_USART1CLKSOURCE_LSE: \
Kojto 122:f9eeca106725 270 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
Kojto 122:f9eeca106725 271 break; \
Kojto 122:f9eeca106725 272 default: \
Kojto 122:f9eeca106725 273 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 274 break; \
bogdanm 86:04dd9b1680ae 275 } \
bogdanm 86:04dd9b1680ae 276 } \
bogdanm 86:04dd9b1680ae 277 else if((__HANDLE__)->Instance == USART2) \
bogdanm 86:04dd9b1680ae 278 { \
bogdanm 86:04dd9b1680ae 279 switch(__HAL_RCC_GET_USART2_SOURCE()) \
bogdanm 86:04dd9b1680ae 280 { \
bogdanm 86:04dd9b1680ae 281 case RCC_USART2CLKSOURCE_PCLK1: \
bogdanm 86:04dd9b1680ae 282 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
bogdanm 86:04dd9b1680ae 283 break; \
bogdanm 86:04dd9b1680ae 284 case RCC_USART2CLKSOURCE_HSI: \
bogdanm 86:04dd9b1680ae 285 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
bogdanm 86:04dd9b1680ae 286 break; \
bogdanm 86:04dd9b1680ae 287 case RCC_USART2CLKSOURCE_SYSCLK: \
bogdanm 86:04dd9b1680ae 288 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
bogdanm 86:04dd9b1680ae 289 break; \
bogdanm 86:04dd9b1680ae 290 case RCC_USART2CLKSOURCE_LSE: \
bogdanm 86:04dd9b1680ae 291 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
bogdanm 86:04dd9b1680ae 292 break; \
Kojto 122:f9eeca106725 293 default: \
Kojto 122:f9eeca106725 294 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
bogdanm 86:04dd9b1680ae 295 break; \
bogdanm 86:04dd9b1680ae 296 } \
bogdanm 86:04dd9b1680ae 297 } \
bogdanm 86:04dd9b1680ae 298 else if((__HANDLE__)->Instance == USART3) \
bogdanm 86:04dd9b1680ae 299 { \
bogdanm 86:04dd9b1680ae 300 switch(__HAL_RCC_GET_USART3_SOURCE()) \
bogdanm 86:04dd9b1680ae 301 { \
bogdanm 86:04dd9b1680ae 302 case RCC_USART3CLKSOURCE_PCLK1: \
bogdanm 86:04dd9b1680ae 303 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \
bogdanm 86:04dd9b1680ae 304 break; \
bogdanm 86:04dd9b1680ae 305 case RCC_USART3CLKSOURCE_HSI: \
bogdanm 86:04dd9b1680ae 306 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
bogdanm 86:04dd9b1680ae 307 break; \
bogdanm 86:04dd9b1680ae 308 case RCC_USART3CLKSOURCE_SYSCLK: \
bogdanm 86:04dd9b1680ae 309 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \
bogdanm 86:04dd9b1680ae 310 break; \
bogdanm 86:04dd9b1680ae 311 case RCC_USART3CLKSOURCE_LSE: \
bogdanm 86:04dd9b1680ae 312 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
bogdanm 86:04dd9b1680ae 313 break; \
Kojto 122:f9eeca106725 314 default: \
Kojto 122:f9eeca106725 315 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 316 break; \
bogdanm 86:04dd9b1680ae 317 } \
bogdanm 86:04dd9b1680ae 318 } \
Kojto 122:f9eeca106725 319 else \
Kojto 122:f9eeca106725 320 { \
Kojto 122:f9eeca106725 321 (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 322 } \
bogdanm 86:04dd9b1680ae 323 } while(0)
bogdanm 92:4fc01daae5a5 324 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
Kojto 122:f9eeca106725 325 /* STM32F302xC || STM32F303xC || STM32F358xx || */
Kojto 122:f9eeca106725 326
Kojto 122:f9eeca106725 327
Kojto 122:f9eeca106725 328 /** @brief Compute the mask to apply to retrieve the received data
bogdanm 86:04dd9b1680ae 329 * according to the word length and to the parity bits activation.
Kojto 122:f9eeca106725 330 * @note If PCE = 1, the parity bit is not included in the data extracted
Kojto 122:f9eeca106725 331 * by the reception API().
Kojto 122:f9eeca106725 332 * This masking operation is not carried out in the case of
Kojto 122:f9eeca106725 333 * DMA transfers.
bogdanm 86:04dd9b1680ae 334 * @param __HANDLE__: specifies the IRDA Handle
Kojto 122:f9eeca106725 335 * @retval None, the mask to apply to IRDA RDR register is stored in (__HANDLE__)->Mask field.
Kojto 122:f9eeca106725 336 */
bogdanm 92:4fc01daae5a5 337 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
bogdanm 92:4fc01daae5a5 338 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx) || \
bogdanm 92:4fc01daae5a5 339 defined(STM32F334x8)
Kojto 122:f9eeca106725 340 #define IRDA_MASK_COMPUTATION(__HANDLE__) \
bogdanm 86:04dd9b1680ae 341 do { \
bogdanm 86:04dd9b1680ae 342 if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_9B) \
bogdanm 86:04dd9b1680ae 343 { \
bogdanm 86:04dd9b1680ae 344 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \
bogdanm 86:04dd9b1680ae 345 { \
bogdanm 86:04dd9b1680ae 346 (__HANDLE__)->Mask = 0x01FF ; \
bogdanm 86:04dd9b1680ae 347 } \
bogdanm 86:04dd9b1680ae 348 else \
bogdanm 86:04dd9b1680ae 349 { \
bogdanm 86:04dd9b1680ae 350 (__HANDLE__)->Mask = 0x00FF ; \
bogdanm 86:04dd9b1680ae 351 } \
bogdanm 86:04dd9b1680ae 352 } \
bogdanm 86:04dd9b1680ae 353 else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_8B) \
bogdanm 86:04dd9b1680ae 354 { \
bogdanm 86:04dd9b1680ae 355 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \
bogdanm 86:04dd9b1680ae 356 { \
bogdanm 86:04dd9b1680ae 357 (__HANDLE__)->Mask = 0x00FF ; \
bogdanm 86:04dd9b1680ae 358 } \
bogdanm 86:04dd9b1680ae 359 else \
bogdanm 86:04dd9b1680ae 360 { \
bogdanm 86:04dd9b1680ae 361 (__HANDLE__)->Mask = 0x007F ; \
bogdanm 86:04dd9b1680ae 362 } \
bogdanm 86:04dd9b1680ae 363 } \
bogdanm 86:04dd9b1680ae 364 else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_7B) \
bogdanm 86:04dd9b1680ae 365 { \
bogdanm 86:04dd9b1680ae 366 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \
bogdanm 86:04dd9b1680ae 367 { \
bogdanm 86:04dd9b1680ae 368 (__HANDLE__)->Mask = 0x007F ; \
bogdanm 86:04dd9b1680ae 369 } \
bogdanm 86:04dd9b1680ae 370 else \
bogdanm 86:04dd9b1680ae 371 { \
bogdanm 86:04dd9b1680ae 372 (__HANDLE__)->Mask = 0x003F ; \
bogdanm 86:04dd9b1680ae 373 } \
bogdanm 86:04dd9b1680ae 374 } \
Kojto 122:f9eeca106725 375 } while(0)
bogdanm 86:04dd9b1680ae 376 #else
Kojto 122:f9eeca106725 377 #define IRDA_MASK_COMPUTATION(__HANDLE__) \
bogdanm 86:04dd9b1680ae 378 do { \
bogdanm 86:04dd9b1680ae 379 if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_9B) \
bogdanm 86:04dd9b1680ae 380 { \
bogdanm 86:04dd9b1680ae 381 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \
bogdanm 86:04dd9b1680ae 382 { \
bogdanm 86:04dd9b1680ae 383 (__HANDLE__)->Mask = 0x01FF ; \
bogdanm 86:04dd9b1680ae 384 } \
bogdanm 86:04dd9b1680ae 385 else \
bogdanm 86:04dd9b1680ae 386 { \
bogdanm 86:04dd9b1680ae 387 (__HANDLE__)->Mask = 0x00FF ; \
bogdanm 86:04dd9b1680ae 388 } \
bogdanm 86:04dd9b1680ae 389 } \
bogdanm 86:04dd9b1680ae 390 else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_8B) \
bogdanm 86:04dd9b1680ae 391 { \
bogdanm 86:04dd9b1680ae 392 if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \
bogdanm 86:04dd9b1680ae 393 { \
bogdanm 86:04dd9b1680ae 394 (__HANDLE__)->Mask = 0x00FF ; \
bogdanm 86:04dd9b1680ae 395 } \
bogdanm 86:04dd9b1680ae 396 else \
bogdanm 86:04dd9b1680ae 397 { \
bogdanm 86:04dd9b1680ae 398 (__HANDLE__)->Mask = 0x007F ; \
bogdanm 86:04dd9b1680ae 399 } \
bogdanm 86:04dd9b1680ae 400 } \
Kojto 122:f9eeca106725 401 } while(0)
bogdanm 92:4fc01daae5a5 402 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
bogdanm 92:4fc01daae5a5 403 /* STM32F301x8 || STM32F302x8 || STM32F318xx || */
bogdanm 92:4fc01daae5a5 404 /* STM32F334x8 */
bogdanm 86:04dd9b1680ae 405 /**
Kojto 122:f9eeca106725 406 * @brief Ensure that IRDA frame length is valid.
Kojto 122:f9eeca106725 407 * @param __LENGTH__: IRDA frame length.
Kojto 122:f9eeca106725 408 * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid)
Kojto 122:f9eeca106725 409 */
Kojto 122:f9eeca106725 410 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
Kojto 122:f9eeca106725 411 defined(STM32F334x8) || \
Kojto 122:f9eeca106725 412 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
Kojto 122:f9eeca106725 413 #define IS_IRDA_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == IRDA_WORDLENGTH_7B) || \
Kojto 122:f9eeca106725 414 ((__LENGTH__) == IRDA_WORDLENGTH_8B) || \
Kojto 122:f9eeca106725 415 ((__LENGTH__) == IRDA_WORDLENGTH_9B))
Kojto 122:f9eeca106725 416 #else
Kojto 122:f9eeca106725 417 #define IS_IRDA_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == IRDA_WORDLENGTH_8B) || \
Kojto 122:f9eeca106725 418 ((__LENGTH__) == IRDA_WORDLENGTH_9B))
Kojto 122:f9eeca106725 419 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
Kojto 122:f9eeca106725 420 /* STM32F334x8 || */
Kojto 122:f9eeca106725 421 /* STM32F301x8 || STM32F302x8 || STM32F318xx */
Kojto 122:f9eeca106725 422 /**
bogdanm 86:04dd9b1680ae 423 * @}
bogdanm 86:04dd9b1680ae 424 */
Kojto 122:f9eeca106725 425
bogdanm 86:04dd9b1680ae 426 /* Exported functions --------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 427
bogdanm 86:04dd9b1680ae 428 /**
bogdanm 86:04dd9b1680ae 429 * @}
Kojto 122:f9eeca106725 430 */
bogdanm 86:04dd9b1680ae 431
bogdanm 86:04dd9b1680ae 432 /**
bogdanm 86:04dd9b1680ae 433 * @}
Kojto 122:f9eeca106725 434 */
Kojto 122:f9eeca106725 435
bogdanm 86:04dd9b1680ae 436 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 437 }
bogdanm 86:04dd9b1680ae 438 #endif
bogdanm 86:04dd9b1680ae 439
bogdanm 86:04dd9b1680ae 440 #endif /* __STM32F3xx_HAL_IRDA_EX_H */
bogdanm 86:04dd9b1680ae 441
bogdanm 86:04dd9b1680ae 442 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Kojto 122:f9eeca106725 443