Subversion Repositories LedShow

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 9
Line 4... Line 4...
4
  * @author  MCD Application Team
4
  * @author  MCD Application Team
5
  * @brief   Header file of SMARTCARD HAL module.
5
  * @brief   Header file of SMARTCARD HAL module.
6
  ******************************************************************************
6
  ******************************************************************************
7
  * @attention
7
  * @attention
8
  *
8
  *
9
  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
9
  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
-
 
10
  * All rights reserved.</center></h2>
10
  *
11
  *
11
  * Redistribution and use in source and binary forms, with or without modification,
12
  * This software component is licensed by ST under BSD 3-Clause license,
12
  * are permitted provided that the following conditions are met:
13
  * the "License"; You may not use this file except in compliance with the
13
  *   1. Redistributions of source code must retain the above copyright notice,
-
 
14
  *      this list of conditions and the following disclaimer.
-
 
15
  *   2. Redistributions in binary form must reproduce the above copyright notice,
-
 
16
  *      this list of conditions and the following disclaimer in the documentation
-
 
17
  *      and/or other materials provided with the distribution.
14
  * License. You may obtain a copy of the License at:
18
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-
 
19
  *      may be used to endorse or promote products derived from this software
15
  *                        opensource.org/licenses/BSD-3-Clause
20
  *      without specific prior written permission.
-
 
21
  *
-
 
22
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-
 
23
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-
 
24
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-
 
25
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-
 
26
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-
 
27
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-
 
28
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-
 
29
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-
 
30
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-
 
31
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
32
  *
16
  *
33
  ******************************************************************************
17
  ******************************************************************************
34
  */
18
  */
35
 
19
 
36
/* Define to prevent recursive inclusion -------------------------------------*/
20
/* Define to prevent recursive inclusion -------------------------------------*/
37
#ifndef __STM32F1xx_HAL_SMARTCARD_H
21
#ifndef __STM32F1xx_HAL_SMARTCARD_H
38
#define __STM32F1xx_HAL_SMARTCARD_H
22
#define __STM32F1xx_HAL_SMARTCARD_H
39
 
23
 
40
#ifdef __cplusplus
24
#ifdef __cplusplus
41
extern "C" {
25
 extern "C" {
42
#endif
26
#endif
43
 
27
 
44
/* Includes ------------------------------------------------------------------*/
28
/* Includes ------------------------------------------------------------------*/
45
#include "stm32f1xx_hal_def.h"
29
#include "stm32f1xx_hal_def.h"
46
 
30
 
Line 62... Line 46...
62
  */
46
  */
63
typedef struct
47
typedef struct
64
{
48
{
65
  uint32_t BaudRate;                  /*!< This member configures the SmartCard communication baud rate.
49
  uint32_t BaudRate;                  /*!< This member configures the SmartCard communication baud rate.
66
                                           The baud rate is computed using the following formula:
50
                                           The baud rate is computed using the following formula:
67
                                           - IntegerDivider = ((PCLKx) / (16 * (hsmartcard->Init.BaudRate)))
51
                                           - IntegerDivider = ((PCLKx) / (16 * (hsc->Init.BaudRate)))
68
                                           - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */
52
                                           - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */
69
 
53
 
70
  uint32_t WordLength;                /*!< Specifies the number of data bits transmitted or received in a frame.
54
  uint32_t WordLength;                /*!< Specifies the number of data bits transmitted or received in a frame.
71
                                           This parameter can be a value of @ref SMARTCARD_Word_Length */
55
                                           This parameter can be a value of @ref SMARTCARD_Word_Length */
72
 
56
 
Line 98... Line 82...
98
                                           is multiplied by 2 to give the division factor of the source clock frequency.
82
                                           is multiplied by 2 to give the division factor of the source clock frequency.
99
                                           This parameter can be a value of @ref SMARTCARD_Prescaler */
83
                                           This parameter can be a value of @ref SMARTCARD_Prescaler */
100
 
84
 
101
  uint32_t GuardTime;                 /*!< Specifies the SmartCard Guard Time value in terms of number of baud clocks */
85
  uint32_t GuardTime;                 /*!< Specifies the SmartCard Guard Time value in terms of number of baud clocks */
102
 
86
 
103
  uint32_t NACKState;                 /*!< Specifies the SmartCard NACK Transmission state
87
  uint32_t NACKState;                 /*!< Specifies the SmartCard NACK Transmission state.
104
                                           This parameter can be a value of @ref SMARTCARD_NACK_State */
88
                                           This parameter can be a value of @ref SMARTCARD_NACK_State */
105
} SMARTCARD_InitTypeDef;
89
}SMARTCARD_InitTypeDef;
106
 
90
 
107
/**
91
/**
108
  * @brief HAL SMARTCARD State structures definition
92
  * @brief HAL SMARTCARD State structures definition
109
  * @note  HAL SMARTCARD State value is a combination of 2 different substates: gState and RxState.
93
  * @note  HAL SMARTCARD State value is a combination of 2 different substates: gState and RxState.
110
  *        - gState contains SMARTCARD state information related to global Handle management
94
  *        - gState contains SMARTCARD state information related to global Handle management
Line 160... Line 144...
160
                                                        Value is result of combination (Or) between gState and RxState values */
144
                                                        Value is result of combination (Or) between gState and RxState values */
161
  HAL_SMARTCARD_STATE_TIMEOUT           = 0xA0U,    /*!< Timeout state
145
  HAL_SMARTCARD_STATE_TIMEOUT           = 0xA0U,    /*!< Timeout state
162
                                                        Value is allowed for gState only */
146
                                                        Value is allowed for gState only */
163
  HAL_SMARTCARD_STATE_ERROR             = 0xE0U     /*!< Error
147
  HAL_SMARTCARD_STATE_ERROR             = 0xE0U     /*!< Error
164
                                                        Value is allowed for gState only */
148
                                                        Value is allowed for gState only */
165
} HAL_SMARTCARD_StateTypeDef;
149
}HAL_SMARTCARD_StateTypeDef;
166
 
150
 
167
/**
151
/**
168
  * @brief  SMARTCARD handle Structure definition
152
  * @brief  SMARTCARD handle Structure definition
169
  */
153
  */
