The official mbed C/C SDK provides the software platform and libraries to build your applications.

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Thu Nov 27 13:33:22 2014 +0000
Revision:
92:4fc01daae5a5
Parent:
86:04dd9b1680ae
Release 92 of the mbed libray

Main changes:

- nRF51822: fixed pin assignment issues
- ST targets moving to the STM32Cube driver
- LPC1439: fixed serial interrupt issue
- first Cortex-A platform supported in mbed (RZ_A1H)

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_smartcard.h
bogdanm 86:04dd9b1680ae 4 * @author MCD Application Team
bogdanm 92:4fc01daae5a5 5 * @version V1.1.0
bogdanm 92:4fc01daae5a5 6 * @date 12-Sept-2014
bogdanm 86:04dd9b1680ae 7 * @brief Header file of SMARTCARD HAL module.
bogdanm 86:04dd9b1680ae 8 ******************************************************************************
bogdanm 86:04dd9b1680ae 9 * @attention
bogdanm 86:04dd9b1680ae 10 *
bogdanm 86:04dd9b1680ae 11 * <h2><center>&copy; COPYRIGHT(c) 2014 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 *
bogdanm 86:04dd9b1680ae 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_SMARTCARD_H
bogdanm 86:04dd9b1680ae 40 #define __STM32F3xx_HAL_SMARTCARD_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
bogdanm 86:04dd9b1680ae 53 /** @addtogroup SMARTCARD
bogdanm 86:04dd9b1680ae 54 * @{
bogdanm 86:04dd9b1680ae 55 */
bogdanm 86:04dd9b1680ae 56
bogdanm 86:04dd9b1680ae 57 /* Exported types ------------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 58 /** @defgroup SMARTCARD_Exported_Types SMARTCARD Exported Types
bogdanm 92:4fc01daae5a5 59 * @{
bogdanm 92:4fc01daae5a5 60 */
bogdanm 92:4fc01daae5a5 61
bogdanm 86:04dd9b1680ae 62 /**
bogdanm 86:04dd9b1680ae 63 * @brief SMARTCARD Init Structure definition
bogdanm 86:04dd9b1680ae 64 */
bogdanm 86:04dd9b1680ae 65 typedef struct
bogdanm 86:04dd9b1680ae 66 {
bogdanm 86:04dd9b1680ae 67 uint32_t BaudRate; /*!< Configures the SmartCard communication baud rate.
bogdanm 86:04dd9b1680ae 68 The baud rate register is computed using the following formula:
bogdanm 86:04dd9b1680ae 69 Baud Rate Register = ((PCLKx) / ((hsmartcard->Init.BaudRate))) */
bogdanm 86:04dd9b1680ae 70
bogdanm 86:04dd9b1680ae 71 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
bogdanm 86:04dd9b1680ae 72 This parameter @ref SMARTCARD_Word_Length can only be set to 9 (8 data + 1 parity bits). */
bogdanm 86:04dd9b1680ae 73
bogdanm 86:04dd9b1680ae 74 uint32_t StopBits; /*!< Specifies the number of stop bits @ref SMARTCARD_Stop_Bits.
bogdanm 86:04dd9b1680ae 75 Only 1.5 stop bits are authorized in SmartCard mode. */
bogdanm 86:04dd9b1680ae 76
bogdanm 86:04dd9b1680ae 77 uint16_t Parity; /*!< Specifies the parity mode.
bogdanm 86:04dd9b1680ae 78 This parameter can be a value of @ref SMARTCARD_Parity
bogdanm 86:04dd9b1680ae 79 @note The parity is enabled by default (PCE is forced to 1).
bogdanm 86:04dd9b1680ae 80 Since the WordLength is forced to 8 bits + parity, M is
bogdanm 86:04dd9b1680ae 81 forced to 1 and the parity bit is the 9th bit. */
bogdanm 86:04dd9b1680ae 82
bogdanm 86:04dd9b1680ae 83 uint16_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
bogdanm 86:04dd9b1680ae 84 This parameter can be a value of @ref SMARTCARD_Mode */
bogdanm 86:04dd9b1680ae 85
bogdanm 86:04dd9b1680ae 86 uint16_t CLKPolarity; /*!< Specifies the steady state of the serial clock.
bogdanm 86:04dd9b1680ae 87 This parameter can be a value of @ref SMARTCARD_Clock_Polarity */
bogdanm 86:04dd9b1680ae 88
bogdanm 86:04dd9b1680ae 89 uint16_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made.
bogdanm 86:04dd9b1680ae 90 This parameter can be a value of @ref SMARTCARD_Clock_Phase */
bogdanm 86:04dd9b1680ae 91
bogdanm 86:04dd9b1680ae 92 uint16_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
bogdanm 86:04dd9b1680ae 93 data bit (MSB) has to be output on the SCLK pin in synchronous mode.
bogdanm 86:04dd9b1680ae 94 This parameter can be a value of @ref SMARTCARD_Last_Bit */
bogdanm 86:04dd9b1680ae 95
bogdanm 92:4fc01daae5a5 96 uint16_t OneBitSampling; /*!< Specifies whether a single sample or three samples' majority vote is selected.
bogdanm 86:04dd9b1680ae 97 Selecting the single sample method increases the receiver tolerance to clock
bogdanm 86:04dd9b1680ae 98 deviations. This parameter can be a value of @ref SMARTCARD_OneBit_Sampling. */
bogdanm 86:04dd9b1680ae 99
bogdanm 86:04dd9b1680ae 100 uint8_t Prescaler; /*!< Specifies the SmartCard Prescaler */
bogdanm 86:04dd9b1680ae 101
bogdanm 86:04dd9b1680ae 102 uint8_t GuardTime; /*!< Specifies the SmartCard Guard Time */
bogdanm 86:04dd9b1680ae 103
bogdanm 86:04dd9b1680ae 104 uint16_t NACKEnable; /*!< Specifies whether the SmartCard NACK transmission is enabled
bogdanm 86:04dd9b1680ae 105 in case of parity error.
bogdanm 86:04dd9b1680ae 106 This parameter can be a value of @ref SMARTCARD_NACK_Enable */
bogdanm 86:04dd9b1680ae 107
bogdanm 86:04dd9b1680ae 108 uint32_t TimeOutEnable; /*!< Specifies whether the receiver timeout is enabled.
bogdanm 86:04dd9b1680ae 109 This parameter can be a value of @ref SMARTCARD_Timeout_Enable*/
bogdanm 86:04dd9b1680ae 110
bogdanm 86:04dd9b1680ae 111 uint32_t TimeOutValue; /*!< Specifies the receiver time out value in number of baud blocks:
bogdanm 86:04dd9b1680ae 112 it is used to implement the Character Wait Time (CWT) and
bogdanm 86:04dd9b1680ae 113 Block Wait Time (BWT). It is coded over 24 bits. */
bogdanm 86:04dd9b1680ae 114
bogdanm 86:04dd9b1680ae 115 uint8_t BlockLength; /*!< Specifies the SmartCard Block Length in T=1 Reception mode.
bogdanm 86:04dd9b1680ae 116 This parameter can be any value from 0x0 to 0xFF */
bogdanm 86:04dd9b1680ae 117
bogdanm 86:04dd9b1680ae 118 uint8_t AutoRetryCount; /*!< Specifies the SmartCard auto-retry count (number of retries in
bogdanm 86:04dd9b1680ae 119 receive and transmit mode). When set to 0, retransmission is
bogdanm 86:04dd9b1680ae 120 disabled. Otherwise, its maximum value is 7 (before signalling
bogdanm 86:04dd9b1680ae 121 an error) */
bogdanm 86:04dd9b1680ae 122
bogdanm 86:04dd9b1680ae 123 }SMARTCARD_InitTypeDef;
bogdanm 86:04dd9b1680ae 124
bogdanm 86:04dd9b1680ae 125 /**
bogdanm 86:04dd9b1680ae 126 * @brief SMARTCARD advanced features initalization structure definition
bogdanm 86:04dd9b1680ae 127 */
bogdanm 86:04dd9b1680ae 128 typedef struct
bogdanm 86:04dd9b1680ae 129 {
bogdanm 86:04dd9b1680ae 130 uint32_t AdvFeatureInit; /*!< Specifies which advanced SMARTCARD features is initialized. Several
bogdanm 86:04dd9b1680ae 131 advanced features may be initialized at the same time. This parameter
bogdanm 86:04dd9b1680ae 132 can be a value of @ref SMARTCARD_Advanced_Features_Initialization_Type */
bogdanm 86:04dd9b1680ae 133
bogdanm 86:04dd9b1680ae 134 uint32_t TxPinLevelInvert; /*!< Specifies whether the TX pin active level is inverted.
bogdanm 86:04dd9b1680ae 135 This parameter can be a value of @ref SMARTCARD_Tx_Inv */
bogdanm 86:04dd9b1680ae 136
bogdanm 86:04dd9b1680ae 137 uint32_t RxPinLevelInvert; /*!< Specifies whether the RX pin active level is inverted.
bogdanm 86:04dd9b1680ae 138 This parameter can be a value of @ref SMARTCARD_Rx_Inv */
bogdanm 86:04dd9b1680ae 139
bogdanm 86:04dd9b1680ae 140 uint32_t DataInvert; /*!< Specifies whether data are inverted (positive/direct logic
bogdanm 86:04dd9b1680ae 141 vs negative/inverted logic).
bogdanm 86:04dd9b1680ae 142 This parameter can be a value of @ref SMARTCARD_Data_Inv */
bogdanm 86:04dd9b1680ae 143
bogdanm 86:04dd9b1680ae 144 uint32_t Swap; /*!< Specifies whether TX and RX pins are swapped.
bogdanm 86:04dd9b1680ae 145 This parameter can be a value of @ref SMARTCARD_Rx_Tx_Swap */
bogdanm 86:04dd9b1680ae 146
bogdanm 86:04dd9b1680ae 147 uint32_t OverrunDisable; /*!< Specifies whether the reception overrun detection is disabled.
bogdanm 86:04dd9b1680ae 148 This parameter can be a value of @ref SMARTCARD_Overrun_Disable */
bogdanm 86:04dd9b1680ae 149
bogdanm 86:04dd9b1680ae 150 uint32_t DMADisableonRxError; /*!< Specifies whether the DMA is disabled in case of reception error.
bogdanm 86:04dd9b1680ae 151 This parameter can be a value of @ref SMARTCARD_DMA_Disable_on_Rx_Error */
bogdanm 86:04dd9b1680ae 152
bogdanm 86:04dd9b1680ae 153 uint32_t MSBFirst; /*!< Specifies whether MSB is sent first on UART line.
bogdanm 86:04dd9b1680ae 154 This parameter can be a value of @ref SMARTCARD_MSB_First */
bogdanm 86:04dd9b1680ae 155 }SMARTCARD_AdvFeatureInitTypeDef;
bogdanm 86:04dd9b1680ae 156
bogdanm 86:04dd9b1680ae 157 /**
bogdanm 86:04dd9b1680ae 158 * @brief HAL State structures definition
bogdanm 86:04dd9b1680ae 159 */
bogdanm 86:04dd9b1680ae 160 typedef enum
bogdanm 86:04dd9b1680ae 161 {
bogdanm 86:04dd9b1680ae 162 HAL_SMARTCARD_STATE_RESET = 0x00, /*!< Peripheral is not initialized */
bogdanm 86:04dd9b1680ae 163 HAL_SMARTCARD_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
bogdanm 86:04dd9b1680ae 164 HAL_SMARTCARD_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
bogdanm 86:04dd9b1680ae 165 HAL_SMARTCARD_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
bogdanm 86:04dd9b1680ae 166 HAL_SMARTCARD_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
bogdanm 86:04dd9b1680ae 167 HAL_SMARTCARD_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */
bogdanm 86:04dd9b1680ae 168 HAL_SMARTCARD_STATE_TIMEOUT = 0x03, /*!< Timeout state */
bogdanm 86:04dd9b1680ae 169 HAL_SMARTCARD_STATE_ERROR = 0x04 /*!< Error */
bogdanm 86:04dd9b1680ae 170 }HAL_SMARTCARD_StateTypeDef;
bogdanm 86:04dd9b1680ae 171
bogdanm 86:04dd9b1680ae 172 /**
bogdanm 86:04dd9b1680ae 173 * @brief HAL SMARTCARD Error Code structure definition
bogdanm 86:04dd9b1680ae 174 */
bogdanm 86:04dd9b1680ae 175 typedef enum
bogdanm 86:04dd9b1680ae 176 {
bogdanm 86:04dd9b1680ae 177 HAL_SMARTCARD_ERROR_NONE = 0x00, /*!< No error */
bogdanm 86:04dd9b1680ae 178 HAL_SMARTCARD_ERROR_PE = 0x01, /*!< Parity error */
bogdanm 86:04dd9b1680ae 179 HAL_SMARTCARD_ERROR_NE = 0x02, /*!< Noise error */
bogdanm 86:04dd9b1680ae 180 HAL_SMARTCARD_ERROR_FE = 0x04, /*!< frame error */
bogdanm 86:04dd9b1680ae 181 HAL_SMARTCARD_ERROR_ORE = 0x08, /*!< Overrun error */
bogdanm 86:04dd9b1680ae 182 HAL_SMARTCARD_ERROR_DMA = 0x10, /*!< DMA transfer error */
bogdanm 86:04dd9b1680ae 183 HAL_SMARTCARD_ERROR_RTO = 0x20 /*!< Receiver TimeOut error */
bogdanm 86:04dd9b1680ae 184 }HAL_SMARTCARD_ErrorTypeDef;
bogdanm 86:04dd9b1680ae 185
bogdanm 86:04dd9b1680ae 186 /**
bogdanm 86:04dd9b1680ae 187 * @brief SMARTCARD handle Structure definition
bogdanm 86:04dd9b1680ae 188 */
bogdanm 86:04dd9b1680ae 189 typedef struct
bogdanm 86:04dd9b1680ae 190 {
bogdanm 86:04dd9b1680ae 191 USART_TypeDef *Instance; /* USART registers base address */
bogdanm 86:04dd9b1680ae 192
bogdanm 86:04dd9b1680ae 193 SMARTCARD_InitTypeDef Init; /* SmartCard communication parameters */
bogdanm 86:04dd9b1680ae 194
bogdanm 86:04dd9b1680ae 195 SMARTCARD_AdvFeatureInitTypeDef AdvancedInit; /* SmartCard advanced features initialization parameters */
bogdanm 86:04dd9b1680ae 196
bogdanm 86:04dd9b1680ae 197 uint8_t *pTxBuffPtr; /* Pointer to SmartCard Tx transfer Buffer */
bogdanm 86:04dd9b1680ae 198
bogdanm 86:04dd9b1680ae 199 uint16_t TxXferSize; /* SmartCard Tx Transfer size */
bogdanm 86:04dd9b1680ae 200
bogdanm 86:04dd9b1680ae 201 uint16_t TxXferCount; /* SmartCard Tx Transfer Counter */
bogdanm 86:04dd9b1680ae 202
bogdanm 86:04dd9b1680ae 203 uint8_t *pRxBuffPtr; /* Pointer to SmartCard Rx transfer Buffer */
bogdanm 86:04dd9b1680ae 204
bogdanm 86:04dd9b1680ae 205 uint16_t RxXferSize; /* SmartCard Rx Transfer size */
bogdanm 86:04dd9b1680ae 206
bogdanm 86:04dd9b1680ae 207 uint16_t RxXferCount; /* SmartCard Rx Transfer Counter */
bogdanm 86:04dd9b1680ae 208
bogdanm 86:04dd9b1680ae 209 DMA_HandleTypeDef *hdmatx; /* SmartCard Tx DMA Handle parameters */
bogdanm 86:04dd9b1680ae 210
bogdanm 86:04dd9b1680ae 211 DMA_HandleTypeDef *hdmarx; /* SmartCard Rx DMA Handle parameters */
bogdanm 86:04dd9b1680ae 212
bogdanm 86:04dd9b1680ae 213 HAL_LockTypeDef Lock; /* Locking object */
bogdanm 86:04dd9b1680ae 214
bogdanm 86:04dd9b1680ae 215 HAL_SMARTCARD_StateTypeDef State; /* SmartCard communication state */
bogdanm 86:04dd9b1680ae 216
bogdanm 86:04dd9b1680ae 217 HAL_SMARTCARD_ErrorTypeDef ErrorCode; /* SmartCard Error code */
bogdanm 86:04dd9b1680ae 218
bogdanm 86:04dd9b1680ae 219 }SMARTCARD_HandleTypeDef;
bogdanm 86:04dd9b1680ae 220
bogdanm 86:04dd9b1680ae 221 /**
bogdanm 86:04dd9b1680ae 222 * @brief SMARTCARD clock sources
bogdanm 86:04dd9b1680ae 223 */
bogdanm 86:04dd9b1680ae 224 typedef enum
bogdanm 86:04dd9b1680ae 225 {
bogdanm 86:04dd9b1680ae 226 SMARTCARD_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */
bogdanm 86:04dd9b1680ae 227 SMARTCARD_CLOCKSOURCE_PCLK2 = 0x01, /*!< PCLK2 clock source */
bogdanm 86:04dd9b1680ae 228 SMARTCARD_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */
bogdanm 86:04dd9b1680ae 229 SMARTCARD_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */
bogdanm 86:04dd9b1680ae 230 SMARTCARD_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */
bogdanm 86:04dd9b1680ae 231 SMARTCARD_CLOCKSOURCE_UNDEFINED = 0x10 /*!< undefined clock source */
bogdanm 86:04dd9b1680ae 232 }SMARTCARD_ClockSourceTypeDef;
bogdanm 86:04dd9b1680ae 233
bogdanm 92:4fc01daae5a5 234 /**
bogdanm 92:4fc01daae5a5 235 * @}
bogdanm 92:4fc01daae5a5 236 */
bogdanm 86:04dd9b1680ae 237
bogdanm 86:04dd9b1680ae 238 /* Exported constants --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 239 /** @defgroup SMARTCARD_Exported_Constants SMARTCARD Exported Constants
bogdanm 86:04dd9b1680ae 240 * @{
bogdanm 86:04dd9b1680ae 241 */
bogdanm 86:04dd9b1680ae 242
bogdanm 86:04dd9b1680ae 243 /** @defgroup SMARTCARD_Word_Length SMARTCARD Word Length
bogdanm 86:04dd9b1680ae 244 * @{
bogdanm 86:04dd9b1680ae 245 */
bogdanm 86:04dd9b1680ae 246 #define SMARTCARD_WORDLENGTH_9B ((uint32_t)USART_CR1_M0)
bogdanm 86:04dd9b1680ae 247 #define IS_SMARTCARD_WORD_LENGTH(LENGTH) ((LENGTH) == SMARTCARD_WORDLENGTH_9B)
bogdanm 86:04dd9b1680ae 248 /**
bogdanm 86:04dd9b1680ae 249 * @}
bogdanm 86:04dd9b1680ae 250 */
bogdanm 86:04dd9b1680ae 251
bogdanm 86:04dd9b1680ae 252 /** @defgroup SMARTCARD_Stop_Bits SMARTCARD Stop Bits
bogdanm 86:04dd9b1680ae 253 * @{
bogdanm 86:04dd9b1680ae 254 */
bogdanm 86:04dd9b1680ae 255 #define SMARTCARD_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP))
bogdanm 86:04dd9b1680ae 256 #define IS_SMARTCARD_STOPBITS(STOPBITS) ((STOPBITS) == SMARTCARD_STOPBITS_1_5)
bogdanm 86:04dd9b1680ae 257 /**
bogdanm 86:04dd9b1680ae 258 * @}
bogdanm 86:04dd9b1680ae 259 */
bogdanm 86:04dd9b1680ae 260
bogdanm 86:04dd9b1680ae 261 /** @defgroup SMARTCARD_Parity SMARTCARD Parity
bogdanm 86:04dd9b1680ae 262 * @{
bogdanm 86:04dd9b1680ae 263 */
bogdanm 86:04dd9b1680ae 264 #define SMARTCARD_PARITY_EVEN ((uint16_t)USART_CR1_PCE)
bogdanm 86:04dd9b1680ae 265 #define SMARTCARD_PARITY_ODD ((uint16_t)(USART_CR1_PCE | USART_CR1_PS))
bogdanm 86:04dd9b1680ae 266 #define IS_SMARTCARD_PARITY(PARITY) (((PARITY) == SMARTCARD_PARITY_EVEN) || \
bogdanm 86:04dd9b1680ae 267 ((PARITY) == SMARTCARD_PARITY_ODD))
bogdanm 86:04dd9b1680ae 268 /**
bogdanm 86:04dd9b1680ae 269 * @}
bogdanm 86:04dd9b1680ae 270 */
bogdanm 86:04dd9b1680ae 271
bogdanm 86:04dd9b1680ae 272 /** @defgroup SMARTCARD_Mode SMARTCARD Transfer Mode
bogdanm 86:04dd9b1680ae 273 * @{
bogdanm 86:04dd9b1680ae 274 */
bogdanm 86:04dd9b1680ae 275 #define SMARTCARD_MODE_RX ((uint16_t)USART_CR1_RE)
bogdanm 86:04dd9b1680ae 276 #define SMARTCARD_MODE_TX ((uint16_t)USART_CR1_TE)
bogdanm 86:04dd9b1680ae 277 #define SMARTCARD_MODE_TX_RX ((uint16_t)(USART_CR1_TE |USART_CR1_RE))
bogdanm 86:04dd9b1680ae 278 #define IS_SMARTCARD_MODE(MODE) ((((MODE) & (uint16_t)0xFFF3) == 0x00) && ((MODE) != (uint16_t)0x00))
bogdanm 86:04dd9b1680ae 279 /**
bogdanm 86:04dd9b1680ae 280 * @}
bogdanm 86:04dd9b1680ae 281 */
bogdanm 86:04dd9b1680ae 282
bogdanm 86:04dd9b1680ae 283 /** @defgroup SMARTCARD_Clock_Polarity SMARTCARD Clock Polarity
bogdanm 86:04dd9b1680ae 284 * @{
bogdanm 86:04dd9b1680ae 285 */
bogdanm 86:04dd9b1680ae 286 #define SMARTCARD_POLARITY_LOW ((uint16_t)0x0000)
bogdanm 86:04dd9b1680ae 287 #define SMARTCARD_POLARITY_HIGH ((uint16_t)USART_CR2_CPOL)
bogdanm 86:04dd9b1680ae 288 #define IS_SMARTCARD_POLARITY(CPOL) (((CPOL) == SMARTCARD_POLARITY_LOW) || ((CPOL) == SMARTCARD_POLARITY_HIGH))
bogdanm 86:04dd9b1680ae 289 /**
bogdanm 86:04dd9b1680ae 290 * @}
bogdanm 86:04dd9b1680ae 291 */
bogdanm 86:04dd9b1680ae 292
bogdanm 86:04dd9b1680ae 293 /** @defgroup SMARTCARD_Clock_Phase SMARTCARD Clock Phase
bogdanm 86:04dd9b1680ae 294 * @{
bogdanm 86:04dd9b1680ae 295 */
bogdanm 86:04dd9b1680ae 296 #define SMARTCARD_PHASE_1EDGE ((uint16_t)0x0000)
bogdanm 86:04dd9b1680ae 297 #define SMARTCARD_PHASE_2EDGE ((uint16_t)USART_CR2_CPHA)
bogdanm 86:04dd9b1680ae 298 #define IS_SMARTCARD_PHASE(CPHA) (((CPHA) == SMARTCARD_PHASE_1EDGE) || ((CPHA) == SMARTCARD_PHASE_2EDGE))
bogdanm 86:04dd9b1680ae 299 /**
bogdanm 86:04dd9b1680ae 300 * @}
bogdanm 86:04dd9b1680ae 301 */
bogdanm 86:04dd9b1680ae 302
bogdanm 86:04dd9b1680ae 303 /** @defgroup SMARTCARD_Last_Bit SMARTCARD Last Bit
bogdanm 86:04dd9b1680ae 304 * @{
bogdanm 86:04dd9b1680ae 305 */
bogdanm 86:04dd9b1680ae 306 #define SMARTCARD_LASTBIT_DISABLED ((uint16_t)0x0000)
bogdanm 86:04dd9b1680ae 307 #define SMARTCARD_LASTBIT_ENABLED ((uint16_t)USART_CR2_LBCL)
bogdanm 86:04dd9b1680ae 308 #define IS_SMARTCARD_LASTBIT(LASTBIT) (((LASTBIT) == SMARTCARD_LASTBIT_DISABLED) || \
bogdanm 86:04dd9b1680ae 309 ((LASTBIT) == SMARTCARD_LASTBIT_ENABLED))
bogdanm 86:04dd9b1680ae 310 /**
bogdanm 86:04dd9b1680ae 311 * @}
bogdanm 86:04dd9b1680ae 312 */
bogdanm 86:04dd9b1680ae 313
bogdanm 86:04dd9b1680ae 314 /** @defgroup SMARTCARD_OneBit_Sampling SMARTCARD One Bit Sampling Method
bogdanm 86:04dd9b1680ae 315 * @{
bogdanm 86:04dd9b1680ae 316 */
bogdanm 86:04dd9b1680ae 317 #define SMARTCARD_ONEBIT_SAMPLING_DISABLED ((uint16_t)0x0000)
bogdanm 86:04dd9b1680ae 318 #define SMARTCARD_ONEBIT_SAMPLING_ENABLED ((uint16_t)USART_CR3_ONEBIT)
bogdanm 86:04dd9b1680ae 319 #define IS_SMARTCARD_ONEBIT_SAMPLING(ONEBIT) (((ONEBIT) == SMARTCARD_ONEBIT_SAMPLING_DISABLED) || \
bogdanm 86:04dd9b1680ae 320 ((ONEBIT) == SMARTCARD_ONEBIT_SAMPLING_ENABLED))
bogdanm 86:04dd9b1680ae 321 /**
bogdanm 86:04dd9b1680ae 322 * @}
bogdanm 86:04dd9b1680ae 323 */
bogdanm 86:04dd9b1680ae 324
bogdanm 86:04dd9b1680ae 325
bogdanm 86:04dd9b1680ae 326 /** @defgroup SMARTCARD_NACK_Enable SMARTCARD NACK Enable
bogdanm 86:04dd9b1680ae 327 * @{
bogdanm 86:04dd9b1680ae 328 */
bogdanm 86:04dd9b1680ae 329 #define SMARTCARD_NACK_ENABLED ((uint16_t)USART_CR3_NACK)
bogdanm 86:04dd9b1680ae 330 #define SMARTCARD_NACK_DISABLED ((uint16_t)0x0000)
bogdanm 86:04dd9b1680ae 331 #define IS_SMARTCARD_NACK(NACK) (((NACK) == SMARTCARD_NACK_ENABLED) || \
bogdanm 86:04dd9b1680ae 332 ((NACK) == SMARTCARD_NACK_DISABLED))
bogdanm 86:04dd9b1680ae 333 /**
bogdanm 86:04dd9b1680ae 334 * @}
bogdanm 86:04dd9b1680ae 335 */
bogdanm 86:04dd9b1680ae 336
bogdanm 86:04dd9b1680ae 337 /** @defgroup SMARTCARD_Timeout_Enable SMARTCARD Timeout Enable
bogdanm 86:04dd9b1680ae 338 * @{
bogdanm 86:04dd9b1680ae 339 */
bogdanm 86:04dd9b1680ae 340 #define SMARTCARD_TIMEOUT_DISABLED ((uint32_t)0x00000000)
bogdanm 86:04dd9b1680ae 341 #define SMARTCARD_TIMEOUT_ENABLED ((uint32_t)USART_CR2_RTOEN)
bogdanm 86:04dd9b1680ae 342 #define IS_SMARTCARD_TIMEOUT(TIMEOUT) (((TIMEOUT) == SMARTCARD_TIMEOUT_DISABLED) || \
bogdanm 86:04dd9b1680ae 343 ((TIMEOUT) == SMARTCARD_TIMEOUT_ENABLED))
bogdanm 86:04dd9b1680ae 344 /**
bogdanm 86:04dd9b1680ae 345 * @}
bogdanm 86:04dd9b1680ae 346 */
bogdanm 86:04dd9b1680ae 347
bogdanm 86:04dd9b1680ae 348 /** @defgroup SMARTCARD_Advanced_Features_Initialization_Type SMARTCARD advanced feature initialization type
bogdanm 86:04dd9b1680ae 349 * @{
bogdanm 86:04dd9b1680ae 350 */
bogdanm 86:04dd9b1680ae 351 #define SMARTCARD_ADVFEATURE_NO_INIT ((uint32_t)0x00000000)
bogdanm 86:04dd9b1680ae 352 #define SMARTCARD_ADVFEATURE_TXINVERT_INIT ((uint32_t)0x00000001)
bogdanm 86:04dd9b1680ae 353 #define SMARTCARD_ADVFEATURE_RXINVERT_INIT ((uint32_t)0x00000002)
bogdanm 86:04dd9b1680ae 354 #define SMARTCARD_ADVFEATURE_DATAINVERT_INIT ((uint32_t)0x00000004)
bogdanm 86:04dd9b1680ae 355 #define SMARTCARD_ADVFEATURE_SWAP_INIT ((uint32_t)0x00000008)
bogdanm 86:04dd9b1680ae 356 #define SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT ((uint32_t)0x00000010)
bogdanm 86:04dd9b1680ae 357 #define SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT ((uint32_t)0x00000020)
bogdanm 86:04dd9b1680ae 358 #define SMARTCARD_ADVFEATURE_MSBFIRST_INIT ((uint32_t)0x00000080)
bogdanm 86:04dd9b1680ae 359 #define IS_SMARTCARD_ADVFEATURE_INIT(INIT) ((INIT) <= (SMARTCARD_ADVFEATURE_NO_INIT | \
bogdanm 86:04dd9b1680ae 360 SMARTCARD_ADVFEATURE_TXINVERT_INIT | \
bogdanm 86:04dd9b1680ae 361 SMARTCARD_ADVFEATURE_RXINVERT_INIT | \
bogdanm 86:04dd9b1680ae 362 SMARTCARD_ADVFEATURE_DATAINVERT_INIT | \
bogdanm 86:04dd9b1680ae 363 SMARTCARD_ADVFEATURE_SWAP_INIT | \
bogdanm 86:04dd9b1680ae 364 SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
bogdanm 86:04dd9b1680ae 365 SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT | \
bogdanm 86:04dd9b1680ae 366 SMARTCARD_ADVFEATURE_MSBFIRST_INIT))
bogdanm 86:04dd9b1680ae 367 /**
bogdanm 86:04dd9b1680ae 368 * @}
bogdanm 86:04dd9b1680ae 369 */
bogdanm 86:04dd9b1680ae 370
bogdanm 86:04dd9b1680ae 371 /** @defgroup SMARTCARD_Tx_Inv SMARTCARD advanced feature TX pin active level inversion
bogdanm 86:04dd9b1680ae 372 * @{
bogdanm 86:04dd9b1680ae 373 */
bogdanm 86:04dd9b1680ae 374 #define SMARTCARD_ADVFEATURE_TXINV_DISABLE ((uint32_t)0x00000000)
bogdanm 86:04dd9b1680ae 375 #define SMARTCARD_ADVFEATURE_TXINV_ENABLE ((uint32_t)USART_CR2_TXINV)
bogdanm 86:04dd9b1680ae 376 #define IS_SMARTCARD_ADVFEATURE_TXINV(TXINV) (((TXINV) == SMARTCARD_ADVFEATURE_TXINV_DISABLE) || \
bogdanm 86:04dd9b1680ae 377 ((TXINV) == SMARTCARD_ADVFEATURE_TXINV_ENABLE))
bogdanm 86:04dd9b1680ae 378 /**
bogdanm 86:04dd9b1680ae 379 * @}
bogdanm 86:04dd9b1680ae 380 */
bogdanm 86:04dd9b1680ae 381
bogdanm 86:04dd9b1680ae 382 /** @defgroup SMARTCARD_Rx_Inv SMARTCARD advanced feature RX pin active level inversion
bogdanm 86:04dd9b1680ae 383 * @{
bogdanm 86:04dd9b1680ae 384 */
bogdanm 86:04dd9b1680ae 385 #define SMARTCARD_ADVFEATURE_RXINV_DISABLE ((uint32_t)0x00000000)
bogdanm 86:04dd9b1680ae 386 #define SMARTCARD_ADVFEATURE_RXINV_ENABLE ((uint32_t)USART_CR2_RXINV)
bogdanm 86:04dd9b1680ae 387 #define IS_SMARTCARD_ADVFEATURE_RXINV(RXINV) (((RXINV) == SMARTCARD_ADVFEATURE_RXINV_DISABLE) || \
bogdanm 86:04dd9b1680ae 388 ((RXINV) == SMARTCARD_ADVFEATURE_RXINV_ENABLE))
bogdanm 86:04dd9b1680ae 389 /**
bogdanm 86:04dd9b1680ae 390 * @}
bogdanm 86:04dd9b1680ae 391 */
bogdanm 86:04dd9b1680ae 392
bogdanm 86:04dd9b1680ae 393 /** @defgroup SMARTCARD_Data_Inv SMARTCARD advanced feature Binary Data inversion
bogdanm 86:04dd9b1680ae 394 * @{
bogdanm 86:04dd9b1680ae 395 */
bogdanm 86:04dd9b1680ae 396 #define SMARTCARD_ADVFEATURE_DATAINV_DISABLE ((uint32_t)0x00000000)
bogdanm 86:04dd9b1680ae 397 #define SMARTCARD_ADVFEATURE_DATAINV_ENABLE ((uint32_t)USART_CR2_DATAINV)
bogdanm 86:04dd9b1680ae 398 #define IS_SMARTCARD_ADVFEATURE_DATAINV(DATAINV) (((DATAINV) == SMARTCARD_ADVFEATURE_DATAINV_DISABLE) || \
bogdanm 86:04dd9b1680ae 399 ((DATAINV) == SMARTCARD_ADVFEATURE_DATAINV_ENABLE))
bogdanm 86:04dd9b1680ae 400 /**
bogdanm 86:04dd9b1680ae 401 * @}
bogdanm 86:04dd9b1680ae 402 */
bogdanm 86:04dd9b1680ae 403
bogdanm 86:04dd9b1680ae 404 /** @defgroup SMARTCARD_Rx_Tx_Swap SMARTCARD advanced feature RX TX pins swap
bogdanm 86:04dd9b1680ae 405 * @{
bogdanm 86:04dd9b1680ae 406 */
bogdanm 86:04dd9b1680ae 407 #define SMARTCARD_ADVFEATURE_SWAP_DISABLE ((uint32_t)0x00000000)
bogdanm 86:04dd9b1680ae 408 #define SMARTCARD_ADVFEATURE_SWAP_ENABLE ((uint32_t)USART_CR2_SWAP)
bogdanm 86:04dd9b1680ae 409 #define IS_SMARTCARD_ADVFEATURE_SWAP(SWAP) (((SWAP) == SMARTCARD_ADVFEATURE_SWAP_DISABLE) || \
bogdanm 86:04dd9b1680ae 410 ((SWAP) == SMARTCARD_ADVFEATURE_SWAP_ENABLE))
bogdanm 86:04dd9b1680ae 411 /**
bogdanm 86:04dd9b1680ae 412 * @}
bogdanm 86:04dd9b1680ae 413 */
bogdanm 86:04dd9b1680ae 414
bogdanm 86:04dd9b1680ae 415 /** @defgroup SMARTCARD_Overrun_Disable SMARTCARD advanced feature Overrun Disable
bogdanm 86:04dd9b1680ae 416 * @{
bogdanm 86:04dd9b1680ae 417 */
bogdanm 86:04dd9b1680ae 418 #define SMARTCARD_ADVFEATURE_OVERRUN_ENABLE ((uint32_t)0x00000000)
bogdanm 86:04dd9b1680ae 419 #define SMARTCARD_ADVFEATURE_OVERRUN_DISABLE ((uint32_t)USART_CR3_OVRDIS)
bogdanm 86:04dd9b1680ae 420 #define IS_SMARTCARD_OVERRUN(OVERRUN) (((OVERRUN) == SMARTCARD_ADVFEATURE_OVERRUN_ENABLE) || \
bogdanm 86:04dd9b1680ae 421 ((OVERRUN) == SMARTCARD_ADVFEATURE_OVERRUN_DISABLE))
bogdanm 86:04dd9b1680ae 422 /**
bogdanm 86:04dd9b1680ae 423 * @}
bogdanm 86:04dd9b1680ae 424 */
bogdanm 86:04dd9b1680ae 425
bogdanm 86:04dd9b1680ae 426 /** @defgroup SMARTCARD_DMA_Disable_on_Rx_Error SMARTCARD advanced feature DMA Disable on Rx Error
bogdanm 86:04dd9b1680ae 427 * @{
bogdanm 86:04dd9b1680ae 428 */
bogdanm 86:04dd9b1680ae 429 #define SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR ((uint32_t)0x00000000)
bogdanm 86:04dd9b1680ae 430 #define SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR ((uint32_t)USART_CR3_DDRE)
bogdanm 86:04dd9b1680ae 431 #define IS_SMARTCARD_ADVFEATURE_DMAONRXERROR(DMA) (((DMA) == SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR) || \
bogdanm 86:04dd9b1680ae 432 ((DMA) == SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR))
bogdanm 86:04dd9b1680ae 433 /**
bogdanm 86:04dd9b1680ae 434 * @}
bogdanm 86:04dd9b1680ae 435 */
bogdanm 86:04dd9b1680ae 436
bogdanm 86:04dd9b1680ae 437 /** @defgroup SMARTCARD_MSB_First SMARTCARD advanced feature MSB first
bogdanm 86:04dd9b1680ae 438 * @{
bogdanm 86:04dd9b1680ae 439 */
bogdanm 86:04dd9b1680ae 440 #define SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE ((uint32_t)0x00000000)
bogdanm 86:04dd9b1680ae 441 #define SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE ((uint32_t)USART_CR2_MSBFIRST)
bogdanm 86:04dd9b1680ae 442 #define IS_SMARTCARD_ADVFEATURE_MSBFIRST(MSBFIRST) (((MSBFIRST) == SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE) || \
bogdanm 86:04dd9b1680ae 443 ((MSBFIRST) == SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE))
bogdanm 86:04dd9b1680ae 444 /**
bogdanm 86:04dd9b1680ae 445 * @}
bogdanm 86:04dd9b1680ae 446 */
bogdanm 86:04dd9b1680ae 447
bogdanm 86:04dd9b1680ae 448 /** @defgroup SmartCard_Flags SMARTCARD Flags
bogdanm 86:04dd9b1680ae 449 * Elements values convention: 0xXXXX
bogdanm 86:04dd9b1680ae 450 * - 0xXXXX : Flag mask in the ISR register
bogdanm 86:04dd9b1680ae 451 * @{
bogdanm 86:04dd9b1680ae 452 */
bogdanm 86:04dd9b1680ae 453 #define SMARTCARD_FLAG_REACK ((uint32_t)0x00400000)
bogdanm 86:04dd9b1680ae 454 #define SMARTCARD_FLAG_TEACK ((uint32_t)0x00200000)
bogdanm 86:04dd9b1680ae 455 #define SMARTCARD_FLAG_BUSY ((uint32_t)0x00010000)
bogdanm 86:04dd9b1680ae 456 #define SMARTCARD_FLAG_EOBF ((uint32_t)0x00001000)
bogdanm 86:04dd9b1680ae 457 #define SMARTCARD_FLAG_RTOF ((uint32_t)0x00000800)
bogdanm 86:04dd9b1680ae 458 #define SMARTCARD_FLAG_TXE ((uint32_t)0x00000080)
bogdanm 86:04dd9b1680ae 459 #define SMARTCARD_FLAG_TC ((uint32_t)0x00000040)
bogdanm 86:04dd9b1680ae 460 #define SMARTCARD_FLAG_RXNE ((uint32_t)0x00000020)
bogdanm 86:04dd9b1680ae 461 #define SMARTCARD_FLAG_ORE ((uint32_t)0x00000008)
bogdanm 86:04dd9b1680ae 462 #define SMARTCARD_FLAG_NE ((uint32_t)0x00000004)
bogdanm 86:04dd9b1680ae 463 #define SMARTCARD_FLAG_FE ((uint32_t)0x00000002)
bogdanm 86:04dd9b1680ae 464 #define SMARTCARD_FLAG_PE ((uint32_t)0x00000001)
bogdanm 86:04dd9b1680ae 465 /**
bogdanm 86:04dd9b1680ae 466 * @}
bogdanm 86:04dd9b1680ae 467 */
bogdanm 86:04dd9b1680ae 468
bogdanm 86:04dd9b1680ae 469 /** @defgroup SMARTCARD_Interrupt_definition SMARTCARD Interrupts Definition
bogdanm 86:04dd9b1680ae 470 * Elements values convention: 0000ZZZZ0XXYYYYYb
bogdanm 86:04dd9b1680ae 471 * - YYYYY : Interrupt source position in the XX register (5bits)
bogdanm 86:04dd9b1680ae 472 * - XX : Interrupt source register (2bits)
bogdanm 86:04dd9b1680ae 473 * - 01: CR1 register
bogdanm 86:04dd9b1680ae 474 * - 10: CR2 register
bogdanm 86:04dd9b1680ae 475 * - 11: CR3 register
bogdanm 86:04dd9b1680ae 476 * - ZZZZ : Flag position in the ISR register(4bits)
bogdanm 86:04dd9b1680ae 477 * @{
bogdanm 86:04dd9b1680ae 478 */
bogdanm 86:04dd9b1680ae 479
bogdanm 86:04dd9b1680ae 480 #define SMARTCARD_IT_PE ((uint16_t)0x0028)
bogdanm 86:04dd9b1680ae 481 #define SMARTCARD_IT_TXE ((uint16_t)0x0727)
bogdanm 86:04dd9b1680ae 482 #define SMARTCARD_IT_TC ((uint16_t)0x0626)
bogdanm 86:04dd9b1680ae 483 #define SMARTCARD_IT_RXNE ((uint16_t)0x0525)
bogdanm 86:04dd9b1680ae 484
bogdanm 86:04dd9b1680ae 485 #define SMARTCARD_IT_ERR ((uint16_t)0x0060)
bogdanm 86:04dd9b1680ae 486 #define SMARTCARD_IT_ORE ((uint16_t)0x0300)
bogdanm 86:04dd9b1680ae 487 #define SMARTCARD_IT_NE ((uint16_t)0x0200)
bogdanm 86:04dd9b1680ae 488 #define SMARTCARD_IT_FE ((uint16_t)0x0100)
bogdanm 86:04dd9b1680ae 489
bogdanm 86:04dd9b1680ae 490 #define SMARTCARD_IT_EOB ((uint16_t)0x0C3B)
bogdanm 86:04dd9b1680ae 491 #define SMARTCARD_IT_RTO ((uint16_t)0x0B3A)
bogdanm 86:04dd9b1680ae 492 /**
bogdanm 86:04dd9b1680ae 493 * @}
bogdanm 86:04dd9b1680ae 494 */
bogdanm 86:04dd9b1680ae 495
bogdanm 86:04dd9b1680ae 496
bogdanm 86:04dd9b1680ae 497 /** @defgroup SMARTCARD_IT_CLEAR_Flags SMARTCARD Interruption Clear Flags
bogdanm 86:04dd9b1680ae 498 * @{
bogdanm 86:04dd9b1680ae 499 */
bogdanm 86:04dd9b1680ae 500 #define SMARTCARD_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
bogdanm 86:04dd9b1680ae 501 #define SMARTCARD_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
bogdanm 86:04dd9b1680ae 502 #define SMARTCARD_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
bogdanm 86:04dd9b1680ae 503 #define SMARTCARD_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
bogdanm 86:04dd9b1680ae 504 #define SMARTCARD_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
bogdanm 86:04dd9b1680ae 505 #define SMARTCARD_CLEAR_RTOF USART_ICR_RTOCF /*!< Receiver Time Out Clear Flag */
bogdanm 86:04dd9b1680ae 506 #define SMARTCARD_CLEAR_EOBF USART_ICR_EOBCF /*!< End Of Block Clear Flag */
bogdanm 86:04dd9b1680ae 507 /**
bogdanm 86:04dd9b1680ae 508 * @}
bogdanm 86:04dd9b1680ae 509 */
bogdanm 86:04dd9b1680ae 510
bogdanm 86:04dd9b1680ae 511 /** @defgroup SMARTCARD_Request_Parameters SMARTCARD Request Parameters
bogdanm 86:04dd9b1680ae 512 * @{
bogdanm 86:04dd9b1680ae 513 */
bogdanm 86:04dd9b1680ae 514 #define SMARTCARD_RXDATA_FLUSH_REQUEST ((uint16_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
bogdanm 86:04dd9b1680ae 515 #define SMARTCARD_TXDATA_FLUSH_REQUEST ((uint16_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
bogdanm 86:04dd9b1680ae 516 #define IS_SMARTCARD_REQUEST_PARAMETER(PARAM) (((PARAM) == SMARTCARD_RXDATA_FLUSH_REQUEST) || \
bogdanm 86:04dd9b1680ae 517 ((PARAM) == SMARTCARD_TXDATA_FLUSH_REQUEST))
bogdanm 86:04dd9b1680ae 518 /**
bogdanm 86:04dd9b1680ae 519 * @}
bogdanm 86:04dd9b1680ae 520 */
bogdanm 86:04dd9b1680ae 521
bogdanm 86:04dd9b1680ae 522
bogdanm 86:04dd9b1680ae 523 /** @defgroup SMARTCARD_CR3_SCARCNT_LSB_POS SMARTCARD auto retry counter LSB position in CR3 register
bogdanm 86:04dd9b1680ae 524 * @{
bogdanm 86:04dd9b1680ae 525 */
bogdanm 86:04dd9b1680ae 526 #define SMARTCARD_CR3_SCARCNT_LSB_POS ((uint32_t) 17)
bogdanm 86:04dd9b1680ae 527 /**
bogdanm 86:04dd9b1680ae 528 * @}
bogdanm 86:04dd9b1680ae 529 */
bogdanm 86:04dd9b1680ae 530
bogdanm 86:04dd9b1680ae 531 /** @defgroup SMARTCARD_GTPR_GT_LSB_POS SMARTCARD guard time value LSB position in GTPR register
bogdanm 86:04dd9b1680ae 532 * @{
bogdanm 86:04dd9b1680ae 533 */
bogdanm 86:04dd9b1680ae 534 #define SMARTCARD_GTPR_GT_LSB_POS ((uint32_t) 8)
bogdanm 86:04dd9b1680ae 535 /**
bogdanm 86:04dd9b1680ae 536 * @}
bogdanm 86:04dd9b1680ae 537 */
bogdanm 86:04dd9b1680ae 538
bogdanm 86:04dd9b1680ae 539 /** @defgroup SMARTCARD_RTOR_BLEN_LSB_POS SMARTCARD block length LSB position in RTOR register
bogdanm 86:04dd9b1680ae 540 * @{
bogdanm 86:04dd9b1680ae 541 */
bogdanm 86:04dd9b1680ae 542 #define SMARTCARD_RTOR_BLEN_LSB_POS ((uint32_t) 24)
bogdanm 86:04dd9b1680ae 543 /**
bogdanm 86:04dd9b1680ae 544 * @}
bogdanm 86:04dd9b1680ae 545 */
bogdanm 86:04dd9b1680ae 546
bogdanm 86:04dd9b1680ae 547 /** @defgroup SMARTCARD_Interruption_Mask SMARTCARD interruptions flag mask
bogdanm 86:04dd9b1680ae 548 * @{
bogdanm 86:04dd9b1680ae 549 */
bogdanm 86:04dd9b1680ae 550 #define SMARTCARD_IT_MASK ((uint16_t)0x001F)
bogdanm 86:04dd9b1680ae 551 /**
bogdanm 86:04dd9b1680ae 552 * @}
bogdanm 86:04dd9b1680ae 553 */
bogdanm 86:04dd9b1680ae 554
bogdanm 86:04dd9b1680ae 555 /**
bogdanm 86:04dd9b1680ae 556 * @}
bogdanm 86:04dd9b1680ae 557 */
bogdanm 86:04dd9b1680ae 558
bogdanm 86:04dd9b1680ae 559 /* Exported macros -----------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 560 /** @defgroup SMARTCARD_Exported_Macros SMARTCARD Exported Macros
bogdanm 86:04dd9b1680ae 561 * @{
bogdanm 86:04dd9b1680ae 562 */
bogdanm 86:04dd9b1680ae 563
bogdanm 86:04dd9b1680ae 564 /** @brief Reset SMARTCARD handle state
bogdanm 86:04dd9b1680ae 565 * @param __HANDLE__: SMARTCARD handle.
bogdanm 86:04dd9b1680ae 566 * @retval None
bogdanm 86:04dd9b1680ae 567 */
bogdanm 86:04dd9b1680ae 568 #define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SMARTCARD_STATE_RESET)
bogdanm 86:04dd9b1680ae 569
bogdanm 86:04dd9b1680ae 570 /** @brief Checks whether the specified Smartcard flag is set or not.
bogdanm 86:04dd9b1680ae 571 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 86:04dd9b1680ae 572 * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral.
bogdanm 86:04dd9b1680ae 573 * @param __FLAG__: specifies the flag to check.
bogdanm 86:04dd9b1680ae 574 * This parameter can be one of the following values:
bogdanm 86:04dd9b1680ae 575 * @arg SMARTCARD_FLAG_REACK: Receive enable ackowledge flag
bogdanm 86:04dd9b1680ae 576 * @arg SMARTCARD_FLAG_TEACK: Transmit enable ackowledge flag
bogdanm 86:04dd9b1680ae 577 * @arg SMARTCARD_FLAG_BUSY: Busy flag
bogdanm 86:04dd9b1680ae 578 * @arg SMARTCARD_FLAG_EOBF: End of block flag
bogdanm 86:04dd9b1680ae 579 * @arg SMARTCARD_FLAG_RTOF: Receiver timeout flag
bogdanm 86:04dd9b1680ae 580 * @arg SMARTCARD_FLAG_TXE: Transmit data register empty flag
bogdanm 86:04dd9b1680ae 581 * @arg SMARTCARD_FLAG_TC: Transmission Complete flag
bogdanm 86:04dd9b1680ae 582 * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag
bogdanm 86:04dd9b1680ae 583 * @arg SMARTCARD_FLAG_ORE: OverRun Error flag
bogdanm 86:04dd9b1680ae 584 * @arg SMARTCARD_FLAG_NE: Noise Error flag
bogdanm 86:04dd9b1680ae 585 * @arg SMARTCARD_FLAG_FE: Framing Error flag
bogdanm 86:04dd9b1680ae 586 * @arg SMARTCARD_FLAG_PE: Parity Error flag
bogdanm 86:04dd9b1680ae 587 * @retval The new state of __FLAG__ (TRUE or FALSE).
bogdanm 86:04dd9b1680ae 588 */
bogdanm 86:04dd9b1680ae 589 #define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
bogdanm 86:04dd9b1680ae 590
bogdanm 86:04dd9b1680ae 591
bogdanm 86:04dd9b1680ae 592 /** @brief Enables the specified SmartCard interrupt.
bogdanm 86:04dd9b1680ae 593 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 86:04dd9b1680ae 594 * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral.
bogdanm 86:04dd9b1680ae 595 * @param __INTERRUPT__: specifies the SMARTCARD interrupt to enable.
bogdanm 86:04dd9b1680ae 596 * This parameter can be one of the following values:
bogdanm 86:04dd9b1680ae 597 * @arg SMARTCARD_IT_EOBF: End Of Block interrupt
bogdanm 86:04dd9b1680ae 598 * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt
bogdanm 86:04dd9b1680ae 599 * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
bogdanm 86:04dd9b1680ae 600 * @arg SMARTCARD_IT_TC: Transmission complete interrupt
bogdanm 86:04dd9b1680ae 601 * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
bogdanm 86:04dd9b1680ae 602 * @arg SMARTCARD_IT_PE: Parity Error interrupt
bogdanm 86:04dd9b1680ae 603 * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
bogdanm 86:04dd9b1680ae 604 * @retval None
bogdanm 86:04dd9b1680ae 605 */
bogdanm 86:04dd9b1680ae 606 #define __HAL_SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
bogdanm 86:04dd9b1680ae 607 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
bogdanm 86:04dd9b1680ae 608 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))))
bogdanm 86:04dd9b1680ae 609
bogdanm 86:04dd9b1680ae 610 /** @brief Disables the specified SmartCard interrupt.
bogdanm 86:04dd9b1680ae 611 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 86:04dd9b1680ae 612 * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral.
bogdanm 86:04dd9b1680ae 613 * @param __INTERRUPT__: specifies the SMARTCARD interrupt to disable.
bogdanm 86:04dd9b1680ae 614 * This parameter can be one of the following values:
bogdanm 86:04dd9b1680ae 615 * @arg SMARTCARD_IT_EOBF: End Of Block interrupt
bogdanm 86:04dd9b1680ae 616 * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt
bogdanm 86:04dd9b1680ae 617 * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
bogdanm 86:04dd9b1680ae 618 * @arg SMARTCARD_IT_TC: Transmission complete interrupt
bogdanm 86:04dd9b1680ae 619 * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
bogdanm 86:04dd9b1680ae 620 * @arg SMARTCARD_IT_PE: Parity Error interrupt
bogdanm 86:04dd9b1680ae 621 * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
bogdanm 86:04dd9b1680ae 622 * @retval None
bogdanm 86:04dd9b1680ae 623 */
bogdanm 86:04dd9b1680ae 624 #define __HAL_SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
bogdanm 86:04dd9b1680ae 625 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
bogdanm 86:04dd9b1680ae 626 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))))
bogdanm 86:04dd9b1680ae 627
bogdanm 86:04dd9b1680ae 628
bogdanm 86:04dd9b1680ae 629 /** @brief Checks whether the specified SmartCard interrupt has occurred or not.
bogdanm 86:04dd9b1680ae 630 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 86:04dd9b1680ae 631 * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral.
bogdanm 86:04dd9b1680ae 632 * @param __IT__: specifies the SMARTCARD interrupt to check.
bogdanm 86:04dd9b1680ae 633 * This parameter can be one of the following values:
bogdanm 86:04dd9b1680ae 634 * @arg SMARTCARD_IT_EOBF: End Of Block interrupt
bogdanm 86:04dd9b1680ae 635 * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt
bogdanm 86:04dd9b1680ae 636 * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
bogdanm 86:04dd9b1680ae 637 * @arg SMARTCARD_IT_TC: Transmission complete interrupt
bogdanm 86:04dd9b1680ae 638 * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
bogdanm 86:04dd9b1680ae 639 * @arg SMARTCARD_IT_ORE: OverRun Error interrupt
bogdanm 86:04dd9b1680ae 640 * @arg SMARTCARD_IT_NE: Noise Error interrupt
bogdanm 86:04dd9b1680ae 641 * @arg SMARTCARD_IT_FE: Framing Error interrupt
bogdanm 86:04dd9b1680ae 642 * @arg SMARTCARD_IT_PE: Parity Error interrupt
bogdanm 86:04dd9b1680ae 643 * @retval The new state of __IT__ (TRUE or FALSE).
bogdanm 86:04dd9b1680ae 644 */
bogdanm 86:04dd9b1680ae 645 #define __HAL_SMARTCARD_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
bogdanm 86:04dd9b1680ae 646
bogdanm 86:04dd9b1680ae 647 /** @brief Checks whether the specified SmartCard interrupt interrupt source is enabled.
bogdanm 86:04dd9b1680ae 648 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 86:04dd9b1680ae 649 * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral.
bogdanm 86:04dd9b1680ae 650 * @param __IT__: specifies the SMARTCARD interrupt source to check.
bogdanm 86:04dd9b1680ae 651 * This parameter can be one of the following values:
bogdanm 86:04dd9b1680ae 652 * @arg SMARTCARD_IT_EOBF: End Of Block interrupt
bogdanm 86:04dd9b1680ae 653 * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt
bogdanm 86:04dd9b1680ae 654 * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
bogdanm 86:04dd9b1680ae 655 * @arg SMARTCARD_IT_TC: Transmission complete interrupt
bogdanm 86:04dd9b1680ae 656 * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
bogdanm 86:04dd9b1680ae 657 * @arg SMARTCARD_IT_ORE: OverRun Error interrupt
bogdanm 86:04dd9b1680ae 658 * @arg SMARTCARD_IT_NE: Noise Error interrupt
bogdanm 86:04dd9b1680ae 659 * @arg SMARTCARD_IT_FE: Framing Error interrupt
bogdanm 86:04dd9b1680ae 660 * @arg SMARTCARD_IT_PE: Parity Error interrupt
bogdanm 86:04dd9b1680ae 661 * @retval The new state of __IT__ (TRUE or FALSE).
bogdanm 86:04dd9b1680ae 662 */
bogdanm 86:04dd9b1680ae 663 #define __HAL_SMARTCARD_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1)? (__HANDLE__)->Instance->CR1 : \
bogdanm 86:04dd9b1680ae 664 (((((uint8_t)(__IT__)) >> 5U) == 2)? (__HANDLE__)->Instance->CR2 : \
bogdanm 86:04dd9b1680ae 665 (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << (((uint16_t)(__IT__)) & SMARTCARD_IT_MASK)))
bogdanm 86:04dd9b1680ae 666
bogdanm 86:04dd9b1680ae 667
bogdanm 86:04dd9b1680ae 668 /** @brief Clears the specified SMARTCARD ISR flag, in setting the proper ICR register flag.
bogdanm 86:04dd9b1680ae 669 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 86:04dd9b1680ae 670 * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral.
bogdanm 86:04dd9b1680ae 671 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
bogdanm 86:04dd9b1680ae 672 * to clear the corresponding interrupt
bogdanm 86:04dd9b1680ae 673 * This parameter can be one of the following values:
bogdanm 86:04dd9b1680ae 674 * @arg USART_CLEAR_PEF: Parity Error Clear Flag
bogdanm 86:04dd9b1680ae 675 * @arg USART_CLEAR_FEF: Framing Error Clear Flag
bogdanm 86:04dd9b1680ae 676 * @arg USART_CLEAR_NEF: Noise detected Clear Flag
bogdanm 86:04dd9b1680ae 677 * @arg USART_CLEAR_OREF: OverRun Error Clear Flag
bogdanm 86:04dd9b1680ae 678 * @arg USART_CLEAR_TCF: Transmission Complete Clear Flag
bogdanm 86:04dd9b1680ae 679 * @arg USART_CLEAR_RTOF: Receiver Time Out Clear Flag
bogdanm 86:04dd9b1680ae 680 * @arg USART_CLEAR_EOBF: End Of Block Clear Flag
bogdanm 86:04dd9b1680ae 681 * @retval None
bogdanm 86:04dd9b1680ae 682 */
bogdanm 86:04dd9b1680ae 683 #define __HAL_SMARTCARD_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
bogdanm 86:04dd9b1680ae 684
bogdanm 86:04dd9b1680ae 685 /** @brief Set a specific SMARTCARD request flag.
bogdanm 86:04dd9b1680ae 686 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 86:04dd9b1680ae 687 * The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral.
bogdanm 86:04dd9b1680ae 688 * @param __REQ__: specifies the request flag to set
bogdanm 86:04dd9b1680ae 689 * This parameter can be one of the following values:
bogdanm 86:04dd9b1680ae 690 * @arg SMARTCARD_RXDATA_FLUSH_REQUEST: Receive Data flush Request
bogdanm 86:04dd9b1680ae 691 * @arg SMARTCARD_TXDATA_FLUSH_REQUEST: Transmit data flush Request
bogdanm 86:04dd9b1680ae 692 *
bogdanm 86:04dd9b1680ae 693 * @retval None
bogdanm 86:04dd9b1680ae 694 */
bogdanm 86:04dd9b1680ae 695 #define __HAL_SMARTCARD_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__))
bogdanm 86:04dd9b1680ae 696
bogdanm 86:04dd9b1680ae 697 /** @brief Enable the USART associated to the SMARTCARD Handle
bogdanm 86:04dd9b1680ae 698 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 86:04dd9b1680ae 699 * The Handle Instance can be UARTx where x: 1, 2, 3 to select the USART peripheral
bogdanm 86:04dd9b1680ae 700 * @retval None
bogdanm 86:04dd9b1680ae 701 */
bogdanm 86:04dd9b1680ae 702 #define __HAL_SMARTCARD_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
bogdanm 86:04dd9b1680ae 703
bogdanm 86:04dd9b1680ae 704 /** @brief Disable the USART associated to the SMARTCARD Handle
bogdanm 86:04dd9b1680ae 705 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 86:04dd9b1680ae 706 * The Handle Instance can be UARTx where x: 1, 2, 3 to select the USART peripheral
bogdanm 86:04dd9b1680ae 707 * @retval None
bogdanm 86:04dd9b1680ae 708 */
bogdanm 86:04dd9b1680ae 709 #define __HAL_SMARTCARD_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
bogdanm 86:04dd9b1680ae 710
bogdanm 86:04dd9b1680ae 711 /** @brief Check the Baud rate range. The maximum Baud Rate is derived from the
bogdanm 86:04dd9b1680ae 712 * maximum clock on F3 (i.e. 72 MHz) divided by the oversampling used
bogdanm 86:04dd9b1680ae 713 * on the SMARTCARD (i.e. 16)
bogdanm 86:04dd9b1680ae 714 * @param __BAUDRATE__: Baud rate set by the configuration function.
bogdanm 86:04dd9b1680ae 715 * @retval Test result (TRUE or FALSE)
bogdanm 86:04dd9b1680ae 716 */
bogdanm 86:04dd9b1680ae 717 #define IS_SMARTCARD_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 4500001)
bogdanm 86:04dd9b1680ae 718
bogdanm 86:04dd9b1680ae 719 /** @brief Check the block length range. The maximum SMARTCARD block length is 0xFF.
bogdanm 86:04dd9b1680ae 720 * @param __LENGTH__: block length.
bogdanm 86:04dd9b1680ae 721 * @retval Test result (TRUE or FALSE)
bogdanm 86:04dd9b1680ae 722 */
bogdanm 86:04dd9b1680ae 723 #define IS_SMARTCARD_BLOCKLENGTH(__LENGTH__) ((__LENGTH__) <= 0xFF)
bogdanm 86:04dd9b1680ae 724
bogdanm 86:04dd9b1680ae 725 /** @brief Check the receiver timeout value. The maximum SMARTCARD receiver timeout
bogdanm 86:04dd9b1680ae 726 * value is 0xFFFFFF.
bogdanm 86:04dd9b1680ae 727 * @param __TIMEOUTVALUE__: receiver timeout value.
bogdanm 86:04dd9b1680ae 728 * @retval Test result (TRUE or FALSE)
bogdanm 86:04dd9b1680ae 729 */
bogdanm 86:04dd9b1680ae 730 #define IS_SMARTCARD_TIMEOUT_VALUE(__TIMEOUTVALUE__) ((__TIMEOUTVALUE__) <= 0xFFFFFF)
bogdanm 86:04dd9b1680ae 731
bogdanm 86:04dd9b1680ae 732 /** @brief Check the SMARTCARD autoretry counter value. The maximum number of
bogdanm 86:04dd9b1680ae 733 * retransmissions is 0x7.
bogdanm 86:04dd9b1680ae 734 * @param __COUNT__: number of retransmissions
bogdanm 86:04dd9b1680ae 735 * @retval Test result (TRUE or FALSE)
bogdanm 86:04dd9b1680ae 736 */
bogdanm 86:04dd9b1680ae 737 #define IS_SMARTCARD_AUTORETRY_COUNT(__COUNT__) ((__COUNT__) <= 0x7)
bogdanm 86:04dd9b1680ae 738
bogdanm 86:04dd9b1680ae 739
bogdanm 86:04dd9b1680ae 740
bogdanm 86:04dd9b1680ae 741 /**
bogdanm 86:04dd9b1680ae 742 * @}
bogdanm 86:04dd9b1680ae 743 */
bogdanm 86:04dd9b1680ae 744
bogdanm 92:4fc01daae5a5 745 /* Include SMARTCARD HAL Extended module */
bogdanm 86:04dd9b1680ae 746 #include "stm32f3xx_hal_smartcard_ex.h"
bogdanm 86:04dd9b1680ae 747
bogdanm 86:04dd9b1680ae 748
bogdanm 86:04dd9b1680ae 749 /* Exported functions --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 750 /** @addtogroup SMARTCARD_Exported_Functions SMARTCARD Exported Functions
bogdanm 92:4fc01daae5a5 751 * @{
bogdanm 92:4fc01daae5a5 752 */
bogdanm 92:4fc01daae5a5 753
bogdanm 92:4fc01daae5a5 754 /** @addtogroup SMARTCARD_Exported_Functions_Group1 Initialization and de-initialization functions
bogdanm 92:4fc01daae5a5 755 * @{
bogdanm 92:4fc01daae5a5 756 */
bogdanm 92:4fc01daae5a5 757
bogdanm 86:04dd9b1680ae 758 /* Initialization and de-initialization functions ****************************/
bogdanm 86:04dd9b1680ae 759 HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsmartcard);
bogdanm 86:04dd9b1680ae 760 HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsmartcard);
bogdanm 86:04dd9b1680ae 761 void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsmartcard);
bogdanm 86:04dd9b1680ae 762 void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsmartcard);
bogdanm 86:04dd9b1680ae 763
bogdanm 92:4fc01daae5a5 764 /**
bogdanm 92:4fc01daae5a5 765 * @}
bogdanm 92:4fc01daae5a5 766 */
bogdanm 92:4fc01daae5a5 767
bogdanm 92:4fc01daae5a5 768 /** @addtogroup SMARTCARD_Exported_Functions_Group2 Input and Output operation functions
bogdanm 92:4fc01daae5a5 769 * @{
bogdanm 92:4fc01daae5a5 770 */
bogdanm 86:04dd9b1680ae 771
bogdanm 86:04dd9b1680ae 772 /* IO operation functions *****************************************************/
bogdanm 86:04dd9b1680ae 773 HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size, uint32_t Timeout);
bogdanm 86:04dd9b1680ae 774 HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size, uint32_t Timeout);
bogdanm 86:04dd9b1680ae 775 HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size);
bogdanm 86:04dd9b1680ae 776 HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size);
bogdanm 86:04dd9b1680ae 777 HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size);
bogdanm 86:04dd9b1680ae 778 HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size);
bogdanm 86:04dd9b1680ae 779 void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsmartcard);
bogdanm 86:04dd9b1680ae 780 void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsmartcard);
bogdanm 86:04dd9b1680ae 781 void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsmartcard);
bogdanm 86:04dd9b1680ae 782 void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsmartcard);
bogdanm 86:04dd9b1680ae 783
bogdanm 92:4fc01daae5a5 784 /**
bogdanm 92:4fc01daae5a5 785 * @}
bogdanm 92:4fc01daae5a5 786 */
bogdanm 92:4fc01daae5a5 787
bogdanm 92:4fc01daae5a5 788 /** @defgroup SMARTCARD_Exported_Functions_Group3 Peripheral Control functions
bogdanm 92:4fc01daae5a5 789 * @{
bogdanm 92:4fc01daae5a5 790 */
bogdanm 86:04dd9b1680ae 791
bogdanm 86:04dd9b1680ae 792 /* Peripheral State and Error functions ***************************************/
bogdanm 86:04dd9b1680ae 793 HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsmartcard);
bogdanm 86:04dd9b1680ae 794 uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsmartcard);
bogdanm 86:04dd9b1680ae 795 /**
bogdanm 86:04dd9b1680ae 796 * @}
bogdanm 92:4fc01daae5a5 797 */
bogdanm 92:4fc01daae5a5 798
bogdanm 92:4fc01daae5a5 799 /**
bogdanm 92:4fc01daae5a5 800 * @}
bogdanm 92:4fc01daae5a5 801 */
bogdanm 92:4fc01daae5a5 802
bogdanm 92:4fc01daae5a5 803 /**
bogdanm 92:4fc01daae5a5 804 * @}
bogdanm 86:04dd9b1680ae 805 */
bogdanm 86:04dd9b1680ae 806
bogdanm 86:04dd9b1680ae 807 /**
bogdanm 86:04dd9b1680ae 808 * @}
bogdanm 86:04dd9b1680ae 809 */
bogdanm 92:4fc01daae5a5 810
bogdanm 86:04dd9b1680ae 811 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 812 }
bogdanm 86:04dd9b1680ae 813 #endif
bogdanm 86:04dd9b1680ae 814
bogdanm 86:04dd9b1680ae 815 #endif /* __STM32F3xx_HAL_SMARTCARD_H */
bogdanm 86:04dd9b1680ae 816
bogdanm 86:04dd9b1680ae 817 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/