meh

Fork of mbed by mbed official

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