TUKS MCU Introductory course / TUKS-COURSE-THERMOMETER

Fork of TUKS-COURSE-TIMER by TUKS MCU Introductory course

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers stm32l4xx_hal_smartcard.h Source File

stm32l4xx_hal_smartcard.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_hal_smartcard.h
00004   * @author  MCD Application Team
00005   * @version V1.5.1
00006   * @date    31-May-2016
00007   * @brief   Header file of SMARTCARD HAL module.
00008   ******************************************************************************
00009   * @attention
00010   *
00011   * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
00012   *
00013   * Redistribution and use in source and binary forms, with or without modification,
00014   * are permitted provided that the following conditions are met:
00015   *   1. Redistributions of source code must retain the above copyright notice,
00016   *      this list of conditions and the following disclaimer.
00017   *   2. Redistributions in binary form must reproduce the above copyright notice,
00018   *      this list of conditions and the following disclaimer in the documentation
00019   *      and/or other materials provided with the distribution.
00020   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00021   *      may be used to endorse or promote products derived from this software
00022   *      without specific prior written permission.
00023   *
00024   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00025   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00026   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00027   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00028   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00029   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00030   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00032   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00033   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034   *
00035   ******************************************************************************
00036   */
00037 
00038 /* Define to prevent recursive inclusion -------------------------------------*/
00039 #ifndef __STM32L4xx_HAL_SMARTCARD_H
00040 #define __STM32L4xx_HAL_SMARTCARD_H
00041 
00042 #ifdef __cplusplus
00043  extern "C" {
00044 #endif
00045 
00046 /* Includes ------------------------------------------------------------------*/
00047 #include "stm32l4xx_hal_def.h"
00048 
00049 /** @addtogroup STM32L4xx_HAL_Driver
00050   * @{
00051   */
00052 
00053 /** @addtogroup SMARTCARD
00054   * @{
00055   */
00056 
00057 /* Exported types ------------------------------------------------------------*/
00058 /** @defgroup SMARTCARD_Exported_Types SMARTCARD Exported Types
00059   * @{
00060   */
00061 
00062 /**
00063   * @brief SMARTCARD Init Structure definition
00064   */
00065 typedef struct
00066 {
00067   uint32_t BaudRate;                  /*!< Configures the SmartCard communication baud rate.
00068                                            The baud rate register is computed using the following formula:
00069                                               Baud Rate Register = ((PCLKx) / ((hsmartcard->Init.BaudRate))) */
00070 
00071   uint32_t WordLength;                /*!< Specifies the number of data bits transmitted or received in a frame.
00072                                            This parameter @ref SMARTCARD_Word_Length can only be set to 9 (8 data + 1 parity bits). */
00073 
00074   uint32_t StopBits;                  /*!< Specifies the number of stop bits.
00075                                            This parameter can be a value of @ref SMARTCARD_Stop_Bits. */
00076 
00077   uint16_t Parity;                    /*!< Specifies the parity mode.
00078                                            This parameter can be a value of @ref SMARTCARD_Parity
00079                                            @note The parity is enabled by default (PCE is forced to 1).
00080                                                  Since the WordLength is forced to 8 bits + parity, M is
00081                                                  forced to 1 and the parity bit is the 9th bit. */
00082 
00083   uint16_t Mode;                      /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
00084                                            This parameter can be a value of @ref SMARTCARD_Mode */
00085 
00086   uint16_t CLKPolarity;               /*!< Specifies the steady state of the serial clock.
00087                                            This parameter can be a value of @ref SMARTCARD_Clock_Polarity */
00088 
00089   uint16_t CLKPhase;                  /*!< Specifies the clock transition on which the bit capture is made.
00090                                            This parameter can be a value of @ref SMARTCARD_Clock_Phase */
00091 
00092   uint16_t CLKLastBit;                /*!< Specifies whether the clock pulse corresponding to the last transmitted
00093                                            data bit (MSB) has to be output on the SCLK pin in synchronous mode.
00094                                            This parameter can be a value of @ref SMARTCARD_Last_Bit */
00095 
00096   uint16_t OneBitSampling;            /*!< Specifies whether a single sample or three samples' majority vote is selected.
00097                                            Selecting the single sample method increases the receiver tolerance to clock
00098                                            deviations. This parameter can be a value of @ref SMARTCARD_OneBit_Sampling. */
00099 
00100   uint8_t  Prescaler;                 /*!< Specifies the SmartCard Prescaler. */
00101 
00102   uint8_t  GuardTime;                 /*!< Specifies the SmartCard Guard Time applied after stop bits. */
00103 
00104   uint16_t NACKEnable;                /*!< Specifies whether the SmartCard NACK transmission is enabled
00105                                            in case of parity error.
00106                                            This parameter can be a value of @ref SMARTCARD_NACK_Enable */
00107 
00108   uint32_t TimeOutEnable;             /*!< Specifies whether the receiver timeout is enabled.
00109                                             This parameter can be a value of @ref SMARTCARD_Timeout_Enable*/
00110 
00111   uint32_t TimeOutValue;              /*!< Specifies the receiver time out value in number of baud blocks:
00112                                            it is used to implement the Character Wait Time (CWT) and
00113                                            Block Wait Time (BWT). It is coded over 24 bits. */
00114 
00115   uint8_t BlockLength;                /*!< Specifies the SmartCard Block Length in T=1 Reception mode.
00116                                            This parameter can be any value from 0x0 to 0xFF */
00117 
00118   uint8_t AutoRetryCount;             /*!< Specifies the SmartCard auto-retry count (number of retries in
00119                                             receive and transmit mode). When set to 0, retransmission is
00120                                             disabled. Otherwise, its maximum value is 7 (before signalling
00121                                             an error) */
00122 
00123 }SMARTCARD_InitTypeDef;
00124 
00125 /**
00126   * @brief  SMARTCARD advanced features initalization structure definition
00127   */
00128 typedef struct
00129 {
00130   uint32_t AdvFeatureInit;            /*!< Specifies which advanced SMARTCARD features is initialized. Several
00131                                            advanced features may be initialized at the same time. This parameter
00132                                            can be a value of @ref SMARTCARDEx_Advanced_Features_Initialization_Type */
00133 
00134   uint32_t TxPinLevelInvert;          /*!< Specifies whether the TX pin active level is inverted.
00135                                            This parameter can be a value of @ref SMARTCARD_Tx_Inv  */
00136 
00137   uint32_t RxPinLevelInvert;          /*!< Specifies whether the RX pin active level is inverted.
00138                                            This parameter can be a value of @ref SMARTCARD_Rx_Inv  */
00139 
00140   uint32_t DataInvert;                /*!< Specifies whether data are inverted (positive/direct logic
00141                                            vs negative/inverted logic).
00142                                            This parameter can be a value of @ref SMARTCARD_Data_Inv */
00143 
00144   uint32_t Swap;                      /*!< Specifies whether TX and RX pins are swapped.
00145                                            This parameter can be a value of @ref SMARTCARD_Rx_Tx_Swap */
00146 
00147   uint32_t OverrunDisable;            /*!< Specifies whether the reception overrun detection is disabled.
00148                                            This parameter can be a value of @ref SMARTCARD_Overrun_Disable */
00149 
00150   uint32_t DMADisableonRxError;       /*!< Specifies whether the DMA is disabled in case of reception error.
00151                                            This parameter can be a value of @ref SMARTCARD_DMA_Disable_on_Rx_Error */
00152 
00153   uint32_t MSBFirst;                  /*!< Specifies whether MSB is sent first on UART line.
00154                                            This parameter can be a value of @ref SMARTCARD_MSB_First */
00155                                            
00156   uint16_t TxCompletionIndication;     /*!< Specifies which transmission completion indication is used: before (when 
00157                                             relevant flag is available) or once guard time period has elapsed.
00158                                            This parameter can be a value of @ref SMARTCARDEx_Transmission_Completion_Indication. */                                            
00159 }SMARTCARD_AdvFeatureInitTypeDef;
00160 
00161 /**
00162   * @brief HAL SMARTCARD State structures definition
00163   * @note  HAL SMARTCARD State value is a combination of 2 different substates: gState and RxState.
00164   *        - gState contains SMARTCARD state information related to global Handle management 
00165   *          and also information related to Tx operations.
00166   *          gState value coding follow below described bitmap :
00167   *          b7-b6  Error information 
00168   *             00 : No Error
00169   *             01 : (Not Used)
00170   *             10 : Timeout
00171   *             11 : Error
00172   *          b5     IP initilisation status
00173   *             0  : Reset (IP not initialized)
00174   *             1  : Init done (IP not initialized. HAL SMARTCARD Init function already called)
00175   *          b4-b3  (not used)
00176   *             xx : Should be set to 00
00177   *          b2     Intrinsic process state
00178   *             0  : Ready
00179   *             1  : Busy (IP busy with some configuration or internal operations)
00180   *          b1     (not used)
00181   *             x  : Should be set to 0
00182   *          b0     Tx state
00183   *             0  : Ready (no Tx operation ongoing)
00184   *             1  : Busy (Tx operation ongoing)
00185   *        - RxState contains information related to Rx operations.
00186   *          RxState value coding follow below described bitmap :
00187   *          b7-b6  (not used)
00188   *             xx : Should be set to 00
00189   *          b5     IP initilisation status
00190   *             0  : Reset (IP not initialized)
00191   *             1  : Init done (IP not initialized)
00192   *          b4-b2  (not used)
00193   *            xxx : Should be set to 000
00194   *          b1     Rx state
00195   *             0  : Ready (no Rx operation ongoing)
00196   *             1  : Busy (Rx operation ongoing)
00197   *          b0     (not used)
00198   *             x  : Should be set to 0.
00199   */
00200 typedef enum
00201 {
00202   HAL_SMARTCARD_STATE_RESET             = 0x00U,   /*!< Peripheral is not initialized
00203                                                         Value is allowed for gState and RxState */
00204   HAL_SMARTCARD_STATE_READY             = 0x20U,   /*!< Peripheral Initialized and ready for use
00205                                                         Value is allowed for gState and RxState */
00206   HAL_SMARTCARD_STATE_BUSY              = 0x24U,   /*!< an internal process is ongoing 
00207                                                         Value is allowed for gState only */
00208   HAL_SMARTCARD_STATE_BUSY_TX           = 0x21U,   /*!< Data Transmission process is ongoing
00209                                                         Value is allowed for gState only */
00210   HAL_SMARTCARD_STATE_BUSY_RX           = 0x22U,   /*!< Data Reception process is ongoing
00211                                                         Value is allowed for RxState only */
00212   HAL_SMARTCARD_STATE_BUSY_TX_RX        = 0x23U,   /*!< Data Transmission and Reception process is ongoing
00213                                                         Not to be used for neither gState nor RxState.
00214                                                         Value is result of combination (Or) between gState and RxState values */
00215   HAL_SMARTCARD_STATE_TIMEOUT           = 0xA0U,   /*!< Timeout state
00216                                                         Value is allowed for gState only */
00217   HAL_SMARTCARD_STATE_ERROR             = 0xE0U    /*!< Error
00218                                                         Value is allowed for gState only */
00219 }HAL_SMARTCARD_StateTypeDef;
00220 
00221 /**
00222   * @brief  HAL SMARTCARD Error Code structure definition
00223   */
00224 typedef enum
00225 {
00226   HAL_SMARTCARD_ERROR_NONE      = 0x00,    /*!< No error                */
00227   HAL_SMARTCARD_ERROR_PE        = 0x01,    /*!< Parity error            */
00228   HAL_SMARTCARD_ERROR_NE        = 0x02,    /*!< Noise error             */
00229   HAL_SMARTCARD_ERROR_FE        = 0x04,    /*!< frame error             */
00230   HAL_SMARTCARD_ERROR_ORE       = 0x08,    /*!< Overrun error           */
00231   HAL_SMARTCARD_ERROR_DMA       = 0x10,    /*!< DMA transfer error      */
00232   HAL_SMARTCARD_ERROR_RTO       = 0x20     /*!< Receiver TimeOut error  */
00233 }HAL_SMARTCARD_ErrorTypeDef;
00234 
00235 /**
00236   * @brief  SMARTCARD handle Structure definition
00237   */
00238 typedef struct
00239 {
00240   USART_TypeDef                   *Instance;        /*!< USART registers base address                          */
00241 
00242   SMARTCARD_InitTypeDef           Init;             /*!< SmartCard communication parameters                    */
00243 
00244   SMARTCARD_AdvFeatureInitTypeDef AdvancedInit;     /*!< SmartCard advanced features initialization parameters */
00245 
00246   uint8_t                         *pTxBuffPtr;      /*!< Pointer to SmartCard Tx transfer Buffer               */
00247 
00248   uint16_t                        TxXferSize;       /*!< SmartCard Tx Transfer size                            */
00249 
00250   uint16_t                        TxXferCount;      /*!< SmartCard Tx Transfer Counter                         */
00251 
00252   uint8_t                         *pRxBuffPtr;      /*!< Pointer to SmartCard Rx transfer Buffer               */
00253 
00254   uint16_t                        RxXferSize;       /*!< SmartCard Rx Transfer size                            */
00255 
00256   uint16_t                        RxXferCount;      /*!< SmartCard Rx Transfer Counter                         */
00257 
00258   DMA_HandleTypeDef               *hdmatx;          /*!< SmartCard Tx DMA Handle parameters                    */
00259 
00260   DMA_HandleTypeDef               *hdmarx;          /*!< SmartCard Rx DMA Handle parameters                    */
00261 
00262   HAL_LockTypeDef                 Lock;             /*!< Locking object                                        */
00263 
00264   __IO HAL_SMARTCARD_StateTypeDef    gState;        /*!< SmartCard state information related to global Handle management 
00265                                                          and also related to Tx operations.
00266                                                          This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
00267 
00268   __IO HAL_SMARTCARD_StateTypeDef    RxState;       /*!< SmartCard state information related to Rx operations.
00269                                                          This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
00270 
00271   uint32_t                        ErrorCode;        /*!< SmartCard Error code                                  */
00272 
00273 }SMARTCARD_HandleTypeDef;
00274 
00275 /**
00276   * @brief  SMARTCARD clock sources
00277   */
00278 typedef enum
00279 {
00280   SMARTCARD_CLOCKSOURCE_PCLK1     = 0x00, /*!< PCLK1 clock source     */
00281   SMARTCARD_CLOCKSOURCE_PCLK2     = 0x01, /*!< PCLK2 clock source     */
00282   SMARTCARD_CLOCKSOURCE_HSI       = 0x02, /*!< HSI clock source       */
00283   SMARTCARD_CLOCKSOURCE_SYSCLK    = 0x04, /*!< SYSCLK clock source    */
00284   SMARTCARD_CLOCKSOURCE_LSE       = 0x08, /*!< LSE clock source       */
00285   SMARTCARD_CLOCKSOURCE_UNDEFINED = 0x10  /*!< undefined clock source */
00286 }SMARTCARD_ClockSourceTypeDef;
00287 
00288 /**
00289   * @}
00290   */
00291 
00292 /* Exported constants --------------------------------------------------------*/
00293 /** @defgroup SMARTCARD_Exported_Constants  SMARTCARD Exported Constants
00294   * @{
00295   */
00296 
00297 /** @defgroup SMARTCARD_Word_Length SMARTCARD Word Length
00298   * @{
00299   */
00300 #define SMARTCARD_WORDLENGTH_9B             ((uint32_t)USART_CR1_M0)              /*!< SMARTCARD frame length */
00301 /**
00302   * @}
00303   */
00304 
00305 /** @defgroup SMARTCARD_Stop_Bits SMARTCARD Number of Stop Bits
00306   * @{
00307   */
00308 #define SMARTCARD_STOPBITS_0_5              ((uint32_t)USART_CR2_STOP_0)                      /*!< SMARTCARD frame with 0.5 stop bit  */
00309 #define SMARTCARD_STOPBITS_1_5              ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) /*!< SMARTCARD frame with 1.5 stop bits */
00310 /**
00311   * @}
00312   */
00313 
00314 /** @defgroup SMARTCARD_Parity SMARTCARD Parity
00315   * @{
00316   */
00317 #define SMARTCARD_PARITY_EVEN               ((uint32_t)USART_CR1_PCE)                  /*!< SMARTCARD frame even parity */
00318 #define SMARTCARD_PARITY_ODD                ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) /*!< SMARTCARD frame odd parity  */
00319 /**
00320   * @}
00321   */
00322 
00323 /** @defgroup SMARTCARD_Mode SMARTCARD Transfer Mode
00324   * @{
00325   */
00326 #define SMARTCARD_MODE_RX                   ((uint32_t)USART_CR1_RE)                  /*!< SMARTCARD RX mode        */
00327 #define SMARTCARD_MODE_TX                   ((uint32_t)USART_CR1_TE)                  /*!< SMARTCARD TX mode        */
00328 #define SMARTCARD_MODE_TX_RX                ((uint32_t)(USART_CR1_TE |USART_CR1_RE))  /*!< SMARTCARD RX and TX mode */
00329 /**
00330   * @}
00331   */
00332 
00333 /** @defgroup SMARTCARD_Clock_Polarity SMARTCARD Clock Polarity
00334   * @{
00335   */
00336 #define SMARTCARD_POLARITY_LOW              ((uint32_t)0x00000000)                   /*!< SMARTCARD frame low polarity  */
00337 #define SMARTCARD_POLARITY_HIGH             ((uint32_t)USART_CR2_CPOL)               /*!< SMARTCARD frame high polarity */
00338 /**
00339   * @}
00340   */
00341 
00342 /** @defgroup SMARTCARD_Clock_Phase SMARTCARD Clock Phase
00343   * @{
00344   */
00345 #define SMARTCARD_PHASE_1EDGE               ((uint32_t)0x00000000)                  /*!< SMARTCARD frame phase on first clock transition  */
00346 #define SMARTCARD_PHASE_2EDGE               ((uint32_t)USART_CR2_CPHA)              /*!< SMARTCARD frame phase on second clock transition */
00347 /**
00348   * @}
00349   */
00350 
00351 /** @defgroup SMARTCARD_Last_Bit SMARTCARD Last Bit
00352   * @{
00353   */
00354 #define SMARTCARD_LASTBIT_DISABLE           ((uint32_t)0x00000000)                 /*!< SMARTCARD frame last data bit clock pulse not output to SCLK pin */
00355 #define SMARTCARD_LASTBIT_ENABLE            ((uint32_t)USART_CR2_LBCL)             /*!< SMARTCARD frame last data bit clock pulse output to SCLK pin     */
00356 /**
00357   * @}
00358   */
00359 
00360 /** @defgroup SMARTCARD_OneBit_Sampling SMARTCARD One Bit Sampling Method
00361   * @{
00362   */
00363 #define SMARTCARD_ONE_BIT_SAMPLE_DISABLE    ((uint32_t)0x00000000)                 /*!< SMARTCARD frame one-bit sample disabled */
00364 #define SMARTCARD_ONE_BIT_SAMPLE_ENABLE     ((uint32_t)USART_CR3_ONEBIT)           /*!< SMARTCARD frame one-bit sample enabled  */
00365 /**
00366   * @}
00367   */
00368 
00369 
00370 /** @defgroup SMARTCARD_NACK_Enable SMARTCARD NACK Enable
00371   * @{
00372   */
00373 #define SMARTCARD_NACK_ENABLE               ((uint32_t)USART_CR3_NACK)            /*!< SMARTCARD NACK transmission disabled */
00374 #define SMARTCARD_NACK_DISABLE              ((uint32_t)0x00000000)                /*!< SMARTCARD NACK transmission enabled  */
00375 /**
00376   * @}
00377   */
00378 
00379 /** @defgroup SMARTCARD_Timeout_Enable SMARTCARD Timeout Enable
00380   * @{
00381   */
00382 #define SMARTCARD_TIMEOUT_DISABLE           ((uint32_t)0x00000000)                /*!< SMARTCARD receiver timeout disabled */
00383 #define SMARTCARD_TIMEOUT_ENABLE            ((uint32_t)USART_CR2_RTOEN)           /*!< SMARTCARD receiver timeout enabled  */
00384 /**
00385   * @}
00386   */
00387 
00388 /** @defgroup SMARTCARD_Tx_Inv SMARTCARD advanced feature TX pin active level inversion
00389   * @{
00390   */
00391 #define SMARTCARD_ADVFEATURE_TXINV_DISABLE  ((uint32_t)0x00000000)                /*!< TX pin active level inversion disable */
00392 #define SMARTCARD_ADVFEATURE_TXINV_ENABLE   ((uint32_t)USART_CR2_TXINV)           /*!< TX pin active level inversion enable  */
00393 /**
00394   * @}
00395   */
00396 
00397 /** @defgroup SMARTCARD_Rx_Inv SMARTCARD advanced feature RX pin active level inversion
00398   * @{
00399   */
00400 #define SMARTCARD_ADVFEATURE_RXINV_DISABLE  ((uint32_t)0x00000000)                /*!< RX pin active level inversion disable */
00401 #define SMARTCARD_ADVFEATURE_RXINV_ENABLE   ((uint32_t)USART_CR2_RXINV)           /*!< RX pin active level inversion enable  */
00402 /**
00403   * @}
00404   */
00405 
00406 /** @defgroup SMARTCARD_Data_Inv SMARTCARD advanced feature Binary Data inversion
00407   * @{
00408   */
00409 #define SMARTCARD_ADVFEATURE_DATAINV_DISABLE  ((uint32_t)0x00000000)              /*!< Binary data inversion disable */
00410 #define SMARTCARD_ADVFEATURE_DATAINV_ENABLE   ((uint32_t)USART_CR2_DATAINV)       /*!< Binary data inversion enable  */
00411 /**
00412   * @}
00413   */
00414 
00415 /** @defgroup SMARTCARD_Rx_Tx_Swap SMARTCARD advanced feature RX TX pins swap
00416   * @{
00417   */
00418 #define SMARTCARD_ADVFEATURE_SWAP_DISABLE   ((uint32_t)0x00000000)                /*!< TX/RX pins swap disable */
00419 #define SMARTCARD_ADVFEATURE_SWAP_ENABLE    ((uint32_t)USART_CR2_SWAP)            /*!< TX/RX pins swap enable  */
00420 /**
00421   * @}
00422   */
00423 
00424 /** @defgroup SMARTCARD_Overrun_Disable SMARTCARD advanced feature Overrun Disable
00425   * @{
00426   */
00427 #define SMARTCARD_ADVFEATURE_OVERRUN_ENABLE   ((uint32_t)0x00000000)              /*!< RX overrun enable  */
00428 #define SMARTCARD_ADVFEATURE_OVERRUN_DISABLE  ((uint32_t)USART_CR3_OVRDIS)        /*!< RX overrun disable */
00429 /**
00430   * @}
00431   */
00432 
00433 /** @defgroup SMARTCARD_DMA_Disable_on_Rx_Error SMARTCARD advanced feature DMA Disable on Rx Error
00434   * @{
00435   */
00436 #define SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR   ((uint32_t)0x00000000)         /*!< DMA enable on Reception Error  */
00437 #define SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR  ((uint32_t)USART_CR3_DDRE)     /*!< DMA disable on Reception Error */
00438 /**
00439   * @}
00440   */
00441 
00442 /** @defgroup SMARTCARD_MSB_First   SMARTCARD advanced feature MSB first
00443   * @{
00444   */
00445 #define SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE      ((uint32_t)0x00000000)           /*!< Most significant bit sent/received first disable */
00446 #define SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE       ((uint32_t)USART_CR2_MSBFIRST)   /*!< Most significant bit sent/received first enable  */
00447 /**
00448   * @}
00449   */
00450 
00451 /** @defgroup SMARTCARD_Request_Parameters SMARTCARD Request Parameters
00452   * @{
00453   */
00454 #define SMARTCARD_RXDATA_FLUSH_REQUEST      ((uint16_t)USART_RQR_RXFRQ)        /*!< Receive data flush request */
00455 #define SMARTCARD_TXDATA_FLUSH_REQUEST      ((uint16_t)USART_RQR_TXFRQ)        /*!< Transmit data flush request */
00456 /**
00457   * @}
00458   */
00459 
00460 /** @defgroup SMARTCARD_CR3_SCARCNT_LSB_POS SMARTCARD auto retry counter LSB position in CR3 register
00461   * @{
00462   */
00463 #define SMARTCARD_CR3_SCARCNT_LSB_POS       ((uint32_t) 17)   /*!< SMARTCARD auto retry counter LSB position in CR3 register */
00464 /**
00465   * @}
00466   */
00467 
00468 /** @defgroup SMARTCARD_GTPR_GT_LSB_POS SMARTCARD guard time value LSB position in GTPR register
00469   * @{
00470   */
00471 #define SMARTCARD_GTPR_GT_LSB_POS           ((uint32_t) 8)   /*!<  SMARTCARD guard time value LSB position in GTPR register */
00472 /**
00473   * @}
00474   */
00475 
00476 /** @defgroup SMARTCARD_RTOR_BLEN_LSB_POS SMARTCARD block length LSB position in RTOR register
00477   * @{
00478   */
00479 #define SMARTCARD_RTOR_BLEN_LSB_POS         ((uint32_t) 24)  /*!< SMARTCARD block length LSB position in RTOR register */
00480 /**
00481   * @}
00482   */
00483 
00484 /** @defgroup SMARTCARD_Interruption_Mask SMARTCARD interruptions flags mask
00485   * @{
00486   */
00487 #define SMARTCARD_IT_MASK                   ((uint16_t)0x001F)   /*!< SMARTCARD interruptions flags mask */
00488 /**
00489   * @}
00490   */
00491 
00492 /**
00493   * @}
00494   */
00495 
00496 /* Exported macros -----------------------------------------------------------*/
00497 /** @defgroup SMARTCARD_Exported_Macros  SMARTCARD Exported Macros
00498   * @{
00499   */
00500 
00501 /** @brief  Reset SMARTCARD handle states.
00502   * @param  __HANDLE__: SMARTCARD handle.
00503   * @retval None
00504   */
00505 #define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__)  do{                                                       \
00506                                                            (__HANDLE__)->gState = HAL_SMARTCARD_STATE_RESET;      \
00507                                                            (__HANDLE__)->RxState = HAL_SMARTCARD_STATE_RESET;     \
00508                                                           } while(0)
00509 
00510 /** @brief  Flush the Smartcard Data registers.
00511   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00512   * @retval None
00513   */
00514 #define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__)                                 \
00515     do{                                                                              \
00516       SET_BIT((__HANDLE__)->Instance->RQR, SMARTCARD_RXDATA_FLUSH_REQUEST); \
00517       SET_BIT((__HANDLE__)->Instance->RQR, SMARTCARD_TXDATA_FLUSH_REQUEST); \
00518       } while(0)
00519 
00520 /** @brief  Clear the specified SMARTCARD pending flag.
00521   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00522   * @param  __FLAG__: specifies the flag to check.
00523   *          This parameter can be any combination of the following values:
00524   *            @arg @ref SMARTCARD_CLEAR_PEF    Parity error clear flag
00525   *            @arg @ref SMARTCARD_CLEAR_FEF    Framing error clear flag
00526   *            @arg @ref SMARTCARD_CLEAR_NEF    Noise detected clear flag
00527   *            @arg @ref SMARTCARD_CLEAR_OREF   OverRun error clear flag
00528   *            @arg @ref SMARTCARD_CLEAR_IDLEF  Idle line detected clear flag
00529   *            @arg @ref SMARTCARD_CLEAR_TCF    Transmission complete clear flag
00530   @if STM32L443xx
00531   *            @arg @ref SMARTCARD_CLEAR_TCBGTF Transmission complete before guard time clear flag (when flag available)    
00532   @endif
00533   *            @arg @ref SMARTCARD_CLEAR_RTOF   Receiver timeout clear flag
00534   *            @arg @ref SMARTCARD_CLEAR_EOBF   End of block clear flag
00535   * @retval None
00536   */
00537 #define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
00538 
00539 /** @brief  Clear the SMARTCARD PE pending flag.
00540   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00541   * @retval None
00542   */
00543 #define __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)   __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_PEF)
00544 
00545 
00546 /** @brief  Clear the SMARTCARD FE pending flag.
00547   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00548   * @retval None
00549   */
00550 #define __HAL_SMARTCARD_CLEAR_FEFLAG(__HANDLE__)   __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_FEF)
00551 
00552 /** @brief  Clear the SMARTCARD NE pending flag.
00553   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00554   * @retval None
00555   */
00556 #define __HAL_SMARTCARD_CLEAR_NEFLAG(__HANDLE__)   __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_NEF)
00557 
00558 /** @brief  Clear the SMARTCARD ORE pending flag.
00559   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00560   * @retval None
00561   */
00562 #define __HAL_SMARTCARD_CLEAR_OREFLAG(__HANDLE__)   __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_OREF)
00563 
00564 /** @brief  Clear the SMARTCARD IDLE pending flag.
00565   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00566   * @retval None
00567   */
00568 #define __HAL_SMARTCARD_CLEAR_IDLEFLAG(__HANDLE__)   __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_IDLEF)
00569 
00570 /** @brief  Check whether the specified Smartcard flag is set or not.
00571   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00572   * @param  __FLAG__: specifies the flag to check.
00573   *        This parameter can be one of the following values:
00574   @if STM32L443xx
00575   *            @arg @ref SMARTCARD_FLAG_TCBGT Transmission complete before guard time flag (when flag available)  
00576   @endif
00577   *            @arg @ref SMARTCARD_FLAG_REACK Receive enable acknowledge flag
00578   *            @arg @ref SMARTCARD_FLAG_TEACK Transmit enable acknowledge flag
00579   *            @arg @ref SMARTCARD_FLAG_BUSY  Busy flag
00580   *            @arg @ref SMARTCARD_FLAG_EOBF  End of block flag
00581   *            @arg @ref SMARTCARD_FLAG_RTOF  Receiver timeout flag
00582   *            @arg @ref SMARTCARD_FLAG_TXE   Transmit data register empty flag
00583   *            @arg @ref SMARTCARD_FLAG_TC    Transmission complete flag
00584   *            @arg @ref SMARTCARD_FLAG_RXNE  Receive data register not empty flag
00585   *            @arg @ref SMARTCARD_FLAG_IDLE  Idle line detection flag  
00586   *            @arg @ref SMARTCARD_FLAG_ORE   Overrun error flag
00587   *            @arg @ref SMARTCARD_FLAG_NE    Noise error flag
00588   *            @arg @ref SMARTCARD_FLAG_FE    Framing error flag
00589   *            @arg @ref SMARTCARD_FLAG_PE    Parity error flag
00590   * @retval The new state of __FLAG__ (TRUE or FALSE).
00591   */
00592 #define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
00593 
00594 
00595 /** @brief  Enable the specified SmartCard interrupt.
00596   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00597   * @param  __INTERRUPT__: specifies the SMARTCARD interrupt to enable.
00598   *          This parameter can be one of the following values:
00599   *            @arg @ref SMARTCARD_IT_EOB   End of block interrupt
00600   *            @arg @ref SMARTCARD_IT_RTO   Receive timeout interrupt
00601   *            @arg @ref SMARTCARD_IT_TXE   Transmit data register empty interrupt
00602   *            @arg @ref SMARTCARD_IT_TC    Transmission complete interrupt
00603   @if STM32L443xx
00604   *            @arg @ref SMARTCARD_IT_TCBGT Transmission complete before guard time interrupt (when interruption available)             
00605   @endif
00606   *            @arg @ref SMARTCARD_IT_RXNE  Receive data register not empty interrupt
00607   *            @arg @ref SMARTCARD_IT_IDLE  Idle line detection interrupt  
00608   *            @arg @ref SMARTCARD_IT_PE    Parity error interrupt
00609   *            @arg @ref SMARTCARD_IT_ERR   Error interrupt(frame error, noise error, overrun error)
00610   * @retval None
00611   */
00612 #define __HAL_SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__)   (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
00613                                                                 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
00614                                                                 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))))
00615 
00616 /** @brief  Disable the specified SmartCard interrupt.
00617   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00618   * @param  __INTERRUPT__: specifies the SMARTCARD interrupt to disable.
00619   *          This parameter can be one of the following values:
00620   *            @arg @ref SMARTCARD_IT_EOB   End of block interrupt
00621   *            @arg @ref SMARTCARD_IT_RTO   Receive timeout interrupt
00622   *            @arg @ref SMARTCARD_IT_TXE   Transmit data register empty interrupt
00623   *            @arg @ref SMARTCARD_IT_TC    Transmission complete interrupt
00624   @if STM32L443xx
00625   *            @arg @ref SMARTCARD_IT_TCBGT Transmission complete before guard time interrupt (when interruption available)   
00626   @endif
00627   *            @arg @ref SMARTCARD_IT_RXNE  Receive data register not empty interrupt
00628   *            @arg @ref SMARTCARD_IT_IDLE  Idle line detection interrupt   
00629   *            @arg @ref SMARTCARD_IT_PE    Parity error interrupt
00630   *            @arg @ref SMARTCARD_IT_ERR   Error interrupt(frame error, noise error, overrun error)
00631   * @retval None
00632   */
00633 #define __HAL_SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__)  (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
00634                                                                 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
00635                                                                 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & SMARTCARD_IT_MASK))))
00636 
00637 
00638 /** @brief  Check whether the specified SmartCard interrupt has occurred or not.
00639   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00640   * @param  __IT__: specifies the SMARTCARD interrupt to check.
00641   *          This parameter can be one of the following values:
00642   *            @arg @ref SMARTCARD_IT_EOB   End of block interrupt
00643   *            @arg @ref SMARTCARD_IT_RTO   Receive timeout interrupt
00644   *            @arg @ref SMARTCARD_IT_TXE   Transmit data register empty interrupt
00645   *            @arg @ref SMARTCARD_IT_TC    Transmission complete interrupt
00646   @if STM32L443xx
00647   *            @arg @ref SMARTCARD_IT_TCBGT Transmission complete before guard time interrupt (when interruption available)    
00648   @endif
00649   *            @arg @ref SMARTCARD_IT_RXNE  Receive data register not empty interrupt
00650   *            @arg @ref SMARTCARD_IT_IDLE  Idle line detection interrupt  
00651   *            @arg @ref SMARTCARD_IT_ORE   Overrun error interrupt
00652   *            @arg @ref SMARTCARD_IT_NE    Noise error interrupt
00653   *            @arg @ref SMARTCARD_IT_FE    Framing error interrupt
00654   *            @arg @ref SMARTCARD_IT_PE    Parity error interrupt
00655   * @retval The new state of __IT__ (TRUE or FALSE).
00656   */
00657 #define __HAL_SMARTCARD_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
00658 
00659 /** @brief  Check whether the specified SmartCard interrupt source is enabled or not.
00660   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00661   * @param  __IT__: specifies the SMARTCARD interrupt source to check.
00662   *          This parameter can be one of the following values:
00663   *            @arg @ref SMARTCARD_IT_EOB   End of block interrupt
00664   *            @arg @ref SMARTCARD_IT_RTO   Receive timeout interrupt
00665   *            @arg @ref SMARTCARD_IT_TXE   Transmit data register empty interrupt
00666   *            @arg @ref SMARTCARD_IT_TC    Transmission complete interrupt
00667   @if STM32L443xx
00668   *            @arg @ref SMARTCARD_IT_TCBGT Transmission complete before guard time interrupt (when interruption available)     
00669   @endif
00670   *            @arg @ref SMARTCARD_IT_RXNE  Receive data register not empty interrupt
00671   *            @arg @ref SMARTCARD_IT_IDLE  Idle line detection interrupt  
00672   *            @arg @ref SMARTCARD_IT_ERR   Framing, overrun or noise error interrupt
00673   *            @arg @ref SMARTCARD_IT_PE    Parity error interrupt
00674   * @retval The new state of __IT__ (TRUE or FALSE).
00675   */
00676 #define __HAL_SMARTCARD_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1)? (__HANDLE__)->Instance->CR1 : \
00677                                                            (((((uint8_t)(__IT__)) >> 5U) == 2)? (__HANDLE__)->Instance->CR2 : \
00678                                                            (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << (((uint16_t)(__IT__)) & SMARTCARD_IT_MASK)))
00679 
00680 
00681 /** @brief  Clear the specified SMARTCARD ISR flag, in setting the proper ICR register flag.
00682   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00683   * @param  __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
00684   *                       to clear the corresponding interrupt.
00685   *          This parameter can be one of the following values:
00686   *            @arg @ref SMARTCARD_CLEAR_PEF    Parity error clear flag
00687   *            @arg @ref SMARTCARD_CLEAR_FEF    Framing error clear flag
00688   *            @arg @ref SMARTCARD_CLEAR_NEF    Noise detected clear flag
00689   *            @arg @ref SMARTCARD_CLEAR_OREF   OverRun error clear flag
00690   *            @arg @ref SMARTCARD_CLEAR_IDLEF  Idle line detection clear flag    
00691   *            @arg @ref SMARTCARD_CLEAR_TCF    Transmission complete clear flag
00692   @if STM32L443xx
00693   *            @arg @ref SMARTCARD_CLEAR_TCBGTF Transmission complete before guard time clear flag (when flag available)     
00694   @endif
00695   *            @arg @ref SMARTCARD_CLEAR_RTOF   Receiver timeout clear flag
00696   *            @arg @ref SMARTCARD_CLEAR_EOBF   End of block clear flag
00697   * @retval None
00698   */
00699 #define __HAL_SMARTCARD_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR |= (uint32_t)(__IT_CLEAR__))
00700 
00701 /** @brief  Set a specific SMARTCARD request flag.
00702   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00703   * @param  __REQ__: specifies the request flag to set
00704   *          This parameter can be one of the following values:
00705   *            @arg @ref SMARTCARD_RXDATA_FLUSH_REQUEST Receive data flush Request
00706   *            @arg @ref SMARTCARD_TXDATA_FLUSH_REQUEST Transmit data flush Request
00707   *
00708   * @retval None
00709   */
00710 #define __HAL_SMARTCARD_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__))
00711 
00712 /** @brief  Enable the SMARTCARD one bit sample method.
00713   * @param  __HANDLE__: specifies the SMARTCARD Handle.  
00714   * @retval None
00715   */     
00716 #define __HAL_SMARTCARD_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
00717 
00718 /** @brief  Disable the SMARTCARD one bit sample method.
00719   * @param  __HANDLE__: specifies the SMARTCARD Handle.  
00720   * @retval None
00721   */      
00722 #define __HAL_SMARTCARD_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
00723 
00724 /** @brief  Enable the USART associated to the SMARTCARD Handle.
00725   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00726   * @retval None
00727   */
00728 #define __HAL_SMARTCARD_ENABLE(__HANDLE__)               ((__HANDLE__)->Instance->CR1 |=  USART_CR1_UE)
00729 
00730 /** @brief  Disable the USART associated to the SMARTCARD Handle
00731   * @param  __HANDLE__: specifies the SMARTCARD Handle.
00732   * @retval None
00733   */
00734 #define __HAL_SMARTCARD_DISABLE(__HANDLE__)              ((__HANDLE__)->Instance->CR1 &=  ~USART_CR1_UE)
00735 
00736 /**
00737   * @}
00738   */
00739 
00740 /* Private macros -------------------------------------------------------------*/
00741 /** @defgroup SMARTCARD_Private_Macros SMARTCARD Private Macros
00742   * @{
00743   */
00744 
00745 /** @brief  Check the Baud rate range. 
00746   * @note   The maximum Baud Rate is derived from the maximum clock on L4 (80 MHz)
00747   *         divided by the oversampling used on the SMARTCARD (i.e. 16).
00748   * @param  __BAUDRATE__: Baud rate set by the configuration function.
00749   * @retval Test result (TRUE or FALSE)
00750   */
00751 #define IS_SMARTCARD_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 5000001)
00752 
00753 /** @brief  Check the block length range.
00754   * @note   The maximum SMARTCARD block length is 0xFF.
00755   * @param  __LENGTH__: block length.
00756   * @retval Test result (TRUE or FALSE)
00757   */
00758 #define IS_SMARTCARD_BLOCKLENGTH(__LENGTH__) ((__LENGTH__) <= 0xFF)
00759 
00760 /** @brief  Check the receiver timeout value. 
00761   * @note   The maximum SMARTCARD receiver timeout value is 0xFFFFFF.
00762   * @param  __TIMEOUTVALUE__: receiver timeout value.
00763   * @retval Test result (TRUE or FALSE)
00764   */
00765 #define IS_SMARTCARD_TIMEOUT_VALUE(__TIMEOUTVALUE__)    ((__TIMEOUTVALUE__) <= 0xFFFFFF)
00766 
00767 /** @brief  Check the SMARTCARD autoretry counter value. 
00768   * @note   The maximum number of retransmissions is 0x7.
00769   * @param  __COUNT__: number of retransmissions.
00770   * @retval Test result (TRUE or FALSE)
00771   */
00772 #define IS_SMARTCARD_AUTORETRY_COUNT(__COUNT__)         ((__COUNT__) <= 0x7)
00773 
00774 /**
00775   * @brief Ensure that SMARTCARD frame length is valid.
00776   * @param __LENGTH__: SMARTCARD frame length. 
00777   * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid)
00778   */ 
00779 #define IS_SMARTCARD_WORD_LENGTH(__LENGTH__) ((__LENGTH__) == SMARTCARD_WORDLENGTH_9B)
00780 
00781 /**
00782   * @brief Ensure that SMARTCARD frame number of stop bits is valid.
00783   * @param __STOPBITS__: SMARTCARD frame number of stop bits. 
00784   * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
00785   */ 
00786 #define IS_SMARTCARD_STOPBITS(__STOPBITS__) (((__STOPBITS__) == SMARTCARD_STOPBITS_0_5) ||\
00787                                              ((__STOPBITS__) == SMARTCARD_STOPBITS_1_5))
00788 
00789 /**
00790   * @brief Ensure that SMARTCARD frame parity is valid.
00791   * @param __PARITY__: SMARTCARD frame parity. 
00792   * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
00793   */ 
00794 #define IS_SMARTCARD_PARITY(__PARITY__) (((__PARITY__) == SMARTCARD_PARITY_EVEN) || \
00795                                          ((__PARITY__) == SMARTCARD_PARITY_ODD))
00796 
00797 /**
00798   * @brief Ensure that SMARTCARD communication mode is valid.
00799   * @param __MODE__: SMARTCARD communication mode. 
00800   * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
00801   */ 
00802 #define IS_SMARTCARD_MODE(__MODE__) ((((__MODE__) & (uint16_t)0xFFF3) == 0x00) && ((__MODE__) != (uint16_t)0x00))
00803 
00804 /**
00805   * @brief Ensure that SMARTCARD frame polarity is valid.
00806   * @param __CPOL__: SMARTCARD frame polarity. 
00807   * @retval SET (__CPOL__ is valid) or RESET (__CPOL__ is invalid)
00808   */ 
00809 #define IS_SMARTCARD_POLARITY(__CPOL__) (((__CPOL__) == SMARTCARD_POLARITY_LOW) || ((__CPOL__) == SMARTCARD_POLARITY_HIGH))
00810 
00811 /**
00812   * @brief Ensure that SMARTCARD frame phase is valid.
00813   * @param __CPHA__: SMARTCARD frame phase. 
00814   * @retval SET (__CPHA__ is valid) or RESET (__CPHA__ is invalid)
00815   */
00816 #define IS_SMARTCARD_PHASE(__CPHA__) (((__CPHA__) == SMARTCARD_PHASE_1EDGE) || ((__CPHA__) == SMARTCARD_PHASE_2EDGE))
00817 
00818 /**
00819   * @brief Ensure that SMARTCARD frame last bit clock pulse setting is valid.
00820   * @param __LASTBIT__: SMARTCARD frame last bit clock pulse setting. 
00821   * @retval SET (__LASTBIT__ is valid) or RESET (__LASTBIT__ is invalid)
00822   */
00823 #define IS_SMARTCARD_LASTBIT(__LASTBIT__) (((__LASTBIT__) == SMARTCARD_LASTBIT_DISABLE) || \
00824                                            ((__LASTBIT__) == SMARTCARD_LASTBIT_ENABLE))
00825 
00826 /**
00827   * @brief Ensure that SMARTCARD frame sampling is valid.
00828   * @param __ONEBIT__: SMARTCARD frame sampling. 
00829   * @retval SET (__ONEBIT__ is valid) or RESET (__ONEBIT__ is invalid)
00830   */
00831 #define IS_SMARTCARD_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == SMARTCARD_ONE_BIT_SAMPLE_DISABLE) || \
00832                                                  ((__ONEBIT__) == SMARTCARD_ONE_BIT_SAMPLE_ENABLE))
00833 
00834 /**
00835   * @brief Ensure that SMARTCARD NACK transmission setting is valid.
00836   * @param __NACK__: SMARTCARD NACK transmission setting. 
00837   * @retval SET (__NACK__ is valid) or RESET (__NACK__ is invalid)
00838   */
00839 #define IS_SMARTCARD_NACK(__NACK__) (((__NACK__) == SMARTCARD_NACK_ENABLE) || \
00840                                      ((__NACK__) == SMARTCARD_NACK_DISABLE))
00841 
00842 /**
00843   * @brief Ensure that SMARTCARD receiver timeout setting is valid.
00844   * @param __TIMEOUT__: SMARTCARD receiver timeout setting. 
00845   * @retval SET (__TIMEOUT__ is valid) or RESET (__TIMEOUT__ is invalid)
00846   */
00847 #define IS_SMARTCARD_TIMEOUT(__TIMEOUT__) (((__TIMEOUT__) == SMARTCARD_TIMEOUT_DISABLE) || \
00848                                            ((__TIMEOUT__) == SMARTCARD_TIMEOUT_ENABLE))
00849 
00850 /**
00851   * @brief Ensure that SMARTCARD advanced features initialization is valid.
00852   * @param __INIT__: SMARTCARD advanced features initialization. 
00853   * @retval SET (__INIT__ is valid) or RESET (__INIT__ is invalid)
00854   */
00855 #define IS_SMARTCARD_ADVFEATURE_INIT(__INIT__) ((__INIT__) <= (SMARTCARD_ADVFEATURE_NO_INIT                | \
00856                                                                SMARTCARD_ADVFEATURE_TXINVERT_INIT          | \
00857                                                                SMARTCARD_ADVFEATURE_RXINVERT_INIT          | \
00858                                                                SMARTCARD_ADVFEATURE_DATAINVERT_INIT        | \
00859                                                                SMARTCARD_ADVFEATURE_SWAP_INIT              | \
00860                                                                SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT  | \
00861                                                                SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT | \
00862                                                                SMARTCARD_ADVFEATURE_MSBFIRST_INIT))
00863 
00864 /**
00865   * @brief Ensure that SMARTCARD frame TX inversion setting is valid.
00866   * @param __TXINV__: SMARTCARD frame TX inversion setting. 
00867   * @retval SET (__TXINV__ is valid) or RESET (__TXINV__ is invalid)
00868   */
00869 #define IS_SMARTCARD_ADVFEATURE_TXINV(__TXINV__) (((__TXINV__) == SMARTCARD_ADVFEATURE_TXINV_DISABLE) || \
00870                                                   ((__TXINV__) == SMARTCARD_ADVFEATURE_TXINV_ENABLE))
00871 
00872 /**
00873   * @brief Ensure that SMARTCARD frame RX inversion setting is valid.
00874   * @param __RXINV__: SMARTCARD frame RX inversion setting. 
00875   * @retval SET (__RXINV__ is valid) or RESET (__RXINV__ is invalid)
00876   */
00877 #define IS_SMARTCARD_ADVFEATURE_RXINV(__RXINV__) (((__RXINV__) == SMARTCARD_ADVFEATURE_RXINV_DISABLE) || \
00878                                                   ((__RXINV__) == SMARTCARD_ADVFEATURE_RXINV_ENABLE))
00879 
00880 /**
00881   * @brief Ensure that SMARTCARD frame data inversion setting is valid.
00882   * @param __DATAINV__: SMARTCARD frame data inversion setting. 
00883   * @retval SET (__DATAINV__ is valid) or RESET (__DATAINV__ is invalid)
00884   */
00885 #define IS_SMARTCARD_ADVFEATURE_DATAINV(__DATAINV__) (((__DATAINV__) == SMARTCARD_ADVFEATURE_DATAINV_DISABLE) || \
00886                                                       ((__DATAINV__) == SMARTCARD_ADVFEATURE_DATAINV_ENABLE))
00887 
00888 /**
00889   * @brief Ensure that SMARTCARD frame RX/TX pins swap setting is valid.
00890   * @param __SWAP__: SMARTCARD frame RX/TX pins swap setting. 
00891   * @retval SET (__SWAP__ is valid) or RESET (__SWAP__ is invalid)
00892   */
00893 #define IS_SMARTCARD_ADVFEATURE_SWAP(__SWAP__) (((__SWAP__) == SMARTCARD_ADVFEATURE_SWAP_DISABLE) || \
00894                                                 ((__SWAP__) == SMARTCARD_ADVFEATURE_SWAP_ENABLE))
00895 
00896 /**
00897   * @brief Ensure that SMARTCARD frame overrun setting is valid.
00898   * @param __OVERRUN__: SMARTCARD frame overrun setting. 
00899   * @retval SET (__OVERRUN__ is valid) or RESET (__OVERRUN__ is invalid)
00900   */
00901 #define IS_SMARTCARD_OVERRUN(__OVERRUN__) (((__OVERRUN__) == SMARTCARD_ADVFEATURE_OVERRUN_ENABLE) || \
00902                                            ((__OVERRUN__) == SMARTCARD_ADVFEATURE_OVERRUN_DISABLE))
00903 
00904 /**
00905   * @brief Ensure that SMARTCARD DMA enabling or disabling on error setting is valid.
00906   * @param __DMA__: SMARTCARD DMA enabling or disabling on error setting. 
00907   * @retval SET (__DMA__ is valid) or RESET (__DMA__ is invalid)
00908   */
00909 #define IS_SMARTCARD_ADVFEATURE_DMAONRXERROR(__DMA__) (((__DMA__) == SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR) || \
00910                                                        ((__DMA__) == SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR))
00911 
00912 /**
00913   * @brief Ensure that SMARTCARD frame MSB first setting is valid.
00914   * @param __MSBFIRST__: SMARTCARD frame MSB first setting. 
00915   * @retval SET (__MSBFIRST__ is valid) or RESET (__MSBFIRST__ is invalid)
00916   */
00917 #define IS_SMARTCARD_ADVFEATURE_MSBFIRST(__MSBFIRST__) (((__MSBFIRST__) == SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE) || \
00918                                                         ((__MSBFIRST__) == SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE))
00919 
00920 /**
00921   * @brief Ensure that SMARTCARD request parameter is valid.
00922   * @param __PARAM__: SMARTCARD request parameter. 
00923   * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid)
00924   */
00925 #define IS_SMARTCARD_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == SMARTCARD_RXDATA_FLUSH_REQUEST) || \
00926                                                    ((__PARAM__) == SMARTCARD_TXDATA_FLUSH_REQUEST))
00927 
00928 /**
00929   * @}
00930   */
00931 
00932 /* Include SMARTCARD HAL Extended module */
00933 #include "stm32l4xx_hal_smartcard_ex.h"
00934 
00935 
00936 /* Exported functions --------------------------------------------------------*/
00937 /** @addtogroup SMARTCARD_Exported_Functions
00938   * @{
00939   */
00940 
00941 /* Initialization and de-initialization functions  ****************************/
00942 /** @addtogroup SMARTCARD_Exported_Functions_Group1
00943   * @{
00944   */
00945 
00946 HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsmartcard);
00947 HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsmartcard);
00948 void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsmartcard);
00949 void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsmartcard);
00950 
00951 /**
00952   * @}
00953   */
00954 
00955 /* IO operation functions *****************************************************/
00956 /** @addtogroup SMARTCARD_Exported_Functions_Group2
00957   * @{
00958   */
00959 
00960 HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size, uint32_t Timeout);
00961 HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size, uint32_t Timeout);
00962 HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size);
00963 HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size);
00964 HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size);
00965 HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t *pData, uint16_t Size);
00966 void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsmartcard);
00967 void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsmartcard);
00968 void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsmartcard);
00969 void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsmartcard);
00970 
00971 /**
00972   * @}
00973   */
00974 
00975 /* Peripheral Control functions ***********************************************/
00976 /* Peripheral State and Error functions ***************************************/
00977 /** @addtogroup SMARTCARD_Exported_Functions_Group4
00978   * @{
00979   */
00980 
00981 HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsmartcard);
00982 uint32_t                   HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsmartcard);
00983 
00984 /**
00985   * @}
00986   */
00987 
00988 /**
00989   * @}
00990   */
00991 
00992 /**
00993   * @}
00994   */
00995 
00996 /**
00997   * @}
00998   */
00999 
01000 #ifdef __cplusplus
01001 }
01002 #endif
01003 
01004 #endif /* __STM32L4xx_HAL_SMARTCARD_H */
01005 
01006 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/