170
typedef struct
154
typedef struct __SMARTCARD_HandleTypeDef
171
{
155
{
172
  USART_TypeDef                    *Instance;        /*!< USART registers base address */
156
  USART_TypeDef                    *Instance;        /*!< USART registers base address */
173
 
157
 
174
  SMARTCARD_InitTypeDef            Init;             /*!< SmartCard communication parameters */
158
  SMARTCARD_InitTypeDef            Init;             /*!< SmartCard communication parameters */
175
 
159
 
Line 197... Line 181...
197
 
181
 
198
  __IO HAL_SMARTCARD_StateTypeDef  RxState;          /*!< SmartCard state information related to Rx operations.
182
  __IO HAL_SMARTCARD_StateTypeDef  RxState;          /*!< SmartCard state information related to Rx operations.
199
                                                        This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
183
                                                        This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
200
 
184
 
201
  __IO uint32_t                    ErrorCode;        /*!< SmartCard Error code */
185
  __IO uint32_t                    ErrorCode;        /*!< SmartCard Error code */
-
 
186
 
-
 
187
#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
-
 
188
  void (* TxCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc);            /*!< SMARTCARD Tx Complete Callback             */
-
 
189
 
-
 
190
  void (* RxCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc);            /*!< SMARTCARD Rx Complete Callback             */
-
 
191
 
-
 
192
  void (* ErrorCallback)(struct __SMARTCARD_HandleTypeDef *hsc);             /*!< SMARTCARD Error Callback                   */
-
 
193
 
-
 
194
  void (* AbortCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc);         /*!< SMARTCARD Abort Complete Callback          */
-
 
195
 
-
 
196
  void (* AbortTransmitCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc); /*!< SMARTCARD Abort Transmit Complete Callback */
-
 
197
 
-
 
198
  void (* AbortReceiveCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc);  /*!< SMARTCARD Abort Receive Complete Callback  */
-
 
199
 
-
 
200
  void (* MspInitCallback)(struct __SMARTCARD_HandleTypeDef *hsc);           /*!< SMARTCARD Msp Init callback                */
-
 
201
 
-
 
202
  void (* MspDeInitCallback)(struct __SMARTCARD_HandleTypeDef *hsc);         /*!< SMARTCARD Msp DeInit callback              */
-
 
203
#endif  /* USE_HAL_SMARTCARD_REGISTER_CALLBACKS */
-
 
204
 
202
} SMARTCARD_HandleTypeDef;
205
} SMARTCARD_HandleTypeDef;
203
 
206
 
-
 
207
#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
-
 
208
/**
-
 
209
  * @brief  HAL SMARTCARD Callback ID enumeration definition
-
 
210
  */
-
 
211
typedef enum
-
 
212
{
-
 
213
  HAL_SMARTCARD_TX_COMPLETE_CB_ID             = 0x00U,    /*!< SMARTCARD Tx Complete Callback ID             */
-
 
214
  HAL_SMARTCARD_RX_COMPLETE_CB_ID             = 0x01U,    /*!< SMARTCARD Rx Complete Callback ID             */
-
 
215
  HAL_SMARTCARD_ERROR_CB_ID                   = 0x02U,    /*!< SMARTCARD Error Callback ID                   */
-
 
216
  HAL_SMARTCARD_ABORT_COMPLETE_CB_ID          = 0x03U,    /*!< SMARTCARD Abort Complete Callback ID          */
-
 
217
  HAL_SMARTCARD_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x04U,    /*!< SMARTCARD Abort Transmit Complete Callback ID */
-
 
218
  HAL_SMARTCARD_ABORT_RECEIVE_COMPLETE_CB_ID  = 0x05U,    /*!< SMARTCARD Abort Receive Complete Callback ID  */
-
 
219
 
-
 
220
  HAL_SMARTCARD_MSPINIT_CB_ID                 = 0x08U,    /*!< SMARTCARD MspInit callback ID                 */
-
 
221
  HAL_SMARTCARD_MSPDEINIT_CB_ID               = 0x09U     /*!< SMARTCARD MspDeInit callback ID               */
-
 
222
 
-
 
223
} HAL_SMARTCARD_CallbackIDTypeDef;
-
 
224
 
-
 
225
/**
-
 
226
  * @brief  HAL SMARTCARD Callback pointer definition
-
 
227
  */
-
 
228
typedef  void (*pSMARTCARD_CallbackTypeDef)(SMARTCARD_HandleTypeDef *hsc);  /*!< pointer to an SMARTCARD callback function */
-
 
229
 
-
 
230
#endif /* USE_HAL_SMARTCARD_REGISTER_CALLBACKS */
-
 
231
 
204
/**
232
/**
205
  * @}
233
  * @}
206
  */
234
  */
207
 
235
 
208
/* Exported constants --------------------------------------------------------*/
236
/* Exported constants --------------------------------------------------------*/
Line 211... Line 239...
211
  */
239
  */
212
 
240
 
213
/** @defgroup SMARTCARD_Error_Code SMARTCARD Error Code
241
/** @defgroup SMARTCARD_Error_Code SMARTCARD Error Code
214
  * @{
242
  * @{
215
  */
243
  */
216
#define HAL_SMARTCARD_ERROR_NONE         0x00000000U   /*!< No error            */
244
#define HAL_SMARTCARD_ERROR_NONE             0x00000000U   /*!< No error            */
217
#define HAL_SMARTCARD_ERROR_PE           0x00000001U   /*!< Parity error        */
245
#define HAL_SMARTCARD_ERROR_PE               0x00000001U   /*!< Parity error        */
218
#define HAL_SMARTCARD_ERROR_NE           0x00000002U   /*!< Noise error         */
246
#define HAL_SMARTCARD_ERROR_NE               0x00000002U   /*!< Noise error         */
219
#define HAL_SMARTCARD_ERROR_FE           0x00000004U   /*!< Frame error         */
247
#define HAL_SMARTCARD_ERROR_FE               0x00000004U   /*!< Frame error         */
220
#define HAL_SMARTCARD_ERROR_ORE          0x00000008U   /*!< OverRun error       */
248
#define HAL_SMARTCARD_ERROR_ORE              0x00000008U   /*!< Overrun error       */
221
#define HAL_SMARTCARD_ERROR_DMA          0x00000010U   /*!< DMA transfer error  */
249
#define HAL_SMARTCARD_ERROR_DMA              0x00000010U   /*!< DMA transfer error  */
-
 
250
#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
-
 
251
#define HAL_SMARTCARD_ERROR_INVALID_CALLBACK 0x00000020U   /*!< Invalid Callback error  */
-
 
252
#endif /* USE_HAL_SMARTCARD_REGISTER_CALLBACKS */
222
/**
253
/**
223
  * @}
254
  * @}
224
  */
255
  */
225
 
256
 
226
/** @defgroup SMARTCARD_Word_Length SMARTCARD Word Length
257
/** @defgroup SMARTCARD_Word_Length SMARTCARD Word Length
227
  * @{
258
  * @{
228
  */
259
  */
229
#define SMARTCARD_WORDLENGTH_9B                  ((uint32_t)USART_CR1_M)
260
#define SMARTCARD_WORDLENGTH_9B             ((uint32_t)USART_CR1_M)
230
/**
261
/**
231
  * @}
262
  * @}
232
  */
263
  */
233
 
264
 
234
/** @defgroup SMARTCARD_Stop_Bits SMARTCARD Number of Stop Bits
265
/** @defgroup SMARTCARD_Stop_Bits SMARTCARD Number of Stop Bits
235
  * @{
266
  * @{
236
  */
267
  */
237
#define SMARTCARD_STOPBITS_0_5                   ((uint32_t)USART_CR2_STOP_0)
268
#define SMARTCARD_STOPBITS_0_5              ((uint32_t)USART_CR2_STOP_0)
238
#define SMARTCARD_STOPBITS_1_5                   ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1))
269
#define SMARTCARD_STOPBITS_1_5              ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1))
239
/**
270
/**
240
  * @}
271
  * @}
241
  */
272
  */
242
 
273
 
243
/** @defgroup SMARTCARD_Parity SMARTCARD Parity
274
/** @defgroup SMARTCARD_Parity SMARTCARD Parity
244
  * @{
275
  * @{
245
  */
276
  */
246
#define SMARTCARD_PARITY_EVEN                    ((uint32_t)USART_CR1_PCE)
277
#define SMARTCARD_PARITY_EVEN               ((uint32_t)USART_CR1_PCE)
247
#define SMARTCARD_PARITY_ODD                     ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
278
#define SMARTCARD_PARITY_ODD                ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
248
/**
279
/**
249
  * @}
280
  * @}
250
  */
