TUKS MCU Introductory course / TUKS-COURSE-TIMER
Committer:
elmot
Date:
Fri Feb 24 21:13:56 2017 +0000
Revision:
1:d0dfbce63a89
Ready-to-copy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elmot 1:d0dfbce63a89 1 /**
elmot 1:d0dfbce63a89 2 ******************************************************************************
elmot 1:d0dfbce63a89 3 * @file stm32l4xx_hal_smartcard_ex.h
elmot 1:d0dfbce63a89 4 * @author MCD Application Team
elmot 1:d0dfbce63a89 5 * @version V1.5.1
elmot 1:d0dfbce63a89 6 * @date 31-May-2016
elmot 1:d0dfbce63a89 7 * @brief Header file of SMARTCARD HAL Extended module.
elmot 1:d0dfbce63a89 8 ******************************************************************************
elmot 1:d0dfbce63a89 9 * @attention
elmot 1:d0dfbce63a89 10 *
elmot 1:d0dfbce63a89 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
elmot 1:d0dfbce63a89 12 *
elmot 1:d0dfbce63a89 13 * Redistribution and use in source and binary forms, with or without modification,
elmot 1:d0dfbce63a89 14 * are permitted provided that the following conditions are met:
elmot 1:d0dfbce63a89 15 * 1. Redistributions of source code must retain the above copyright notice,
elmot 1:d0dfbce63a89 16 * this list of conditions and the following disclaimer.
elmot 1:d0dfbce63a89 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
elmot 1:d0dfbce63a89 18 * this list of conditions and the following disclaimer in the documentation
elmot 1:d0dfbce63a89 19 * and/or other materials provided with the distribution.
elmot 1:d0dfbce63a89 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
elmot 1:d0dfbce63a89 21 * may be used to endorse or promote products derived from this software
elmot 1:d0dfbce63a89 22 * without specific prior written permission.
elmot 1:d0dfbce63a89 23 *
elmot 1:d0dfbce63a89 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
elmot 1:d0dfbce63a89 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
elmot 1:d0dfbce63a89 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
elmot 1:d0dfbce63a89 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
elmot 1:d0dfbce63a89 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
elmot 1:d0dfbce63a89 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
elmot 1:d0dfbce63a89 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
elmot 1:d0dfbce63a89 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
elmot 1:d0dfbce63a89 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
elmot 1:d0dfbce63a89 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
elmot 1:d0dfbce63a89 34 *
elmot 1:d0dfbce63a89 35 ******************************************************************************
elmot 1:d0dfbce63a89 36 */
elmot 1:d0dfbce63a89 37
elmot 1:d0dfbce63a89 38 /* Define to prevent recursive inclusion -------------------------------------*/
elmot 1:d0dfbce63a89 39 #ifndef __STM32L4xx_HAL_SMARTCARD_EX_H
elmot 1:d0dfbce63a89 40 #define __STM32L4xx_HAL_SMARTCARD_EX_H
elmot 1:d0dfbce63a89 41
elmot 1:d0dfbce63a89 42 #ifdef __cplusplus
elmot 1:d0dfbce63a89 43 extern "C" {
elmot 1:d0dfbce63a89 44 #endif
elmot 1:d0dfbce63a89 45
elmot 1:d0dfbce63a89 46 /* Includes ------------------------------------------------------------------*/
elmot 1:d0dfbce63a89 47 #include "stm32l4xx_hal_def.h"
elmot 1:d0dfbce63a89 48
elmot 1:d0dfbce63a89 49 /** @addtogroup STM32L4xx_HAL_Driver
elmot 1:d0dfbce63a89 50 * @{
elmot 1:d0dfbce63a89 51 */
elmot 1:d0dfbce63a89 52
elmot 1:d0dfbce63a89 53 /** @addtogroup SMARTCARDEx
elmot 1:d0dfbce63a89 54 * @{
elmot 1:d0dfbce63a89 55 */
elmot 1:d0dfbce63a89 56
elmot 1:d0dfbce63a89 57 /* Exported types ------------------------------------------------------------*/
elmot 1:d0dfbce63a89 58 /* Exported constants --------------------------------------------------------*/
elmot 1:d0dfbce63a89 59
elmot 1:d0dfbce63a89 60 /** @addtogroup SMARTCARDEx_Exported_Constants SMARTCARD Extended Exported Constants
elmot 1:d0dfbce63a89 61 * @{
elmot 1:d0dfbce63a89 62 */
elmot 1:d0dfbce63a89 63
elmot 1:d0dfbce63a89 64 /** @defgroup SMARTCARDEx_Transmission_Completion_Indication SMARTCARD Transmission Completion Indication
elmot 1:d0dfbce63a89 65 * @{
elmot 1:d0dfbce63a89 66 */
elmot 1:d0dfbce63a89 67 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
elmot 1:d0dfbce63a89 68 #define SMARTCARD_TCBGT SMARTCARD_IT_TCBGT /*!< SMARTCARD transmission complete before guard time */
elmot 1:d0dfbce63a89 69 #endif /* defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) */
elmot 1:d0dfbce63a89 70 #define SMARTCARD_TC SMARTCARD_IT_TC /*!< SMARTCARD transmission complete (flag raised when guard time has elapsed) */
elmot 1:d0dfbce63a89 71 /**
elmot 1:d0dfbce63a89 72 * @}
elmot 1:d0dfbce63a89 73 */
elmot 1:d0dfbce63a89 74
elmot 1:d0dfbce63a89 75 /** @defgroup SMARTCARDEx_Advanced_Features_Initialization_Type SMARTCARD advanced feature initialization type
elmot 1:d0dfbce63a89 76 * @{
elmot 1:d0dfbce63a89 77 */
elmot 1:d0dfbce63a89 78 #define SMARTCARD_ADVFEATURE_NO_INIT ((uint32_t)0x00000000) /*!< No advanced feature initialization */
elmot 1:d0dfbce63a89 79 #define SMARTCARD_ADVFEATURE_TXINVERT_INIT ((uint32_t)0x00000001) /*!< TX pin active level inversion */
elmot 1:d0dfbce63a89 80 #define SMARTCARD_ADVFEATURE_RXINVERT_INIT ((uint32_t)0x00000002) /*!< RX pin active level inversion */
elmot 1:d0dfbce63a89 81 #define SMARTCARD_ADVFEATURE_DATAINVERT_INIT ((uint32_t)0x00000004) /*!< Binary data inversion */
elmot 1:d0dfbce63a89 82 #define SMARTCARD_ADVFEATURE_SWAP_INIT ((uint32_t)0x00000008) /*!< TX/RX pins swap */
elmot 1:d0dfbce63a89 83 #define SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT ((uint32_t)0x00000010) /*!< RX overrun disable */
elmot 1:d0dfbce63a89 84 #define SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT ((uint32_t)0x00000020) /*!< DMA disable on Reception Error */
elmot 1:d0dfbce63a89 85 #define SMARTCARD_ADVFEATURE_MSBFIRST_INIT ((uint32_t)0x00000080) /*!< Most significant bit sent/received first */
elmot 1:d0dfbce63a89 86 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
elmot 1:d0dfbce63a89 87 #define SMARTCARD_ADVFEATURE_TXCOMPLETION ((uint32_t)0x00000100) /*!< TX completion indication before of after guard time */
elmot 1:d0dfbce63a89 88 #endif /* defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) */
elmot 1:d0dfbce63a89 89 /**
elmot 1:d0dfbce63a89 90 * @}
elmot 1:d0dfbce63a89 91 */
elmot 1:d0dfbce63a89 92
elmot 1:d0dfbce63a89 93
elmot 1:d0dfbce63a89 94
elmot 1:d0dfbce63a89 95
elmot 1:d0dfbce63a89 96 /** @defgroup SMARTCARDEx_Flags SMARTCARD Flags
elmot 1:d0dfbce63a89 97 * Elements values convention: 0xXXXX
elmot 1:d0dfbce63a89 98 * - 0xXXXX : Flag mask in the ISR register
elmot 1:d0dfbce63a89 99 * @{
elmot 1:d0dfbce63a89 100 */
elmot 1:d0dfbce63a89 101 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
elmot 1:d0dfbce63a89 102 #define SMARTCARD_FLAG_TCBGT USART_ISR_TCBGT /*!< SMARTCARD transmission complete before guard time completion */
elmot 1:d0dfbce63a89 103 #endif /* defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) */
elmot 1:d0dfbce63a89 104 #define SMARTCARD_FLAG_REACK USART_ISR_REACK /*!< SMARTCARD receive enable acknowledge flag */
elmot 1:d0dfbce63a89 105 #define SMARTCARD_FLAG_TEACK USART_ISR_TEACK /*!< SMARTCARD transmit enable acknowledge flag */
elmot 1:d0dfbce63a89 106 #define SMARTCARD_FLAG_BUSY USART_ISR_BUSY /*!< SMARTCARD busy flag */
elmot 1:d0dfbce63a89 107 #define SMARTCARD_FLAG_EOBF USART_ISR_EOBF /*!< SMARTCARD end of block flag */
elmot 1:d0dfbce63a89 108 #define SMARTCARD_FLAG_RTOF USART_ISR_RTOF /*!< SMARTCARD receiver timeout flag */
elmot 1:d0dfbce63a89 109 #define SMARTCARD_FLAG_TXE USART_ISR_TXE /*!< SMARTCARD transmit data register empty */
elmot 1:d0dfbce63a89 110 #define SMARTCARD_FLAG_TC USART_ISR_TC /*!< SMARTCARD transmission complete */
elmot 1:d0dfbce63a89 111 #define SMARTCARD_FLAG_RXNE USART_ISR_RXNE /*!< SMARTCARD read data register not empty */
elmot 1:d0dfbce63a89 112 #define SMARTCARD_FLAG_IDLE USART_ISR_IDLE /*!< SMARTCARD idle line detection */
elmot 1:d0dfbce63a89 113 #define SMARTCARD_FLAG_ORE USART_ISR_ORE /*!< SMARTCARD overrun error */
elmot 1:d0dfbce63a89 114 #define SMARTCARD_FLAG_NE USART_ISR_NE /*!< SMARTCARD noise error */
elmot 1:d0dfbce63a89 115 #define SMARTCARD_FLAG_FE USART_ISR_FE /*!< SMARTCARD frame error */
elmot 1:d0dfbce63a89 116 #define SMARTCARD_FLAG_PE USART_ISR_PE /*!< SMARTCARD parity error */
elmot 1:d0dfbce63a89 117 /**
elmot 1:d0dfbce63a89 118 * @}
elmot 1:d0dfbce63a89 119 */
elmot 1:d0dfbce63a89 120
elmot 1:d0dfbce63a89 121 /** @defgroup SMARTCARDEx_Interrupt_definition SMARTCARD Interrupts Definition
elmot 1:d0dfbce63a89 122 * Elements values convention: 000ZZZZZ0XXYYYYYb
elmot 1:d0dfbce63a89 123 * - YYYYY : Interrupt source position in the XX register (5 bits)
elmot 1:d0dfbce63a89 124 * - XX : Interrupt source register (2 bits)
elmot 1:d0dfbce63a89 125 * - 01: CR1 register
elmot 1:d0dfbce63a89 126 * - 10: CR2 register
elmot 1:d0dfbce63a89 127 * - 11: CR3 register
elmot 1:d0dfbce63a89 128 * - ZZZZZ : Flag position in the ISR register(5 bits)
elmot 1:d0dfbce63a89 129 * @{
elmot 1:d0dfbce63a89 130 */
elmot 1:d0dfbce63a89 131 #define SMARTCARD_IT_PE ((uint16_t)0x0028) /*!< SMARTCARD parity error interruption */
elmot 1:d0dfbce63a89 132 #define SMARTCARD_IT_TXE ((uint16_t)0x0727) /*!< SMARTCARD transmit data register empty interruption */
elmot 1:d0dfbce63a89 133 #define SMARTCARD_IT_TC ((uint16_t)0x0626) /*!< SMARTCARD transmission complete interruption */
elmot 1:d0dfbce63a89 134 #define SMARTCARD_IT_RXNE ((uint16_t)0x0525) /*!< SMARTCARD read data register not empty interruption */
elmot 1:d0dfbce63a89 135 #define SMARTCARD_IT_IDLE ((uint16_t)0x0424) /*!< SMARTCARD idle line detection interruption */
elmot 1:d0dfbce63a89 136
elmot 1:d0dfbce63a89 137 #define SMARTCARD_IT_ERR ((uint16_t)0x0060) /*!< SMARTCARD error interruption */
elmot 1:d0dfbce63a89 138 #define SMARTCARD_IT_ORE ((uint16_t)0x0300) /*!< SMARTCARD overrun error interruption */
elmot 1:d0dfbce63a89 139 #define SMARTCARD_IT_NE ((uint16_t)0x0200) /*!< SMARTCARD noise error interruption */
elmot 1:d0dfbce63a89 140 #define SMARTCARD_IT_FE ((uint16_t)0x0100) /*!< SMARTCARD frame error interruption */
elmot 1:d0dfbce63a89 141
elmot 1:d0dfbce63a89 142 #define SMARTCARD_IT_EOB ((uint16_t)0x0C3B) /*!< SMARTCARD end of block interruption */
elmot 1:d0dfbce63a89 143 #define SMARTCARD_IT_RTO ((uint16_t)0x0B3A) /*!< SMARTCARD receiver timeout interruption */
elmot 1:d0dfbce63a89 144
elmot 1:d0dfbce63a89 145 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
elmot 1:d0dfbce63a89 146 #define SMARTCARD_IT_TCBGT ((uint16_t)0x1978) /*!< SMARTCARD transmission complete before guard time completion interruption */
elmot 1:d0dfbce63a89 147 #endif /* defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) */
elmot 1:d0dfbce63a89 148 /**
elmot 1:d0dfbce63a89 149 * @}
elmot 1:d0dfbce63a89 150 */
elmot 1:d0dfbce63a89 151
elmot 1:d0dfbce63a89 152 /** @defgroup SMARTCARDEx_IT_CLEAR_Flags SMARTCARD Interruption Clear Flags
elmot 1:d0dfbce63a89 153 * @{
elmot 1:d0dfbce63a89 154 */
elmot 1:d0dfbce63a89 155 #define SMARTCARD_CLEAR_PEF USART_ICR_PECF /*!< SMARTCARD parity error clear flag */
elmot 1:d0dfbce63a89 156 #define SMARTCARD_CLEAR_FEF USART_ICR_FECF /*!< SMARTCARD framing error clear flag */
elmot 1:d0dfbce63a89 157 #define SMARTCARD_CLEAR_NEF USART_ICR_NCF /*!< SMARTCARD noise detected clear flag */
elmot 1:d0dfbce63a89 158 #define SMARTCARD_CLEAR_OREF USART_ICR_ORECF /*!< SMARTCARD overrun error clear flag */
elmot 1:d0dfbce63a89 159 #define SMARTCARD_CLEAR_IDLEF USART_ICR_IDLECF /*!< SMARTCARD idle line detected clear flag */
elmot 1:d0dfbce63a89 160 #define SMARTCARD_CLEAR_TCF USART_ICR_TCCF /*!< SMARTCARD transmission complete clear flag */
elmot 1:d0dfbce63a89 161 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
elmot 1:d0dfbce63a89 162 #define SMARTCARD_CLEAR_TCBGTF USART_ICR_TCBGTCF /*!< SMARTCARD transmission complete before guard time completion clear flag */
elmot 1:d0dfbce63a89 163 #endif /* defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) */
elmot 1:d0dfbce63a89 164 #define SMARTCARD_CLEAR_RTOF USART_ICR_RTOCF /*!< SMARTCARD receiver time out clear flag */
elmot 1:d0dfbce63a89 165 #define SMARTCARD_CLEAR_EOBF USART_ICR_EOBCF /*!< SMARTCARD end of block clear flag */
elmot 1:d0dfbce63a89 166 /**
elmot 1:d0dfbce63a89 167 * @}
elmot 1:d0dfbce63a89 168 */
elmot 1:d0dfbce63a89 169
elmot 1:d0dfbce63a89 170 /**
elmot 1:d0dfbce63a89 171 * @}
elmot 1:d0dfbce63a89 172 */
elmot 1:d0dfbce63a89 173 /* Exported macros -----------------------------------------------------------*/
elmot 1:d0dfbce63a89 174 /* Private macros ------------------------------------------------------------*/
elmot 1:d0dfbce63a89 175 /** @defgroup SMARTCARDEx_Private_Macros SMARTCARD Extended Private Macros
elmot 1:d0dfbce63a89 176 * @{
elmot 1:d0dfbce63a89 177 */
elmot 1:d0dfbce63a89 178
elmot 1:d0dfbce63a89 179 /** @brief Report the SMARTCARD clock source.
elmot 1:d0dfbce63a89 180 * @param __HANDLE__: specifies the SMARTCARD Handle.
elmot 1:d0dfbce63a89 181 * @param __CLOCKSOURCE__: output variable.
elmot 1:d0dfbce63a89 182 * @retval the SMARTCARD clocking source, written in __CLOCKSOURCE__.
elmot 1:d0dfbce63a89 183 */
elmot 1:d0dfbce63a89 184 #if defined (STM32L432xx) || defined (STM32L442xx)
elmot 1:d0dfbce63a89 185 #define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
elmot 1:d0dfbce63a89 186 do { \
elmot 1:d0dfbce63a89 187 if((__HANDLE__)->Instance == USART1) \
elmot 1:d0dfbce63a89 188 { \
elmot 1:d0dfbce63a89 189 switch(__HAL_RCC_GET_USART1_SOURCE()) \
elmot 1:d0dfbce63a89 190 { \
elmot 1:d0dfbce63a89 191 case RCC_USART1CLKSOURCE_PCLK2: \
elmot 1:d0dfbce63a89 192 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK2; \
elmot 1:d0dfbce63a89 193 break; \
elmot 1:d0dfbce63a89 194 case RCC_USART1CLKSOURCE_HSI: \
elmot 1:d0dfbce63a89 195 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
elmot 1:d0dfbce63a89 196 break; \
elmot 1:d0dfbce63a89 197 case RCC_USART1CLKSOURCE_SYSCLK: \
elmot 1:d0dfbce63a89 198 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
elmot 1:d0dfbce63a89 199 break; \
elmot 1:d0dfbce63a89 200 case RCC_USART1CLKSOURCE_LSE: \
elmot 1:d0dfbce63a89 201 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
elmot 1:d0dfbce63a89 202 break; \
elmot 1:d0dfbce63a89 203 default: \
elmot 1:d0dfbce63a89 204 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
elmot 1:d0dfbce63a89 205 break; \
elmot 1:d0dfbce63a89 206 } \
elmot 1:d0dfbce63a89 207 } \
elmot 1:d0dfbce63a89 208 else if((__HANDLE__)->Instance == USART2) \
elmot 1:d0dfbce63a89 209 { \
elmot 1:d0dfbce63a89 210 switch(__HAL_RCC_GET_USART2_SOURCE()) \
elmot 1:d0dfbce63a89 211 { \
elmot 1:d0dfbce63a89 212 case RCC_USART2CLKSOURCE_PCLK1: \
elmot 1:d0dfbce63a89 213 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
elmot 1:d0dfbce63a89 214 break; \
elmot 1:d0dfbce63a89 215 case RCC_USART2CLKSOURCE_HSI: \
elmot 1:d0dfbce63a89 216 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
elmot 1:d0dfbce63a89 217 break; \
elmot 1:d0dfbce63a89 218 case RCC_USART2CLKSOURCE_SYSCLK: \
elmot 1:d0dfbce63a89 219 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
elmot 1:d0dfbce63a89 220 break; \
elmot 1:d0dfbce63a89 221 case RCC_USART2CLKSOURCE_LSE: \
elmot 1:d0dfbce63a89 222 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
elmot 1:d0dfbce63a89 223 break; \
elmot 1:d0dfbce63a89 224 default: \
elmot 1:d0dfbce63a89 225 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
elmot 1:d0dfbce63a89 226 break; \
elmot 1:d0dfbce63a89 227 } \
elmot 1:d0dfbce63a89 228 } \
elmot 1:d0dfbce63a89 229 } while(0)
elmot 1:d0dfbce63a89 230 #else
elmot 1:d0dfbce63a89 231 #define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
elmot 1:d0dfbce63a89 232 do { \
elmot 1:d0dfbce63a89 233 if((__HANDLE__)->Instance == USART1) \
elmot 1:d0dfbce63a89 234 { \
elmot 1:d0dfbce63a89 235 switch(__HAL_RCC_GET_USART1_SOURCE()) \
elmot 1:d0dfbce63a89 236 { \
elmot 1:d0dfbce63a89 237 case RCC_USART1CLKSOURCE_PCLK2: \
elmot 1:d0dfbce63a89 238 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK2; \
elmot 1:d0dfbce63a89 239 break; \
elmot 1:d0dfbce63a89 240 case RCC_USART1CLKSOURCE_HSI: \
elmot 1:d0dfbce63a89 241 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
elmot 1:d0dfbce63a89 242 break; \
elmot 1:d0dfbce63a89 243 case RCC_USART1CLKSOURCE_SYSCLK: \
elmot 1:d0dfbce63a89 244 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
elmot 1:d0dfbce63a89 245 break; \
elmot 1:d0dfbce63a89 246 case RCC_USART1CLKSOURCE_LSE: \
elmot 1:d0dfbce63a89 247 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
elmot 1:d0dfbce63a89 248 break; \
elmot 1:d0dfbce63a89 249 default: \
elmot 1:d0dfbce63a89 250 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
elmot 1:d0dfbce63a89 251 break; \
elmot 1:d0dfbce63a89 252 } \
elmot 1:d0dfbce63a89 253 } \
elmot 1:d0dfbce63a89 254 else if((__HANDLE__)->Instance == USART2) \
elmot 1:d0dfbce63a89 255 { \
elmot 1:d0dfbce63a89 256 switch(__HAL_RCC_GET_USART2_SOURCE()) \
elmot 1:d0dfbce63a89 257 { \
elmot 1:d0dfbce63a89 258 case RCC_USART2CLKSOURCE_PCLK1: \
elmot 1:d0dfbce63a89 259 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
elmot 1:d0dfbce63a89 260 break; \
elmot 1:d0dfbce63a89 261 case RCC_USART2CLKSOURCE_HSI: \
elmot 1:d0dfbce63a89 262 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
elmot 1:d0dfbce63a89 263 break; \
elmot 1:d0dfbce63a89 264 case RCC_USART2CLKSOURCE_SYSCLK: \
elmot 1:d0dfbce63a89 265 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
elmot 1:d0dfbce63a89 266 break; \
elmot 1:d0dfbce63a89 267 case RCC_USART2CLKSOURCE_LSE: \
elmot 1:d0dfbce63a89 268 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
elmot 1:d0dfbce63a89 269 break; \
elmot 1:d0dfbce63a89 270 default: \
elmot 1:d0dfbce63a89 271 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
elmot 1:d0dfbce63a89 272 break; \
elmot 1:d0dfbce63a89 273 } \
elmot 1:d0dfbce63a89 274 } \
elmot 1:d0dfbce63a89 275 else if((__HANDLE__)->Instance == USART3) \
elmot 1:d0dfbce63a89 276 { \
elmot 1:d0dfbce63a89 277 switch(__HAL_RCC_GET_USART3_SOURCE()) \
elmot 1:d0dfbce63a89 278 { \
elmot 1:d0dfbce63a89 279 case RCC_USART3CLKSOURCE_PCLK1: \
elmot 1:d0dfbce63a89 280 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
elmot 1:d0dfbce63a89 281 break; \
elmot 1:d0dfbce63a89 282 case RCC_USART3CLKSOURCE_HSI: \
elmot 1:d0dfbce63a89 283 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
elmot 1:d0dfbce63a89 284 break; \
elmot 1:d0dfbce63a89 285 case RCC_USART3CLKSOURCE_SYSCLK: \
elmot 1:d0dfbce63a89 286 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
elmot 1:d0dfbce63a89 287 break; \
elmot 1:d0dfbce63a89 288 case RCC_USART3CLKSOURCE_LSE: \
elmot 1:d0dfbce63a89 289 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
elmot 1:d0dfbce63a89 290 break; \
elmot 1:d0dfbce63a89 291 default: \
elmot 1:d0dfbce63a89 292 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
elmot 1:d0dfbce63a89 293 break; \
elmot 1:d0dfbce63a89 294 } \
elmot 1:d0dfbce63a89 295 } \
elmot 1:d0dfbce63a89 296 } while(0)
elmot 1:d0dfbce63a89 297 #endif /* STM32L432xx || STM32L442xx */
elmot 1:d0dfbce63a89 298
elmot 1:d0dfbce63a89 299 /** @brief Set the Transmission Completion flag
elmot 1:d0dfbce63a89 300 * @param __HANDLE__: specifies the SMARTCARD Handle.
elmot 1:d0dfbce63a89 301 * @note If TCBGT (Transmission Complete Before Guard Time) flag is not available or if
elmot 1:d0dfbce63a89 302 * AdvancedInit.TxCompletionIndication is not already filled, the latter is forced
elmot 1:d0dfbce63a89 303 * to SMARTCARD_TC (transmission completion indication when guard time has elapsed).
elmot 1:d0dfbce63a89 304 * @retval None
elmot 1:d0dfbce63a89 305 */
elmot 1:d0dfbce63a89 306 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
elmot 1:d0dfbce63a89 307 #define SMARTCARD_TRANSMISSION_COMPLETION_SETTING(__HANDLE__) \
elmot 1:d0dfbce63a89 308 do { \
elmot 1:d0dfbce63a89 309 (__HANDLE__)->AdvancedInit.TxCompletionIndication = SMARTCARD_TC; \
elmot 1:d0dfbce63a89 310 } while(0)
elmot 1:d0dfbce63a89 311 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
elmot 1:d0dfbce63a89 312 #define SMARTCARD_TRANSMISSION_COMPLETION_SETTING(__HANDLE__) \
elmot 1:d0dfbce63a89 313 do { \
elmot 1:d0dfbce63a89 314 if (HAL_IS_BIT_CLR((__HANDLE__)->AdvancedInit.AdvFeatureInit, SMARTCARD_ADVFEATURE_TXCOMPLETION)) \
elmot 1:d0dfbce63a89 315 { \
elmot 1:d0dfbce63a89 316 (__HANDLE__)->AdvancedInit.TxCompletionIndication = SMARTCARD_TC; \
elmot 1:d0dfbce63a89 317 } \
elmot 1:d0dfbce63a89 318 else \
elmot 1:d0dfbce63a89 319 { \
elmot 1:d0dfbce63a89 320 assert_param(IS_SMARTCARD_TRANSMISSION_COMPLETION((__HANDLE__)->AdvancedInit.TxCompletionIndication)); \
elmot 1:d0dfbce63a89 321 } \
elmot 1:d0dfbce63a89 322 } while(0)
elmot 1:d0dfbce63a89 323 #endif
elmot 1:d0dfbce63a89 324
elmot 1:d0dfbce63a89 325 /** @brief Return the transmission completion flag.
elmot 1:d0dfbce63a89 326 * @param __HANDLE__: specifies the SMARTCARD Handle.
elmot 1:d0dfbce63a89 327 * @note Based on AdvancedInit.TxCompletionIndication setting, return TC or TCBGT flag.
elmot 1:d0dfbce63a89 328 * When TCBGT flag (Transmission Complete Before Guard Time) is not available, TC flag is
elmot 1:d0dfbce63a89 329 * reported.
elmot 1:d0dfbce63a89 330 * @retval Transmission completion flag
elmot 1:d0dfbce63a89 331 */
elmot 1:d0dfbce63a89 332 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
elmot 1:d0dfbce63a89 333 #define SMARTCARD_TRANSMISSION_COMPLETION_FLAG(__HANDLE__) (SMARTCARD_FLAG_TC)
elmot 1:d0dfbce63a89 334 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
elmot 1:d0dfbce63a89 335 #define SMARTCARD_TRANSMISSION_COMPLETION_FLAG(__HANDLE__) \
elmot 1:d0dfbce63a89 336 (((__HANDLE__)->AdvancedInit.TxCompletionIndication == SMARTCARD_TC) ? (SMARTCARD_FLAG_TC) : (SMARTCARD_FLAG_TCBGT))
elmot 1:d0dfbce63a89 337 #endif
elmot 1:d0dfbce63a89 338
elmot 1:d0dfbce63a89 339
elmot 1:d0dfbce63a89 340 /**
elmot 1:d0dfbce63a89 341 * @brief Ensure that SMARTCARD frame transmission completion used flag is valid.
elmot 1:d0dfbce63a89 342 * @param __TXCOMPLETE__: SMARTCARD frame transmission completion used flag.
elmot 1:d0dfbce63a89 343 * @retval SET (__TXCOMPLETE__ is valid) or RESET (__TXCOMPLETE__ is invalid)
elmot 1:d0dfbce63a89 344 */
elmot 1:d0dfbce63a89 345 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
elmot 1:d0dfbce63a89 346 #define IS_SMARTCARD_TRANSMISSION_COMPLETION(__TXCOMPLETE__) ((__TXCOMPLETE__) == SMARTCARD_TC)
elmot 1:d0dfbce63a89 347 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
elmot 1:d0dfbce63a89 348 #define IS_SMARTCARD_TRANSMISSION_COMPLETION(__TXCOMPLETE__) (((__TXCOMPLETE__) == SMARTCARD_TCBGT) ||\
elmot 1:d0dfbce63a89 349 ((__TXCOMPLETE__) == SMARTCARD_TC))
elmot 1:d0dfbce63a89 350 #endif
elmot 1:d0dfbce63a89 351
elmot 1:d0dfbce63a89 352 /**
elmot 1:d0dfbce63a89 353 * @}
elmot 1:d0dfbce63a89 354 */
elmot 1:d0dfbce63a89 355
elmot 1:d0dfbce63a89 356 /* Exported functions --------------------------------------------------------*/
elmot 1:d0dfbce63a89 357 /** @addtogroup SMARTCARDEx_Exported_Functions
elmot 1:d0dfbce63a89 358 * @{
elmot 1:d0dfbce63a89 359 */
elmot 1:d0dfbce63a89 360
elmot 1:d0dfbce63a89 361 /* Initialization and de-initialization functions ****************************/
elmot 1:d0dfbce63a89 362 /* IO operation methods *******************************************************/
elmot 1:d0dfbce63a89 363
elmot 1:d0dfbce63a89 364 /** @addtogroup SMARTCARDEx_Exported_Functions_Group1
elmot 1:d0dfbce63a89 365 * @{
elmot 1:d0dfbce63a89 366 */
elmot 1:d0dfbce63a89 367
elmot 1:d0dfbce63a89 368 /* Peripheral Control functions ***********************************************/
elmot 1:d0dfbce63a89 369 void HAL_SMARTCARDEx_BlockLength_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t BlockLength);
elmot 1:d0dfbce63a89 370 void HAL_SMARTCARDEx_TimeOut_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint32_t TimeOutValue);
elmot 1:d0dfbce63a89 371 HAL_StatusTypeDef HAL_SMARTCARDEx_EnableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard);
elmot 1:d0dfbce63a89 372 HAL_StatusTypeDef HAL_SMARTCARDEx_DisableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard);
elmot 1:d0dfbce63a89 373
elmot 1:d0dfbce63a89 374 /**
elmot 1:d0dfbce63a89 375 * @}
elmot 1:d0dfbce63a89 376 */
elmot 1:d0dfbce63a89 377
elmot 1:d0dfbce63a89 378 /**
elmot 1:d0dfbce63a89 379 * @}
elmot 1:d0dfbce63a89 380 */
elmot 1:d0dfbce63a89 381
elmot 1:d0dfbce63a89 382
elmot 1:d0dfbce63a89 383 /* Private functions ---------------------------------------------------------*/
elmot 1:d0dfbce63a89 384
elmot 1:d0dfbce63a89 385 /**
elmot 1:d0dfbce63a89 386 * @}
elmot 1:d0dfbce63a89 387 */
elmot 1:d0dfbce63a89 388
elmot 1:d0dfbce63a89 389 /**
elmot 1:d0dfbce63a89 390 * @}
elmot 1:d0dfbce63a89 391 */
elmot 1:d0dfbce63a89 392
elmot 1:d0dfbce63a89 393 #ifdef __cplusplus
elmot 1:d0dfbce63a89 394 }
elmot 1:d0dfbce63a89 395 #endif
elmot 1:d0dfbce63a89 396
elmot 1:d0dfbce63a89 397 #endif /* __STM32L4xx_HAL_SMARTCARD_EX_H */
elmot 1:d0dfbce63a89 398
elmot 1:d0dfbce63a89 399 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/