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