281
  */
251
 
282
 
252
/** @defgroup SMARTCARD_Mode SMARTCARD Mode
283
/** @defgroup SMARTCARD_Mode SMARTCARD Mode
253
  * @{
284
  * @{
254
  */
285
  */
255
#define SMARTCARD_MODE_RX                        ((uint32_t)USART_CR1_RE)
286
#define SMARTCARD_MODE_RX                   ((uint32_t)USART_CR1_RE)
256
#define SMARTCARD_MODE_TX                        ((uint32_t)USART_CR1_TE)
287
#define SMARTCARD_MODE_TX                   ((uint32_t)USART_CR1_TE)
257
#define SMARTCARD_MODE_TX_RX                     ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
288
#define SMARTCARD_MODE_TX_RX                ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
258
/**
289
/**
259
  * @}
290
  * @}
260
  */
291
  */
261
 
292
 
262
/** @defgroup SMARTCARD_Clock_Polarity  SMARTCARD Clock Polarity
293
/** @defgroup SMARTCARD_Clock_Polarity SMARTCARD Clock Polarity
263
  * @{
294
  * @{
264
  */
295
  */
265
#define SMARTCARD_POLARITY_LOW                   0x00000000U
296
#define SMARTCARD_POLARITY_LOW              0x00000000U
266
#define SMARTCARD_POLARITY_HIGH                  ((uint32_t)USART_CR2_CPOL)
297
#define SMARTCARD_POLARITY_HIGH             ((uint32_t)USART_CR2_CPOL)
267
/**
298
/**
268
  * @}
299
  * @}
269
  */
300
  */
270
 
301
 
271
/** @defgroup SMARTCARD_Clock_Phase  SMARTCARD Clock Phase
302
/** @defgroup SMARTCARD_Clock_Phase  SMARTCARD Clock Phase
272
  * @{
303
  * @{
273
  */
304
  */
274
#define SMARTCARD_PHASE_1EDGE                    0x00000000U
305
#define SMARTCARD_PHASE_1EDGE               0x00000000U
275
#define SMARTCARD_PHASE_2EDGE                    ((uint32_t)USART_CR2_CPHA)
306
#define SMARTCARD_PHASE_2EDGE               ((uint32_t)USART_CR2_CPHA)
276
/**
307
/**
277
  * @}
308
  * @}
278
  */
309
  */
279
 
310
 
280
/** @defgroup SMARTCARD_Last_Bit  SMARTCARD Last Bit
311
/** @defgroup SMARTCARD_Last_Bit  SMARTCARD Last Bit
281
  * @{
312
  * @{
282
  */
313
  */
283
#define SMARTCARD_LASTBIT_DISABLE                0x00000000U
314
#define SMARTCARD_LASTBIT_DISABLE           0x00000000U
284
#define SMARTCARD_LASTBIT_ENABLE                 ((uint32_t)USART_CR2_LBCL)
315
#define SMARTCARD_LASTBIT_ENABLE            ((uint32_t)USART_CR2_LBCL)
285
/**
316
/**
286
  * @}
317
  * @}
287
  */
318
  */
288
 
319
 
289
/** @defgroup SMARTCARD_NACK_State  SMARTCARD NACK State
320
/** @defgroup SMARTCARD_NACK_State  SMARTCARD NACK State
290
  * @{
321
  * @{
291
  */
322
  */
292
#define SMARTCARD_NACK_ENABLE                  ((uint32_t)USART_CR3_NACK)
323
#define SMARTCARD_NACK_ENABLE               ((uint32_t)USART_CR3_NACK)
293
#define SMARTCARD_NACK_DISABLE                 0x00000000U
324
#define SMARTCARD_NACK_DISABLE              0x00000000U
294
/**
325
/**
295
  * @}
326
  * @}
296
  */
327
  */
297
 
328
 
298
/** @defgroup SMARTCARD_DMA_Requests  SMARTCARD DMA requests
329
/** @defgroup SMARTCARD_DMA_Requests   SMARTCARD DMA requests
299
  * @{
330
  * @{
300
  */
331
  */
301
#define SMARTCARD_DMAREQ_TX                    ((uint32_t)USART_CR3_DMAT)
332
#define SMARTCARD_DMAREQ_TX                 ((uint32_t)USART_CR3_DMAT)
302
#define SMARTCARD_DMAREQ_RX                    ((uint32_t)USART_CR3_DMAR)
333
#define SMARTCARD_DMAREQ_RX                 ((uint32_t)USART_CR3_DMAR)
303
/**
334
/**
304
  * @}
335
  * @}
305
  */
336
  */
306
 
337
 
307
/** @defgroup SMARTCARD_Prescaler  SMARTCARD Prescaler
338
/** @defgroup SMARTCARD_Prescaler SMARTCARD Prescaler
308
  * @{
339
  * @{
309
  */
340
  */
