2 ******************************************************************************
3 * @file stm32f3xx_hal_smartcard.h
4 * @author MCD Application Team
5 * @brief Header file of SMARTCARD HAL module.
6 ******************************************************************************
9 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ******************************************************************************
36 /* Define to prevent recursive inclusion -------------------------------------*/
37 #ifndef __STM32F3xx_HAL_SMARTCARD_H
38 #define __STM32F3xx_HAL_SMARTCARD_H
44 /* Includes ------------------------------------------------------------------*/
45 #include "stm32f3xx_hal_def.h"
47 /** @addtogroup STM32F3xx_HAL_Driver
51 /** @addtogroup SMARTCARD
55 /* Exported types ------------------------------------------------------------*/
56 /** @defgroup SMARTCARD_Exported_Types SMARTCARD Exported Types
61 * @brief SMARTCARD Init Structure definition
65 uint32_t BaudRate
; /*!< Configures the SmartCard communication baud rate.
66 The baud rate register is computed using the following formula:
67 Baud Rate Register = ((PCLKx) / ((hsmartcard->Init.BaudRate))) */
69 uint32_t WordLength
; /*!< Specifies the number of data bits transmitted or received in a frame.
70 This parameter @ref SMARTCARD_Word_Length can only be set to 9 (8 data + 1 parity bits). */
72 uint32_t StopBits
; /*!< Specifies the number of stop bits.
73 This parameter can be a value of @ref SMARTCARD_Stop_Bits. */
75 uint16_t Parity
; /*!< Specifies the parity mode.
76 This parameter can be a value of @ref SMARTCARD_Parity
77 @note The parity is enabled by default (PCE is forced to 1U).
78 Since the WordLength is forced to 8 bits + parity, M is
79 forced to 1 and the parity bit is the 9th bit. */
81 uint16_t Mode
; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
82 This parameter can be a value of @ref SMARTCARD_Mode */
84 uint16_t CLKPolarity
; /*!< Specifies the steady state of the serial clock.
85 This parameter can be a value of @ref SMARTCARD_Clock_Polarity */
87 uint16_t CLKPhase
; /*!< Specifies the clock transition on which the bit capture is made.
88 This parameter can be a value of @ref SMARTCARD_Clock_Phase */
90 uint16_t CLKLastBit
; /*!< Specifies whether the clock pulse corresponding to the last transmitted
91 data bit (MSB) has to be output on the SCLK pin in synchronous mode.
92 This parameter can be a value of @ref SMARTCARD_Last_Bit */
94 uint16_t OneBitSampling
; /*!< Specifies whether a single sample or three samples' majority vote is selected.
95 Selecting the single sample method increases the receiver tolerance to clock
96 deviations. This parameter can be a value of @ref SMARTCARD_OneBit_Sampling. */
98 uint8_t Prescaler
; /*!< Specifies the SmartCard Prescaler. */
100 uint8_t GuardTime
; /*!< Specifies the SmartCard Guard Time applied after stop bits. */
102 uint16_t NACKEnable
; /*!< Specifies whether the SmartCard NACK transmission is enabled
103 in case of parity error.
104 This parameter can be a value of @ref SMARTCARD_NACK_Enable */
106 uint32_t TimeOutEnable
; /*!< Specifies whether the receiver timeout is enabled.
107 This parameter can be a value of @ref SMARTCARD_Timeout_Enable*/
109 uint32_t TimeOutValue
; /*!< Specifies the receiver time out value in number of baud blocks:
110 it is used to implement the Character Wait Time (CWT) and
111 Block Wait Time (BWT). It is coded over 24 bits. */
113 uint8_t BlockLength
; /*!< Specifies the SmartCard Block Length in T=1 Reception mode.
114 This parameter can be any value from 0x0 to 0xFFU */
116 uint8_t AutoRetryCount
; /*!< Specifies the SmartCard auto-retry count (number of retries in
117 receive and transmit mode). When set to 0U, retransmission is
118 disabled. Otherwise, its maximum value is 7 (before signalling
121 }SMARTCARD_InitTypeDef
;
124 * @brief SMARTCARD advanced features initalization structure definition
128 uint32_t AdvFeatureInit
; /*!< Specifies which advanced SMARTCARD features is initialized. Several
129 advanced features may be initialized at the same time. This parameter
130 can be a value of @ref SMARTCARD_Advanced_Features_Initialization_Type */
132 uint32_t TxPinLevelInvert
; /*!< Specifies whether the TX pin active level is inverted.
133 This parameter can be a value of @ref SMARTCARD_Tx_Inv */
135 uint32_t RxPinLevelInvert
; /*!< Specifies whether the RX pin active level is inverted.
136 This parameter can be a value of @ref SMARTCARD_Rx_Inv */
138 uint32_t DataInvert
; /*!< Specifies whether data are inverted (positive/direct logic
139 vs negative/inverted logic).
140 This parameter can be a value of @ref SMARTCARD_Data_Inv */
142 uint32_t Swap
; /*!< Specifies whether TX and RX pins are swapped.
143 This parameter can be a value of @ref SMARTCARD_Rx_Tx_Swap */
145 uint32_t OverrunDisable
; /*!< Specifies whether the reception overrun detection is disabled.
146 This parameter can be a value of @ref SMARTCARD_Overrun_Disable */
148 uint32_t DMADisableonRxError
; /*!< Specifies whether the DMA is disabled in case of reception error.
149 This parameter can be a value of @ref SMARTCARD_DMA_Disable_on_Rx_Error */
151 uint32_t MSBFirst
; /*!< Specifies whether MSB is sent first on UART line.
152 This parameter can be a value of @ref SMARTCARD_MSB_First */
153 }SMARTCARD_AdvFeatureInitTypeDef
;
156 * @brief HAL SMARTCARD State structures definition
157 * @note HAL SMARTCARD State value is a combination of 2 different substates: gState and RxState.
158 * - gState contains SMARTCARD state information related to global Handle management
159 * and also information related to Tx operations.
160 * gState value coding follow below described bitmap :
161 * b7-b6 Error information
166 * b5 IP initilisation status
167 * 0 : Reset (IP not initialized)
168 * 1 : Init done (IP not initialized. HAL SMARTCARD Init function already called)
170 * xx : Should be set to 00
171 * b2 Intrinsic process state
173 * 1 : Busy (IP busy with some configuration or internal operations)
175 * x : Should be set to 0
177 * 0 : Ready (no Tx operation ongoing)
178 * 1 : Busy (Tx operation ongoing)
179 * - RxState contains information related to Rx operations.
180 * RxState value coding follow below described bitmap :
182 * xx : Should be set to 00
183 * b5 IP initilisation status
184 * 0 : Reset (IP not initialized)
185 * 1 : Init done (IP not initialized)
187 * xxx : Should be set to 000
189 * 0 : Ready (no Rx operation ongoing)
190 * 1 : Busy (Rx operation ongoing)
192 * x : Should be set to 0.
196 HAL_SMARTCARD_STATE_RESET
= 0x00U
, /*!< Peripheral is not initialized
197 Value is allowed for gState and RxState */
198 HAL_SMARTCARD_STATE_READY
= 0x20U
, /*!< Peripheral Initialized and ready for use
199 Value is allowed for gState and RxState */
200 HAL_SMARTCARD_STATE_BUSY
= 0x24U
, /*!< an internal process is ongoing
201 Value is allowed for gState only */
202 HAL_SMARTCARD_STATE_BUSY_TX
= 0x21U
, /*!< Data Transmission process is ongoing
203 Value is allowed for gState only */
204 HAL_SMARTCARD_STATE_BUSY_RX
= 0x22U
, /*!< Data Reception process is ongoing
205 Value is allowed for RxState only */
206 HAL_SMARTCARD_STATE_BUSY_TX_RX
= 0x23U
, /*!< Data Transmission and Reception process is ongoing
207 Not to be used for neither gState nor RxState.
208 Value is result of combination (Or) between gState and RxState values */
209 HAL_SMARTCARD_STATE_TIMEOUT
= 0xA0U
, /*!< Timeout state
210 Value is allowed for gState only */
211 HAL_SMARTCARD_STATE_ERROR
= 0xE0U
/*!< Error
212 Value is allowed for gState only */
213 }HAL_SMARTCARD_StateTypeDef
;
216 * @brief SMARTCARD handle Structure definition
220 USART_TypeDef
*Instance
; /*!< USART registers base address */
222 SMARTCARD_InitTypeDef Init
; /*!< SmartCard communication parameters */
224 SMARTCARD_AdvFeatureInitTypeDef AdvancedInit
; /*!< SmartCard advanced features initialization parameters */
226 uint8_t *pTxBuffPtr
; /*!< Pointer to SmartCard Tx transfer Buffer */
228 uint16_t TxXferSize
; /*!< SmartCard Tx Transfer size */
230 __IO
uint16_t TxXferCount
; /*!< SmartCard Tx Transfer Counter */
232 uint8_t *pRxBuffPtr
; /*!< Pointer to SmartCard Rx transfer Buffer */
234 uint16_t RxXferSize
; /*!< SmartCard Rx Transfer size */
236 __IO
uint16_t RxXferCount
; /*!< SmartCard Rx Transfer Counter */
238 DMA_HandleTypeDef
*hdmatx
; /*!< SmartCard Tx DMA Handle parameters */
240 DMA_HandleTypeDef
*hdmarx
; /*!< SmartCard Rx DMA Handle parameters */
242 HAL_LockTypeDef Lock
; /*!< Locking object */
244 __IO HAL_SMARTCARD_StateTypeDef gState
; /*!< SmartCard state information related to global Handle management
245 and also related to Tx operations.
246 This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
248 __IO HAL_SMARTCARD_StateTypeDef RxState
; /*!< SmartCard state information related to Rx operations.
249 This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
251 __IO
uint32_t ErrorCode
; /*!< SmartCard Error code
252 This parameter can be a value of @ref SMARTCARD_Error */
254 }SMARTCARD_HandleTypeDef
;
257 * @brief SMARTCARD clock sources
261 SMARTCARD_CLOCKSOURCE_PCLK1
= 0x00U
, /*!< PCLK1 clock source */
262 SMARTCARD_CLOCKSOURCE_PCLK2
= 0x01U
, /*!< PCLK2 clock source */
263 SMARTCARD_CLOCKSOURCE_HSI
= 0x02U
, /*!< HSI clock source */
264 SMARTCARD_CLOCKSOURCE_SYSCLK
= 0x04U
, /*!< SYSCLK clock source */
265 SMARTCARD_CLOCKSOURCE_LSE
= 0x08U
, /*!< LSE clock source */
266 SMARTCARD_CLOCKSOURCE_UNDEFINED
= 0x10U
/*!< undefined clock source */
267 }SMARTCARD_ClockSourceTypeDef
;
273 /* Exported constants --------------------------------------------------------*/
274 /** @defgroup SMARTCARD_Exported_Constants SMARTCARD Exported Constants
278 /** @defgroup SMARTCARD_Error SMARTCARD Error
281 #define HAL_SMARTCARD_ERROR_NONE (0x00000000U) /*!< No error */
282 #define HAL_SMARTCARD_ERROR_PE (0x00000001U) /*!< Parity error */
283 #define HAL_SMARTCARD_ERROR_NE (0x00000002U) /*!< Noise error */
284 #define HAL_SMARTCARD_ERROR_FE (0x00000004U) /*!< frame error */
285 #define HAL_SMARTCARD_ERROR_ORE (0x00000008U) /*!< Overrun error */
286 #define HAL_SMARTCARD_ERROR_DMA (0x00000010U) /*!< DMA transfer error */
287 #define HAL_SMARTCARD_ERROR_RTO (0x00000020U) /*!< Receiver TimeOut error */
292 /** @defgroup SMARTCARD_Word_Length SMARTCARD Word Length
295 #define SMARTCARD_WORDLENGTH_9B ((uint32_t)USART_CR1_M0) /*!< SMARTCARD frame length */
300 /** @defgroup SMARTCARD_Stop_Bits SMARTCARD Number of Stop Bits
303 #define SMARTCARD_STOPBITS_0_5 ((uint32_t)USART_CR2_STOP_0) /*!< SMARTCARD frame with 0.5 stop bit */
304 #define SMARTCARD_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) /*!< SMARTCARD frame with 1.5 stop bits */
309 /** @defgroup SMARTCARD_Parity SMARTCARD Parity
312 #define SMARTCARD_PARITY_EVEN ((uint32_t)USART_CR1_PCE) /*!< SMARTCARD frame even parity */
313 #define SMARTCARD_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) /*!< SMARTCARD frame odd parity */
318 /** @defgroup SMARTCARD_Mode SMARTCARD Transfer Mode
321 #define SMARTCARD_MODE_RX ((uint32_t)USART_CR1_RE) /*!< SMARTCARD RX mode */
322 #define SMARTCARD_MODE_TX ((uint32_t)USART_CR1_TE) /*!< SMARTCARD TX mode */
323 #define SMARTCARD_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) /*!< SMARTCARD RX and TX mode */
328 /** @defgroup SMARTCARD_Clock_Polarity SMARTCARD Clock Polarity
331 #define SMARTCARD_POLARITY_LOW (0x00000000U) /*!< SMARTCARD frame low polarity */
332 #define SMARTCARD_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL) /*!< SMARTCARD frame high polarity */
337 /** @defgroup SMARTCARD_Clock_Phase SMARTCARD Clock Phase
340 #define SMARTCARD_PHASE_1EDGE (0x00000000U) /*!< SMARTCARD frame phase on first clock transition */
341 #define SMARTCARD_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA) /*!< SMARTCARD frame phase on second clock transition */
346 /** @defgroup SMARTCARD_Last_Bit SMARTCARD Last Bit
349 #define SMARTCARD_LASTBIT_DISABLE (0x00000000U) /*!< SMARTCARD frame last data bit clock pulse not output to SCLK pin */
350 #define SMARTCARD_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL) /*!< SMARTCARD frame last data bit clock pulse output to SCLK pin */
355 /** @defgroup SMARTCARD_OneBit_Sampling SMARTCARD One Bit Sampling Method
358 #define SMARTCARD_ONE_BIT_SAMPLE_DISABLE (0x00000000U) /*!< SMARTCARD frame one-bit sample disabled */
359 #define SMARTCARD_ONE_BIT_SAMPLE_ENABLE ((uint32_t)USART_CR3_ONEBIT) /*!< SMARTCARD frame one-bit sample enabled */
365 /** @defgroup SMARTCARD_NACK_Enable SMARTCARD NACK Enable
368 #define SMARTCARD_NACK_ENABLE ((uint32_t)USART_CR3_NACK) /*!< SMARTCARD NACK transmission disabled */
369 #define SMARTCARD_NACK_DISABLE (0x00000000U) /*!< SMARTCARD NACK transmission enabled */
374 /** @defgroup SMARTCARD_Timeout_Enable SMARTCARD Timeout Enable
377 #define SMARTCARD_TIMEOUT_DISABLE (0x00000000U) /*!< SMARTCARD receiver timeout disabled */
378 #define SMARTCARD_TIMEOUT_ENABLE ((uint32_t)USART_CR2_RTOEN) /*!< SMARTCARD receiver timeout enabled */
383 /** @defgroup SMARTCARD_Advanced_Features_Initialization_Type SMARTCARD advanced feature initialization type
386 #define SMARTCARD_ADVFEATURE_NO_INIT (0x00000000U) /*!< No advanced feature initialization */
387 #define SMARTCARD_ADVFEATURE_TXINVERT_INIT (0x00000001U) /*!< TX pin active level inversion */
388 #define SMARTCARD_ADVFEATURE_RXINVERT_INIT (0x00000002U) /*!< RX pin active level inversion */
389 #define SMARTCARD_ADVFEATURE_DATAINVERT_INIT (0x00000004U) /*!< Binary data inversion */
390 #define SMARTCARD_ADVFEATURE_SWAP_INIT (0x00000008U) /*!< TX/RX pins swap */
391 #define SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT (0x00000010U) /*!< RX overrun disable */
392 #define SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT (0x00000020U) /*!< DMA disable on Reception Error */
393 #define SMARTCARD_ADVFEATURE_MSBFIRST_INIT (0x00000080U) /*!< Most significant bit sent/received first */
398 /** @defgroup SMARTCARD_Tx_Inv SMARTCARD advanced feature TX pin active level inversion
401 #define SMARTCARD_ADVFEATURE_TXINV_DISABLE (0x00000000U) /*!< TX pin active level inversion disable */
402 #define SMARTCARD_ADVFEATURE_TXINV_ENABLE ((uint32_t)USART_CR2_TXINV) /*!< TX pin active level inversion enable */
407 /** @defgroup SMARTCARD_Rx_Inv SMARTCARD advanced feature RX pin active level inversion
410 #define SMARTCARD_ADVFEATURE_RXINV_DISABLE (0x00000000U) /*!< RX pin active level inversion disable */
411 #define SMARTCARD_ADVFEATURE_RXINV_ENABLE ((uint32_t)USART_CR2_RXINV) /*!< RX pin active level inversion enable */
416 /** @defgroup SMARTCARD_Data_Inv SMARTCARD advanced feature Binary Data inversion
419 #define SMARTCARD_ADVFEATURE_DATAINV_DISABLE (0x00000000U) /*!< Binary data inversion disable */
420 #define SMARTCARD_ADVFEATURE_DATAINV_ENABLE ((uint32_t)USART_CR2_DATAINV) /*!< Binary data inversion enable */
425 /** @defgroup SMARTCARD_Rx_Tx_Swap SMARTCARD advanced feature RX TX pins swap
428 #define SMARTCARD_ADVFEATURE_SWAP_DISABLE (0x00000000U) /*!< TX/RX pins swap disable */
429 #define SMARTCARD_ADVFEATURE_SWAP_ENABLE ((uint32_t)USART_CR2_SWAP) /*!< TX/RX pins swap enable */
434 /** @defgroup SMARTCARD_Overrun_Disable SMARTCARD advanced feature Overrun Disable
437 #define SMARTCARD_ADVFEATURE_OVERRUN_ENABLE (0x00000000U) /*!< RX overrun enable */
438 #define SMARTCARD_ADVFEATURE_OVERRUN_DISABLE ((uint32_t)USART_CR3_OVRDIS) /*!< RX overrun disable */
443 /** @defgroup SMARTCARD_DMA_Disable_on_Rx_Error SMARTCARD advanced feature DMA Disable on Rx Error
446 #define SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR (0x00000000U) /*!< DMA enable on Reception Error */
447 #define SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR ((uint32_t)USART_CR3_DDRE) /*!< DMA disable on Reception Error */
452 /** @defgroup SMARTCARD_MSB_First SMARTCARD advanced feature MSB first
455 #define SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE (0x00000000U) /*!< Most significant bit sent/received first disable */
456 #define SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE ((uint32_t)USART_CR2_MSBFIRST) /*!< Most significant bit sent/received first enable */
461 /** @defgroup SMARTCARD_Flags SMARTCARD Flags
462 * Elements values convention: 0xXXXX
463 * - 0xXXXX : Flag mask in the ISR register
466 #define SMARTCARD_FLAG_REACK USART_ISR_REACK /*!< SMARTCARD receive enable acknowledge flag */
467 #define SMARTCARD_FLAG_TEACK USART_ISR_TEACK /*!< SMARTCARD transmit enable acknowledge flag */
468 #define SMARTCARD_FLAG_BUSY USART_ISR_BUSY /*!< SMARTCARD busy flag */
469 #define SMARTCARD_FLAG_EOBF USART_ISR_EOBF /*!< SMARTCARD end of block flag */
470 #define SMARTCARD_FLAG_RTOF USART_ISR_RTOF /*!< SMARTCARD receiver timeout flag */
471 #define SMARTCARD_FLAG_TXE USART_ISR_TXE /*!< SMARTCARD transmit data register empty */
472 #define SMARTCARD_FLAG_TC USART_ISR_TC /*!< SMARTCARD transmission complete */
473 #define SMARTCARD_FLAG_RXNE USART_ISR_RXNE /*!< SMARTCARD read data register not empty */
474 #define SMARTCARD_FLAG_IDLE USART_ISR_IDLE /*!< SMARTCARD idle line detection */
475 #define SMARTCARD_FLAG_ORE USART_ISR_ORE /*!< SMARTCARD overrun error */
476 #define SMARTCARD_FLAG_NE USART_ISR_NE /*!< SMARTCARD noise error */
477 #define SMARTCARD_FLAG_FE USART_ISR_FE /*!< SMARTCARD frame error */
478 #define SMARTCARD_FLAG_PE USART_ISR_PE /*!< SMARTCARD parity error */
483 /** @defgroup SMARTCARD_Interrupt_definition SMARTCARD Interrupts Definition
484 * Elements values convention: 0000ZZZZ0XXYYYYYb
485 * - YYYYY : Interrupt source position in the XX register (5bits)
486 * - XX : Interrupt source register (2bits)
490 * - ZZZZ : Flag position in the ISR register(4bits)
494 #define SMARTCARD_IT_PE ((uint16_t)0x0028U) /*!< SMARTCARD parity error interruption */
495 #define SMARTCARD_IT_TXE ((uint16_t)0x0727U) /*!< SMARTCARD transmit data register empty interruption */
496 #define SMARTCARD_IT_TC ((uint16_t)0x0626U) /*!< SMARTCARD transmission complete interruption */
497 #define SMARTCARD_IT_RXNE ((uint16_t)0x0525U) /*!< SMARTCARD read data register not empty interruption */
498 #define SMARTCARD_IT_IDLE ((uint16_t)0x0424U) /*!< SMARTCARD idle line detection interruption */
500 #define SMARTCARD_IT_ERR ((uint16_t)0x0060U) /*!< SMARTCARD error interruption */
501 #define SMARTCARD_IT_ORE ((uint16_t)0x0300U) /*!< SMARTCARD overrun error interruption */
502 #define SMARTCARD_IT_NE ((uint16_t)0x0200U) /*!< SMARTCARD noise error interruption */
503 #define SMARTCARD_IT_FE ((uint16_t)0x0100U) /*!< SMARTCARD frame error interruption */
505 #define SMARTCARD_IT_EOB ((uint16_t)0x0C3BU) /*!< SMARTCARD end of block interruption */
506 #define SMARTCARD_IT_RTO ((uint16_t)0x0B3AU) /*!< SMARTCARD receiver timeout interruption */
511 /** @defgroup SMARTCARD_IT_CLEAR_Flags SMARTCARD Interruption Clear Flags
514 #define SMARTCARD_CLEAR_PEF USART_ICR_PECF /*!< SMARTCARD parity error clear flag */
515 #define SMARTCARD_CLEAR_FEF USART_ICR_FECF /*!< SMARTCARD framing error clear flag */
516 #define SMARTCARD_CLEAR_NEF USART_ICR_NCF /*!< SMARTCARD noise detected clear flag */
517 #define SMARTCARD_CLEAR_OREF USART_ICR_ORECF /*!< SMARTCARD overrun error clear flag */
518 #define SMARTCARD_CLEAR_IDLEF USART_ICR_IDLECF /*!< SMARTCARD idle line detected clear flag */
519 #define SMARTCARD_CLEAR_TCF USART_ICR_TCCF /*!< SMARTCARD transmission complete clear flag */
520 #define SMARTCARD_CLEAR_RTOF USART_ICR_RTOCF /*!< SMARTCARD receiver time out clear flag */
521 #define SMARTCARD_CLEAR_EOBF USART_ICR_EOBCF /*!< SMARTCARD end of block clear flag */
526 /** @defgroup SMARTCARD_CR3_SCARCNT_LSB_POS SMARTCARD auto retry counter LSB position in CR3 register
529 #define SMARTCARD_CR3_SCARCNT_LSB_POS ( 17U) /*!< SMARTCARD auto retry counter LSB position in CR3 register */
534 /** @defgroup SMARTCARD_GTPR_GT_LSB_POS SMARTCARD guard time value LSB position in GTPR register
537 #define SMARTCARD_GTPR_GT_LSB_POS ( 8U) /*!< SMARTCARD guard time value LSB position in GTPR register */
542 /** @defgroup SMARTCARD_RTOR_BLEN_LSB_POS SMARTCARD block length LSB position in RTOR register
545 #define SMARTCARD_RTOR_BLEN_LSB_POS ( 24U) /*!< SMARTCARD block length LSB position in RTOR register */
550 /** @defgroup SMARTCARD_Interruption_Mask SMARTCARD interruptions flags mask
553 #define SMARTCARD_IT_MASK ((uint16_t)0x001FU) /*!< SMARTCARD interruptions flags mask */
558 /** @defgroup SMARTCARD_Request_Parameters SMARTCARD Request Parameters
561 #define SMARTCARD_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive data flush request */
562 #define SMARTCARD_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush request */
571 /* Exported macros -----------------------------------------------------------*/
572 /** @defgroup SMARTCARD_Exported_Macros SMARTCARD Exported Macros
576 /** @brief Reset SMARTCARD handle states.
577 * @param __HANDLE__ SMARTCARD handle.
580 #define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__) do{ \
581 (__HANDLE__)->gState = HAL_SMARTCARD_STATE_RESET; \
582 (__HANDLE__)->RxState = HAL_SMARTCARD_STATE_RESET; \
585 /** @brief Flush the Smartcard Data registers.
586 * @param __HANDLE__ specifies the SMARTCARD Handle.
589 #define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__) \
591 SET_BIT((__HANDLE__)->Instance->RQR, SMARTCARD_RXDATA_FLUSH_REQUEST); \
592 SET_BIT((__HANDLE__)->Instance->RQR, SMARTCARD_TXDATA_FLUSH_REQUEST); \
595 /** @brief Clear the specified SMARTCARD pending flag.
596 * @param __HANDLE__ specifies the SMARTCARD Handle.
597 * @param __FLAG__ specifies the flag to check.
598 * This parameter can be any combination of the following values:
599 * @arg @ref SMARTCARD_CLEAR_PEF Parity error clear flag
600 * @arg @ref SMARTCARD_CLEAR_FEF Framing error clear flag
601 * @arg @ref SMARTCARD_CLEAR_NEF Noise detected clear flag
602 * @arg @ref SMARTCARD_CLEAR_OREF OverRun error clear flag
603 * @arg @ref SMARTCARD_CLEAR_IDLEF Idle line detected clear flag
604 * @arg @ref SMARTCARD_CLEAR_TCF Transmission complete clear flag
605 * @arg @ref SMARTCARD_CLEAR_RTOF Receiver timeout clear flag
606 * @arg @ref SMARTCARD_CLEAR_EOBF End of block clear flag
609 #define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
611 /** @brief Clear the SMARTCARD PE pending flag.
612 * @param __HANDLE__ specifies the SMARTCARD Handle.
615 #define __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_PEF)
618 /** @brief Clear the SMARTCARD FE pending flag.
619 * @param __HANDLE__ specifies the SMARTCARD Handle.
622 #define __HAL_SMARTCARD_CLEAR_FEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_FEF)
624 /** @brief Clear the SMARTCARD NE pending flag.
625 * @param __HANDLE__ specifies the SMARTCARD Handle.
628 #define __HAL_SMARTCARD_CLEAR_NEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_NEF)
630 /** @brief Clear the SMARTCARD ORE pending flag.
631 * @param __HANDLE__ specifies the SMARTCARD Handle.
634 #define __HAL_SMARTCARD_CLEAR_OREFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_OREF)
636 /** @brief Clear the SMARTCARD IDLE pending flag.
637 * @param __HANDLE__ specifies the SMARTCARD Handle.
640 #define __HAL_SMARTCARD_CLEAR_IDLEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_IDLEF)
642 /** @brief Check whether the specified Smartcard flag is set or not.
643 * @param __HANDLE__ specifies the SMARTCARD Handle.
644 * @param __FLAG__ specifies the flag to check.
645 * This parameter can be one of the following values:
646 * @arg @ref SMARTCARD_FLAG_REACK Receive enable acknowledge flag
647 * @arg @ref SMARTCARD_FLAG_TEACK Transmit enable acknowledge flag
648 * @arg @ref SMARTCARD_FLAG_BUSY Busy flag
649 * @arg @ref SMARTCARD_FLAG_EOBF End of block flag
650 * @arg @ref SMARTCARD_FLAG_RTOF Receiver timeout flag
651 * @arg @ref SMARTCARD_FLAG_TXE Transmit data register empty flag
652 * @arg @ref SMARTCARD_FLAG_TC Transmission complete flag
653 * @arg @ref SMARTCARD_FLAG_RXNE Receive data register not empty flag
654 * @arg @ref SMARTCARD_FLAG_IDLE Idle line detection flag
655 * @arg @ref SMARTCARD_FLAG_ORE Overrun error flag
656 * @arg @ref SMARTCARD_FLAG_NE Noise error flag
657 * @arg @ref SMARTCARD_FLAG_FE Framing error flag
658 * @arg @ref SMARTCARD_FLAG_PE Parity error flag
659 * @retval The new state of __FLAG__ (TRUE or FALSE).
661 #define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
664 /** @brief Enable the specified SmartCard interrupt.
665 * @param __HANDLE__ specifies the SMARTCARD Handle.
666 * @param __INTERRUPT__ specifies the SMARTCARD interrupt to enable.
667 * This parameter can be one of the following values:
668 * @arg @ref SMARTCARD_IT_EOB End of block interrupt
669 * @arg @ref SMARTCARD_IT_RTO Receive timeout interrupt
670 * @arg @ref SMARTCARD_IT_TXE Transmit data register empty interrupt
671 * @arg @ref SMARTCARD_IT_TC Transmission complete interrupt
672 * @arg @ref SMARTCARD_IT_RXNE Receive data register not empty interrupt
673 * @arg @ref SMARTCARD_IT_IDLE Idle line detection interrupt
674 * @arg @ref SMARTCARD_IT_PE Parity error interrupt
675 * @arg @ref SMARTCARD_IT_ERR Error interrupt(frame error, noise error, overrun error)
678 #define __HAL_SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & 0xFFU) >> 5U) == 1U)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
679 ((((__INTERRUPT__) & 0xFFU) >> 5U) == 2U)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
680 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))))
682 /** @brief Disable the specified SmartCard interrupt.
683 * @param __HANDLE__ specifies the SMARTCARD Handle.
684 * @param __INTERRUPT__ specifies the SMARTCARD interrupt to disable.
685 * This parameter can be one of the following values:
686 * @arg @ref SMARTCARD_IT_EOB End of block interrupt
687 * @arg @ref SMARTCARD_IT_RTO Receive timeout interrupt
688 * @arg @ref SMARTCARD_IT_TXE Transmit data register empty interrupt
689 * @arg @ref SMARTCARD_IT_TC Transmission complete interrupt
690 * @arg @ref SMARTCARD_IT_RXNE Receive data register not empty interrupt
691 * @arg @ref SMARTCARD_IT_IDLE Idle line detection interrupt
692 * @arg @ref SMARTCARD_IT_PE Parity error interrupt
693 * @arg @ref SMARTCARD_IT_ERR Error interrupt(frame error, noise error, overrun error)
696 #define __HAL_SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & 0xFFU) >> 5U) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
697 ((((__INTERRUPT__) & 0xFFU) >> 5U) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
698 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))))
701 /** @brief Check whether the specified SmartCard interrupt has occurred or not.
702 * @param __HANDLE__ specifies the SMARTCARD Handle.
703 * @param __IT__ specifies the SMARTCARD interrupt to check.
704 * This parameter can be one of the following values:
705 * @arg @ref SMARTCARD_IT_EOB End of block interrupt
706 * @arg @ref SMARTCARD_IT_RTO Receive timeout interrupt
707 * @arg @ref SMARTCARD_IT_TXE Transmit data register empty interrupt
708 * @arg @ref SMARTCARD_IT_TC Transmission complete interrupt
709 * @arg @ref SMARTCARD_IT_RXNE Receive data register not empty interrupt
710 * @arg @ref SMARTCARD_IT_IDLE Idle line detection interrupt
711 * @arg @ref SMARTCARD_IT_ORE Overrun error interrupt
712 * @arg @ref SMARTCARD_IT_NE Noise error interrupt
713 * @arg @ref SMARTCARD_IT_FE Framing error interrupt
714 * @arg @ref SMARTCARD_IT_PE Parity error interrupt
715 * @retval The new state of __IT__ (TRUE or FALSE).
717 #define __HAL_SMARTCARD_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & (1U << ((__IT__)>> 0x08U)))
719 /** @brief Check whether the specified SmartCard interrupt source is enabled or not.
720 * @param __HANDLE__ specifies the SMARTCARD Handle.
721 * @param __IT__ specifies the SMARTCARD interrupt source to check.
722 * This parameter can be one of the following values:
723 * @arg @ref SMARTCARD_IT_EOB End of block interrupt
724 * @arg @ref SMARTCARD_IT_RTO Receive timeout interrupt
725 * @arg @ref SMARTCARD_IT_TXE Transmit data register empty interrupt
726 * @arg @ref SMARTCARD_IT_TC Transmission complete interrupt
727 * @arg @ref SMARTCARD_IT_RXNE Receive data register not empty interrupt
728 * @arg @ref SMARTCARD_IT_IDLE Idle line detection interrupt
729 * @arg @ref SMARTCARD_IT_ERR Framing, overrun or noise error interrupt
730 * @arg @ref SMARTCARD_IT_PE Parity error interrupt
731 * @retval The new state of __IT__ (TRUE or FALSE).
733 #define __HAL_SMARTCARD_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((__IT__) & 0xFFU) >> 5U) == 1U)? (__HANDLE__)->Instance->CR1 : \
734 (((((__IT__) & 0xFFU) >> 5U) == 2U)? (__HANDLE__)->Instance->CR2 : \
735 (__HANDLE__)->Instance->CR3)) & (1U << (((uint16_t)(__IT__)) & SMARTCARD_IT_MASK)))
738 /** @brief Clear the specified SMARTCARD ISR flag, in setting the proper ICR register flag.
739 * @param __HANDLE__ specifies the SMARTCARD Handle.
740 * @param __IT_CLEAR__ specifies the interrupt clear register flag that needs to be set
741 * to clear the corresponding interrupt.
742 * This parameter can be one of the following values:
743 * @arg @ref SMARTCARD_CLEAR_PEF Parity error clear flag
744 * @arg @ref SMARTCARD_CLEAR_FEF Framing error clear flag
745 * @arg @ref SMARTCARD_CLEAR_NEF Noise detected clear flag
746 * @arg @ref SMARTCARD_CLEAR_OREF OverRun error clear flag
747 * @arg @ref SMARTCARD_CLEAR_IDLEF Idle line detection clear flag
748 * @arg @ref SMARTCARD_CLEAR_TCF Transmission complete clear flag
749 * @arg @ref SMARTCARD_CLEAR_RTOF Receiver timeout clear flag
750 * @arg @ref SMARTCARD_CLEAR_EOBF End of block clear flag
753 #define __HAL_SMARTCARD_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
755 /** @brief Set a specific SMARTCARD request flag.
756 * @param __HANDLE__ specifies the SMARTCARD Handle.
757 * @param __REQ__ specifies the request flag to set
758 * This parameter can be one of the following values:
759 * @arg @ref SMARTCARD_RXDATA_FLUSH_REQUEST Receive data flush Request
760 * @arg @ref SMARTCARD_TXDATA_FLUSH_REQUEST Transmit data flush Request
764 #define __HAL_SMARTCARD_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__))
766 /** @brief Enable the SMARTCARD one bit sample method.
767 * @param __HANDLE__ specifies the SMARTCARD Handle.
770 #define __HAL_SMARTCARD_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
772 /** @brief Disable the SMARTCARD one bit sample method.
773 * @param __HANDLE__ specifies the SMARTCARD Handle.
776 #define __HAL_SMARTCARD_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
778 /** @brief Enable the USART associated to the SMARTCARD Handle.
779 * @param __HANDLE__ specifies the SMARTCARD Handle.
782 #define __HAL_SMARTCARD_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
784 /** @brief Disable the USART associated to the SMARTCARD Handle
785 * @param __HANDLE__ specifies the SMARTCARD Handle.
788 #define __HAL_SMARTCARD_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
794 /* Private macros -------------------------------------------------------------*/
795 /** @defgroup SMARTCARD_Private_Macros SMARTCARD Private Macros
799 /** @brief Check the Baud rate range.
800 * @note The maximum Baud Rate is derived from the maximum clock on F3 (72 MHz)
801 * divided by the oversampling used on the SMARTCARD (i.e. 16).
802 * @param __BAUDRATE__ Baud rate set by the configuration function.
803 * @retval Test result (TRUE or FALSE)
805 #define IS_SMARTCARD_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 4500001U)
807 /** @brief Check the block length range.
808 * @note The maximum SMARTCARD block length is 0xFF.
809 * @param __LENGTH__ block length.
810 * @retval Test result (TRUE or FALSE)
812 #define IS_SMARTCARD_BLOCKLENGTH(__LENGTH__) ((__LENGTH__) <= 0xFFU)
814 /** @brief Check the receiver timeout value.
815 * @note The maximum SMARTCARD receiver timeout value is 0xFFFFFF.
816 * @param __TIMEOUTVALUE__ receiver timeout value.
817 * @retval Test result (TRUE or FALSE)
819 #define IS_SMARTCARD_TIMEOUT_VALUE(__TIMEOUTVALUE__) ((__TIMEOUTVALUE__) <= 0xFFFFFFU)
821 /** @brief Check the SMARTCARD autoretry counter value.
822 * @note The maximum number of retransmissions is 0x7.
823 * @param __COUNT__ number of retransmissions.
824 * @retval Test result (TRUE or FALSE)
826 #define IS_SMARTCARD_AUTORETRY_COUNT(__COUNT__) ((__COUNT__) <= 0x7U)
829 * @brief Ensure that SMARTCARD frame length is valid.
830 * @param __LENGTH__ SMARTCARD frame length.
831 * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid)
833 #define IS_SMARTCARD_WORD_LENGTH(__LENGTH__) ((__LENGTH__) == SMARTCARD_WORDLENGTH_9B)
836 * @brief Ensure that SMARTCARD frame number of stop bits is valid.
837 * @param __STOPBITS__ SMARTCARD frame number of stop bits.
838 * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
840 #define IS_SMARTCARD_STOPBITS(__STOPBITS__) (((__STOPBITS__) == SMARTCARD_STOPBITS_0_5) ||\
841 ((__STOPBITS__) == SMARTCARD_STOPBITS_1_5))
844 * @brief Ensure that SMARTCARD frame parity is valid.
845 * @param __PARITY__ SMARTCARD frame parity.
846 * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
848 #define IS_SMARTCARD_PARITY(__PARITY__) (((__PARITY__) == SMARTCARD_PARITY_EVEN) || \
849 ((__PARITY__) == SMARTCARD_PARITY_ODD))
852 * @brief Ensure that SMARTCARD communication mode is valid.
853 * @param __MODE__ SMARTCARD communication mode.
854 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
856 #define IS_SMARTCARD_MODE(__MODE__) ((((__MODE__) & (uint16_t)0xFFF3U) == 0x00U) && ((__MODE__) != (uint16_t)0x00U))
859 * @brief Ensure that SMARTCARD frame polarity is valid.
860 * @param __CPOL__ SMARTCARD frame polarity.
861 * @retval SET (__CPOL__ is valid) or RESET (__CPOL__ is invalid)
863 #define IS_SMARTCARD_POLARITY(__CPOL__) (((__CPOL__) == SMARTCARD_POLARITY_LOW) || ((__CPOL__) == SMARTCARD_POLARITY_HIGH))
866 * @brief Ensure that SMARTCARD frame phase is valid.
867 * @param __CPHA__ SMARTCARD frame phase.
868 * @retval SET (__CPHA__ is valid) or RESET (__CPHA__ is invalid)
870 #define IS_SMARTCARD_PHASE(__CPHA__) (((__CPHA__) == SMARTCARD_PHASE_1EDGE) || ((__CPHA__) == SMARTCARD_PHASE_2EDGE))
873 * @brief Ensure that SMARTCARD frame last bit clock pulse setting is valid.
874 * @param __LASTBIT__ SMARTCARD frame last bit clock pulse setting.
875 * @retval SET (__LASTBIT__ is valid) or RESET (__LASTBIT__ is invalid)
877 #define IS_SMARTCARD_LASTBIT(__LASTBIT__) (((__LASTBIT__) == SMARTCARD_LASTBIT_DISABLE) || \
878 ((__LASTBIT__) == SMARTCARD_LASTBIT_ENABLE))
881 * @brief Ensure that SMARTCARD frame sampling is valid.
882 * @param __ONEBIT__ SMARTCARD frame sampling.
883 * @retval SET (__ONEBIT__ is valid) or RESET (__ONEBIT__ is invalid)
885 #define IS_SMARTCARD_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == SMARTCARD_ONE_BIT_SAMPLE_DISABLE) || \
886 ((__ONEBIT__) == SMARTCARD_ONE_BIT_SAMPLE_ENABLE))
889 * @brief Ensure that SMARTCARD NACK transmission setting is valid.
890 * @param __NACK__ SMARTCARD NACK transmission setting.
891 * @retval SET (__NACK__ is valid) or RESET (__NACK__ is invalid)
893 #define IS_SMARTCARD_NACK(__NACK__) (((__NACK__) == SMARTCARD_NACK_ENABLE) || \
894 ((__NACK__) == SMARTCARD_NACK_DISABLE))
897 * @brief Ensure that SMARTCARD receiver timeout setting is valid.
898 * @param __TIMEOUT__ SMARTCARD receiver timeout setting.
899 * @retval SET (__TIMEOUT__ is valid) or RESET (__TIMEOUT__ is invalid)
901 #define IS_SMARTCARD_TIMEOUT(__TIMEOUT__) (((__TIMEOUT__) == SMARTCARD_TIMEOUT_DISABLE) || \
902 ((__TIMEOUT__) == SMARTCARD_TIMEOUT_ENABLE))
905 * @brief Ensure that SMARTCARD advanced features initialization is valid.
906 * @param __INIT__ SMARTCARD advanced features initialization.
907 * @retval SET (__INIT__ is valid) or RESET (__INIT__ is invalid)
909 #define IS_SMARTCARD_ADVFEATURE_INIT(__INIT__) ((__INIT__) <= (SMARTCARD_ADVFEATURE_NO_INIT | \
910 SMARTCARD_ADVFEATURE_TXINVERT_INIT | \
911 SMARTCARD_ADVFEATURE_RXINVERT_INIT | \
912 SMARTCARD_ADVFEATURE_DATAINVERT_INIT | \
913 SMARTCARD_ADVFEATURE_SWAP_INIT | \
914 SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
915 SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT | \
916 SMARTCARD_ADVFEATURE_MSBFIRST_INIT))
919 * @brief Ensure that SMARTCARD frame TX inversion setting is valid.
920 * @param __TXINV__ SMARTCARD frame TX inversion setting.
921 * @retval SET (__TXINV__ is valid) or RESET (__TXINV__ is invalid)
923 #define IS_SMARTCARD_ADVFEATURE_TXINV(__TXINV__) (((__TXINV__) == SMARTCARD_ADVFEATURE_TXINV_DISABLE) || \
924 ((__TXINV__) == SMARTCARD_ADVFEATURE_TXINV_ENABLE))
927 * @brief Ensure that SMARTCARD frame RX inversion setting is valid.
928 * @param __RXINV__ SMARTCARD frame RX inversion setting.
929 * @retval SET (__RXINV__ is valid) or RESET (__RXINV__ is invalid)
931 #define IS_SMARTCARD_ADVFEATURE_RXINV(__RXINV__) (((__RXINV__) == SMARTCARD_ADVFEATURE_RXINV_DISABLE) || \
932 ((__RXINV__) == SMARTCARD_ADVFEATURE_RXINV_ENABLE))
935 * @brief Ensure that SMARTCARD frame data inversion setting is valid.
936 * @param __DATAINV__ SMARTCARD frame data inversion setting.
937 * @retval SET (__DATAINV__ is valid) or RESET (__DATAINV__ is invalid)
939 #define IS_SMARTCARD_ADVFEATURE_DATAINV(__DATAINV__) (((__DATAINV__) == SMARTCARD_ADVFEATURE_DATAINV_DISABLE) || \
940 ((__DATAINV__) == SMARTCARD_ADVFEATURE_DATAINV_ENABLE))
943 * @brief Ensure that SMARTCARD frame RX/TX pins swap setting is valid.
944 * @param __SWAP__ SMARTCARD frame RX/TX pins swap setting.
945 * @retval SET (__SWAP__ is valid) or RESET (__SWAP__ is invalid)
947 #define IS_SMARTCARD_ADVFEATURE_SWAP(__SWAP__) (((__SWAP__) == SMARTCARD_ADVFEATURE_SWAP_DISABLE) || \
948 ((__SWAP__) == SMARTCARD_ADVFEATURE_SWAP_ENABLE))
951 * @brief Ensure that SMARTCARD frame overrun setting is valid.
952 * @param __OVERRUN__ SMARTCARD frame overrun setting.
953 * @retval SET (__OVERRUN__ is valid) or RESET (__OVERRUN__ is invalid)
955 #define IS_SMARTCARD_OVERRUN(__OVERRUN__) (((__OVERRUN__) == SMARTCARD_ADVFEATURE_OVERRUN_ENABLE) || \
956 ((__OVERRUN__) == SMARTCARD_ADVFEATURE_OVERRUN_DISABLE))
959 * @brief Ensure that SMARTCARD DMA enabling or disabling on error setting is valid.
960 * @param __DMA__ SMARTCARD DMA enabling or disabling on error setting.
961 * @retval SET (__DMA__ is valid) or RESET (__DMA__ is invalid)
963 #define IS_SMARTCARD_ADVFEATURE_DMAONRXERROR(__DMA__) (((__DMA__) == SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR) || \
964 ((__DMA__) == SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR))
967 * @brief Ensure that SMARTCARD frame MSB first setting is valid.
968 * @param __MSBFIRST__ SMARTCARD frame MSB first setting.
969 * @retval SET (__MSBFIRST__ is valid) or RESET (__MSBFIRST__ is invalid)
971 #define IS_SMARTCARD_ADVFEATURE_MSBFIRST(__MSBFIRST__) (((__MSBFIRST__) == SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE) || \
972 ((__MSBFIRST__) == SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE))
975 * @brief Ensure that SMARTCARD request parameter is valid.
976 * @param __PARAM__ SMARTCARD request parameter.
977 * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid)
979 #define IS_SMARTCARD_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == SMARTCARD_RXDATA_FLUSH_REQUEST) || \
980 ((__PARAM__) == SMARTCARD_TXDATA_FLUSH_REQUEST))
986 /* Include SMARTCARD HAL Extended module */
987 #include "stm32f3xx_hal_smartcard_ex.h"
989 /* Exported functions --------------------------------------------------------*/
990 /** @addtogroup SMARTCARD_Exported_Functions
994 /* Initialization and de-initialization functions ****************************/
996 /** @addtogroup SMARTCARD_Exported_Functions_Group1
1000 HAL_StatusTypeDef
HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef
*hsmartcard
);
1001 HAL_StatusTypeDef
HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef
*hsmartcard
);
1002 void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef
*hsmartcard
);
1003 void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef
*hsmartcard
);
1009 /* IO operation functions *****************************************************/
1010 /** @addtogroup SMARTCARD_Exported_Functions_Group2
1014 HAL_StatusTypeDef
HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef
*hsmartcard
, uint8_t *pData
, uint16_t Size
, uint32_t Timeout
);
1015 HAL_StatusTypeDef
HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef
*hsmartcard
, uint8_t *pData
, uint16_t Size
, uint32_t Timeout
);
1016 HAL_StatusTypeDef
HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef
*hsmartcard
, uint8_t *pData
, uint16_t Size
);
1017 HAL_StatusTypeDef
HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef
*hsmartcard
, uint8_t *pData
, uint16_t Size
);
1018 HAL_StatusTypeDef
HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef
*hsmartcard
, uint8_t *pData
, uint16_t Size
);
1019 HAL_StatusTypeDef
HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef
*hsmartcard
, uint8_t *pData
, uint16_t Size
);
1020 /* Transfer Abort functions */
1021 HAL_StatusTypeDef
HAL_SMARTCARD_Abort(SMARTCARD_HandleTypeDef
*hsmartcard
);
1022 HAL_StatusTypeDef
HAL_SMARTCARD_AbortTransmit(SMARTCARD_HandleTypeDef
*hsmartcard
);
1023 HAL_StatusTypeDef
HAL_SMARTCARD_AbortReceive(SMARTCARD_HandleTypeDef
*hsmartcard
);
1024 HAL_StatusTypeDef
HAL_SMARTCARD_Abort_IT(SMARTCARD_HandleTypeDef
*hsmartcard
);
1025 HAL_StatusTypeDef
HAL_SMARTCARD_AbortTransmit_IT(SMARTCARD_HandleTypeDef
*hsmartcard
);
1026 HAL_StatusTypeDef
HAL_SMARTCARD_AbortReceive_IT(SMARTCARD_HandleTypeDef
*hsmartcard
);
1028 void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef
*hsmartcard
);
1029 void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef
*hsmartcard
);
1030 void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef
*hsmartcard
);
1031 void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef
*hsmartcard
);
1032 void HAL_SMARTCARD_AbortCpltCallback (SMARTCARD_HandleTypeDef
*hsmartcard
);
1033 void HAL_SMARTCARD_AbortTransmitCpltCallback (SMARTCARD_HandleTypeDef
*hsmartcard
);
1034 void HAL_SMARTCARD_AbortReceiveCpltCallback (SMARTCARD_HandleTypeDef
*hsmartcard
);
1040 /* Peripheral State and Error functions ***************************************/
1041 /** @addtogroup SMARTCARD_Exported_Functions_Group3
1045 HAL_SMARTCARD_StateTypeDef
HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef
*hsmartcard
);
1046 uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef
*hsmartcard
);
1068 #endif /* __STM32F3xx_HAL_SMARTCARD_H */
1070 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/