.
TARGET_NUCLEO_F072RB/stm32f0xx_hal_irda_ex.h@0:88e313c910d0, 2015-08-13 (annotated)
- Committer:
- jhon309
- Date:
- Thu Aug 13 00:20:09 2015 +0000
- Revision:
- 0:88e313c910d0
RTC Example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jhon309 | 0:88e313c910d0 | 1 | /** |
jhon309 | 0:88e313c910d0 | 2 | ****************************************************************************** |
jhon309 | 0:88e313c910d0 | 3 | * @file stm32f0xx_hal_irda_ex.h |
jhon309 | 0:88e313c910d0 | 4 | * @author MCD Application Team |
jhon309 | 0:88e313c910d0 | 5 | * @version V1.2.0 |
jhon309 | 0:88e313c910d0 | 6 | * @date 11-December-2014 |
jhon309 | 0:88e313c910d0 | 7 | * @brief Header file of IRDA HAL Extension module. |
jhon309 | 0:88e313c910d0 | 8 | ****************************************************************************** |
jhon309 | 0:88e313c910d0 | 9 | * @attention |
jhon309 | 0:88e313c910d0 | 10 | * |
jhon309 | 0:88e313c910d0 | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
jhon309 | 0:88e313c910d0 | 12 | * |
jhon309 | 0:88e313c910d0 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
jhon309 | 0:88e313c910d0 | 14 | * are permitted provided that the following conditions are met: |
jhon309 | 0:88e313c910d0 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
jhon309 | 0:88e313c910d0 | 16 | * this list of conditions and the following disclaimer. |
jhon309 | 0:88e313c910d0 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
jhon309 | 0:88e313c910d0 | 18 | * this list of conditions and the following disclaimer in the documentation |
jhon309 | 0:88e313c910d0 | 19 | * and/or other materials provided with the distribution. |
jhon309 | 0:88e313c910d0 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
jhon309 | 0:88e313c910d0 | 21 | * may be used to endorse or promote products derived from this software |
jhon309 | 0:88e313c910d0 | 22 | * without specific prior written permission. |
jhon309 | 0:88e313c910d0 | 23 | * |
jhon309 | 0:88e313c910d0 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
jhon309 | 0:88e313c910d0 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
jhon309 | 0:88e313c910d0 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
jhon309 | 0:88e313c910d0 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
jhon309 | 0:88e313c910d0 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
jhon309 | 0:88e313c910d0 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
jhon309 | 0:88e313c910d0 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
jhon309 | 0:88e313c910d0 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
jhon309 | 0:88e313c910d0 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
jhon309 | 0:88e313c910d0 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
jhon309 | 0:88e313c910d0 | 34 | * |
jhon309 | 0:88e313c910d0 | 35 | ****************************************************************************** |
jhon309 | 0:88e313c910d0 | 36 | */ |
jhon309 | 0:88e313c910d0 | 37 | |
jhon309 | 0:88e313c910d0 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
jhon309 | 0:88e313c910d0 | 39 | #ifndef __STM32F0xx_HAL_IRDA_EX_H |
jhon309 | 0:88e313c910d0 | 40 | #define __STM32F0xx_HAL_IRDA_EX_H |
jhon309 | 0:88e313c910d0 | 41 | |
jhon309 | 0:88e313c910d0 | 42 | #ifdef __cplusplus |
jhon309 | 0:88e313c910d0 | 43 | extern "C" { |
jhon309 | 0:88e313c910d0 | 44 | #endif |
jhon309 | 0:88e313c910d0 | 45 | |
jhon309 | 0:88e313c910d0 | 46 | #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) |
jhon309 | 0:88e313c910d0 | 47 | |
jhon309 | 0:88e313c910d0 | 48 | /* Includes ------------------------------------------------------------------*/ |
jhon309 | 0:88e313c910d0 | 49 | #include "stm32f0xx_hal_def.h" |
jhon309 | 0:88e313c910d0 | 50 | |
jhon309 | 0:88e313c910d0 | 51 | /** @addtogroup STM32F0xx_HAL_Driver |
jhon309 | 0:88e313c910d0 | 52 | * @{ |
jhon309 | 0:88e313c910d0 | 53 | */ |
jhon309 | 0:88e313c910d0 | 54 | |
jhon309 | 0:88e313c910d0 | 55 | /** @addtogroup IRDAEx IRDAEx Extended HAL module driver |
jhon309 | 0:88e313c910d0 | 56 | * @{ |
jhon309 | 0:88e313c910d0 | 57 | */ |
jhon309 | 0:88e313c910d0 | 58 | |
jhon309 | 0:88e313c910d0 | 59 | /* Exported types ------------------------------------------------------------*/ |
jhon309 | 0:88e313c910d0 | 60 | /* Exported constants --------------------------------------------------------*/ |
jhon309 | 0:88e313c910d0 | 61 | /** @defgroup IRDAEx_Exported_Constants IRDAEx Exported Constants |
jhon309 | 0:88e313c910d0 | 62 | * @{ |
jhon309 | 0:88e313c910d0 | 63 | */ |
jhon309 | 0:88e313c910d0 | 64 | |
jhon309 | 0:88e313c910d0 | 65 | /** @defgroup IRDAEx_Word_Length IRDA Word Length |
jhon309 | 0:88e313c910d0 | 66 | * @{ |
jhon309 | 0:88e313c910d0 | 67 | */ |
jhon309 | 0:88e313c910d0 | 68 | #if defined (STM32F042x6) || defined (STM32F048xx) || \ |
jhon309 | 0:88e313c910d0 | 69 | defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \ |
jhon309 | 0:88e313c910d0 | 70 | defined (STM32F091xC) || defined (STM32F098xx) |
jhon309 | 0:88e313c910d0 | 71 | #define IRDA_WORDLENGTH_7B ((uint32_t)USART_CR1_M1) |
jhon309 | 0:88e313c910d0 | 72 | #define IRDA_WORDLENGTH_8B ((uint32_t)0x00000000) |
jhon309 | 0:88e313c910d0 | 73 | #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M0) |
jhon309 | 0:88e313c910d0 | 74 | #define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_7B) || \ |
jhon309 | 0:88e313c910d0 | 75 | ((LENGTH) == IRDA_WORDLENGTH_8B) || \ |
jhon309 | 0:88e313c910d0 | 76 | ((LENGTH) == IRDA_WORDLENGTH_9B)) |
jhon309 | 0:88e313c910d0 | 77 | #else |
jhon309 | 0:88e313c910d0 | 78 | #define IRDA_WORDLENGTH_8B ((uint32_t)0x00000000) |
jhon309 | 0:88e313c910d0 | 79 | #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M) |
jhon309 | 0:88e313c910d0 | 80 | #define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_8B) || \ |
jhon309 | 0:88e313c910d0 | 81 | ((LENGTH) == IRDA_WORDLENGTH_9B)) |
jhon309 | 0:88e313c910d0 | 82 | #endif /* defined (STM32F042x6) || defined (STM32F048xx) || \ |
jhon309 | 0:88e313c910d0 | 83 | defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \ |
jhon309 | 0:88e313c910d0 | 84 | defined (STM32F091xC) || defined (STM32F098xx)*/ |
jhon309 | 0:88e313c910d0 | 85 | /** |
jhon309 | 0:88e313c910d0 | 86 | * @} |
jhon309 | 0:88e313c910d0 | 87 | */ |
jhon309 | 0:88e313c910d0 | 88 | |
jhon309 | 0:88e313c910d0 | 89 | |
jhon309 | 0:88e313c910d0 | 90 | /** |
jhon309 | 0:88e313c910d0 | 91 | * @} |
jhon309 | 0:88e313c910d0 | 92 | */ |
jhon309 | 0:88e313c910d0 | 93 | |
jhon309 | 0:88e313c910d0 | 94 | /* Exported macros -----------------------------------------------------------*/ |
jhon309 | 0:88e313c910d0 | 95 | |
jhon309 | 0:88e313c910d0 | 96 | /** @defgroup IRDAEx_Exported_Macros IRDAEx Exported Macros |
jhon309 | 0:88e313c910d0 | 97 | * @{ |
jhon309 | 0:88e313c910d0 | 98 | */ |
jhon309 | 0:88e313c910d0 | 99 | |
jhon309 | 0:88e313c910d0 | 100 | /** @brief Reports the IRDA clock source. |
jhon309 | 0:88e313c910d0 | 101 | * @param __HANDLE__: specifies the IRDA Handle |
jhon309 | 0:88e313c910d0 | 102 | * @param __CLOCKSOURCE__ : output variable |
jhon309 | 0:88e313c910d0 | 103 | * @retval IRDA clocking source, written in __CLOCKSOURCE__. |
jhon309 | 0:88e313c910d0 | 104 | */ |
jhon309 | 0:88e313c910d0 | 105 | |
jhon309 | 0:88e313c910d0 | 106 | #if defined(STM32F031x6) || defined(STM32F038xx) |
jhon309 | 0:88e313c910d0 | 107 | #define __HAL_IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ |
jhon309 | 0:88e313c910d0 | 108 | do { \ |
jhon309 | 0:88e313c910d0 | 109 | switch(__HAL_RCC_GET_USART1_SOURCE()) \ |
jhon309 | 0:88e313c910d0 | 110 | { \ |
jhon309 | 0:88e313c910d0 | 111 | case RCC_USART1CLKSOURCE_PCLK1: \ |
jhon309 | 0:88e313c910d0 | 112 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 113 | break; \ |
jhon309 | 0:88e313c910d0 | 114 | case RCC_USART1CLKSOURCE_HSI: \ |
jhon309 | 0:88e313c910d0 | 115 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \ |
jhon309 | 0:88e313c910d0 | 116 | break; \ |
jhon309 | 0:88e313c910d0 | 117 | case RCC_USART1CLKSOURCE_SYSCLK: \ |
jhon309 | 0:88e313c910d0 | 118 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \ |
jhon309 | 0:88e313c910d0 | 119 | break; \ |
jhon309 | 0:88e313c910d0 | 120 | case RCC_USART1CLKSOURCE_LSE: \ |
jhon309 | 0:88e313c910d0 | 121 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \ |
jhon309 | 0:88e313c910d0 | 122 | break; \ |
jhon309 | 0:88e313c910d0 | 123 | default: \ |
jhon309 | 0:88e313c910d0 | 124 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \ |
jhon309 | 0:88e313c910d0 | 125 | break; \ |
jhon309 | 0:88e313c910d0 | 126 | } \ |
jhon309 | 0:88e313c910d0 | 127 | } while(0) |
jhon309 | 0:88e313c910d0 | 128 | #elif defined (STM32F042x6) || defined (STM32F048xx) || \ |
jhon309 | 0:88e313c910d0 | 129 | defined (STM32F051x8) || defined (STM32F058xx) |
jhon309 | 0:88e313c910d0 | 130 | #define __HAL_IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ |
jhon309 | 0:88e313c910d0 | 131 | do { \ |
jhon309 | 0:88e313c910d0 | 132 | if((__HANDLE__)->Instance == USART1) \ |
jhon309 | 0:88e313c910d0 | 133 | { \ |
jhon309 | 0:88e313c910d0 | 134 | switch(__HAL_RCC_GET_USART1_SOURCE()) \ |
jhon309 | 0:88e313c910d0 | 135 | { \ |
jhon309 | 0:88e313c910d0 | 136 | case RCC_USART1CLKSOURCE_PCLK1: \ |
jhon309 | 0:88e313c910d0 | 137 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 138 | break; \ |
jhon309 | 0:88e313c910d0 | 139 | case RCC_USART1CLKSOURCE_HSI: \ |
jhon309 | 0:88e313c910d0 | 140 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \ |
jhon309 | 0:88e313c910d0 | 141 | break; \ |
jhon309 | 0:88e313c910d0 | 142 | case RCC_USART1CLKSOURCE_SYSCLK: \ |
jhon309 | 0:88e313c910d0 | 143 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \ |
jhon309 | 0:88e313c910d0 | 144 | break; \ |
jhon309 | 0:88e313c910d0 | 145 | case RCC_USART1CLKSOURCE_LSE: \ |
jhon309 | 0:88e313c910d0 | 146 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \ |
jhon309 | 0:88e313c910d0 | 147 | break; \ |
jhon309 | 0:88e313c910d0 | 148 | default: \ |
jhon309 | 0:88e313c910d0 | 149 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \ |
jhon309 | 0:88e313c910d0 | 150 | break; \ |
jhon309 | 0:88e313c910d0 | 151 | } \ |
jhon309 | 0:88e313c910d0 | 152 | } \ |
jhon309 | 0:88e313c910d0 | 153 | else if((__HANDLE__)->Instance == USART2) \ |
jhon309 | 0:88e313c910d0 | 154 | { \ |
jhon309 | 0:88e313c910d0 | 155 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 156 | } \ |
jhon309 | 0:88e313c910d0 | 157 | else \ |
jhon309 | 0:88e313c910d0 | 158 | { \ |
jhon309 | 0:88e313c910d0 | 159 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \ |
jhon309 | 0:88e313c910d0 | 160 | } \ |
jhon309 | 0:88e313c910d0 | 161 | } while(0) |
jhon309 | 0:88e313c910d0 | 162 | #elif defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) |
jhon309 | 0:88e313c910d0 | 163 | #define __HAL_IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ |
jhon309 | 0:88e313c910d0 | 164 | do { \ |
jhon309 | 0:88e313c910d0 | 165 | if((__HANDLE__)->Instance == USART1) \ |
jhon309 | 0:88e313c910d0 | 166 | { \ |
jhon309 | 0:88e313c910d0 | 167 | switch(__HAL_RCC_GET_USART1_SOURCE()) \ |
jhon309 | 0:88e313c910d0 | 168 | { \ |
jhon309 | 0:88e313c910d0 | 169 | case RCC_USART1CLKSOURCE_PCLK1: \ |
jhon309 | 0:88e313c910d0 | 170 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 171 | break; \ |
jhon309 | 0:88e313c910d0 | 172 | case RCC_USART1CLKSOURCE_HSI: \ |
jhon309 | 0:88e313c910d0 | 173 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \ |
jhon309 | 0:88e313c910d0 | 174 | break; \ |
jhon309 | 0:88e313c910d0 | 175 | case RCC_USART1CLKSOURCE_SYSCLK: \ |
jhon309 | 0:88e313c910d0 | 176 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \ |
jhon309 | 0:88e313c910d0 | 177 | break; \ |
jhon309 | 0:88e313c910d0 | 178 | case RCC_USART1CLKSOURCE_LSE: \ |
jhon309 | 0:88e313c910d0 | 179 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \ |
jhon309 | 0:88e313c910d0 | 180 | break; \ |
jhon309 | 0:88e313c910d0 | 181 | default: \ |
jhon309 | 0:88e313c910d0 | 182 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \ |
jhon309 | 0:88e313c910d0 | 183 | break; \ |
jhon309 | 0:88e313c910d0 | 184 | } \ |
jhon309 | 0:88e313c910d0 | 185 | } \ |
jhon309 | 0:88e313c910d0 | 186 | else if((__HANDLE__)->Instance == USART2) \ |
jhon309 | 0:88e313c910d0 | 187 | { \ |
jhon309 | 0:88e313c910d0 | 188 | switch(__HAL_RCC_GET_USART2_SOURCE()) \ |
jhon309 | 0:88e313c910d0 | 189 | { \ |
jhon309 | 0:88e313c910d0 | 190 | case RCC_USART2CLKSOURCE_PCLK1: \ |
jhon309 | 0:88e313c910d0 | 191 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 192 | break; \ |
jhon309 | 0:88e313c910d0 | 193 | case RCC_USART2CLKSOURCE_HSI: \ |
jhon309 | 0:88e313c910d0 | 194 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \ |
jhon309 | 0:88e313c910d0 | 195 | break; \ |
jhon309 | 0:88e313c910d0 | 196 | case RCC_USART2CLKSOURCE_SYSCLK: \ |
jhon309 | 0:88e313c910d0 | 197 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \ |
jhon309 | 0:88e313c910d0 | 198 | break; \ |
jhon309 | 0:88e313c910d0 | 199 | case RCC_USART2CLKSOURCE_LSE: \ |
jhon309 | 0:88e313c910d0 | 200 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \ |
jhon309 | 0:88e313c910d0 | 201 | break; \ |
jhon309 | 0:88e313c910d0 | 202 | default: \ |
jhon309 | 0:88e313c910d0 | 203 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \ |
jhon309 | 0:88e313c910d0 | 204 | break; \ |
jhon309 | 0:88e313c910d0 | 205 | } \ |
jhon309 | 0:88e313c910d0 | 206 | } \ |
jhon309 | 0:88e313c910d0 | 207 | else if((__HANDLE__)->Instance == USART3) \ |
jhon309 | 0:88e313c910d0 | 208 | { \ |
jhon309 | 0:88e313c910d0 | 209 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 210 | } \ |
jhon309 | 0:88e313c910d0 | 211 | else if((__HANDLE__)->Instance == USART4) \ |
jhon309 | 0:88e313c910d0 | 212 | { \ |
jhon309 | 0:88e313c910d0 | 213 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 214 | } \ |
jhon309 | 0:88e313c910d0 | 215 | else \ |
jhon309 | 0:88e313c910d0 | 216 | { \ |
jhon309 | 0:88e313c910d0 | 217 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \ |
jhon309 | 0:88e313c910d0 | 218 | } \ |
jhon309 | 0:88e313c910d0 | 219 | } while(0) |
jhon309 | 0:88e313c910d0 | 220 | #elif defined(STM32F091xC) || defined(STM32F098xx) |
jhon309 | 0:88e313c910d0 | 221 | #define __HAL_IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ |
jhon309 | 0:88e313c910d0 | 222 | do { \ |
jhon309 | 0:88e313c910d0 | 223 | if((__HANDLE__)->Instance == USART1) \ |
jhon309 | 0:88e313c910d0 | 224 | { \ |
jhon309 | 0:88e313c910d0 | 225 | switch(__HAL_RCC_GET_USART1_SOURCE()) \ |
jhon309 | 0:88e313c910d0 | 226 | { \ |
jhon309 | 0:88e313c910d0 | 227 | case RCC_USART1CLKSOURCE_PCLK1: \ |
jhon309 | 0:88e313c910d0 | 228 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 229 | break; \ |
jhon309 | 0:88e313c910d0 | 230 | case RCC_USART1CLKSOURCE_HSI: \ |
jhon309 | 0:88e313c910d0 | 231 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \ |
jhon309 | 0:88e313c910d0 | 232 | break; \ |
jhon309 | 0:88e313c910d0 | 233 | case RCC_USART1CLKSOURCE_SYSCLK: \ |
jhon309 | 0:88e313c910d0 | 234 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \ |
jhon309 | 0:88e313c910d0 | 235 | break; \ |
jhon309 | 0:88e313c910d0 | 236 | case RCC_USART1CLKSOURCE_LSE: \ |
jhon309 | 0:88e313c910d0 | 237 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \ |
jhon309 | 0:88e313c910d0 | 238 | break; \ |
jhon309 | 0:88e313c910d0 | 239 | default: \ |
jhon309 | 0:88e313c910d0 | 240 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \ |
jhon309 | 0:88e313c910d0 | 241 | break; \ |
jhon309 | 0:88e313c910d0 | 242 | } \ |
jhon309 | 0:88e313c910d0 | 243 | } \ |
jhon309 | 0:88e313c910d0 | 244 | else if((__HANDLE__)->Instance == USART2) \ |
jhon309 | 0:88e313c910d0 | 245 | { \ |
jhon309 | 0:88e313c910d0 | 246 | switch(__HAL_RCC_GET_USART2_SOURCE()) \ |
jhon309 | 0:88e313c910d0 | 247 | { \ |
jhon309 | 0:88e313c910d0 | 248 | case RCC_USART2CLKSOURCE_PCLK1: \ |
jhon309 | 0:88e313c910d0 | 249 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 250 | break; \ |
jhon309 | 0:88e313c910d0 | 251 | case RCC_USART2CLKSOURCE_HSI: \ |
jhon309 | 0:88e313c910d0 | 252 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \ |
jhon309 | 0:88e313c910d0 | 253 | break; \ |
jhon309 | 0:88e313c910d0 | 254 | case RCC_USART2CLKSOURCE_SYSCLK: \ |
jhon309 | 0:88e313c910d0 | 255 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \ |
jhon309 | 0:88e313c910d0 | 256 | break; \ |
jhon309 | 0:88e313c910d0 | 257 | case RCC_USART2CLKSOURCE_LSE: \ |
jhon309 | 0:88e313c910d0 | 258 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \ |
jhon309 | 0:88e313c910d0 | 259 | break; \ |
jhon309 | 0:88e313c910d0 | 260 | default: \ |
jhon309 | 0:88e313c910d0 | 261 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \ |
jhon309 | 0:88e313c910d0 | 262 | break; \ |
jhon309 | 0:88e313c910d0 | 263 | } \ |
jhon309 | 0:88e313c910d0 | 264 | } \ |
jhon309 | 0:88e313c910d0 | 265 | else if((__HANDLE__)->Instance == USART3) \ |
jhon309 | 0:88e313c910d0 | 266 | { \ |
jhon309 | 0:88e313c910d0 | 267 | switch(__HAL_RCC_GET_USART3_SOURCE()) \ |
jhon309 | 0:88e313c910d0 | 268 | { \ |
jhon309 | 0:88e313c910d0 | 269 | case RCC_USART3CLKSOURCE_PCLK1: \ |
jhon309 | 0:88e313c910d0 | 270 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 271 | break; \ |
jhon309 | 0:88e313c910d0 | 272 | case RCC_USART3CLKSOURCE_HSI: \ |
jhon309 | 0:88e313c910d0 | 273 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \ |
jhon309 | 0:88e313c910d0 | 274 | break; \ |
jhon309 | 0:88e313c910d0 | 275 | case RCC_USART3CLKSOURCE_SYSCLK: \ |
jhon309 | 0:88e313c910d0 | 276 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \ |
jhon309 | 0:88e313c910d0 | 277 | break; \ |
jhon309 | 0:88e313c910d0 | 278 | case RCC_USART3CLKSOURCE_LSE: \ |
jhon309 | 0:88e313c910d0 | 279 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \ |
jhon309 | 0:88e313c910d0 | 280 | break; \ |
jhon309 | 0:88e313c910d0 | 281 | default: \ |
jhon309 | 0:88e313c910d0 | 282 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \ |
jhon309 | 0:88e313c910d0 | 283 | break; \ |
jhon309 | 0:88e313c910d0 | 284 | } \ |
jhon309 | 0:88e313c910d0 | 285 | } \ |
jhon309 | 0:88e313c910d0 | 286 | else if((__HANDLE__)->Instance == USART4) \ |
jhon309 | 0:88e313c910d0 | 287 | { \ |
jhon309 | 0:88e313c910d0 | 288 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 289 | } \ |
jhon309 | 0:88e313c910d0 | 290 | else if((__HANDLE__)->Instance == USART5) \ |
jhon309 | 0:88e313c910d0 | 291 | { \ |
jhon309 | 0:88e313c910d0 | 292 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 293 | } \ |
jhon309 | 0:88e313c910d0 | 294 | else if((__HANDLE__)->Instance == USART6) \ |
jhon309 | 0:88e313c910d0 | 295 | { \ |
jhon309 | 0:88e313c910d0 | 296 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 297 | } \ |
jhon309 | 0:88e313c910d0 | 298 | else if((__HANDLE__)->Instance == USART7) \ |
jhon309 | 0:88e313c910d0 | 299 | { \ |
jhon309 | 0:88e313c910d0 | 300 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 301 | } \ |
jhon309 | 0:88e313c910d0 | 302 | else if((__HANDLE__)->Instance == USART8) \ |
jhon309 | 0:88e313c910d0 | 303 | { \ |
jhon309 | 0:88e313c910d0 | 304 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1; \ |
jhon309 | 0:88e313c910d0 | 305 | } \ |
jhon309 | 0:88e313c910d0 | 306 | else \ |
jhon309 | 0:88e313c910d0 | 307 | { \ |
jhon309 | 0:88e313c910d0 | 308 | (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \ |
jhon309 | 0:88e313c910d0 | 309 | } \ |
jhon309 | 0:88e313c910d0 | 310 | } while(0) |
jhon309 | 0:88e313c910d0 | 311 | |
jhon309 | 0:88e313c910d0 | 312 | #endif /* defined(STM32F031x6) || defined(STM32F038xx) */ |
jhon309 | 0:88e313c910d0 | 313 | |
jhon309 | 0:88e313c910d0 | 314 | |
jhon309 | 0:88e313c910d0 | 315 | /** @brief Computes the mask to apply to retrieve the received data |
jhon309 | 0:88e313c910d0 | 316 | * according to the word length and to the parity bits activation. |
jhon309 | 0:88e313c910d0 | 317 | * @param __HANDLE__: specifies the IRDA Handle |
jhon309 | 0:88e313c910d0 | 318 | * @retval none |
jhon309 | 0:88e313c910d0 | 319 | */ |
jhon309 | 0:88e313c910d0 | 320 | #if defined (STM32F042x6) || defined (STM32F048xx) || \ |
jhon309 | 0:88e313c910d0 | 321 | defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \ |
jhon309 | 0:88e313c910d0 | 322 | defined (STM32F091xC) || defined (STM32F098xx) |
jhon309 | 0:88e313c910d0 | 323 | #define __HAL_IRDA_MASK_COMPUTATION(__HANDLE__) \ |
jhon309 | 0:88e313c910d0 | 324 | do { \ |
jhon309 | 0:88e313c910d0 | 325 | if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_9B) \ |
jhon309 | 0:88e313c910d0 | 326 | { \ |
jhon309 | 0:88e313c910d0 | 327 | if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \ |
jhon309 | 0:88e313c910d0 | 328 | { \ |
jhon309 | 0:88e313c910d0 | 329 | (__HANDLE__)->Mask = 0x01FF ; \ |
jhon309 | 0:88e313c910d0 | 330 | } \ |
jhon309 | 0:88e313c910d0 | 331 | else \ |
jhon309 | 0:88e313c910d0 | 332 | { \ |
jhon309 | 0:88e313c910d0 | 333 | (__HANDLE__)->Mask = 0x00FF ; \ |
jhon309 | 0:88e313c910d0 | 334 | } \ |
jhon309 | 0:88e313c910d0 | 335 | } \ |
jhon309 | 0:88e313c910d0 | 336 | else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_8B) \ |
jhon309 | 0:88e313c910d0 | 337 | { \ |
jhon309 | 0:88e313c910d0 | 338 | if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \ |
jhon309 | 0:88e313c910d0 | 339 | { \ |
jhon309 | 0:88e313c910d0 | 340 | (__HANDLE__)->Mask = 0x00FF ; \ |
jhon309 | 0:88e313c910d0 | 341 | } \ |
jhon309 | 0:88e313c910d0 | 342 | else \ |
jhon309 | 0:88e313c910d0 | 343 | { \ |
jhon309 | 0:88e313c910d0 | 344 | (__HANDLE__)->Mask = 0x007F ; \ |
jhon309 | 0:88e313c910d0 | 345 | } \ |
jhon309 | 0:88e313c910d0 | 346 | } \ |
jhon309 | 0:88e313c910d0 | 347 | else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_7B) \ |
jhon309 | 0:88e313c910d0 | 348 | { \ |
jhon309 | 0:88e313c910d0 | 349 | if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \ |
jhon309 | 0:88e313c910d0 | 350 | { \ |
jhon309 | 0:88e313c910d0 | 351 | (__HANDLE__)->Mask = 0x007F ; \ |
jhon309 | 0:88e313c910d0 | 352 | } \ |
jhon309 | 0:88e313c910d0 | 353 | else \ |
jhon309 | 0:88e313c910d0 | 354 | { \ |
jhon309 | 0:88e313c910d0 | 355 | (__HANDLE__)->Mask = 0x003F ; \ |
jhon309 | 0:88e313c910d0 | 356 | } \ |
jhon309 | 0:88e313c910d0 | 357 | } \ |
jhon309 | 0:88e313c910d0 | 358 | } while(0) |
jhon309 | 0:88e313c910d0 | 359 | #else |
jhon309 | 0:88e313c910d0 | 360 | #define __HAL_IRDA_MASK_COMPUTATION(__HANDLE__) \ |
jhon309 | 0:88e313c910d0 | 361 | do { \ |
jhon309 | 0:88e313c910d0 | 362 | if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_9B) \ |
jhon309 | 0:88e313c910d0 | 363 | { \ |
jhon309 | 0:88e313c910d0 | 364 | if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \ |
jhon309 | 0:88e313c910d0 | 365 | { \ |
jhon309 | 0:88e313c910d0 | 366 | (__HANDLE__)->Mask = 0x01FF ; \ |
jhon309 | 0:88e313c910d0 | 367 | } \ |
jhon309 | 0:88e313c910d0 | 368 | else \ |
jhon309 | 0:88e313c910d0 | 369 | { \ |
jhon309 | 0:88e313c910d0 | 370 | (__HANDLE__)->Mask = 0x00FF ; \ |
jhon309 | 0:88e313c910d0 | 371 | } \ |
jhon309 | 0:88e313c910d0 | 372 | } \ |
jhon309 | 0:88e313c910d0 | 373 | else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_8B) \ |
jhon309 | 0:88e313c910d0 | 374 | { \ |
jhon309 | 0:88e313c910d0 | 375 | if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \ |
jhon309 | 0:88e313c910d0 | 376 | { \ |
jhon309 | 0:88e313c910d0 | 377 | (__HANDLE__)->Mask = 0x00FF ; \ |
jhon309 | 0:88e313c910d0 | 378 | } \ |
jhon309 | 0:88e313c910d0 | 379 | else \ |
jhon309 | 0:88e313c910d0 | 380 | { \ |
jhon309 | 0:88e313c910d0 | 381 | (__HANDLE__)->Mask = 0x007F ; \ |
jhon309 | 0:88e313c910d0 | 382 | } \ |
jhon309 | 0:88e313c910d0 | 383 | } \ |
jhon309 | 0:88e313c910d0 | 384 | } while(0) |
jhon309 | 0:88e313c910d0 | 385 | #endif /* defined (STM32F042x6) || defined (STM32F048xx) || \ |
jhon309 | 0:88e313c910d0 | 386 | defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \ |
jhon309 | 0:88e313c910d0 | 387 | defined (STM32F091xC) || defined(STM32F098xx) */ |
jhon309 | 0:88e313c910d0 | 388 | /** |
jhon309 | 0:88e313c910d0 | 389 | * @} |
jhon309 | 0:88e313c910d0 | 390 | */ |
jhon309 | 0:88e313c910d0 | 391 | |
jhon309 | 0:88e313c910d0 | 392 | /* Exported functions --------------------------------------------------------*/ |
jhon309 | 0:88e313c910d0 | 393 | /* Initialization and de-initialization functions ****************************/ |
jhon309 | 0:88e313c910d0 | 394 | /* IO operation functions *****************************************************/ |
jhon309 | 0:88e313c910d0 | 395 | /* Peripheral Control functions ***********************************************/ |
jhon309 | 0:88e313c910d0 | 396 | /* Peripheral State and Error functions ***************************************/ |
jhon309 | 0:88e313c910d0 | 397 | |
jhon309 | 0:88e313c910d0 | 398 | /** |
jhon309 | 0:88e313c910d0 | 399 | * @} |
jhon309 | 0:88e313c910d0 | 400 | */ |
jhon309 | 0:88e313c910d0 | 401 | |
jhon309 | 0:88e313c910d0 | 402 | /** |
jhon309 | 0:88e313c910d0 | 403 | * @} |
jhon309 | 0:88e313c910d0 | 404 | */ |
jhon309 | 0:88e313c910d0 | 405 | |
jhon309 | 0:88e313c910d0 | 406 | #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */ |
jhon309 | 0:88e313c910d0 | 407 | |
jhon309 | 0:88e313c910d0 | 408 | #ifdef __cplusplus |
jhon309 | 0:88e313c910d0 | 409 | } |
jhon309 | 0:88e313c910d0 | 410 | #endif |
jhon309 | 0:88e313c910d0 | 411 | |
jhon309 | 0:88e313c910d0 | 412 | #endif /* __STM32F0xx_HAL_IRDA_EX_H */ |
jhon309 | 0:88e313c910d0 | 413 | |
jhon309 | 0:88e313c910d0 | 414 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
jhon309 | 0:88e313c910d0 | 415 |