310
#define SMARTCARD_PRESCALER_SYSCLK_DIV2         0x00000001U          /*!< SYSCLK divided by 2 */
341
#define SMARTCARD_PRESCALER_SYSCLK_DIV2     0x00000001U          /*!< SYSCLK divided by 2 */
311
#define SMARTCARD_PRESCALER_SYSCLK_DIV4         0x00000002U          /*!< SYSCLK divided by 4 */
342
#define SMARTCARD_PRESCALER_SYSCLK_DIV4     0x00000002U          /*!< SYSCLK divided by 4 */
312
#define SMARTCARD_PRESCALER_SYSCLK_DIV6         0x00000003U          /*!< SYSCLK divided by 6 */
343
#define SMARTCARD_PRESCALER_SYSCLK_DIV6     0x00000003U          /*!< SYSCLK divided by 6 */
313
#define SMARTCARD_PRESCALER_SYSCLK_DIV8         0x00000004U          /*!< SYSCLK divided by 8 */
344
#define SMARTCARD_PRESCALER_SYSCLK_DIV8     0x00000004U          /*!< SYSCLK divided by 8 */
314
#define SMARTCARD_PRESCALER_SYSCLK_DIV10        0x00000005U          /*!< SYSCLK divided by 10 */
345
#define SMARTCARD_PRESCALER_SYSCLK_DIV10    0x00000005U          /*!< SYSCLK divided by 10 */
315
#define SMARTCARD_PRESCALER_SYSCLK_DIV12        0x00000006U          /*!< SYSCLK divided by 12 */
346
#define SMARTCARD_PRESCALER_SYSCLK_DIV12    0x00000006U          /*!< SYSCLK divided by 12 */
316
#define SMARTCARD_PRESCALER_SYSCLK_DIV14        0x00000007U          /*!< SYSCLK divided by 14 */
347
#define SMARTCARD_PRESCALER_SYSCLK_DIV14    0x00000007U          /*!< SYSCLK divided by 14 */
317
#define SMARTCARD_PRESCALER_SYSCLK_DIV16        0x00000008U          /*!< SYSCLK divided by 16 */
348
#define SMARTCARD_PRESCALER_SYSCLK_DIV16    0x00000008U          /*!< SYSCLK divided by 16 */
318
#define SMARTCARD_PRESCALER_SYSCLK_DIV18        0x00000009U          /*!< SYSCLK divided by 18 */
349
#define SMARTCARD_PRESCALER_SYSCLK_DIV18    0x00000009U          /*!< SYSCLK divided by 18 */
319
#define SMARTCARD_PRESCALER_SYSCLK_DIV20        0x0000000AU          /*!< SYSCLK divided by 20 */
350
#define SMARTCARD_PRESCALER_SYSCLK_DIV20    0x0000000AU          /*!< SYSCLK divided by 20 */
320
#define SMARTCARD_PRESCALER_SYSCLK_DIV22        0x0000000BU          /*!< SYSCLK divided by 22 */
351
#define SMARTCARD_PRESCALER_SYSCLK_DIV22    0x0000000BU          /*!< SYSCLK divided by 22 */
321
#define SMARTCARD_PRESCALER_SYSCLK_DIV24        0x0000000CU          /*!< SYSCLK divided by 24 */
352
#define SMARTCARD_PRESCALER_SYSCLK_DIV24    0x0000000CU          /*!< SYSCLK divided by 24 */
322
#define SMARTCARD_PRESCALER_SYSCLK_DIV26        0x0000000DU          /*!< SYSCLK divided by 26 */
353
#define SMARTCARD_PRESCALER_SYSCLK_DIV26    0x0000000DU          /*!< SYSCLK divided by 26 */
323
#define SMARTCARD_PRESCALER_SYSCLK_DIV28        0x0000000EU          /*!< SYSCLK divided by 28 */
354
#define SMARTCARD_PRESCALER_SYSCLK_DIV28    0x0000000EU          /*!< SYSCLK divided by 28 */
324
#define SMARTCARD_PRESCALER_SYSCLK_DIV30        0x0000000FU          /*!< SYSCLK divided by 30 */
355
#define SMARTCARD_PRESCALER_SYSCLK_DIV30    0x0000000FU          /*!< SYSCLK divided by 30 */
325
#define SMARTCARD_PRESCALER_SYSCLK_DIV32        0x00000010U          /*!< SYSCLK divided by 32 */
356
#define SMARTCARD_PRESCALER_SYSCLK_DIV32    0x00000010U          /*!< SYSCLK divided by 32 */
326
#define SMARTCARD_PRESCALER_SYSCLK_DIV34        0x00000011U          /*!< SYSCLK divided by 34 */
357
#define SMARTCARD_PRESCALER_SYSCLK_DIV34    0x00000011U          /*!< SYSCLK divided by 34 */
327
#define SMARTCARD_PRESCALER_SYSCLK_DIV36        0x00000012U          /*!< SYSCLK divided by 36 */
358
#define SMARTCARD_PRESCALER_SYSCLK_DIV36    0x00000012U          /*!< SYSCLK divided by 36 */
328
#define SMARTCARD_PRESCALER_SYSCLK_DIV38        0x00000013U          /*!< SYSCLK divided by 38 */
359
#define SMARTCARD_PRESCALER_SYSCLK_DIV38    0x00000013U          /*!< SYSCLK divided by 38 */
329
#define SMARTCARD_PRESCALER_SYSCLK_DIV40        0x00000014U          /*!< SYSCLK divided by 40 */
360
#define SMARTCARD_PRESCALER_SYSCLK_DIV40    0x00000014U          /*!< SYSCLK divided by 40 */
330
#define SMARTCARD_PRESCALER_SYSCLK_DIV42        0x00000015U          /*!< SYSCLK divided by 42 */
361
#define SMARTCARD_PRESCALER_SYSCLK_DIV42    0x00000015U          /*!< SYSCLK divided by 42 */
331
#define SMARTCARD_PRESCALER_SYSCLK_DIV44        0x00000016U          /*!< SYSCLK divided by 44 */
362
#define SMARTCARD_PRESCALER_SYSCLK_DIV44    0x00000016U          /*!< SYSCLK divided by 44 */
332
#define SMARTCARD_PRESCALER_SYSCLK_DIV46        0x00000017U          /*!< SYSCLK divided by 46 */
363
#define SMARTCARD_PRESCALER_SYSCLK_DIV46    0x00000017U          /*!< SYSCLK divided by 46 */
333
#define SMARTCARD_PRESCALER_SYSCLK_DIV48        0x00000018U          /*!< SYSCLK divided by 48 */
364
#define SMARTCARD_PRESCALER_SYSCLK_DIV48    0x00000018U          /*!< SYSCLK divided by 48 */
334
#define SMARTCARD_PRESCALER_SYSCLK_DIV50        0x00000019U          /*!< SYSCLK divided by 50 */
365
#define SMARTCARD_PRESCALER_SYSCLK_DIV50    0x00000019U          /*!< SYSCLK divided by 50 */
335
#define SMARTCARD_PRESCALER_SYSCLK_DIV52        0x0000001AU          /*!< SYSCLK divided by 52 */
366
#define SMARTCARD_PRESCALER_SYSCLK_DIV52    0x0000001AU          /*!< SYSCLK divided by 52 */
336
#define SMARTCARD_PRESCALER_SYSCLK_DIV54        0x0000001BU          /*!< SYSCLK divided by 54 */
367
#define SMARTCARD_PRESCALER_SYSCLK_DIV54    0x0000001BU          /*!< SYSCLK divided by 54 */
337
#define SMARTCARD_PRESCALER_SYSCLK_DIV56        0x0000001CU          /*!< SYSCLK divided by 56 */
368
#define SMARTCARD_PRESCALER_SYSCLK_DIV56    0x0000001CU          /*!< SYSCLK divided by 56 */
338
#define SMARTCARD_PRESCALER_SYSCLK_DIV58        0x0000001DU          /*!< SYSCLK divided by 58 */
369
#define SMARTCARD_PRESCALER_SYSCLK_DIV58    0x0000001DU          /*!< SYSCLK divided by 58 */
339
#define SMARTCARD_PRESCALER_SYSCLK_DIV60        0x0000001EU          /*!< SYSCLK divided by 60 */
370
#define SMARTCARD_PRESCALER_SYSCLK_DIV60    0x0000001EU          /*!< SYSCLK divided by 60 */
340
#define SMARTCARD_PRESCALER_SYSCLK_DIV62        0x0000001FU          /*!< SYSCLK divided by 62 */
371
#define SMARTCARD_PRESCALER_SYSCLK_DIV62    0x0000001FU          /*!< SYSCLK divided by 62 */
341
/**
372
/**
342
  * @}
373
  * @}
343
  */
374
  */
344
 
375
 
345
/** @defgroup SmartCard_Flags  SMARTCARD Flags
376
/** @defgroup SmartCard_Flags SMARTCARD Flags
346
  *        Elements values convention: 0xXXXX
377
  *        Elements values convention: 0xXXXX
347
  *           - 0xXXXX  : Flag mask in the SR register
378
  *           - 0xXXXX  : Flag mask in the SR register
348
  * @{
379
  * @{
349
  */
380
  */
