meh

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Mar 17 14:27:45 2015 +0000
Revision:
96:487b796308b0
Parent:
92:4fc01daae5a5
Release 96 of the mbed library

Changes:
- IAR support for ble boards, lpc, ethernet stack
- RTC - attach function to redirect time functions
- Nucleo F103RB - cube driver
- k20xx - fixes for teensy and k20 platforms in sleep/deepsleep and usb
- STM32L0, Nucleo/Disco L053 - refactoring

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
Kojto 96:487b796308b0 5 * @version V1.2.0
Kojto 96:487b796308b0 6 * @date 06-February-2015
bogdanm 84:0b3ab51c8877 7 * @brief Header file of SMARTCARD HAL module.
bogdanm 84:0b3ab51c8877 8 ******************************************************************************
bogdanm 84:0b3ab51c8877 9 * @attention
bogdanm 84:0b3ab51c8877 10 *
Kojto 96:487b796308b0 11 * <h2><center>&copy; COPYRIGHT(c) 2015 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
Kojto 96:487b796308b0 53 /** @defgroup SMARTCARD 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 /**
Kojto 96:487b796308b0 169 * @brief HAL SMARTCARD Error Code definition
bogdanm 84:0b3ab51c8877 170 */
Kojto 96:487b796308b0 171
Kojto 96:487b796308b0 172 #define HAL_SMARTCARD_ERROR_NONE ((uint32_t)0x00) /*!< No error */
Kojto 96:487b796308b0 173 #define HAL_SMARTCARD_ERROR_PE ((uint32_t)0x01) /*!< Parity error */
Kojto 96:487b796308b0 174 #define HAL_SMARTCARD_ERROR_NE ((uint32_t)0x02) /*!< Noise error */
Kojto 96:487b796308b0 175 #define HAL_SMARTCARD_ERROR_FE ((uint32_t)0x04) /*!< frame error */
Kojto 96:487b796308b0 176 #define HAL_SMARTCARD_ERROR_ORE ((uint32_t)0x08) /*!< Overrun error */
Kojto 96:487b796308b0 177 #define HAL_SMARTCARD_ERROR_DMA ((uint32_t)0x10) /*!< DMA transfer error */
Kojto 96:487b796308b0 178 #define HAL_SMARTCARD_ERROR_RTO ((uint32_t)0x20) /*!< Receiver TimeOut error */
Kojto 96:487b796308b0 179
bogdanm 84:0b3ab51c8877 180
bogdanm 84:0b3ab51c8877 181 /**
bogdanm 84:0b3ab51c8877 182 * @brief SMARTCARD clock sources definition
bogdanm 84:0b3ab51c8877 183 */
bogdanm 84:0b3ab51c8877 184 typedef enum
bogdanm 84:0b3ab51c8877 185 {
bogdanm 84:0b3ab51c8877 186 SMARTCARD_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */
bogdanm 84:0b3ab51c8877 187 SMARTCARD_CLOCKSOURCE_PCLK2 = 0x01, /*!< PCLK2 clock source */
bogdanm 84:0b3ab51c8877 188 SMARTCARD_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */
bogdanm 84:0b3ab51c8877 189 SMARTCARD_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */
bogdanm 84:0b3ab51c8877 190 SMARTCARD_CLOCKSOURCE_LSE = 0x08 /*!< LSE clock source */
bogdanm 84:0b3ab51c8877 191 }SMARTCARD_ClockSourceTypeDef;
bogdanm 84:0b3ab51c8877 192
bogdanm 84:0b3ab51c8877 193 /**
bogdanm 84:0b3ab51c8877 194 * @brief SMARTCARD handle Structure definition
bogdanm 84:0b3ab51c8877 195 */
bogdanm 84:0b3ab51c8877 196 typedef struct
bogdanm 84:0b3ab51c8877 197 {
bogdanm 84:0b3ab51c8877 198 USART_TypeDef *Instance; /* USART registers base address */
bogdanm 84:0b3ab51c8877 199
bogdanm 84:0b3ab51c8877 200 SMARTCARD_InitTypeDef Init; /* SmartCard communication parameters */
bogdanm 84:0b3ab51c8877 201
bogdanm 84:0b3ab51c8877 202 SMARTCARD_AdvFeatureInitTypeDef AdvancedInit; /* SmartCard advanced features initialization parameters */
bogdanm 84:0b3ab51c8877 203
bogdanm 84:0b3ab51c8877 204 uint8_t *pTxBuffPtr; /* Pointer to SmartCard Tx transfer Buffer */
bogdanm 84:0b3ab51c8877 205
bogdanm 84:0b3ab51c8877 206 uint16_t TxXferSize; /* SmartCard Tx Transfer size */
bogdanm 84:0b3ab51c8877 207
bogdanm 84:0b3ab51c8877 208 uint16_t TxXferCount; /* SmartCard Tx Transfer Counter */
bogdanm 84:0b3ab51c8877 209
bogdanm 84:0b3ab51c8877 210 uint8_t *pRxBuffPtr; /* Pointer to SmartCard Rx transfer Buffer */
bogdanm 84:0b3ab51c8877 211
bogdanm 84:0b3ab51c8877 212 uint16_t RxXferSize; /* SmartCard Rx Transfer size */
bogdanm 84:0b3ab51c8877 213
bogdanm 84:0b3ab51c8877 214 uint16_t RxXferCount; /* SmartCard Rx Transfer Counter */
bogdanm 84:0b3ab51c8877 215
bogdanm 84:0b3ab51c8877 216 DMA_HandleTypeDef *hdmatx; /* SmartCard Tx DMA Handle parameters */
bogdanm 84:0b3ab51c8877 217
bogdanm 84:0b3ab51c8877 218 DMA_HandleTypeDef *hdmarx; /* SmartCard Rx DMA Handle parameters */
bogdanm 84:0b3ab51c8877 219
bogdanm 84:0b3ab51c8877 220 HAL_LockTypeDef Lock; /* Locking object */
bogdanm 84:0b3ab51c8877 221
Kojto 96:487b796308b0 222 __IO HAL_SMARTCARD_StateTypeDef State; /* SmartCard communication state */
bogdanm 84:0b3ab51c8877 223
Kojto 96:487b796308b0 224 __IO uint32_t ErrorCode; /* SmartCard Error code */
bogdanm 84:0b3ab51c8877 225
bogdanm 84:0b3ab51c8877 226 }SMARTCARD_HandleTypeDef;
bogdanm 84:0b3ab51c8877 227
bogdanm 84:0b3ab51c8877 228 /* Exported constants --------------------------------------------------------*/
Kojto 96:487b796308b0 229 /** @defgroup SMARTCARD_Exported_Constants SMARTCARD Exported Constants
bogdanm 84:0b3ab51c8877 230 * @{
bogdanm 84:0b3ab51c8877 231 */
bogdanm 84:0b3ab51c8877 232
Kojto 96:487b796308b0 233 /** @defgroup SMARTCARD_Word_Length SMARTCARD Word Length
bogdanm 84:0b3ab51c8877 234 * @{
bogdanm 84:0b3ab51c8877 235 */
bogdanm 84:0b3ab51c8877 236 #define SMARTCARD_WORDLENGTH_9B ((uint32_t)USART_CR1_M_0)
bogdanm 84:0b3ab51c8877 237 #define IS_SMARTCARD_WORD_LENGTH(LENGTH) ((LENGTH) == SMARTCARD_WORDLENGTH_9B)
bogdanm 84:0b3ab51c8877 238 /**
bogdanm 84:0b3ab51c8877 239 * @}
bogdanm 84:0b3ab51c8877 240 */
bogdanm 84:0b3ab51c8877 241
Kojto 96:487b796308b0 242 /** @defgroup SMARTCARD_Stop_Bits SMARTCARD Stop Bits
bogdanm 84:0b3ab51c8877 243 * @{
bogdanm 84:0b3ab51c8877 244 */
bogdanm 84:0b3ab51c8877 245 #define SMARTCARD_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP))
bogdanm 84:0b3ab51c8877 246 #define IS_SMARTCARD_STOPBITS(STOPBITS) ((STOPBITS) == SMARTCARD_STOPBITS_1_5)
bogdanm 84:0b3ab51c8877 247 /**
bogdanm 84:0b3ab51c8877 248 * @}
bogdanm 84:0b3ab51c8877 249 */
bogdanm 84:0b3ab51c8877 250
Kojto 96:487b796308b0 251 /** @defgroup SMARTCARD_Parity SMARTCARD Parity
bogdanm 84:0b3ab51c8877 252 * @{
bogdanm 84:0b3ab51c8877 253 */
bogdanm 84:0b3ab51c8877 254 #define SMARTCARD_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
bogdanm 84:0b3ab51c8877 255 #define SMARTCARD_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
bogdanm 84:0b3ab51c8877 256 #define IS_SMARTCARD_PARITY(PARITY) (((PARITY) == SMARTCARD_PARITY_EVEN) || \
bogdanm 84:0b3ab51c8877 257 ((PARITY) == SMARTCARD_PARITY_ODD))
bogdanm 84:0b3ab51c8877 258 /**
bogdanm 84:0b3ab51c8877 259 * @}
bogdanm 84:0b3ab51c8877 260 */
bogdanm 84:0b3ab51c8877 261
Kojto 96:487b796308b0 262 /** @defgroup SMARTCARD_Mode SMARTCARD Mode
bogdanm 84:0b3ab51c8877 263 * @{
bogdanm 84:0b3ab51c8877 264 */
bogdanm 84:0b3ab51c8877 265 #define SMARTCARD_MODE_RX ((uint32_t)USART_CR1_RE)
bogdanm 84:0b3ab51c8877 266 #define SMARTCARD_MODE_TX ((uint32_t)USART_CR1_TE)
bogdanm 84:0b3ab51c8877 267 #define SMARTCARD_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
bogdanm 84:0b3ab51c8877 268 #define IS_SMARTCARD_MODE(MODE) ((((MODE) & (uint32_t)0xFFF3) == 0x00) && ((MODE) != (uint32_t)0x00))
bogdanm 84:0b3ab51c8877 269 /**
bogdanm 84:0b3ab51c8877 270 * @}
bogdanm 84:0b3ab51c8877 271 */
bogdanm 84:0b3ab51c8877 272
Kojto 96:487b796308b0 273 /** @defgroup SMARTCARD_Clock_Polarity SMARTCARD Clock Polarity
bogdanm 84:0b3ab51c8877 274 * @{
bogdanm 84:0b3ab51c8877 275 */
bogdanm 84:0b3ab51c8877 276 #define SMARTCARD_POLARITY_LOW ((uint32_t)0x0000)
bogdanm 84:0b3ab51c8877 277 #define SMARTCARD_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL)
bogdanm 84:0b3ab51c8877 278 #define IS_SMARTCARD_POLARITY(CPOL) (((CPOL) == SMARTCARD_POLARITY_LOW) || ((CPOL) == SMARTCARD_POLARITY_HIGH))
bogdanm 84:0b3ab51c8877 279 /**
bogdanm 84:0b3ab51c8877 280 * @}
bogdanm 84:0b3ab51c8877 281 */
bogdanm 84:0b3ab51c8877 282
Kojto 96:487b796308b0 283 /** @defgroup SMARTCARD_Clock_Phase SMARTCARD Clock Phase
bogdanm 84:0b3ab51c8877 284 * @{
bogdanm 84:0b3ab51c8877 285 */
bogdanm 84:0b3ab51c8877 286 #define SMARTCARD_PHASE_1EDGE ((uint32_t)0x0000)
bogdanm 84:0b3ab51c8877 287 #define SMARTCARD_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA)
bogdanm 84:0b3ab51c8877 288 #define IS_SMARTCARD_PHASE(CPHA) (((CPHA) == SMARTCARD_PHASE_1EDGE) || ((CPHA) == SMARTCARD_PHASE_2EDGE))
bogdanm 84:0b3ab51c8877 289 /**
bogdanm 84:0b3ab51c8877 290 * @}
bogdanm 84:0b3ab51c8877 291 */
bogdanm 84:0b3ab51c8877 292
Kojto 96:487b796308b0 293 /** @defgroup SMARTCARD_Last_Bit SMARTCARD Last Bit
bogdanm 84:0b3ab51c8877 294 * @{
bogdanm 84:0b3ab51c8877 295 */
bogdanm 84:0b3ab51c8877 296 #define SMARTCARD_LASTBIT_DISABLE ((uint32_t)0x0000)
bogdanm 84:0b3ab51c8877 297 #define SMARTCARD_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL)
bogdanm 84:0b3ab51c8877 298 #define IS_SMARTCARD_LASTBIT(LASTBIT) (((LASTBIT) == SMARTCARD_LASTBIT_DISABLE) || \
bogdanm 84:0b3ab51c8877 299 ((LASTBIT) == SMARTCARD_LASTBIT_ENABLE))
bogdanm 84:0b3ab51c8877 300 /**
bogdanm 84:0b3ab51c8877 301 * @}
bogdanm 84:0b3ab51c8877 302 */
bogdanm 84:0b3ab51c8877 303
Kojto 96:487b796308b0 304 /** @defgroup SMARTCARD_OneBit_Sampling SMARTCARD OneBit Sampling
bogdanm 84:0b3ab51c8877 305 * @{
bogdanm 84:0b3ab51c8877 306 */
Kojto 96:487b796308b0 307 #define SMARTCARD_ONE_BIT_SAMPLE_DISABLE ((uint32_t)0x0000)
Kojto 96:487b796308b0 308 #define SMARTCARD_ONE_BIT_SAMPLE_ENABLE ((uint32_t)USART_CR3_ONEBIT)
Kojto 96:487b796308b0 309 #define IS_SMARTCARD_ONE_BIT_SAMPLE(ONEBIT) (((ONEBIT) == SMARTCARD_ONE_BIT_SAMPLE_DISABLE) || \
Kojto 96:487b796308b0 310 ((ONEBIT) == SMARTCARD_ONE_BIT_SAMPLE_ENABLE))
bogdanm 84:0b3ab51c8877 311 /**
bogdanm 84:0b3ab51c8877 312 * @}
bogdanm 84:0b3ab51c8877 313 */
bogdanm 84:0b3ab51c8877 314
bogdanm 84:0b3ab51c8877 315
Kojto 96:487b796308b0 316 /** @defgroup SMARTCARD_NACK_Enable SMARTCARD NACK Enable
bogdanm 84:0b3ab51c8877 317 * @{
bogdanm 84:0b3ab51c8877 318 */
Kojto 96:487b796308b0 319 #define SMARTCARD_NACK_ENABLE ((uint32_t)USART_CR3_NACK)
Kojto 96:487b796308b0 320 #define SMARTCARD_NACK_DISABLE ((uint32_t)0x0000)
Kojto 96:487b796308b0 321 #define IS_SMARTCARD_NACK(NACK) (((NACK) == SMARTCARD_NACK_ENABLE) || \
Kojto 96:487b796308b0 322 ((NACK) == SMARTCARD_NACK_DISABLE))
bogdanm 84:0b3ab51c8877 323 /**
bogdanm 84:0b3ab51c8877 324 * @}
bogdanm 84:0b3ab51c8877 325 */
bogdanm 84:0b3ab51c8877 326
Kojto 96:487b796308b0 327 /** @defgroup SMARTCARD_Timeout_Enable SMARTCARD Timeout Enable
bogdanm 84:0b3ab51c8877 328 * @{
bogdanm 84:0b3ab51c8877 329 */
Kojto 96:487b796308b0 330 #define SMARTCARD_TIMEOUT_DISABLE ((uint32_t)0x00000000)
Kojto 96:487b796308b0 331 #define SMARTCARD_TIMEOUT_ENABLE ((uint32_t)USART_CR2_RTOEN)
Kojto 96:487b796308b0 332 #define IS_SMARTCARD_TIMEOUT(TIMEOUT) (((TIMEOUT) == SMARTCARD_TIMEOUT_DISABLE) || \
Kojto 96:487b796308b0 333 ((TIMEOUT) == SMARTCARD_TIMEOUT_ENABLE))
bogdanm 84:0b3ab51c8877 334 /**
bogdanm 84:0b3ab51c8877 335 * @}
bogdanm 84:0b3ab51c8877 336 */
bogdanm 84:0b3ab51c8877 337
Kojto 96:487b796308b0 338 /** @defgroup SMARTCARD_DMA_Requests SMARTCARD DMA Requests
bogdanm 84:0b3ab51c8877 339 * @{
bogdanm 84:0b3ab51c8877 340 */
bogdanm 84:0b3ab51c8877 341
bogdanm 84:0b3ab51c8877 342 #define SMARTCARD_DMAREQ_TX ((uint32_t)USART_CR3_DMAT)
bogdanm 84:0b3ab51c8877 343 #define SMARTCARD_DMAREQ_RX ((uint32_t)USART_CR3_DMAR)
bogdanm 84:0b3ab51c8877 344
bogdanm 84:0b3ab51c8877 345 /**
bogdanm 84:0b3ab51c8877 346 * @}
bogdanm 84:0b3ab51c8877 347 */
bogdanm 84:0b3ab51c8877 348
Kojto 96:487b796308b0 349 /** @defgroup SMARTCARD_Advanced_Features_Initialization_Type SMARTCARD Advanced Features Initialization
bogdanm 84:0b3ab51c8877 350 * @{
bogdanm 84:0b3ab51c8877 351 */
bogdanm 84:0b3ab51c8877 352 #define SMARTCARD_ADVFEATURE_NO_INIT ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 353 #define SMARTCARD_ADVFEATURE_TXINVERT_INIT ((uint32_t)0x00000001)
bogdanm 84:0b3ab51c8877 354 #define SMARTCARD_ADVFEATURE_RXINVERT_INIT ((uint32_t)0x00000002)
bogdanm 84:0b3ab51c8877 355 #define SMARTCARD_ADVFEATURE_DATAINVERT_INIT ((uint32_t)0x00000004)
bogdanm 84:0b3ab51c8877 356 #define SMARTCARD_ADVFEATURE_SWAP_INIT ((uint32_t)0x00000008)
bogdanm 84:0b3ab51c8877 357 #define SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT ((uint32_t)0x00000010)
bogdanm 84:0b3ab51c8877 358 #define SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT ((uint32_t)0x00000020)
bogdanm 84:0b3ab51c8877 359 #define SMARTCARD_ADVFEATURE_MSBFIRST_INIT ((uint32_t)0x00000080)
bogdanm 84:0b3ab51c8877 360 #define IS_SMARTCARD_ADVFEATURE_INIT(INIT) ((INIT) <= (SMARTCARD_ADVFEATURE_NO_INIT | \
bogdanm 84:0b3ab51c8877 361 SMARTCARD_ADVFEATURE_TXINVERT_INIT | \
bogdanm 84:0b3ab51c8877 362 SMARTCARD_ADVFEATURE_RXINVERT_INIT | \
bogdanm 84:0b3ab51c8877 363 SMARTCARD_ADVFEATURE_DATAINVERT_INIT | \
bogdanm 84:0b3ab51c8877 364 SMARTCARD_ADVFEATURE_SWAP_INIT | \
bogdanm 84:0b3ab51c8877 365 SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
bogdanm 84:0b3ab51c8877 366 SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT | \
bogdanm 84:0b3ab51c8877 367 SMARTCARD_ADVFEATURE_MSBFIRST_INIT))
bogdanm 84:0b3ab51c8877 368 /**
bogdanm 84:0b3ab51c8877 369 * @}
bogdanm 84:0b3ab51c8877 370 */
bogdanm 84:0b3ab51c8877 371
Kojto 96:487b796308b0 372 /** @defgroup SMARTCARD_Tx_Inv SMARTCARD Tx Inv
bogdanm 84:0b3ab51c8877 373 * @{
bogdanm 84:0b3ab51c8877 374 */
bogdanm 84:0b3ab51c8877 375 #define SMARTCARD_ADVFEATURE_TXINV_DISABLE ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 376 #define SMARTCARD_ADVFEATURE_TXINV_ENABLE ((uint32_t)USART_CR2_TXINV)
bogdanm 84:0b3ab51c8877 377 #define IS_SMARTCARD_ADVFEATURE_TXINV(TXINV) (((TXINV) == SMARTCARD_ADVFEATURE_TXINV_DISABLE) || \
bogdanm 84:0b3ab51c8877 378 ((TXINV) == SMARTCARD_ADVFEATURE_TXINV_ENABLE))
bogdanm 84:0b3ab51c8877 379 /**
bogdanm 84:0b3ab51c8877 380 * @}
bogdanm 84:0b3ab51c8877 381 */
bogdanm 84:0b3ab51c8877 382
Kojto 96:487b796308b0 383 /** @defgroup SMARTCARD_Rx_Inv SMARTCARD Rx Inv
bogdanm 84:0b3ab51c8877 384 * @{
bogdanm 84:0b3ab51c8877 385 */
bogdanm 84:0b3ab51c8877 386 #define SMARTCARD_ADVFEATURE_RXINV_DISABLE ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 387 #define SMARTCARD_ADVFEATURE_RXINV_ENABLE ((uint32_t)USART_CR2_RXINV)
bogdanm 84:0b3ab51c8877 388 #define IS_SMARTCARD_ADVFEATURE_RXINV(RXINV) (((RXINV) == SMARTCARD_ADVFEATURE_RXINV_DISABLE) || \
bogdanm 84:0b3ab51c8877 389 ((RXINV) == SMARTCARD_ADVFEATURE_RXINV_ENABLE))
bogdanm 84:0b3ab51c8877 390 /**
bogdanm 84:0b3ab51c8877 391 * @}
bogdanm 84:0b3ab51c8877 392 */
bogdanm 84:0b3ab51c8877 393
Kojto 96:487b796308b0 394 /** @defgroup SMARTCARD_Data_Inv SMARTCARD Data Inv
bogdanm 84:0b3ab51c8877 395 * @{
bogdanm 84:0b3ab51c8877 396 */
bogdanm 84:0b3ab51c8877 397 #define SMARTCARD_ADVFEATURE_DATAINV_DISABLE ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 398 #define SMARTCARD_ADVFEATURE_DATAINV_ENABLE ((uint32_t)USART_CR2_DATAINV)
bogdanm 84:0b3ab51c8877 399 #define IS_SMARTCARD_ADVFEATURE_DATAINV(DATAINV) (((DATAINV) == SMARTCARD_ADVFEATURE_DATAINV_DISABLE) || \
bogdanm 84:0b3ab51c8877 400 ((DATAINV) == SMARTCARD_ADVFEATURE_DATAINV_ENABLE))
bogdanm 84:0b3ab51c8877 401 /**
bogdanm 84:0b3ab51c8877 402 * @}
bogdanm 84:0b3ab51c8877 403 */
bogdanm 84:0b3ab51c8877 404
Kojto 96:487b796308b0 405 /** @defgroup SMARTCARD_Rx_Tx_Swap SMARTCARD Rx Tx Swap
bogdanm 84:0b3ab51c8877 406 * @{
bogdanm 84:0b3ab51c8877 407 */
bogdanm 84:0b3ab51c8877 408 #define SMARTCARD_ADVFEATURE_SWAP_DISABLE ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 409 #define SMARTCARD_ADVFEATURE_SWAP_ENABLE ((uint32_t)USART_CR2_SWAP)
bogdanm 84:0b3ab51c8877 410 #define IS_SMARTCARD_ADVFEATURE_SWAP(SWAP) (((SWAP) == SMARTCARD_ADVFEATURE_SWAP_DISABLE) || \
bogdanm 84:0b3ab51c8877 411 ((SWAP) == SMARTCARD_ADVFEATURE_SWAP_ENABLE))
bogdanm 84:0b3ab51c8877 412 /**
bogdanm 84:0b3ab51c8877 413 * @}
bogdanm 84:0b3ab51c8877 414 */
bogdanm 84:0b3ab51c8877 415
Kojto 96:487b796308b0 416 /** @defgroup SMARTCARD_Overrun_Disable SMARTCARD Overrun Enabling
bogdanm 84:0b3ab51c8877 417 * @{
bogdanm 84:0b3ab51c8877 418 */
bogdanm 84:0b3ab51c8877 419 #define SMARTCARD_ADVFEATURE_OVERRUN_ENABLE ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 420 #define SMARTCARD_ADVFEATURE_OVERRUN_DISABLE ((uint32_t)USART_CR3_OVRDIS)
bogdanm 84:0b3ab51c8877 421 #define IS_SMARTCARD_OVERRUN(OVERRUN) (((OVERRUN) == SMARTCARD_ADVFEATURE_OVERRUN_ENABLE) || \
bogdanm 84:0b3ab51c8877 422 ((OVERRUN) == SMARTCARD_ADVFEATURE_OVERRUN_DISABLE))
bogdanm 84:0b3ab51c8877 423 /**
bogdanm 84:0b3ab51c8877 424 * @}
bogdanm 84:0b3ab51c8877 425 */
bogdanm 84:0b3ab51c8877 426
Kojto 96:487b796308b0 427 /** @defgroup SMARTCARD_DMA_Disable_on_Rx_Error SMARTCARD DMA on Rx Error
bogdanm 84:0b3ab51c8877 428 * @{
bogdanm 84:0b3ab51c8877 429 */
bogdanm 84:0b3ab51c8877 430 #define SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 431 #define SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR ((uint32_t)USART_CR3_DDRE)
bogdanm 84:0b3ab51c8877 432 #define IS_SMARTCARD_ADVFEATURE_DMAONRXERROR(DMA) (((DMA) == SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR) || \
bogdanm 84:0b3ab51c8877 433 ((DMA) == SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR))
bogdanm 84:0b3ab51c8877 434 /**
bogdanm 84:0b3ab51c8877 435 * @}
bogdanm 84:0b3ab51c8877 436 */
bogdanm 84:0b3ab51c8877 437
Kojto 96:487b796308b0 438 /** @defgroup SMARTCARD_MSB_First SMARTCARD MSB First
bogdanm 84:0b3ab51c8877 439 * @{
bogdanm 84:0b3ab51c8877 440 */
bogdanm 84:0b3ab51c8877 441 #define SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 442 #define SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE ((uint32_t)USART_CR2_MSBFIRST)
bogdanm 84:0b3ab51c8877 443 #define IS_SMARTCARD_ADVFEATURE_MSBFIRST(MSBFIRST) (((MSBFIRST) == SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE) || \
bogdanm 84:0b3ab51c8877 444 ((MSBFIRST) == SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE))
bogdanm 84:0b3ab51c8877 445 /**
bogdanm 84:0b3ab51c8877 446 * @}
bogdanm 84:0b3ab51c8877 447 */
bogdanm 84:0b3ab51c8877 448
Kojto 96:487b796308b0 449 /** @defgroup SMARTCARD_Flags SMARTCARD Flags
bogdanm 84:0b3ab51c8877 450 * Elements values convention: 0xXXXX
bogdanm 84:0b3ab51c8877 451 * - 0xXXXX : Flag mask in the ISR register
bogdanm 84:0b3ab51c8877 452 * @{
bogdanm 84:0b3ab51c8877 453 */
bogdanm 84:0b3ab51c8877 454 #define SMARTCARD_FLAG_REACK ((uint32_t)0x00400000)
bogdanm 84:0b3ab51c8877 455 #define SMARTCARD_FLAG_TEACK ((uint32_t)0x00200000)
bogdanm 84:0b3ab51c8877 456 #define SMARTCARD_FLAG_BUSY ((uint32_t)0x00010000)
bogdanm 84:0b3ab51c8877 457 #define SMARTCARD_FLAG_EOBF ((uint32_t)0x00001000)
bogdanm 84:0b3ab51c8877 458 #define SMARTCARD_FLAG_RTOF ((uint32_t)0x00000800)
bogdanm 84:0b3ab51c8877 459 #define SMARTCARD_FLAG_TXE ((uint32_t)0x00000080)
bogdanm 84:0b3ab51c8877 460 #define SMARTCARD_FLAG_TC ((uint32_t)0x00000040)
bogdanm 84:0b3ab51c8877 461 #define SMARTCARD_FLAG_RXNE ((uint32_t)0x00000020)
bogdanm 84:0b3ab51c8877 462 #define SMARTCARD_FLAG_ORE ((uint32_t)0x00000008)
bogdanm 84:0b3ab51c8877 463 #define SMARTCARD_FLAG_NE ((uint32_t)0x00000004)
bogdanm 84:0b3ab51c8877 464 #define SMARTCARD_FLAG_FE ((uint32_t)0x00000002)
bogdanm 84:0b3ab51c8877 465 #define SMARTCARD_FLAG_PE ((uint32_t)0x00000001)
bogdanm 84:0b3ab51c8877 466 /**
bogdanm 84:0b3ab51c8877 467 * @}
bogdanm 84:0b3ab51c8877 468 */
bogdanm 84:0b3ab51c8877 469
Kojto 96:487b796308b0 470 /** @defgroup SMARTCARD_Interrupt_definition SMARTCARD Interrupt definition
bogdanm 84:0b3ab51c8877 471 * Elements values convention: 0000ZZZZ0XXYYYYYb
bogdanm 84:0b3ab51c8877 472 * - YYYYY : Interrupt source position in the XX register (5bits)
bogdanm 84:0b3ab51c8877 473 * - XX : Interrupt source register (2bits)
bogdanm 84:0b3ab51c8877 474 * - 01: CR1 register
bogdanm 84:0b3ab51c8877 475 * - 10: CR2 register
bogdanm 84:0b3ab51c8877 476 * - 11: CR3 register
bogdanm 84:0b3ab51c8877 477 * - ZZZZ : Flag position in the ISR register(4bits)
bogdanm 84:0b3ab51c8877 478 * @{
bogdanm 84:0b3ab51c8877 479 */
bogdanm 84:0b3ab51c8877 480
bogdanm 84:0b3ab51c8877 481 #define SMARTCARD_IT_PE ((uint16_t)0x0028)
bogdanm 84:0b3ab51c8877 482 #define SMARTCARD_IT_TXE ((uint16_t)0x0727)
bogdanm 84:0b3ab51c8877 483 #define SMARTCARD_IT_TC ((uint16_t)0x0626)
bogdanm 84:0b3ab51c8877 484 #define SMARTCARD_IT_RXNE ((uint16_t)0x0525)
bogdanm 84:0b3ab51c8877 485
bogdanm 84:0b3ab51c8877 486 #define SMARTCARD_IT_ERR ((uint16_t)0x0060)
bogdanm 84:0b3ab51c8877 487 #define SMARTCARD_IT_ORE ((uint16_t)0x0300)
bogdanm 84:0b3ab51c8877 488 #define SMARTCARD_IT_NE ((uint16_t)0x0200)
bogdanm 84:0b3ab51c8877 489 #define SMARTCARD_IT_FE ((uint16_t)0x0100)
bogdanm 84:0b3ab51c8877 490
bogdanm 84:0b3ab51c8877 491 #define SMARTCARD_IT_EOB ((uint16_t)0x0C3B)
bogdanm 84:0b3ab51c8877 492 #define SMARTCARD_IT_RTO ((uint16_t)0x0B3A)
bogdanm 84:0b3ab51c8877 493 /**
bogdanm 84:0b3ab51c8877 494 * @}
bogdanm 84:0b3ab51c8877 495 */
bogdanm 84:0b3ab51c8877 496
bogdanm 84:0b3ab51c8877 497
Kojto 96:487b796308b0 498 /** @defgroup SMARTCARD_IT_CLEAR_Flags SMARTCARD IT CLEAR Flags
bogdanm 84:0b3ab51c8877 499 * @{
bogdanm 84:0b3ab51c8877 500 */
bogdanm 84:0b3ab51c8877 501 #define SMARTCARD_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
bogdanm 84:0b3ab51c8877 502 #define SMARTCARD_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
bogdanm 84:0b3ab51c8877 503 #define SMARTCARD_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
bogdanm 84:0b3ab51c8877 504 #define SMARTCARD_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
Kojto 96:487b796308b0 505 #define SMARTCARD_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected 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
Kojto 96:487b796308b0 513 /** @defgroup SMARTCARD_Request_Parameters 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
Kojto 96:487b796308b0 525 /** @defgroup SMARTCARD_CR3_SCAR_CNT_LSB_POS SMARTCARD CR3 LSB Position
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
Kojto 96:487b796308b0 533 /** @defgroup SMARTCARD_GTPR_GT_LSBPOS SMARTCARD GTPR GT LSB Position
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
Kojto 96:487b796308b0 541 /** @defgroup SMARTCARD_RTOR_BLEN_LSBPOS SMARTCARD RTOR BLEN LSB Position
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
Kojto 96:487b796308b0 549 /** @defgroup SMARTCARD_Interruption_Mask 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 ------------------------------------------------------------*/
Kojto 96:487b796308b0 562 /** @defgroup SMARTCARD_Exported_Macros 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.
Kojto 96:487b796308b0 575 * @retval None
Kojto 96:487b796308b0 576 */
Kojto 96:487b796308b0 577 #define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__) \
Kojto 96:487b796308b0 578 do{ \
Kojto 96:487b796308b0 579 SET_BIT((__HANDLE__)->Instance->RQR, SMARTCARD_RXDATA_FLUSH_REQUEST); \
Kojto 96:487b796308b0 580 SET_BIT((__HANDLE__)->Instance->RQR, SMARTCARD_TXDATA_FLUSH_REQUEST); \
Kojto 96:487b796308b0 581 } while(0)
Kojto 96:487b796308b0 582
Kojto 96:487b796308b0 583 /** @brief Clears the specified SMARTCARD pending flag.
Kojto 96:487b796308b0 584 * @param __HANDLE__: specifies the SMARTCARD Handle.
Kojto 96:487b796308b0 585 * @param __FLAG__: specifies the flag to check.
Kojto 96:487b796308b0 586 * This parameter can be any combination of the following values:
Kojto 96:487b796308b0 587 * @arg SMARTCARD_CLEAR_PEF
Kojto 96:487b796308b0 588 * @arg SMARTCARD_CLEAR_FEF
Kojto 96:487b796308b0 589 * @arg SMARTCARD_CLEAR_NEF
Kojto 96:487b796308b0 590 * @arg SMARTCARD_CLEAR_OREF
Kojto 96:487b796308b0 591 * @arg SMARTCARD_CLEAR_IDLEF
Kojto 96:487b796308b0 592 * @arg SMARTCARD_CLEAR_TCF
Kojto 96:487b796308b0 593 * @arg SMARTCARD_CLEAR_RTOF
Kojto 96:487b796308b0 594 * @arg SMARTCARD_CLEAR_EOBF
bogdanm 84:0b3ab51c8877 595 * @retval None
bogdanm 84:0b3ab51c8877 596 */
Kojto 96:487b796308b0 597 #define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = ~(__FLAG__))
Kojto 96:487b796308b0 598
Kojto 96:487b796308b0 599 /** @brief Clear the SMARTCARD PE pending flag.
Kojto 96:487b796308b0 600 * @param __HANDLE__: specifies the SMARTCARD Handle.
Kojto 96:487b796308b0 601 * @retval None
Kojto 96:487b796308b0 602 */
Kojto 96:487b796308b0 603 #define __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__,SMARTCARD_CLEAR_PEF)
Kojto 96:487b796308b0 604
Kojto 96:487b796308b0 605
Kojto 96:487b796308b0 606 /** @brief Clear the SMARTCARD FE pending flag.
Kojto 96:487b796308b0 607 * @param __HANDLE__: specifies the SMARTCARD Handle.
Kojto 96:487b796308b0 608 * @retval None
Kojto 96:487b796308b0 609 */
Kojto 96:487b796308b0 610 #define __HAL_SMARTCARD_CLEAR_FEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__,SMARTCARD_CLEAR_FEF)
Kojto 96:487b796308b0 611
Kojto 96:487b796308b0 612 /** @brief Clear the SMARTCARD NE pending flag.
Kojto 96:487b796308b0 613 * @param __HANDLE__: specifies the SMARTCARD Handle.
Kojto 96:487b796308b0 614 * @retval None
Kojto 96:487b796308b0 615 */
Kojto 96:487b796308b0 616 #define __HAL_SMARTCARD_CLEAR_NEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__,SMARTCARD_CLEAR_NEF)
Kojto 96:487b796308b0 617
Kojto 96:487b796308b0 618 /** @brief Clear the SMARTCARD ORE pending flag.
Kojto 96:487b796308b0 619 * @param __HANDLE__: specifies the SMARTCARD Handle.
Kojto 96:487b796308b0 620 * @retval None
Kojto 96:487b796308b0 621 */
Kojto 96:487b796308b0 622 #define __HAL_SMARTCARD_CLEAR_OREFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__,SMARTCARD_CLEAR_OREF)
Kojto 96:487b796308b0 623
Kojto 96:487b796308b0 624 /** @brief Clear the SMARTCARD IDLE pending flag.
Kojto 96:487b796308b0 625 * @param __HANDLE__: specifies the SMARTCARD Handle.
Kojto 96:487b796308b0 626 * @retval None
Kojto 96:487b796308b0 627 */
Kojto 96:487b796308b0 628 #define __HAL_SMARTCARD_CLEAR_IDLEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__,SMARTCARD_CLEAR_IDLEF)
bogdanm 84:0b3ab51c8877 629
bogdanm 84:0b3ab51c8877 630 /** @brief Checks whether the specified Smartcard flag is set or not.
bogdanm 84:0b3ab51c8877 631 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 84:0b3ab51c8877 632 * The Handle Instance which can be USART1 or USART2.
bogdanm 84:0b3ab51c8877 633 * @param __FLAG__: specifies the flag to check.
bogdanm 84:0b3ab51c8877 634 * This parameter can be one of the following values:
bogdanm 84:0b3ab51c8877 635 * @arg SMARTCARD_FLAG_REACK: Receive enable ackowledge flag
bogdanm 84:0b3ab51c8877 636 * @arg SMARTCARD_FLAG_TEACK: Transmit enable ackowledge flag
bogdanm 84:0b3ab51c8877 637 * @arg SMARTCARD_FLAG_BUSY: Busy flag
bogdanm 84:0b3ab51c8877 638 * @arg SMARTCARD_FLAG_EOBF: End of block flag
bogdanm 84:0b3ab51c8877 639 * @arg SMARTCARD_FLAG_RTOF: Receiver timeout flag
bogdanm 84:0b3ab51c8877 640 * @arg SMARTCARD_FLAG_TXE: Transmit data register empty flag
bogdanm 84:0b3ab51c8877 641 * @arg SMARTCARD_FLAG_TC: Transmission Complete flag
bogdanm 84:0b3ab51c8877 642 * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag
bogdanm 84:0b3ab51c8877 643 * @arg SMARTCARD_FLAG_ORE: OverRun Error flag
bogdanm 84:0b3ab51c8877 644 * @arg SMARTCARD_FLAG_NE: Noise Error flag
bogdanm 84:0b3ab51c8877 645 * @arg SMARTCARD_FLAG_FE: Framing Error flag
bogdanm 84:0b3ab51c8877 646 * @arg SMARTCARD_FLAG_PE: Parity Error flag
bogdanm 84:0b3ab51c8877 647 * @retval The new state of __FLAG__ (TRUE or FALSE).
bogdanm 84:0b3ab51c8877 648 */
bogdanm 84:0b3ab51c8877 649 #define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
bogdanm 84:0b3ab51c8877 650
bogdanm 84:0b3ab51c8877 651 /** @brief Enables the specified SmartCard interrupt.
bogdanm 84:0b3ab51c8877 652 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 84:0b3ab51c8877 653 * The Handle Instance which can be USART1 or USART2.
bogdanm 84:0b3ab51c8877 654 * @param __INTERRUPT__: specifies the SMARTCARD interrupt to enable.
bogdanm 84:0b3ab51c8877 655 * This parameter can be one of the following values:
bogdanm 84:0b3ab51c8877 656 * @arg SMARTCARD_IT_EOBF: End Of Block interrupt
bogdanm 84:0b3ab51c8877 657 * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt
bogdanm 84:0b3ab51c8877 658 * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
bogdanm 84:0b3ab51c8877 659 * @arg SMARTCARD_IT_TC: Transmission complete interrupt
bogdanm 84:0b3ab51c8877 660 * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
bogdanm 84:0b3ab51c8877 661 * @arg SMARTCARD_IT_PE: Parity Error interrupt
bogdanm 84:0b3ab51c8877 662 * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
bogdanm 84:0b3ab51c8877 663 * @retval None
bogdanm 84:0b3ab51c8877 664 */
bogdanm 84:0b3ab51c8877 665 #define __HAL_SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5) == 1)? ((__HANDLE__)->Instance->CR1 |= (1 << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
bogdanm 84:0b3ab51c8877 666 ((((uint8_t)(__INTERRUPT__)) >> 5) == 2)? ((__HANDLE__)->Instance->CR2 |= (1 << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
bogdanm 84:0b3ab51c8877 667 ((__HANDLE__)->Instance->CR3 |= (1 << ((__INTERRUPT__) & SMARTCARD_IT_MASK))))
bogdanm 84:0b3ab51c8877 668 /** @brief Disables the specified SmartCard interrupt.
bogdanm 84:0b3ab51c8877 669 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 84:0b3ab51c8877 670 * The Handle Instance which can be USART1 or USART2.
bogdanm 84:0b3ab51c8877 671 * @param __INTERRUPT__: specifies the SMARTCARD interrupt to enable.
bogdanm 84:0b3ab51c8877 672 * This parameter can be one of the following values:
bogdanm 84:0b3ab51c8877 673 * @arg SMARTCARD_IT_EOBF: End Of Block interrupt
bogdanm 84:0b3ab51c8877 674 * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt
bogdanm 84:0b3ab51c8877 675 * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
bogdanm 84:0b3ab51c8877 676 * @arg SMARTCARD_IT_TC: Transmission complete interrupt
bogdanm 84:0b3ab51c8877 677 * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
bogdanm 84:0b3ab51c8877 678 * @arg SMARTCARD_IT_PE: Parity Error interrupt
bogdanm 84:0b3ab51c8877 679 * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
bogdanm 84:0b3ab51c8877 680 * @retval None
bogdanm 84:0b3ab51c8877 681 */
bogdanm 84:0b3ab51c8877 682 #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 683 ((((uint8_t)(__INTERRUPT__)) >> 5) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ ((uint32_t)1 << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
bogdanm 84:0b3ab51c8877 684 ((__HANDLE__)->Instance->CR3 &= ~ ((uint32_t)1 << ((__INTERRUPT__) & SMARTCARD_IT_MASK))))
bogdanm 84:0b3ab51c8877 685
bogdanm 84:0b3ab51c8877 686 /** @brief Checks whether the specified SmartCard interrupt has occurred or not.
bogdanm 84:0b3ab51c8877 687 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 84:0b3ab51c8877 688 * The Handle Instance which can be USART1 or USART2.
bogdanm 84:0b3ab51c8877 689 * @param __IT__: specifies the SMARTCARD interrupt to check.
bogdanm 84:0b3ab51c8877 690 * This parameter can be one of the following values:
bogdanm 84:0b3ab51c8877 691 * @arg SMARTCARD_IT_EOBF: End Of Block interrupt
bogdanm 84:0b3ab51c8877 692 * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt
bogdanm 84:0b3ab51c8877 693 * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
bogdanm 84:0b3ab51c8877 694 * @arg SMARTCARD_IT_TC: Transmission complete interrupt
bogdanm 84:0b3ab51c8877 695 * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
bogdanm 84:0b3ab51c8877 696 * @arg SMARTCARD_IT_ORE: OverRun Error interrupt
bogdanm 84:0b3ab51c8877 697 * @arg SMARTCARD_IT_NE: Noise Error interrupt
bogdanm 84:0b3ab51c8877 698 * @arg SMARTCARD_IT_FE: Framing Error interrupt
bogdanm 84:0b3ab51c8877 699 * @arg SMARTCARD_IT_PE: Parity Error interrupt
bogdanm 84:0b3ab51c8877 700 * @retval The new state of __IT__ (TRUE or FALSE).
bogdanm 84:0b3ab51c8877 701 */
bogdanm 84:0b3ab51c8877 702 #define __HAL_SMARTCARD_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
bogdanm 84:0b3ab51c8877 703
bogdanm 84:0b3ab51c8877 704 /** @brief Checks whether the specified SmartCard interrupt interrupt source is enabled.
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 * @param __IT__: specifies the SMARTCARD interrupt source to check.
bogdanm 84:0b3ab51c8877 708 * This parameter can be one of the following values:
bogdanm 84:0b3ab51c8877 709 * @arg SMARTCARD_IT_EOBF: End Of Block interrupt
bogdanm 84:0b3ab51c8877 710 * @arg SMARTCARD_IT_RTOF: Receive TimeOut interrupt
bogdanm 84:0b3ab51c8877 711 * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
bogdanm 84:0b3ab51c8877 712 * @arg SMARTCARD_IT_TC: Transmission complete interrupt
bogdanm 84:0b3ab51c8877 713 * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
bogdanm 84:0b3ab51c8877 714 * @arg SMARTCARD_IT_ORE: OverRun Error interrupt
bogdanm 84:0b3ab51c8877 715 * @arg SMARTCARD_IT_NE: Noise Error interrupt
bogdanm 84:0b3ab51c8877 716 * @arg SMARTCARD_IT_FE: Framing Error interrupt
bogdanm 84:0b3ab51c8877 717 * @arg SMARTCARD_IT_PE: Parity Error interrupt
bogdanm 84:0b3ab51c8877 718 * @retval The new state of __IT__ (TRUE or FALSE).
bogdanm 84:0b3ab51c8877 719 */
bogdanm 84:0b3ab51c8877 720 #define __HAL_SMARTCARD_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5) == 2)? \
bogdanm 84:0b3ab51c8877 721 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << \
bogdanm 84:0b3ab51c8877 722 (((uint16_t)(__IT__)) & SMARTCARD_IT_MASK)))
bogdanm 84:0b3ab51c8877 723
bogdanm 84:0b3ab51c8877 724
bogdanm 84:0b3ab51c8877 725 /** @brief Clears the specified SMARTCARD ISR flag, in setting the proper ICR register flag.
bogdanm 84:0b3ab51c8877 726 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 84:0b3ab51c8877 727 * The Handle Instance which can be USART1 or USART2.
bogdanm 84:0b3ab51c8877 728 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
bogdanm 84:0b3ab51c8877 729 * to clear the corresponding interrupt
bogdanm 84:0b3ab51c8877 730 * This parameter can be one of the following values:
bogdanm 84:0b3ab51c8877 731 * @arg USART_CLEAR_PEF: Parity Error Clear Flag
bogdanm 84:0b3ab51c8877 732 * @arg USART_CLEAR_FEF: Framing Error Clear Flag
bogdanm 84:0b3ab51c8877 733 * @arg USART_CLEAR_NEF: Noise detected Clear Flag
bogdanm 84:0b3ab51c8877 734 * @arg USART_CLEAR_OREF: OverRun Error Clear Flag
bogdanm 84:0b3ab51c8877 735 * @arg USART_CLEAR_TCF: Transmission Complete Clear Flag
bogdanm 84:0b3ab51c8877 736 * @arg USART_CLEAR_RTOF: Receiver Time Out Clear Flag
bogdanm 84:0b3ab51c8877 737 * @arg USART_CLEAR_EOBF: End Of Block Clear Flag
bogdanm 84:0b3ab51c8877 738 * @retval None
bogdanm 84:0b3ab51c8877 739 */
bogdanm 92:4fc01daae5a5 740 #define __HAL_SMARTCARD_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
bogdanm 84:0b3ab51c8877 741
bogdanm 84:0b3ab51c8877 742 /** @brief Set a specific SMARTCARD request flag.
bogdanm 84:0b3ab51c8877 743 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 84:0b3ab51c8877 744 * The Handle Instance which can be USART1 or USART2.
bogdanm 84:0b3ab51c8877 745 * @param __REQ__: specifies the request flag to set
bogdanm 84:0b3ab51c8877 746 * This parameter can be one of the following values:
bogdanm 84:0b3ab51c8877 747 * @arg SMARTCARD_RXDATA_FLUSH_REQUEST: Receive Data flush Request
bogdanm 84:0b3ab51c8877 748 * @arg SMARTCARD_TXDATA_FLUSH_REQUEST: Transmit data flush Request
bogdanm 84:0b3ab51c8877 749 *
bogdanm 84:0b3ab51c8877 750 * @retval None
bogdanm 84:0b3ab51c8877 751 */
bogdanm 84:0b3ab51c8877 752 #define __HAL_SMARTCARD_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint32_t)(__REQ__))
bogdanm 84:0b3ab51c8877 753
Kojto 96:487b796308b0 754 /** @brief Enables the SMARTCARD one bit sample method
Kojto 96:487b796308b0 755 * @param __HANDLE__: specifies the SMARTCARD Handle.
Kojto 96:487b796308b0 756 * @retval None
Kojto 96:487b796308b0 757 */
Kojto 96:487b796308b0 758 #define __HAL_SMARTCARD_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
Kojto 96:487b796308b0 759
Kojto 96:487b796308b0 760 /** @brief Disables the SMARTCARD one bit sample method
Kojto 96:487b796308b0 761 * @param __HANDLE__: specifies the SMARTCARD Handle.
Kojto 96:487b796308b0 762 * @retval None
Kojto 96:487b796308b0 763 */
Kojto 96:487b796308b0 764 #define __HAL_SMARTCARD_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
Kojto 96:487b796308b0 765
bogdanm 84:0b3ab51c8877 766 /** @brief Enable the USART associated to the SMARTCARD Handle
bogdanm 84:0b3ab51c8877 767 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 84:0b3ab51c8877 768 * The Handle Instance which can be USART1 or USART2.
bogdanm 84:0b3ab51c8877 769 * @retval None
bogdanm 84:0b3ab51c8877 770 */
Kojto 96:487b796308b0 771
bogdanm 84:0b3ab51c8877 772 #define __HAL_SMARTCARD_ENABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
bogdanm 84:0b3ab51c8877 773
bogdanm 84:0b3ab51c8877 774 /** @brief Disable the USART associated to the SMARTCARD Handle
bogdanm 84:0b3ab51c8877 775 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 84:0b3ab51c8877 776 * The Handle Instance which can be USART1 or USART2.
bogdanm 84:0b3ab51c8877 777 * @retval None
bogdanm 84:0b3ab51c8877 778 */
bogdanm 84:0b3ab51c8877 779 #define __HAL_SMARTCARD_DISABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
bogdanm 84:0b3ab51c8877 780
bogdanm 84:0b3ab51c8877 781 /** @brief Macros to enable or disable the SmartCard DMA request.
bogdanm 84:0b3ab51c8877 782 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 84:0b3ab51c8877 783 * The Handle Instance which can be USART1 or USART2.
bogdanm 84:0b3ab51c8877 784 * @param __REQUEST__: specifies the SmartCard DMA request.
bogdanm 84:0b3ab51c8877 785 * This parameter can be one of the following values:
bogdanm 84:0b3ab51c8877 786 * @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request
bogdanm 84:0b3ab51c8877 787 * @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request
bogdanm 84:0b3ab51c8877 788 */
bogdanm 84:0b3ab51c8877 789 #define __HAL_SMARTCARD_DMA_REQUEST_ENABLE(__HANDLE__, __REQUEST__) ((__HANDLE__)->Instance->CR3 |= (__REQUEST__))
bogdanm 84:0b3ab51c8877 790 #define __HAL_SMARTCARD_DMA_REQUEST_DISABLE(__HANDLE__, __REQUEST__) ((__HANDLE__)->Instance->CR3 &= ~(__REQUEST__))
bogdanm 84:0b3ab51c8877 791
bogdanm 84:0b3ab51c8877 792 /** @brief Check the Baud rate range. The maximum Baud Rate is derived from the
bogdanm 84:0b3ab51c8877 793 * maximum clock on F3 (i.e. 72 MHz) divided by the oversampling used
bogdanm 84:0b3ab51c8877 794 * on the SMARTCARD (i.e. 16)
bogdanm 84:0b3ab51c8877 795 * @param __BAUDRATE__: Baud rate set by the configuration function.
bogdanm 84:0b3ab51c8877 796 * @retval Test result (TRUE or FALSE)
bogdanm 84:0b3ab51c8877 797 */
bogdanm 84:0b3ab51c8877 798 #define IS_SMARTCARD_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 4500001)
bogdanm 84:0b3ab51c8877 799
bogdanm 84:0b3ab51c8877 800 /** @brief Check the block length range. The maximum SMARTCARD block length is 0xFF.
bogdanm 84:0b3ab51c8877 801 * @param __LENGTH__: block length.
bogdanm 84:0b3ab51c8877 802 * @retval Test result (TRUE or FALSE)
bogdanm 84:0b3ab51c8877 803 */
bogdanm 84:0b3ab51c8877 804 #define IS_SMARTCARD_BLOCKLENGTH(__LENGTH__) ((__LENGTH__) <= 0xFF)
bogdanm 84:0b3ab51c8877 805
bogdanm 84:0b3ab51c8877 806 /** @brief Check the receiver timeout value. The maximum SMARTCARD receiver timeout
bogdanm 84:0b3ab51c8877 807 * value is 0xFFFFFF.
bogdanm 84:0b3ab51c8877 808 * @param __TIMEOUTVALUE__: receiver timeout value.
bogdanm 84:0b3ab51c8877 809 * @retval Test result (TRUE or FALSE)
bogdanm 84:0b3ab51c8877 810 */
bogdanm 84:0b3ab51c8877 811 #define IS_SMARTCARD_TIMEOUT_VALUE(__TIMEOUTVALUE__) ((__TIMEOUTVALUE__) <= 0xFFFFFF)
bogdanm 84:0b3ab51c8877 812
bogdanm 84:0b3ab51c8877 813 /** @brief Check the SMARTCARD autoretry counter value. The maximum number of
bogdanm 84:0b3ab51c8877 814 * retransmissions is 0x7.
bogdanm 84:0b3ab51c8877 815 * @param __COUNT__: number of retransmissions
bogdanm 84:0b3ab51c8877 816 * @retval Test result (TRUE or FALSE)
bogdanm 84:0b3ab51c8877 817 */
bogdanm 84:0b3ab51c8877 818 #define IS_SMARTCARD_AUTORETRY_COUNT(__COUNT__) ((__COUNT__) <= 0x7)
bogdanm 84:0b3ab51c8877 819
bogdanm 84:0b3ab51c8877 820 /**
bogdanm 84:0b3ab51c8877 821 * @}
bogdanm 84:0b3ab51c8877 822 */
bogdanm 84:0b3ab51c8877 823
bogdanm 84:0b3ab51c8877 824 /* Include SMARTCARD HAL Extension module */
bogdanm 84:0b3ab51c8877 825 #include "stm32l0xx_hal_smartcard_ex.h"
bogdanm 84:0b3ab51c8877 826 /* Exported functions --------------------------------------------------------*/
Kojto 96:487b796308b0 827 /** @defgroup SMARTCARD_Exported_Functions SMARTCARD Exported Functions
Kojto 96:487b796308b0 828 * @{
Kojto 96:487b796308b0 829 */
bogdanm 84:0b3ab51c8877 830 /* Initialization/de-initialization functions **********************************/
Kojto 96:487b796308b0 831 /** @defgroup SMARTCARD_Exported_Functions_Group1 Initialization/de-initialization functions
Kojto 96:487b796308b0 832 * @{
Kojto 96:487b796308b0 833 */
bogdanm 84:0b3ab51c8877 834 HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc);
bogdanm 84:0b3ab51c8877 835 HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc);
bogdanm 84:0b3ab51c8877 836 void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc);
bogdanm 84:0b3ab51c8877 837 void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc);
Kojto 96:487b796308b0 838 /**
Kojto 96:487b796308b0 839 * @}
Kojto 96:487b796308b0 840 */
bogdanm 84:0b3ab51c8877 841
bogdanm 84:0b3ab51c8877 842 /* IO operation functions *******************************************************/
Kojto 96:487b796308b0 843 /** @defgroup SMARTCARD_Exported_Functions_Group2 IO operation functions
Kojto 96:487b796308b0 844 * @{
Kojto 96:487b796308b0 845 */
bogdanm 84:0b3ab51c8877 846 HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout);
bogdanm 84:0b3ab51c8877 847 HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout);
bogdanm 84:0b3ab51c8877 848 HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
bogdanm 84:0b3ab51c8877 849 HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
bogdanm 84:0b3ab51c8877 850 HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
bogdanm 84:0b3ab51c8877 851 HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
bogdanm 84:0b3ab51c8877 852 void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsc);
bogdanm 84:0b3ab51c8877 853 void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc);
bogdanm 84:0b3ab51c8877 854 void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc);
bogdanm 84:0b3ab51c8877 855 void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc);
Kojto 96:487b796308b0 856 /**
Kojto 96:487b796308b0 857 * @}
Kojto 96:487b796308b0 858 */
Kojto 96:487b796308b0 859 /* IO operation functions *******************************************************/
Kojto 96:487b796308b0 860 /** @defgroup SMARTCARD_Exported_Functions_Group3 Peripheral State functions
Kojto 96:487b796308b0 861 * @{
Kojto 96:487b796308b0 862 */
bogdanm 84:0b3ab51c8877 863 /* Peripheral State functions **************************************************/
bogdanm 84:0b3ab51c8877 864 HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsc);
bogdanm 84:0b3ab51c8877 865 uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsc);
bogdanm 84:0b3ab51c8877 866 /**
bogdanm 84:0b3ab51c8877 867 * @}
Kojto 96:487b796308b0 868 */
Kojto 96:487b796308b0 869
Kojto 96:487b796308b0 870 /**
Kojto 96:487b796308b0 871 * @}
Kojto 96:487b796308b0 872 */
Kojto 96:487b796308b0 873
Kojto 96:487b796308b0 874 /**
Kojto 96:487b796308b0 875 * @}
bogdanm 84:0b3ab51c8877 876 */
bogdanm 84:0b3ab51c8877 877
bogdanm 84:0b3ab51c8877 878 /**
bogdanm 84:0b3ab51c8877 879 * @}
bogdanm 84:0b3ab51c8877 880 */
bogdanm 84:0b3ab51c8877 881
bogdanm 84:0b3ab51c8877 882 #ifdef __cplusplus
bogdanm 84:0b3ab51c8877 883 }
bogdanm 84:0b3ab51c8877 884 #endif
bogdanm 84:0b3ab51c8877 885
bogdanm 84:0b3ab51c8877 886 #endif /* __STM32L0xx_HAL_SMARTCARD_H */
bogdanm 84:0b3ab51c8877 887
bogdanm 84:0b3ab51c8877 888 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Kojto 96:487b796308b0 889