350
#define SMARTCARD_FLAG_TXE                      ((uint32_t)USART_SR_TXE)
381
#define SMARTCARD_FLAG_TXE                  ((uint32_t)USART_SR_TXE)
351
#define SMARTCARD_FLAG_TC                       ((uint32_t)USART_SR_TC)
382
#define SMARTCARD_FLAG_TC                   ((uint32_t)USART_SR_TC)
352
#define SMARTCARD_FLAG_RXNE                     ((uint32_t)USART_SR_RXNE)
383
#define SMARTCARD_FLAG_RXNE                 ((uint32_t)USART_SR_RXNE)
353
#define SMARTCARD_FLAG_IDLE                     ((uint32_t)USART_SR_IDLE)
384
#define SMARTCARD_FLAG_IDLE                 ((uint32_t)USART_SR_IDLE)
354
#define SMARTCARD_FLAG_ORE                      ((uint32_t)USART_SR_ORE)
385
#define SMARTCARD_FLAG_ORE                  ((uint32_t)USART_SR_ORE)
355
#define SMARTCARD_FLAG_NE                       ((uint32_t)USART_SR_NE)
386
#define SMARTCARD_FLAG_NE                   ((uint32_t)USART_SR_NE)
356
#define SMARTCARD_FLAG_FE                       ((uint32_t)USART_SR_FE)
387
#define SMARTCARD_FLAG_FE                   ((uint32_t)USART_SR_FE)
357
#define SMARTCARD_FLAG_PE                       ((uint32_t)USART_SR_PE)
388
#define SMARTCARD_FLAG_PE                   ((uint32_t)USART_SR_PE)
358
/**
389
/**
359
  * @}
390
  * @}
360
  */
391
  */
361
 
392
 
362
/** @defgroup SmartCard_Interrupt_definition  SMARTCARD Interrupts Definition
393
/** @defgroup SmartCard_Interrupt_definition SMARTCARD Interrupts Definition
363
  *        Elements values convention: 0xY000XXXX
394
  *        Elements values convention: 0xY000XXXX
364
  *           - XXXX  : Interrupt mask in the XX register
395
  *           - XXXX  : Interrupt mask in the Y register
365
  *           - Y  : Interrupt source register (2bits)
396
  *           - Y  : Interrupt source register (2bits)
366
  *                 - 01: CR1 register
397
  *                 - 01: CR1 register
367
  *                 - 11: CR3 register
398
  *                 - 11: CR3 register
368
  * @{
399
  * @{
369
  */
400
  */
370
#define SMARTCARD_IT_PE                         ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_PEIE))
401
#define SMARTCARD_IT_PE                     ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_PEIE))
371
#define SMARTCARD_IT_TXE                        ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_TXEIE))
402
#define SMARTCARD_IT_TXE                    ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_TXEIE))
372
#define SMARTCARD_IT_TC                         ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_TCIE))
403
#define SMARTCARD_IT_TC                     ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_TCIE))
373
#define SMARTCARD_IT_RXNE                       ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE))
404
#define SMARTCARD_IT_RXNE                   ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE))
374
#define SMARTCARD_IT_IDLE                       ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE))
405
#define SMARTCARD_IT_IDLE                   ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE))
375
#define SMARTCARD_IT_ERR                        ((uint32_t)(SMARTCARD_CR3_REG_INDEX << 28U | USART_CR3_EIE))
406
#define SMARTCARD_IT_ERR                    ((uint32_t)(SMARTCARD_CR3_REG_INDEX << 28U | USART_CR3_EIE))
376
/**
407
/**
377
  * @}
408
  * @}
378
  */
409
  */
379
 
410
 
380
/**
411
/**
381
  * @}
412
  * @}
382
  */
413
  */
383
 
414
 
384
/* Exported macro ------------------------------------------------------------*/
415
/* Exported macro ------------------------------------------------------------*/
385
/** @defgroup SMARTCARD_Exported_Macros  SMARTCARD Exported Macros
416
/** @defgroup SMARTCARD_Exported_Macros SMARTCARD Exported Macros
386
  * @{
417
  * @{
387
  */
418
  */
388
 
419
 
389
/** @brief Reset SMARTCARD handle gstate & RxState
420
/** @brief Reset SMARTCARD handle gstate & RxState
390
  * @param  __HANDLE__: specifies the SMARTCARD Handle.
421
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
391
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
422
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
-
 
423
  * @retval None
392
  */
424
  */
-
 
425
#if USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1
393
#define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__)  do{                                                        \
426
#define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__)  do{                                                       \
394
                                                            (__HANDLE__)->gState = HAL_SMARTCARD_STATE_RESET;      \
427
                                                           (__HANDLE__)->gState = HAL_SMARTCARD_STATE_RESET;      \
395
                                                            (__HANDLE__)->RxState = HAL_SMARTCARD_STATE_RESET;     \
428
                                                           (__HANDLE__)->RxState = HAL_SMARTCARD_STATE_RESET;     \
-
 
429
                                                           (__HANDLE__)->MspInitCallback = NULL;                  \
-
 
430
                                                           (__HANDLE__)->MspDeInitCallback = NULL;                \
396
                                                          } while(0U)
431
                                                          } while(0U)
-
 
432
#else
-
 
433
#define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__)  do{                                                       \
-
 
434
                                                           (__HANDLE__)->gState = HAL_SMARTCARD_STATE_RESET;      \
-
 
435
                                                           (__HANDLE__)->RxState = HAL_SMARTCARD_STATE_RESET;     \
-
 
436
                                                          } while(0U)
-
 
437
#endif /*USE_HAL_SMARTCARD_REGISTER_CALLBACKS  */
397
 
438
 
398
/** @brief  Flush the Smartcard DR register
439
/** @brief  Flush the Smartcard DR register
399
  * @param  __HANDLE__: specifies the SMARTCARD Handle.
440
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
400
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
441
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
-
 
442
  * @retval None
401
  */
443
  */
402
#define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
444
#define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
403
 
445
 
404
/** @brief  Check whether the specified Smartcard flag is set or not.
446
/** @brief  Check whether the specified Smartcard flag is set or not.
405
  * @param  __HANDLE__: specifies the SMARTCARD Handle.
447
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
406
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
448
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
407
  * @param  __FLAG__: specifies the flag to check.
449
  * @param  __FLAG__ specifies the flag to check.
408
  *         This parameter can be one of the following values:
450
  *        This parameter can be one of the following values:
409
  *            @arg SMARTCARD_FLAG_TXE:  Transmit data register empty flag
451
  *            @arg SMARTCARD_FLAG_TXE:  Transmit data register empty flag
410
  *            @arg SMARTCARD_FLAG_TC:   Transmission Complete flag
452
  *            @arg SMARTCARD_FLAG_TC:   Transmission Complete flag
411
  *            @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag
453
  *            @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag
412
  *            @arg SMARTCARD_FLAG_IDLE: Idle Line detection flag
454
  *            @arg SMARTCARD_FLAG_IDLE: Idle Line detection flag
413
  *            @arg SMARTCARD_FLAG_ORE:  OverRun Error flag
455
  *            @arg SMARTCARD_FLAG_ORE:  Overrun Error flag
414
  *            @arg SMARTCARD_FLAG_NE:   Noise Error flag
456
  *            @arg SMARTCARD_FLAG_NE:   Noise Error flag
415
  *            @arg SMARTCARD_FLAG_FE:   Framing Error flag
457
  *            @arg SMARTCARD_FLAG_FE:   Framing Error flag
416
  *            @arg SMARTCARD_FLAG_PE:   Parity Error flag
458
  *            @arg SMARTCARD_FLAG_PE:   Parity Error flag
417
  * @retval The new state of __FLAG__ (TRUE or FALSE).
459
  * @retval The new state of __FLAG__ (TRUE or FALSE).
418
  */
460
  */
419
#define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
461
#define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
420
 
462
 
421
/** @brief  Clear the specified Smartcard pending flags.
463
/** @brief  Clear the specified Smartcard pending flags.
422
  * @param  __HANDLE__: specifies the SMARTCARD Handle.
464
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
423
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
465
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
424
  * @param  __FLAG__: specifies the flag to check.
466
  * @param  __FLAG__ specifies the flag to check.
425
  *         This parameter can be any combination of the following values:
467
  *          This parameter can be any combination of the following values:
426
  *            @arg SMARTCARD_FLAG_TC:   Transmission Complete flag.
468
  *            @arg SMARTCARD_FLAG_TC:   Transmission Complete flag.
427
  *            @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag.
469
  *            @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag.
428
  *
470
  *
429
  * @note   PE (Parity error), FE (Framing error), NE (Noise error) and ORE (OverRun
471
  * @note   PE (Parity error), FE (Framing error), NE (Noise error) and ORE (Overrun
430
  *          error) flags are cleared by software sequence: a read operation to
472
  *          error) flags are cleared by software sequence: a read operation to
431
  *          USART_SR register followed by a read operation to USART_DR register.
473
  *          USART_SR register followed by a read operation to USART_DR register.
432
  * @note   RXNE flag can be also cleared by a read to the USART_DR register.
474
  * @note   RXNE flag can be also cleared by a read to the USART_DR register.
433
  * @note   TC flag can be also cleared by software sequence: a read operation to
475
  * @note   TC flag can be also cleared by software sequence: a read operation to
434
  *          USART_SR register followed by a write operation to USART_DR register.
476
  *          USART_SR register followed by a write operation to USART_DR register.
435
  * @note   TXE flag is cleared only by a write to the USART_DR register.
477
  * @note   TXE flag is cleared only by a write to the USART_DR register.
-
 
478
  * @retval None
436
  */
479
  */
437
#define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
480
#define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
438
 
481
 
439
/** @brief  Clear the SMARTCARD PE pending flag.
482
/** @brief  Clear the SMARTCARD PE pending flag.
440
  * @param  __HANDLE__: specifies the USART Handle.
483
  * @param  __HANDLE__ specifies the USART Handle.
441
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
484
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
-
 
485
  * @retval None
442
  */
486
  */
443
#define __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)     \
487
#define __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)  \
444
  do{                                                \
488
    do{                                           \
445
    __IO uint32_t tmpreg = 0x00U;                    \
489
      __IO uint32_t tmpreg = 0x00U;               \
446
    tmpreg = (__HANDLE__)->Instance->SR;             \
490
      tmpreg = (__HANDLE__)->Instance->SR;        \
447
    tmpreg = (__HANDLE__)->Instance->DR;             \
491
      tmpreg = (__HANDLE__)->Instance->DR;        \
448
    UNUSED(tmpreg);                                  \
492
      UNUSED(tmpreg);                             \
449
  } while(0U)
493
    } while(0U)
450
 
494
 
451
/** @brief  Clear the SMARTCARD FE pending flag.
495
/** @brief  Clear the SMARTCARD FE pending flag.
452
  * @param  __HANDLE__: specifies the USART Handle.
496
  * @param  __HANDLE__ specifies the USART Handle.
453
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
497
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
-
 
498
  * @retval None
454
  */
499
  */
455
#define __HAL_SMARTCARD_CLEAR_FEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
500
#define __HAL_SMARTCARD_CLEAR_FEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
456
 
501
 
457
/** @brief  Clear the SMARTCARD NE pending flag.
502
/** @brief  Clear the SMARTCARD NE pending flag.
458
  * @param  __HANDLE__: specifies the USART Handle.
503
  * @param  __HANDLE__ specifies the USART Handle.
459
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
504
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
-
 
505
  * @retval None
460
  */
506
  */
461
#define __HAL_SMARTCARD_CLEAR_NEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
507
#define __HAL_SMARTCARD_CLEAR_NEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
462
 
508
 
463
/** @brief  Clear the SMARTCARD ORE pending flag.
509
/** @brief  Clear the SMARTCARD ORE pending flag.
464
  * @param  __HANDLE__: specifies the USART Handle.
510
  * @param  __HANDLE__ specifies the USART Handle.
465
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
511
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
-
 
512
  * @retval None
466
  */
513
  */
467
#define __HAL_SMARTCARD_CLEAR_OREFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
514
#define __HAL_SMARTCARD_CLEAR_OREFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
468
 
515
 
469
/** @brief  Clear the SMARTCARD IDLE pending flag.
516
/** @brief  Clear the SMARTCARD IDLE pending flag.
470
  * @param  __HANDLE__: specifies the USART Handle.
517
  * @param  __HANDLE__ specifies the USART Handle.
471
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
518
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
-
 
519
  * @retval None
472
  */
520
  */
473
#define __HAL_SMARTCARD_CLEAR_IDLEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
521
#define __HAL_SMARTCARD_CLEAR_IDLEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
474
 
522
 
475
/** @brief  Enable the specified SmartCard interrupt.
523
/** @brief  Enable the specified SmartCard interrupt.
476
  * @param  __HANDLE__: specifies the SMARTCARD Handle.
524
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
477
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
525
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
478
  * @param  __INTERRUPT__: specifies the SMARTCARD interrupt to enable.
526
  * @param  __INTERRUPT__ specifies the SMARTCARD interrupt to enable.
479
  *          This parameter can be one of the following values:
527
  *          This parameter can be one of the following values:
480
  *            @arg SMARTCARD_IT_TXE:  Transmit Data Register empty interrupt
528
  *            @arg SMARTCARD_IT_TXE:  Transmit Data Register empty interrupt
481
  *            @arg SMARTCARD_IT_TC:   Transmission complete interrupt
529
  *            @arg SMARTCARD_IT_TC:   Transmission complete interrupt
482
  *            @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
530
  *            @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
483
  *            @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
531
  *            @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
484
  *            @arg SMARTCARD_IT_PE:   Parity Error interrupt
532
  *            @arg SMARTCARD_IT_PE:   Parity Error interrupt
485
  *            @arg SMARTCARD_IT_ERR:  Error interrupt(Frame error, noise error, overRun error)
533
  *            @arg SMARTCARD_IT_ERR:  Error interrupt(Frame error, noise error, overrun error)
-
 
534
  * @retval None
486
  */
535
  */
487
#define __HAL_SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__)   ((((__INTERRUPT__) >> 28U) == SMARTCARD_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK)): \
536
#define __HAL_SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__)   ((((__INTERRUPT__) >> 28U) == SMARTCARD_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK)): \
488
                                                                 ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK)))
537
                                                                 ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK)))
489
 
538
 
490
/** @brief  Disable the specified SmartCard interrupt.
539
/** @brief  Disable the specified SmartCard interrupt.
491
  * @param  __HANDLE__: specifies the SMARTCARD Handle.
540
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
492
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
541
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
493
  * @param  __INTERRUPT__: specifies the SMARTCARD interrupt to disable.
542
  * @param  __INTERRUPT__ specifies the SMARTCARD interrupt to disable.
494
  *          This parameter can be one of the following values:
543
  *          This parameter can be one of the following values:
495
  *            @arg SMARTCARD_IT_TXE:  Transmit Data Register empty interrupt
544
  *            @arg SMARTCARD_IT_TXE:  Transmit Data Register empty interrupt
496
  *            @arg SMARTCARD_IT_TC:   Transmission complete interrupt
545
  *            @arg SMARTCARD_IT_TC:   Transmission complete interrupt
497
  *            @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
546
  *            @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
498
  *            @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
547
  *            @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
499
  *            @arg SMARTCARD_IT_PE:   Parity Error interrupt
548
  *            @arg SMARTCARD_IT_PE:   Parity Error interrupt
500
  *            @arg SMARTCARD_IT_ERR:  Error interrupt(Frame error, noise error, overRun error)
549
  *            @arg SMARTCARD_IT_ERR:  Error interrupt(Frame error, noise error, overrun error)
-
 
550
  * @retval None
501
  */
551
  */
502
#define __HAL_SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__)  ((((__INTERRUPT__) >> 28U) == SMARTCARD_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & SMARTCARD_IT_MASK)): \
552
#define __HAL_SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__)  ((((__INTERRUPT__) >> 28U) == SMARTCARD_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & SMARTCARD_IT_MASK)): \
503
                                                                 ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & SMARTCARD_IT_MASK)))
553
                                                                 ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & SMARTCARD_IT_MASK)))
504
 
554
 
505
/** @brief  Checks whether the specified SmartCard interrupt has occurred or not.
555
/** @brief  Checks whether the specified SmartCard interrupt has occurred or not.
506
  * @param  __HANDLE__: specifies the SmartCard Handle.
556
  * @param  __HANDLE__ specifies the SmartCard Handle.
507
  * @param  __IT__: specifies the SMARTCARD interrupt source to check.
557
  * @param  __IT__ specifies the SMARTCARD interrupt source to check.
508
  *          This parameter can be one of the following values:
558
  *          This parameter can be one of the following values:
509
  *            @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
559
  *            @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
510
  *            @arg SMARTCARD_IT_TC:  Transmission complete interrupt
560
  *            @arg SMARTCARD_IT_TC:  Transmission complete interrupt
511
  *            @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
561
  *            @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
512
  *            @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
562
  *            @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
Line 515... Line 565...
515
  * @retval The new state of __IT__ (TRUE or FALSE).
565
  * @retval The new state of __IT__ (TRUE or FALSE).
516
  */
566
  */
517
#define __HAL_SMARTCARD_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == SMARTCARD_CR1_REG_INDEX)? (__HANDLE__)->Instance->CR1: (__HANDLE__)->Instance->CR3) & (((uint32_t)(__IT__)) & SMARTCARD_IT_MASK))
567
#define __HAL_SMARTCARD_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == SMARTCARD_CR1_REG_INDEX)? (__HANDLE__)->Instance->CR1: (__HANDLE__)->Instance->CR3) & (((uint32_t)(__IT__)) & SMARTCARD_IT_MASK))
518
 
568
 
519
/** @brief  Enable the USART associated to the SMARTCARD Handle
569
/** @brief  Enable the USART associated to the SMARTCARD Handle
520
  * @param  __HANDLE__: specifies the SMARTCARD Handle.
570
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
521
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
571
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
-
 
572
  * @retval None
522
  */
573
  */
523
#define __HAL_SMARTCARD_ENABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
574
#define __HAL_SMARTCARD_ENABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR1 |=  USART_CR1_UE)
524
 
575
 
525
/** @brief  Disable the USART associated to the SMARTCARD Handle
576
/** @brief  Disable the USART associated to the SMARTCARD Handle
526
  * @param  __HANDLE__: specifies the SMARTCARD Handle.
577
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
527
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
578
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
-
 
579
  * @retval None
528
  */
580
  */
529
#define __HAL_SMARTCARD_DISABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR1 &=  ~USART_CR1_UE)
581
#define __HAL_SMARTCARD_DISABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR1 &=  ~USART_CR1_UE)
530
 
582
 
531
/** @brief  Macros to enable the SmartCard DMA request.
583
/** @brief  Macros to enable the SmartCard DMA request.
532
  * @param  __HANDLE__: specifies the SmartCard Handle.
584
  * @param  __HANDLE__ specifies the SmartCard Handle.
533
  * @param  __REQUEST__: specifies the SmartCard DMA request.
585
  * @param  __REQUEST__ specifies the SmartCard DMA request.
534
  *          This parameter can be one of the following values:
586
  *          This parameter can be one of the following values:
535
  *            @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request
587
  *            @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request
536
  *            @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request
588
  *            @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request
-
 
589
  * @retval None
537
  */
590
  */
538
#define __HAL_SMARTCARD_DMA_REQUEST_ENABLE(__HANDLE__, __REQUEST__)    ((__HANDLE__)->Instance->CR3 |=  (__REQUEST__))
591
#define __HAL_SMARTCARD_DMA_REQUEST_ENABLE(__HANDLE__, __REQUEST__)    ((__HANDLE__)->Instance->CR3 |=  (__REQUEST__))
539
 
592
 
540
/** @brief  Macros to disable the SmartCard DMA request.
593
/** @brief  Macros to disable the SmartCard DMA request.
541
  * @param  __HANDLE__: specifies the SmartCard Handle.
594
  * @param  __HANDLE__ specifies the SmartCard Handle.
542
  * @param  __REQUEST__: specifies the SmartCard DMA request.
595
  * @param  __REQUEST__ specifies the SmartCard DMA request.
543
  *          This parameter can be one of the following values:
596
  *          This parameter can be one of the following values:
544
  *            @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request
597
  *            @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request
545
  *            @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request
598
  *            @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request
-
 
599
  * @retval None
546
  */
600
  */
547
#define __HAL_SMARTCARD_DMA_REQUEST_DISABLE(__HANDLE__, __REQUEST__)   ((__HANDLE__)->Instance->CR3 &=  ~(__REQUEST__))
601
#define __HAL_SMARTCARD_DMA_REQUEST_DISABLE(__HANDLE__, __REQUEST__)   ((__HANDLE__)->Instance->CR3 &=  ~(__REQUEST__))
548
 
602
 
549
/**
603
/**
550
  * @}
604
  * @}
551
  */
605
  */
-
 
606
 
552
/* Exported functions --------------------------------------------------------*/
607
/* Exported functions --------------------------------------------------------*/
553
/** @addtogroup SMARTCARD_Exported_Functions
608
/** @addtogroup SMARTCARD_Exported_Functions
554
  * @{
609
  * @{
555
  */
610
  */
556
 
611
 
Line 561... Line 616...
561
HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc);
616
HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc);
562
HAL_StatusTypeDef HAL_SMARTCARD_ReInit(SMARTCARD_HandleTypeDef *hsc);
617
HAL_StatusTypeDef HAL_SMARTCARD_ReInit(SMARTCARD_HandleTypeDef *hsc);
563
HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc);
618
HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc);
564
void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc);
619
void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc);
565
void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc);
620
void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc);
-
 
621
#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
-
 
622
/* Callbacks Register/UnRegister functions  ***********************************/
-
 
623
HAL_StatusTypeDef HAL_SMARTCARD_RegisterCallback(SMARTCARD_HandleTypeDef *hsc, HAL_SMARTCARD_CallbackIDTypeDef CallbackID, pSMARTCARD_CallbackTypeDef pCallback);
-
 
624
HAL_StatusTypeDef HAL_SMARTCARD_UnRegisterCallback(SMARTCARD_HandleTypeDef *hsc, HAL_SMARTCARD_CallbackIDTypeDef CallbackID);
-
 
625
#endif /* USE_HAL_SMARTCARD_REGISTER_CALLBACKS */
566
/**
626
/**
567
  * @}
627
  * @}
568
  */
628
  */
569
 
629
 
570
/** @addtogroup SMARTCARD_Exported_Functions_Group2
630
/** @addtogroup SMARTCARD_Exported_Functions_Group2
Line 617... Line 677...
617
  */
677
  */
618
 
678
 
619
/** @brief SMARTCARD interruptions flag mask
679
/** @brief SMARTCARD interruptions flag mask
620
  *
680
  *
621
  */
681
  */
622
#define SMARTCARD_IT_MASK                     0x0000FFFFU
682
#define SMARTCARD_IT_MASK                   ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \
-
 
683
                                                        USART_CR1_IDLEIE | USART_CR3_EIE )
623
 
684
 
624
#define SMARTCARD_CR1_REG_INDEX               1U
685
#define SMARTCARD_CR1_REG_INDEX             1U
625
#define SMARTCARD_CR3_REG_INDEX               3U
686
#define SMARTCARD_CR3_REG_INDEX             3U
626
/**
687
/**
627
  * @}
688
  * @}
628
  */
689
  */
629
 
690
 
630
/* Private macros --------------------------------------------------------*/
691
/* Private macros --------------------------------------------------------*/
631
/** @defgroup SMARTCARD_Private_Macros   SMARTCARD Private Macros
692
/** @defgroup SMARTCARD_Private_Macros   SMARTCARD Private Macros
632
  * @{
693
  * @{
633
  */
694
  */
634
#define IS_SMARTCARD_WORD_LENGTH(LENGTH) ((LENGTH) == SMARTCARD_WORDLENGTH_9B)
695
#define IS_SMARTCARD_WORD_LENGTH(LENGTH)    ((LENGTH) == SMARTCARD_WORDLENGTH_9B)
635
#define IS_SMARTCARD_STOPBITS(STOPBITS) (((STOPBITS) == SMARTCARD_STOPBITS_0_5) || \
696
#define IS_SMARTCARD_STOPBITS(STOPBITS)     (((STOPBITS) == SMARTCARD_STOPBITS_0_5) || \
636
                                         ((STOPBITS) == SMARTCARD_STOPBITS_1_5))
697
                                             ((STOPBITS) == SMARTCARD_STOPBITS_1_5))
637
#define IS_SMARTCARD_PARITY(PARITY) (((PARITY) == SMARTCARD_PARITY_EVEN) || \
698
#define IS_SMARTCARD_PARITY(PARITY)         (((PARITY) == SMARTCARD_PARITY_EVEN) || \
638
                                     ((PARITY) == SMARTCARD_PARITY_ODD))
699
                                             ((PARITY) == SMARTCARD_PARITY_ODD))
639
#define IS_SMARTCARD_MODE(MODE) ((((MODE) & 0x0000FFF3U) == 0x00U) && ((MODE) != 0x000000U))
700
#define IS_SMARTCARD_MODE(MODE)             ((((MODE) & 0x0000FFF3U) == 0x00U) && ((MODE) != 0x000000U))
640
#define IS_SMARTCARD_POLARITY(CPOL) (((CPOL) == SMARTCARD_POLARITY_LOW) || ((CPOL) == SMARTCARD_POLARITY_HIGH))
701
#define IS_SMARTCARD_POLARITY(CPOL)         (((CPOL) == SMARTCARD_POLARITY_LOW) || ((CPOL) == SMARTCARD_POLARITY_HIGH))
641
#define IS_SMARTCARD_PHASE(CPHA) (((CPHA) == SMARTCARD_PHASE_1EDGE) || ((CPHA) == SMARTCARD_PHASE_2EDGE))
702
#define IS_SMARTCARD_PHASE(CPHA)            (((CPHA) == SMARTCARD_PHASE_1EDGE) || ((CPHA) == SMARTCARD_PHASE_2EDGE))
642
#define IS_SMARTCARD_LASTBIT(LASTBIT) (((LASTBIT) == SMARTCARD_LASTBIT_DISABLE) || \
703
#define IS_SMARTCARD_LASTBIT(LASTBIT)       (((LASTBIT) == SMARTCARD_LASTBIT_DISABLE) || \
643
                                       ((LASTBIT) == SMARTCARD_LASTBIT_ENABLE))
704
                                             ((LASTBIT) == SMARTCARD_LASTBIT_ENABLE))
644
#define IS_SMARTCARD_NACK_STATE(NACK) (((NACK) == SMARTCARD_NACK_ENABLE) || \
705
#define IS_SMARTCARD_NACK_STATE(NACK)       (((NACK) == SMARTCARD_NACK_ENABLE) || \
645
                                       ((NACK) == SMARTCARD_NACK_DISABLE))
706
                                             ((NACK) == SMARTCARD_NACK_DISABLE))
646
#define IS_SMARTCARD_BAUDRATE(BAUDRATE) ((BAUDRATE) < 4500001U)
707
#define IS_SMARTCARD_BAUDRATE(BAUDRATE)     ((BAUDRATE) < 4500001U)
647
 
708
 
648
#define SMARTCARD_DIV(_PCLK_, _BAUD_)            (((_PCLK_)*25U)/(4U*(_BAUD_)))
709
#define SMARTCARD_DIV(__PCLK__, __BAUD__)                (((__PCLK__)*25U)/(4U*(__BAUD__)))
649
#define SMARTCARD_DIVMANT(_PCLK_, _BAUD_)        (SMARTCARD_DIV((_PCLK_), (_BAUD_))/100U)
710
#define SMARTCARD_DIVMANT(__PCLK__, __BAUD__)            (SMARTCARD_DIV((__PCLK__), (__BAUD__))/100U)
650
#define SMARTCARD_DIVFRAQ(_PCLK_, _BAUD_)        (((SMARTCARD_DIV((_PCLK_), (_BAUD_)) - (SMARTCARD_DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U + 50U) / 100U)
711
#define SMARTCARD_DIVFRAQ(__PCLK__, __BAUD__)            ((((SMARTCARD_DIV((__PCLK__), (__BAUD__)) - (SMARTCARD_DIVMANT((__PCLK__), (__BAUD__)) * 100U)) * 16U) + 50U) / 100U)
651
/* SMARTCARD BRR = mantissa + overflow + fraction
712
/* SMARTCARD BRR = mantissa + overflow + fraction
652
            = (SMARTCARD DIVMANT << 4) + (SMARTCARD DIVFRAQ & 0xF0) + (SMARTCARD DIVFRAQ & 0x0FU) */
713
            = (SMARTCARD DIVMANT << 4) + (SMARTCARD DIVFRAQ & 0xF0) + (SMARTCARD DIVFRAQ & 0x0FU) */
653
#define SMARTCARD_BRR(_PCLK_, _BAUD_)            (((SMARTCARD_DIVMANT((_PCLK_), (_BAUD_)) << 4U) + \
714
#define SMARTCARD_BRR(__PCLK__, __BAUD__)       (((SMARTCARD_DIVMANT((__PCLK__), (__BAUD__)) << 4U) + \
654
                                                  (SMARTCARD_DIVFRAQ((_PCLK_), (_BAUD_)) & 0xF0U)) + \
715
                                                 (SMARTCARD_DIVFRAQ((__PCLK__), (__BAUD__)) & 0xF0U)) + \
655
                                                  (SMARTCARD_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU))
716
                                                 (SMARTCARD_DIVFRAQ((__PCLK__), (__BAUD__)) & 0x0FU))
-
 
717
 
656
/**
718
/**
657
  * @}
719
  * @}
658
  */
720
  */
659
 
721
 
660
/* Private functions ---------------------------------------------------------*/
722
/* Private functions ---------------------------------------------------------*/