Subversion Repositories DashDisplay

Rev

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

Rev 61 Rev 77
Line 1... Line 1...
1
/**
1
/**
2
  ******************************************************************************
2
  ******************************************************************************
3
  * @file    stm32l1xx_hal_smartcard.h
3
  * @file    stm32l1xx_hal_smartcard.h
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) 2016 STMicroelectronics.
9
  * Copyright (c) 2016 STMicroelectronics.
10
  * All rights reserved.</center></h2>
10
  * All rights reserved.
11
  *
11
  *
12
  * This software component is licensed by ST under BSD 3-Clause license,
12
  * This software is licensed under terms that can be found in the LICENSE file
13
  * the "License"; You may not use this file except in compliance with the
13
  * in the root directory of this software component.
14
  * License. You may obtain a copy of the License at:
14
  * If no LICENSE file comes with this software, it is provided AS-IS.
15
  *                        opensource.org/licenses/BSD-3-Clause
15
  *
16
  *
16
  ******************************************************************************
17
  ******************************************************************************
17
  */
18
  */
18
 
19
 
19
/* Define to prevent recursive inclusion -------------------------------------*/
20
/* Define to prevent recursive inclusion -------------------------------------*/
20
#ifndef __STM32L1xx_HAL_SMARTCARD_H
21
#ifndef __STM32L1xx_HAL_SMARTCARD_H
21
#define __STM32L1xx_HAL_SMARTCARD_H
22
#define __STM32L1xx_HAL_SMARTCARD_H
22
 
23
 
23
#ifdef __cplusplus
24
#ifdef __cplusplus
24
 extern "C" {
25
 extern "C" {
25
#endif
26
#endif
26
 
27
 
27
/* Includes ------------------------------------------------------------------*/
28
/* Includes ------------------------------------------------------------------*/
28
#include "stm32l1xx_hal_def.h"
29
#include "stm32l1xx_hal_def.h"
29
 
30
 
30
/** @addtogroup STM32L1xx_HAL_Driver
31
/** @addtogroup STM32L1xx_HAL_Driver
31
  * @{
32
  * @{
32
  */
33
  */
33
 
34
 
34
/** @addtogroup SMARTCARD
35
/** @addtogroup SMARTCARD
35
  * @{
36
  * @{
36
  */
37
  */
37
 
38
 
38
/* Exported types ------------------------------------------------------------*/
39
/* Exported types ------------------------------------------------------------*/
39
/** @defgroup SMARTCARD_Exported_Types SMARTCARD Exported Types
40
/** @defgroup SMARTCARD_Exported_Types SMARTCARD Exported Types
40
  * @{
41
  * @{
41
  */
42
  */
42
 
43
 
43
/**
44
/**
44
  * @brief SMARTCARD Init Structure definition
45
  * @brief SMARTCARD Init Structure definition
45
  */
46
  */
46
typedef struct
47
typedef struct
47
{
48
{
48
  uint32_t BaudRate;                  /*!< This member configures the SmartCard communication baud rate.
49
  uint32_t BaudRate;                  /*!< This member configures the SmartCard communication baud rate.
49
                                           The baud rate is computed using the following formula:
50
                                           The baud rate is computed using the following formula:
50
                                           - IntegerDivider = ((PCLKx) / (16 * (hsc->Init.BaudRate)))
51
                                           - IntegerDivider = ((PCLKx) / (16 * (hsc->Init.BaudRate)))
51
                                           - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */
52
                                           - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */
52
 
53
 
53
  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.
54
                                           This parameter can be a value of @ref SMARTCARD_Word_Length */
55
                                           This parameter can be a value of @ref SMARTCARD_Word_Length */
55
 
56
 
56
  uint32_t StopBits;                  /*!< Specifies the number of stop bits transmitted.
57
  uint32_t StopBits;                  /*!< Specifies the number of stop bits transmitted.
57
                                           This parameter can be a value of @ref SMARTCARD_Stop_Bits */
58
                                           This parameter can be a value of @ref SMARTCARD_Stop_Bits */
58
 
59
 
59
  uint32_t Parity;                    /*!< Specifies the parity mode.
60
  uint32_t Parity;                    /*!< Specifies the parity mode.
60
                                           This parameter can be a value of @ref SMARTCARD_Parity
61
                                           This parameter can be a value of @ref SMARTCARD_Parity
61
                                           @note When parity is enabled, the computed parity is inserted
62
                                           @note When parity is enabled, the computed parity is inserted
62
                                                 at the MSB position of the transmitted data (9th bit when
63
                                                 at the MSB position of the transmitted data (9th bit when
63
                                                 the word length is set to 9 data bits; 8th bit when the
64
                                                 the word length is set to 9 data bits; 8th bit when the
64
                                                 word length is set to 8 data bits).*/
65
                                                 word length is set to 8 data bits).*/
65
 
66
 
66
  uint32_t Mode;                      /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
67
  uint32_t Mode;                      /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
67
                                           This parameter can be a value of @ref SMARTCARD_Mode */
68
                                           This parameter can be a value of @ref SMARTCARD_Mode */
68
 
69
 
69
  uint32_t CLKPolarity;               /*!< Specifies the steady state of the serial clock.
70
  uint32_t CLKPolarity;               /*!< Specifies the steady state of the serial clock.
70
                                           This parameter can be a value of @ref SMARTCARD_Clock_Polarity */
71
                                           This parameter can be a value of @ref SMARTCARD_Clock_Polarity */
71
 
72
 
72
  uint32_t CLKPhase;                  /*!< Specifies the clock transition on which the bit capture is made.
73
  uint32_t CLKPhase;                  /*!< Specifies the clock transition on which the bit capture is made.
73
                                           This parameter can be a value of @ref SMARTCARD_Clock_Phase */
74
                                           This parameter can be a value of @ref SMARTCARD_Clock_Phase */
74
 
75
 
75
  uint32_t CLKLastBit;                /*!< Specifies whether the clock pulse corresponding to the last transmitted
76
  uint32_t CLKLastBit;                /*!< Specifies whether the clock pulse corresponding to the last transmitted
76
                                           data bit (MSB) has to be output on the SCLK pin in synchronous mode.
77
                                           data bit (MSB) has to be output on the SCLK pin in synchronous mode.
77
                                           This parameter can be a value of @ref SMARTCARD_Last_Bit */
78
                                           This parameter can be a value of @ref SMARTCARD_Last_Bit */
78
 
79
 
79
  uint32_t Prescaler;                 /*!< Specifies the SmartCard Prescaler value used for dividing the system clock
80
  uint32_t Prescaler;                 /*!< Specifies the SmartCard Prescaler value used for dividing the system clock
80
                                           to provide the smartcard clock. The value given in the register (5 significant bits)
81
                                           to provide the smartcard clock. The value given in the register (5 significant bits)
81
                                           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.
82
                                           This parameter can be a value of @ref SMARTCARD_Prescaler */
83
                                           This parameter can be a value of @ref SMARTCARD_Prescaler */
83
 
84
 
84
  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 */
85
 
86
 
86
  uint32_t NACKState;                 /*!< Specifies the SmartCard NACK Transmission state.
87
  uint32_t NACKState;                 /*!< Specifies the SmartCard NACK Transmission state.
87
                                           This parameter can be a value of @ref SMARTCARD_NACK_State */
88
                                           This parameter can be a value of @ref SMARTCARD_NACK_State */
88
}SMARTCARD_InitTypeDef;
89
}SMARTCARD_InitTypeDef;
89
 
90
 
90
/**
91
/**
91
  * @brief HAL SMARTCARD State structures definition
92
  * @brief HAL SMARTCARD State structures definition
92
  * @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.
93
  *        - gState contains SMARTCARD state information related to global Handle management
94
  *        - gState contains SMARTCARD state information related to global Handle management
94
  *          and also information related to Tx operations.
95
  *          and also information related to Tx operations.
95
  *          gState value coding follow below described bitmap :
96
  *          gState value coding follow below described bitmap :
96
  *          b7-b6  Error information
97
  *          b7-b6  Error information
97
  *             00 : No Error
98
  *             00 : No Error
98
  *             01 : (Not Used)
99
  *             01 : (Not Used)
99
  *             10 : Timeout
100
  *             10 : Timeout
100
  *             11 : Error
101
  *             11 : Error
101
  *          b5     IP initialization status
102
  *          b5     IP initialization status
102
  *             0  : Reset (IP not initialized)
103
  *             0  : Reset (IP not initialized)
103
  *             1  : Init done (IP initialized. HAL SMARTCARD Init function already called)
104
  *             1  : Init done (IP initialized. HAL SMARTCARD Init function already called)
104
  *          b4-b3  (not used)
105
  *          b4-b3  (not used)
105
  *             xx : Should be set to 00
106
  *             xx : Should be set to 00
106
  *          b2     Intrinsic process state
107
  *          b2     Intrinsic process state
107
  *             0  : Ready
108
  *             0  : Ready
108
  *             1  : Busy (IP busy with some configuration or internal operations)
109
  *             1  : Busy (IP busy with some configuration or internal operations)
109
  *          b1     (not used)
110
  *          b1     (not used)
110
  *             x  : Should be set to 0
111
  *             x  : Should be set to 0
111
  *          b0     Tx state
112
  *          b0     Tx state
112
  *             0  : Ready (no Tx operation ongoing)
113
  *             0  : Ready (no Tx operation ongoing)
113
  *             1  : Busy (Tx operation ongoing)
114
  *             1  : Busy (Tx operation ongoing)
114
  *        - RxState contains information related to Rx operations.
115
  *        - RxState contains information related to Rx operations.
115
  *          RxState value coding follow below described bitmap :
116
  *          RxState value coding follow below described bitmap :
116
  *          b7-b6  (not used)
117
  *          b7-b6  (not used)
117
  *             xx : Should be set to 00
118
  *             xx : Should be set to 00
118
  *          b5     IP initialization status
119
  *          b5     IP initialization status
119
  *             0  : Reset (IP not initialized)
120
  *             0  : Reset (IP not initialized)
120
  *             1  : Init done (IP initialized)
121
  *             1  : Init done (IP initialized)
121
  *          b4-b2  (not used)
122
  *          b4-b2  (not used)
122
  *            xxx : Should be set to 000
123
  *            xxx : Should be set to 000
123
  *          b1     Rx state
124
  *          b1     Rx state
124
  *             0  : Ready (no Rx operation ongoing)
125
  *             0  : Ready (no Rx operation ongoing)
125
  *             1  : Busy (Rx operation ongoing)
126
  *             1  : Busy (Rx operation ongoing)
126
  *          b0     (not used)
127
  *          b0     (not used)
127
  *             x  : Should be set to 0.
128
  *             x  : Should be set to 0.
128
  */
129
  */
129
typedef enum
130
typedef enum
130
{
131
{
131
  HAL_SMARTCARD_STATE_RESET             = 0x00U,    /*!< Peripheral is not yet Initialized
132
  HAL_SMARTCARD_STATE_RESET             = 0x00U,    /*!< Peripheral is not yet Initialized
132
                                                        Value is allowed for gState and RxState */
133
                                                        Value is allowed for gState and RxState */
133
  HAL_SMARTCARD_STATE_READY             = 0x20U,    /*!< Peripheral Initialized and ready for use
134
  HAL_SMARTCARD_STATE_READY             = 0x20U,    /*!< Peripheral Initialized and ready for use
134
                                                        Value is allowed for gState and RxState */
135
                                                        Value is allowed for gState and RxState */
135
  HAL_SMARTCARD_STATE_BUSY              = 0x24U,    /*!< an internal process is ongoing
136
  HAL_SMARTCARD_STATE_BUSY              = 0x24U,    /*!< an internal process is ongoing
136
                                                        Value is allowed for gState only */
137
                                                        Value is allowed for gState only */
137
  HAL_SMARTCARD_STATE_BUSY_TX           = 0x21U,    /*!< Data Transmission process is ongoing
138
  HAL_SMARTCARD_STATE_BUSY_TX           = 0x21U,    /*!< Data Transmission process is ongoing
138
                                                        Value is allowed for gState only */
139
                                                        Value is allowed for gState only */
139
  HAL_SMARTCARD_STATE_BUSY_RX           = 0x22U,    /*!< Data Reception process is ongoing
140
  HAL_SMARTCARD_STATE_BUSY_RX           = 0x22U,    /*!< Data Reception process is ongoing
140
                                                        Value is allowed for RxState only */
141
                                                        Value is allowed for RxState only */
141
  HAL_SMARTCARD_STATE_BUSY_TX_RX        = 0x23U,    /*!< Data Transmission and Reception process is ongoing
142
  HAL_SMARTCARD_STATE_BUSY_TX_RX        = 0x23U,    /*!< Data Transmission and Reception process is ongoing
142
                                                        Not to be used for neither gState nor RxState.
143
                                                        Not to be used for neither gState nor RxState.
143
                                                        Value is result of combination (Or) between gState and RxState values */
144
                                                        Value is result of combination (Or) between gState and RxState values */
144
  HAL_SMARTCARD_STATE_TIMEOUT           = 0xA0U,    /*!< Timeout state
145
  HAL_SMARTCARD_STATE_TIMEOUT           = 0xA0U,    /*!< Timeout state
145
                                                        Value is allowed for gState only */
146
                                                        Value is allowed for gState only */
146
  HAL_SMARTCARD_STATE_ERROR             = 0xE0U     /*!< Error
147
  HAL_SMARTCARD_STATE_ERROR             = 0xE0U     /*!< Error
147
                                                        Value is allowed for gState only */
148
                                                        Value is allowed for gState only */
148
}HAL_SMARTCARD_StateTypeDef;
149
}HAL_SMARTCARD_StateTypeDef;
149
 
150
 
150
/**
151
/**
151
  * @brief  SMARTCARD handle Structure definition
152
  * @brief  SMARTCARD handle Structure definition
152
  */
153
  */
153
typedef struct __SMARTCARD_HandleTypeDef
154
typedef struct __SMARTCARD_HandleTypeDef
154
{
155
{
155
  USART_TypeDef                    *Instance;        /*!< USART registers base address */
156
  USART_TypeDef                    *Instance;        /*!< USART registers base address */
156
 
157
 
157
  SMARTCARD_InitTypeDef            Init;             /*!< SmartCard communication parameters */
158
  SMARTCARD_InitTypeDef            Init;             /*!< SmartCard communication parameters */
158
 
159
 
159
  const uint8_t                    *pTxBuffPtr;      /*!< Pointer to SmartCard Tx transfer Buffer */
160
  uint8_t                          *pTxBuffPtr;      /*!< Pointer to SmartCard Tx transfer Buffer */
160
 
161
 
161
  uint16_t                         TxXferSize;       /*!< SmartCard Tx Transfer size */
162
  uint16_t                         TxXferSize;       /*!< SmartCard Tx Transfer size */
162
 
163
 
163
  __IO uint16_t                    TxXferCount;      /*!< SmartCard Tx Transfer Counter */
164
  __IO uint16_t                    TxXferCount;      /*!< SmartCard Tx Transfer Counter */
164
 
165
 
165
  uint8_t                          *pRxBuffPtr;      /*!< Pointer to SmartCard Rx transfer Buffer */
166
  uint8_t                          *pRxBuffPtr;      /*!< Pointer to SmartCard Rx transfer Buffer */
166
 
167
 
167
  uint16_t                         RxXferSize;       /*!< SmartCard Rx Transfer size */
168
  uint16_t                         RxXferSize;       /*!< SmartCard Rx Transfer size */
168
 
169
 
169
  __IO uint16_t                    RxXferCount;      /*!< SmartCard Rx Transfer Counter */
170
  __IO uint16_t                    RxXferCount;      /*!< SmartCard Rx Transfer Counter */
170
 
171
 
171
  DMA_HandleTypeDef                *hdmatx;          /*!< SmartCard Tx DMA Handle parameters */
172
  DMA_HandleTypeDef                *hdmatx;          /*!< SmartCard Tx DMA Handle parameters */
172
 
173
 
173
  DMA_HandleTypeDef                *hdmarx;          /*!< SmartCard Rx DMA Handle parameters */
174
  DMA_HandleTypeDef                *hdmarx;          /*!< SmartCard Rx DMA Handle parameters */
174
 
175
 
175
  HAL_LockTypeDef                  Lock;             /*!< Locking object */
176
  HAL_LockTypeDef                  Lock;             /*!< Locking object */
176
 
177
 
177
  __IO HAL_SMARTCARD_StateTypeDef  gState;           /*!< SmartCard state information related to global Handle management
178
  __IO HAL_SMARTCARD_StateTypeDef  gState;           /*!< SmartCard state information related to global Handle management
178
                                                        and also related to Tx operations.
179
                                                        and also related to Tx operations.
179
                                                        This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
180
                                                        This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
180
 
181
 
181
  __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.
182
                                                        This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
183
                                                        This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
183
 
184
 
184
  __IO uint32_t                    ErrorCode;        /*!< SmartCard Error code */
185
  __IO uint32_t                    ErrorCode;        /*!< SmartCard Error code */
185
 
186
 
186
#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
187
#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
187
  void (* TxCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc);            /*!< SMARTCARD Tx Complete Callback             */
188
  void (* TxCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc);            /*!< SMARTCARD Tx Complete Callback             */
188
 
189
 
189
  void (* RxCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc);            /*!< SMARTCARD Rx Complete Callback             */
190
  void (* RxCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc);            /*!< SMARTCARD Rx Complete Callback             */
190
 
191
 
191
  void (* ErrorCallback)(struct __SMARTCARD_HandleTypeDef *hsc);             /*!< SMARTCARD Error Callback                   */
192
  void (* ErrorCallback)(struct __SMARTCARD_HandleTypeDef *hsc);             /*!< SMARTCARD Error Callback                   */
192
 
193
 
193
  void (* AbortCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc);         /*!< SMARTCARD Abort Complete Callback          */
194
  void (* AbortCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc);         /*!< SMARTCARD Abort Complete Callback          */
194
 
195
 
195
  void (* AbortTransmitCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc); /*!< SMARTCARD Abort Transmit Complete Callback */
196
  void (* AbortTransmitCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc); /*!< SMARTCARD Abort Transmit Complete Callback */
196
 
197
 
197
  void (* AbortReceiveCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc);  /*!< SMARTCARD Abort Receive Complete Callback  */
198
  void (* AbortReceiveCpltCallback)(struct __SMARTCARD_HandleTypeDef *hsc);  /*!< SMARTCARD Abort Receive Complete Callback  */
198
 
199
 
199
  void (* MspInitCallback)(struct __SMARTCARD_HandleTypeDef *hsc);           /*!< SMARTCARD Msp Init callback                */
200
  void (* MspInitCallback)(struct __SMARTCARD_HandleTypeDef *hsc);           /*!< SMARTCARD Msp Init callback                */
200
 
201
 
201
  void (* MspDeInitCallback)(struct __SMARTCARD_HandleTypeDef *hsc);         /*!< SMARTCARD Msp DeInit callback              */
202
  void (* MspDeInitCallback)(struct __SMARTCARD_HandleTypeDef *hsc);         /*!< SMARTCARD Msp DeInit callback              */
202
#endif  /* USE_HAL_SMARTCARD_REGISTER_CALLBACKS */
203
#endif  /* USE_HAL_SMARTCARD_REGISTER_CALLBACKS */
203
 
204
 
204
} SMARTCARD_HandleTypeDef;
205
} SMARTCARD_HandleTypeDef;
205
 
206
 
206
#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
207
#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
207
/**
208
/**
208
  * @brief  HAL SMARTCARD Callback ID enumeration definition
209
  * @brief  HAL SMARTCARD Callback ID enumeration definition
209
  */
210
  */
210
typedef enum
211
typedef enum
211
{
212
{
212
  HAL_SMARTCARD_TX_COMPLETE_CB_ID             = 0x00U,    /*!< SMARTCARD Tx Complete Callback ID             */
213
  HAL_SMARTCARD_TX_COMPLETE_CB_ID             = 0x00U,    /*!< SMARTCARD Tx Complete Callback ID             */
213
  HAL_SMARTCARD_RX_COMPLETE_CB_ID             = 0x01U,    /*!< SMARTCARD Rx Complete Callback ID             */
214
  HAL_SMARTCARD_RX_COMPLETE_CB_ID             = 0x01U,    /*!< SMARTCARD Rx Complete Callback ID             */
214
  HAL_SMARTCARD_ERROR_CB_ID                   = 0x02U,    /*!< SMARTCARD Error Callback ID                   */
215
  HAL_SMARTCARD_ERROR_CB_ID                   = 0x02U,    /*!< SMARTCARD Error Callback ID                   */
215
  HAL_SMARTCARD_ABORT_COMPLETE_CB_ID          = 0x03U,    /*!< SMARTCARD Abort Complete Callback ID          */
216
  HAL_SMARTCARD_ABORT_COMPLETE_CB_ID          = 0x03U,    /*!< SMARTCARD Abort Complete Callback ID          */
216
  HAL_SMARTCARD_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x04U,    /*!< SMARTCARD Abort Transmit Complete Callback ID */
217
  HAL_SMARTCARD_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x04U,    /*!< SMARTCARD Abort Transmit Complete Callback ID */
217
  HAL_SMARTCARD_ABORT_RECEIVE_COMPLETE_CB_ID  = 0x05U,    /*!< SMARTCARD Abort Receive Complete Callback ID  */
218
  HAL_SMARTCARD_ABORT_RECEIVE_COMPLETE_CB_ID  = 0x05U,    /*!< SMARTCARD Abort Receive Complete Callback ID  */
218
 
219
 
219
  HAL_SMARTCARD_MSPINIT_CB_ID                 = 0x08U,    /*!< SMARTCARD MspInit callback ID                 */
220
  HAL_SMARTCARD_MSPINIT_CB_ID                 = 0x08U,    /*!< SMARTCARD MspInit callback ID                 */
220
  HAL_SMARTCARD_MSPDEINIT_CB_ID               = 0x09U     /*!< SMARTCARD MspDeInit callback ID               */
221
  HAL_SMARTCARD_MSPDEINIT_CB_ID               = 0x09U     /*!< SMARTCARD MspDeInit callback ID               */
221
 
222
 
222
} HAL_SMARTCARD_CallbackIDTypeDef;
223
} HAL_SMARTCARD_CallbackIDTypeDef;
223
 
224
 
224
/**
225
/**
225
  * @brief  HAL SMARTCARD Callback pointer definition
226
  * @brief  HAL SMARTCARD Callback pointer definition
226
  */
227
  */
227
typedef  void (*pSMARTCARD_CallbackTypeDef)(SMARTCARD_HandleTypeDef *hsc);  /*!< pointer to an SMARTCARD callback function */
228
typedef  void (*pSMARTCARD_CallbackTypeDef)(SMARTCARD_HandleTypeDef *hsc);  /*!< pointer to an SMARTCARD callback function */
228
 
229
 
229
#endif /* USE_HAL_SMARTCARD_REGISTER_CALLBACKS */
230
#endif /* USE_HAL_SMARTCARD_REGISTER_CALLBACKS */
230
 
231
 
231
/**
232
/**
232
  * @}
233
  * @}
233
  */
234
  */
234
 
235
 
235
/* Exported constants --------------------------------------------------------*/
236
/* Exported constants --------------------------------------------------------*/
236
/** @defgroup SMARTCARD_Exported_Constants  SMARTCARD Exported constants
237
/** @defgroup SMARTCARD_Exported_Constants  SMARTCARD Exported constants
237
  * @{
238
  * @{
238
  */
239
  */
239
 
240
 
240
/** @defgroup SMARTCARD_Error_Code SMARTCARD Error Code
241
/** @defgroup SMARTCARD_Error_Code SMARTCARD Error Code
241
  * @{
242
  * @{
242
  */
243
  */
243
#define HAL_SMARTCARD_ERROR_NONE             0x00000000U   /*!< No error            */
244
#define HAL_SMARTCARD_ERROR_NONE             0x00000000U   /*!< No error            */
244
#define HAL_SMARTCARD_ERROR_PE               0x00000001U   /*!< Parity error        */
245
#define HAL_SMARTCARD_ERROR_PE               0x00000001U   /*!< Parity error        */
245
#define HAL_SMARTCARD_ERROR_NE               0x00000002U   /*!< Noise error         */
246
#define HAL_SMARTCARD_ERROR_NE               0x00000002U   /*!< Noise error         */
246
#define HAL_SMARTCARD_ERROR_FE               0x00000004U   /*!< Frame error         */
247
#define HAL_SMARTCARD_ERROR_FE               0x00000004U   /*!< Frame error         */
247
#define HAL_SMARTCARD_ERROR_ORE              0x00000008U   /*!< Overrun error       */
248
#define HAL_SMARTCARD_ERROR_ORE              0x00000008U   /*!< Overrun error       */
248
#define HAL_SMARTCARD_ERROR_DMA              0x00000010U   /*!< DMA transfer error  */
249
#define HAL_SMARTCARD_ERROR_DMA              0x00000010U   /*!< DMA transfer error  */
249
#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
250
#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
250
#define HAL_SMARTCARD_ERROR_INVALID_CALLBACK 0x00000020U   /*!< Invalid Callback error  */
251
#define HAL_SMARTCARD_ERROR_INVALID_CALLBACK 0x00000020U   /*!< Invalid Callback error  */
251
#endif /* USE_HAL_SMARTCARD_REGISTER_CALLBACKS */
252
#endif /* USE_HAL_SMARTCARD_REGISTER_CALLBACKS */
252
/**
253
/**
253
  * @}
254
  * @}
254
  */
255
  */
255
 
256
 
256
/** @defgroup SMARTCARD_Word_Length SMARTCARD Word Length
257
/** @defgroup SMARTCARD_Word_Length SMARTCARD Word Length
257
  * @{
258
  * @{
258
  */
259
  */
259
#define SMARTCARD_WORDLENGTH_9B             ((uint32_t)USART_CR1_M)
260
#define SMARTCARD_WORDLENGTH_9B             ((uint32_t)USART_CR1_M)
260
/**
261
/**
261
  * @}
262
  * @}
262
  */
263
  */
263
 
264
 
264
/** @defgroup SMARTCARD_Stop_Bits SMARTCARD Number of Stop Bits
265
/** @defgroup SMARTCARD_Stop_Bits SMARTCARD Number of Stop Bits
265
  * @{
266
  * @{
266
  */
267
  */
267
#define SMARTCARD_STOPBITS_0_5              ((uint32_t)USART_CR2_STOP_0)
268
#define SMARTCARD_STOPBITS_0_5              ((uint32_t)USART_CR2_STOP_0)
268
#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))
269
/**
270
/**
270
  * @}
271
  * @}
271
  */
272
  */
272
 
273
 
273
/** @defgroup SMARTCARD_Parity SMARTCARD Parity
274
/** @defgroup SMARTCARD_Parity SMARTCARD Parity
274
  * @{
275
  * @{
275
  */
276
  */
276
#define SMARTCARD_PARITY_EVEN               ((uint32_t)USART_CR1_PCE)
277
#define SMARTCARD_PARITY_EVEN               ((uint32_t)USART_CR1_PCE)
277
#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))
278
/**
279
/**
279
  * @}
280
  * @}
280
  */
281
  */
281
 
282
 
282
/** @defgroup SMARTCARD_Mode SMARTCARD Mode
283
/** @defgroup SMARTCARD_Mode SMARTCARD Mode
283
  * @{
284
  * @{
284
  */
285
  */
285
#define SMARTCARD_MODE_RX                   ((uint32_t)USART_CR1_RE)
286
#define SMARTCARD_MODE_RX                   ((uint32_t)USART_CR1_RE)
286
#define SMARTCARD_MODE_TX                   ((uint32_t)USART_CR1_TE)
287
#define SMARTCARD_MODE_TX                   ((uint32_t)USART_CR1_TE)
287
#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))
288
/**
289
/**
289
  * @}
290
  * @}
290
  */
291
  */
291
 
292
 
292
/** @defgroup SMARTCARD_Clock_Polarity SMARTCARD Clock Polarity
293
/** @defgroup SMARTCARD_Clock_Polarity SMARTCARD Clock Polarity
293
  * @{
294
  * @{
294
  */
295
  */
295
#define SMARTCARD_POLARITY_LOW              0x00000000U
296
#define SMARTCARD_POLARITY_LOW              0x00000000U
296
#define SMARTCARD_POLARITY_HIGH             ((uint32_t)USART_CR2_CPOL)
297
#define SMARTCARD_POLARITY_HIGH             ((uint32_t)USART_CR2_CPOL)
297
/**
298
/**
298
  * @}
299
  * @}
299
  */
300
  */
300
 
301
 
301
/** @defgroup SMARTCARD_Clock_Phase  SMARTCARD Clock Phase
302
/** @defgroup SMARTCARD_Clock_Phase  SMARTCARD Clock Phase
302
  * @{
303
  * @{
303
  */
304
  */
304
#define SMARTCARD_PHASE_1EDGE               0x00000000U
305
#define SMARTCARD_PHASE_1EDGE               0x00000000U
305
#define SMARTCARD_PHASE_2EDGE               ((uint32_t)USART_CR2_CPHA)
306
#define SMARTCARD_PHASE_2EDGE               ((uint32_t)USART_CR2_CPHA)
306
/**
307
/**
307
  * @}
308
  * @}
308
  */
309
  */
309
 
310
 
310
/** @defgroup SMARTCARD_Last_Bit  SMARTCARD Last Bit
311
/** @defgroup SMARTCARD_Last_Bit  SMARTCARD Last Bit
311
  * @{
312
  * @{
312
  */
313
  */
313
#define SMARTCARD_LASTBIT_DISABLE           0x00000000U
314
#define SMARTCARD_LASTBIT_DISABLE           0x00000000U
314
#define SMARTCARD_LASTBIT_ENABLE            ((uint32_t)USART_CR2_LBCL)
315
#define SMARTCARD_LASTBIT_ENABLE            ((uint32_t)USART_CR2_LBCL)
315
/**
316
/**
316
  * @}
317
  * @}
317
  */
318
  */
318
 
319
 
319
/** @defgroup SMARTCARD_NACK_State  SMARTCARD NACK State
320
/** @defgroup SMARTCARD_NACK_State  SMARTCARD NACK State
320
  * @{
321
  * @{
321
  */
322
  */
322
#define SMARTCARD_NACK_ENABLE               ((uint32_t)USART_CR3_NACK)
323
#define SMARTCARD_NACK_ENABLE               ((uint32_t)USART_CR3_NACK)
323
#define SMARTCARD_NACK_DISABLE              0x00000000U
324
#define SMARTCARD_NACK_DISABLE              0x00000000U
324
/**
325
/**
325
  * @}
326
  * @}
326
  */
327
  */
327
 
328
 
328
/** @defgroup SMARTCARD_DMA_Requests   SMARTCARD DMA requests
329
/** @defgroup SMARTCARD_DMA_Requests   SMARTCARD DMA requests
329
  * @{
330
  * @{
330
  */
331
  */
331
#define SMARTCARD_DMAREQ_TX                 ((uint32_t)USART_CR3_DMAT)
332
#define SMARTCARD_DMAREQ_TX                 ((uint32_t)USART_CR3_DMAT)
332
#define SMARTCARD_DMAREQ_RX                 ((uint32_t)USART_CR3_DMAR)
333
#define SMARTCARD_DMAREQ_RX                 ((uint32_t)USART_CR3_DMAR)
333
/**
334
/**
334
  * @}
335
  * @}
335
  */
336
  */
336
 
337
 
337
/** @defgroup SMARTCARD_Prescaler SMARTCARD Prescaler
338
/** @defgroup SMARTCARD_Prescaler SMARTCARD Prescaler
338
  * @{
339
  * @{
339
  */
340
  */
340
#define SMARTCARD_PRESCALER_SYSCLK_DIV2     0x00000001U          /*!< SYSCLK divided by 2 */
341
#define SMARTCARD_PRESCALER_SYSCLK_DIV2     0x00000001U          /*!< SYSCLK divided by 2 */
341
#define SMARTCARD_PRESCALER_SYSCLK_DIV4     0x00000002U          /*!< SYSCLK divided by 4 */
342
#define SMARTCARD_PRESCALER_SYSCLK_DIV4     0x00000002U          /*!< SYSCLK divided by 4 */
342
#define SMARTCARD_PRESCALER_SYSCLK_DIV6     0x00000003U          /*!< SYSCLK divided by 6 */
343
#define SMARTCARD_PRESCALER_SYSCLK_DIV6     0x00000003U          /*!< SYSCLK divided by 6 */
343
#define SMARTCARD_PRESCALER_SYSCLK_DIV8     0x00000004U          /*!< SYSCLK divided by 8 */
344
#define SMARTCARD_PRESCALER_SYSCLK_DIV8     0x00000004U          /*!< SYSCLK divided by 8 */
344
#define SMARTCARD_PRESCALER_SYSCLK_DIV10    0x00000005U          /*!< SYSCLK divided by 10 */
345
#define SMARTCARD_PRESCALER_SYSCLK_DIV10    0x00000005U          /*!< SYSCLK divided by 10 */
345
#define SMARTCARD_PRESCALER_SYSCLK_DIV12    0x00000006U          /*!< SYSCLK divided by 12 */
346
#define SMARTCARD_PRESCALER_SYSCLK_DIV12    0x00000006U          /*!< SYSCLK divided by 12 */
346
#define SMARTCARD_PRESCALER_SYSCLK_DIV14    0x00000007U          /*!< SYSCLK divided by 14 */
347
#define SMARTCARD_PRESCALER_SYSCLK_DIV14    0x00000007U          /*!< SYSCLK divided by 14 */
347
#define SMARTCARD_PRESCALER_SYSCLK_DIV16    0x00000008U          /*!< SYSCLK divided by 16 */
348
#define SMARTCARD_PRESCALER_SYSCLK_DIV16    0x00000008U          /*!< SYSCLK divided by 16 */
348
#define SMARTCARD_PRESCALER_SYSCLK_DIV18    0x00000009U          /*!< SYSCLK divided by 18 */
349
#define SMARTCARD_PRESCALER_SYSCLK_DIV18    0x00000009U          /*!< SYSCLK divided by 18 */
349
#define SMARTCARD_PRESCALER_SYSCLK_DIV20    0x0000000AU          /*!< SYSCLK divided by 20 */
350
#define SMARTCARD_PRESCALER_SYSCLK_DIV20    0x0000000AU          /*!< SYSCLK divided by 20 */
350
#define SMARTCARD_PRESCALER_SYSCLK_DIV22    0x0000000BU          /*!< SYSCLK divided by 22 */
351
#define SMARTCARD_PRESCALER_SYSCLK_DIV22    0x0000000BU          /*!< SYSCLK divided by 22 */
351
#define SMARTCARD_PRESCALER_SYSCLK_DIV24    0x0000000CU          /*!< SYSCLK divided by 24 */
352
#define SMARTCARD_PRESCALER_SYSCLK_DIV24    0x0000000CU          /*!< SYSCLK divided by 24 */
352
#define SMARTCARD_PRESCALER_SYSCLK_DIV26    0x0000000DU          /*!< SYSCLK divided by 26 */
353
#define SMARTCARD_PRESCALER_SYSCLK_DIV26    0x0000000DU          /*!< SYSCLK divided by 26 */
353
#define SMARTCARD_PRESCALER_SYSCLK_DIV28    0x0000000EU          /*!< SYSCLK divided by 28 */
354
#define SMARTCARD_PRESCALER_SYSCLK_DIV28    0x0000000EU          /*!< SYSCLK divided by 28 */
354
#define SMARTCARD_PRESCALER_SYSCLK_DIV30    0x0000000FU          /*!< SYSCLK divided by 30 */
355
#define SMARTCARD_PRESCALER_SYSCLK_DIV30    0x0000000FU          /*!< SYSCLK divided by 30 */
355
#define SMARTCARD_PRESCALER_SYSCLK_DIV32    0x00000010U          /*!< SYSCLK divided by 32 */
356
#define SMARTCARD_PRESCALER_SYSCLK_DIV32    0x00000010U          /*!< SYSCLK divided by 32 */
356
#define SMARTCARD_PRESCALER_SYSCLK_DIV34    0x00000011U          /*!< SYSCLK divided by 34 */
357
#define SMARTCARD_PRESCALER_SYSCLK_DIV34    0x00000011U          /*!< SYSCLK divided by 34 */
357
#define SMARTCARD_PRESCALER_SYSCLK_DIV36    0x00000012U          /*!< SYSCLK divided by 36 */
358
#define SMARTCARD_PRESCALER_SYSCLK_DIV36    0x00000012U          /*!< SYSCLK divided by 36 */
358
#define SMARTCARD_PRESCALER_SYSCLK_DIV38    0x00000013U          /*!< SYSCLK divided by 38 */
359
#define SMARTCARD_PRESCALER_SYSCLK_DIV38    0x00000013U          /*!< SYSCLK divided by 38 */
359
#define SMARTCARD_PRESCALER_SYSCLK_DIV40    0x00000014U          /*!< SYSCLK divided by 40 */
360
#define SMARTCARD_PRESCALER_SYSCLK_DIV40    0x00000014U          /*!< SYSCLK divided by 40 */
360
#define SMARTCARD_PRESCALER_SYSCLK_DIV42    0x00000015U          /*!< SYSCLK divided by 42 */
361
#define SMARTCARD_PRESCALER_SYSCLK_DIV42    0x00000015U          /*!< SYSCLK divided by 42 */
361
#define SMARTCARD_PRESCALER_SYSCLK_DIV44    0x00000016U          /*!< SYSCLK divided by 44 */
362
#define SMARTCARD_PRESCALER_SYSCLK_DIV44    0x00000016U          /*!< SYSCLK divided by 44 */
362
#define SMARTCARD_PRESCALER_SYSCLK_DIV46    0x00000017U          /*!< SYSCLK divided by 46 */
363
#define SMARTCARD_PRESCALER_SYSCLK_DIV46    0x00000017U          /*!< SYSCLK divided by 46 */
363
#define SMARTCARD_PRESCALER_SYSCLK_DIV48    0x00000018U          /*!< SYSCLK divided by 48 */
364
#define SMARTCARD_PRESCALER_SYSCLK_DIV48    0x00000018U          /*!< SYSCLK divided by 48 */
364
#define SMARTCARD_PRESCALER_SYSCLK_DIV50    0x00000019U          /*!< SYSCLK divided by 50 */
365
#define SMARTCARD_PRESCALER_SYSCLK_DIV50    0x00000019U          /*!< SYSCLK divided by 50 */
365
#define SMARTCARD_PRESCALER_SYSCLK_DIV52    0x0000001AU          /*!< SYSCLK divided by 52 */
366
#define SMARTCARD_PRESCALER_SYSCLK_DIV52    0x0000001AU          /*!< SYSCLK divided by 52 */
366
#define SMARTCARD_PRESCALER_SYSCLK_DIV54    0x0000001BU          /*!< SYSCLK divided by 54 */
367
#define SMARTCARD_PRESCALER_SYSCLK_DIV54    0x0000001BU          /*!< SYSCLK divided by 54 */
367
#define SMARTCARD_PRESCALER_SYSCLK_DIV56    0x0000001CU          /*!< SYSCLK divided by 56 */
368
#define SMARTCARD_PRESCALER_SYSCLK_DIV56    0x0000001CU          /*!< SYSCLK divided by 56 */
368
#define SMARTCARD_PRESCALER_SYSCLK_DIV58    0x0000001DU          /*!< SYSCLK divided by 58 */
369
#define SMARTCARD_PRESCALER_SYSCLK_DIV58    0x0000001DU          /*!< SYSCLK divided by 58 */
369
#define SMARTCARD_PRESCALER_SYSCLK_DIV60    0x0000001EU          /*!< SYSCLK divided by 60 */
370
#define SMARTCARD_PRESCALER_SYSCLK_DIV60    0x0000001EU          /*!< SYSCLK divided by 60 */
370
#define SMARTCARD_PRESCALER_SYSCLK_DIV62    0x0000001FU          /*!< SYSCLK divided by 62 */
371
#define SMARTCARD_PRESCALER_SYSCLK_DIV62    0x0000001FU          /*!< SYSCLK divided by 62 */
371
/**
372
/**
372
  * @}
373
  * @}
373
  */
374
  */
374
 
375
 
375
/** @defgroup SmartCard_Flags SMARTCARD Flags
376
/** @defgroup SmartCard_Flags SMARTCARD Flags
376
  *        Elements values convention: 0xXXXX
377
  *        Elements values convention: 0xXXXX
377
  *           - 0xXXXX  : Flag mask in the SR register
378
  *           - 0xXXXX  : Flag mask in the SR register
378
  * @{
379
  * @{
379
  */
380
  */
380
#define SMARTCARD_FLAG_TXE                  ((uint32_t)USART_SR_TXE)
381
#define SMARTCARD_FLAG_TXE                  ((uint32_t)USART_SR_TXE)
381
#define SMARTCARD_FLAG_TC                   ((uint32_t)USART_SR_TC)
382
#define SMARTCARD_FLAG_TC                   ((uint32_t)USART_SR_TC)
382
#define SMARTCARD_FLAG_RXNE                 ((uint32_t)USART_SR_RXNE)
383
#define SMARTCARD_FLAG_RXNE                 ((uint32_t)USART_SR_RXNE)
383
#define SMARTCARD_FLAG_IDLE                 ((uint32_t)USART_SR_IDLE)
384
#define SMARTCARD_FLAG_IDLE                 ((uint32_t)USART_SR_IDLE)
384
#define SMARTCARD_FLAG_ORE                  ((uint32_t)USART_SR_ORE)
385
#define SMARTCARD_FLAG_ORE                  ((uint32_t)USART_SR_ORE)
385
#define SMARTCARD_FLAG_NE                   ((uint32_t)USART_SR_NE)
386
#define SMARTCARD_FLAG_NE                   ((uint32_t)USART_SR_NE)
386
#define SMARTCARD_FLAG_FE                   ((uint32_t)USART_SR_FE)
387
#define SMARTCARD_FLAG_FE                   ((uint32_t)USART_SR_FE)
387
#define SMARTCARD_FLAG_PE                   ((uint32_t)USART_SR_PE)
388
#define SMARTCARD_FLAG_PE                   ((uint32_t)USART_SR_PE)
388
/**
389
/**
389
  * @}
390
  * @}
390
  */
391
  */
391
 
392
 
392
/** @defgroup SmartCard_Interrupt_definition SMARTCARD Interrupts Definition
393
/** @defgroup SmartCard_Interrupt_definition SMARTCARD Interrupts Definition
393
  *        Elements values convention: 0xY000XXXX
394
  *        Elements values convention: 0xY000XXXX
394
  *           - XXXX  : Interrupt mask in the Y register
395
  *           - XXXX  : Interrupt mask in the Y register
395
  *           - Y  : Interrupt source register (2bits)
396
  *           - Y  : Interrupt source register (2bits)
396
  *                 - 01: CR1 register
397
  *                 - 01: CR1 register
397
  *                 - 11: CR3 register
398
  *                 - 11: CR3 register
398
  * @{
399
  * @{
399
  */
400
  */
400
#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))
401
#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))
402
#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))
403
#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))
404
#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))
405
#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))
406
/**
407
/**
407
  * @}
408
  * @}
408
  */
409
  */
409
 
410
 
410
/**
411
/**
411
  * @}
412
  * @}
412
  */
413
  */
413
 
414
 
414
/* Exported macro ------------------------------------------------------------*/
415
/* Exported macro ------------------------------------------------------------*/
415
/** @defgroup SMARTCARD_Exported_Macros SMARTCARD Exported Macros
416
/** @defgroup SMARTCARD_Exported_Macros SMARTCARD Exported Macros
416
  * @{
417
  * @{
417
  */
418
  */
418
 
419
 
419
/** @brief Reset SMARTCARD handle gstate & RxState
420
/** @brief Reset SMARTCARD handle gstate & RxState
420
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
421
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
421
  *         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).
422
  * @retval None
423
  * @retval None
423
  */
424
  */
424
#if USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1
425
#if USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1
425
#define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__)  do{                                                       \
426
#define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__)  do{                                                       \
426
                                                           (__HANDLE__)->gState = HAL_SMARTCARD_STATE_RESET;      \
427
                                                           (__HANDLE__)->gState = HAL_SMARTCARD_STATE_RESET;      \
427
                                                           (__HANDLE__)->RxState = HAL_SMARTCARD_STATE_RESET;     \
428
                                                           (__HANDLE__)->RxState = HAL_SMARTCARD_STATE_RESET;     \
428
                                                           (__HANDLE__)->MspInitCallback = NULL;                  \
429
                                                           (__HANDLE__)->MspInitCallback = NULL;                  \
429
                                                           (__HANDLE__)->MspDeInitCallback = NULL;                \
430
                                                           (__HANDLE__)->MspDeInitCallback = NULL;                \
430
                                                          } while(0U)
431
                                                          } while(0U)
431
#else
432
#else
432
#define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__)  do{                                                       \
433
#define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__)  do{                                                       \
433
                                                           (__HANDLE__)->gState = HAL_SMARTCARD_STATE_RESET;      \
434
                                                           (__HANDLE__)->gState = HAL_SMARTCARD_STATE_RESET;      \
434
                                                           (__HANDLE__)->RxState = HAL_SMARTCARD_STATE_RESET;     \
435
                                                           (__HANDLE__)->RxState = HAL_SMARTCARD_STATE_RESET;     \
435
                                                          } while(0U)
436
                                                          } while(0U)
436
#endif /*USE_HAL_SMARTCARD_REGISTER_CALLBACKS  */
437
#endif /*USE_HAL_SMARTCARD_REGISTER_CALLBACKS  */
437
 
438
 
438
/** @brief  Flush the Smartcard DR register
439
/** @brief  Flush the Smartcard DR register
439
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
440
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
440
  *         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).
441
  * @retval None
442
  * @retval None
442
  */
443
  */
443
#define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
444
#define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
444
 
445
 
445
/** @brief  Check whether the specified Smartcard flag is set or not.
446
/** @brief  Check whether the specified Smartcard flag is set or not.
446
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
447
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
447
  *         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).
448
  * @param  __FLAG__ specifies the flag to check.
449
  * @param  __FLAG__ specifies the flag to check.
449
  *        This parameter can be one of the following values:
450
  *        This parameter can be one of the following values:
450
  *            @arg SMARTCARD_FLAG_TXE:  Transmit data register empty flag
451
  *            @arg SMARTCARD_FLAG_TXE:  Transmit data register empty flag
451
  *            @arg SMARTCARD_FLAG_TC:   Transmission Complete flag
452
  *            @arg SMARTCARD_FLAG_TC:   Transmission Complete flag
452
  *            @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag
453
  *            @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag
453
  *            @arg SMARTCARD_FLAG_IDLE: Idle Line detection flag
454
  *            @arg SMARTCARD_FLAG_IDLE: Idle Line detection flag
454
  *            @arg SMARTCARD_FLAG_ORE:  Overrun Error flag
455
  *            @arg SMARTCARD_FLAG_ORE:  Overrun Error flag
455
  *            @arg SMARTCARD_FLAG_NE:   Noise Error flag
456
  *            @arg SMARTCARD_FLAG_NE:   Noise Error flag
456
  *            @arg SMARTCARD_FLAG_FE:   Framing Error flag
457
  *            @arg SMARTCARD_FLAG_FE:   Framing Error flag
457
  *            @arg SMARTCARD_FLAG_PE:   Parity Error flag
458
  *            @arg SMARTCARD_FLAG_PE:   Parity Error flag
458
  * @retval The new state of __FLAG__ (TRUE or FALSE).
459
  * @retval The new state of __FLAG__ (TRUE or FALSE).
459
  */
460
  */
460
#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__))
461
 
462
 
462
/** @brief  Clear the specified Smartcard pending flags.
463
/** @brief  Clear the specified Smartcard pending flags.
463
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
464
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
464
  *         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).
465
  * @param  __FLAG__ specifies the flag to check.
466
  * @param  __FLAG__ specifies the flag to check.
466
  *          This parameter can be any combination of the following values:
467
  *          This parameter can be any combination of the following values:
467
  *            @arg SMARTCARD_FLAG_TC:   Transmission Complete flag.
468
  *            @arg SMARTCARD_FLAG_TC:   Transmission Complete flag.
468
  *            @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag.
469
  *            @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag.
469
  *
470
  *
470
  * @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
471
  *          error) flags are cleared by software sequence: a read operation to
472
  *          error) flags are cleared by software sequence: a read operation to
472
  *          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.
473
  * @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.
474
  * @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
475
  *          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.
476
  * @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.
477
  * @retval None
478
  * @retval None
478
  */
479
  */
479
#define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
480
#define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
480
 
481
 
481
/** @brief  Clear the SMARTCARD PE pending flag.
482
/** @brief  Clear the SMARTCARD PE pending flag.
482
  * @param  __HANDLE__ specifies the USART Handle.
483
  * @param  __HANDLE__ specifies the USART Handle.
483
  *         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).
484
  * @retval None
485
  * @retval None
485
  */
486
  */
486
#define __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)  \
487
#define __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)  \
487
    do{                                           \
488
    do{                                           \
488
      __IO uint32_t tmpreg = 0x00U;               \
489
      __IO uint32_t tmpreg = 0x00U;               \
489
      tmpreg = (__HANDLE__)->Instance->SR;        \
490
      tmpreg = (__HANDLE__)->Instance->SR;        \
490
      tmpreg = (__HANDLE__)->Instance->DR;        \
491
      tmpreg = (__HANDLE__)->Instance->DR;        \
491
      UNUSED(tmpreg);                             \
492
      UNUSED(tmpreg);                             \
492
    } while(0U)
493
    } while(0U)
493
 
494
 
494
/** @brief  Clear the SMARTCARD FE pending flag.
495
/** @brief  Clear the SMARTCARD FE pending flag.
495
  * @param  __HANDLE__ specifies the USART Handle.
496
  * @param  __HANDLE__ specifies the USART Handle.
496
  *         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).
497
  * @retval None
498
  * @retval None
498
  */
499
  */
499
#define __HAL_SMARTCARD_CLEAR_FEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
500
#define __HAL_SMARTCARD_CLEAR_FEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
500
 
501
 
501
/** @brief  Clear the SMARTCARD NE pending flag.
502
/** @brief  Clear the SMARTCARD NE pending flag.
502
  * @param  __HANDLE__ specifies the USART Handle.
503
  * @param  __HANDLE__ specifies the USART Handle.
503
  *         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).
504
  * @retval None
505
  * @retval None
505
  */
506
  */
506
#define __HAL_SMARTCARD_CLEAR_NEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
507
#define __HAL_SMARTCARD_CLEAR_NEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
507
 
508
 
508
/** @brief  Clear the SMARTCARD ORE pending flag.
509
/** @brief  Clear the SMARTCARD ORE pending flag.
509
  * @param  __HANDLE__ specifies the USART Handle.
510
  * @param  __HANDLE__ specifies the USART Handle.
510
  *         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).
511
  * @retval None
512
  * @retval None
512
  */
513
  */
513
#define __HAL_SMARTCARD_CLEAR_OREFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
514
#define __HAL_SMARTCARD_CLEAR_OREFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
514
 
515
 
515
/** @brief  Clear the SMARTCARD IDLE pending flag.
516
/** @brief  Clear the SMARTCARD IDLE pending flag.
516
  * @param  __HANDLE__ specifies the USART Handle.
517
  * @param  __HANDLE__ specifies the USART Handle.
517
  *         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).
518
  * @retval None
519
  * @retval None
519
  */
520
  */
520
#define __HAL_SMARTCARD_CLEAR_IDLEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
521
#define __HAL_SMARTCARD_CLEAR_IDLEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
521
 
522
 
522
/** @brief  Enable the specified SmartCard interrupt.
523
/** @brief  Enable the specified SmartCard interrupt.
523
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
524
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
524
  *         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).
525
  * @param  __INTERRUPT__ specifies the SMARTCARD interrupt to enable.
526
  * @param  __INTERRUPT__ specifies the SMARTCARD interrupt to enable.
526
  *          This parameter can be one of the following values:
527
  *          This parameter can be one of the following values:
527
  *            @arg SMARTCARD_IT_TXE:  Transmit Data Register empty interrupt
528
  *            @arg SMARTCARD_IT_TXE:  Transmit Data Register empty interrupt
528
  *            @arg SMARTCARD_IT_TC:   Transmission complete interrupt
529
  *            @arg SMARTCARD_IT_TC:   Transmission complete interrupt
529
  *            @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
530
  *            @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
530
  *            @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
531
  *            @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
531
  *            @arg SMARTCARD_IT_PE:   Parity Error interrupt
532
  *            @arg SMARTCARD_IT_PE:   Parity Error interrupt
532
  *            @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)
533
  * @retval None
534
  * @retval None
534
  */
535
  */
535
#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)): \
536
                                                                 ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK)))
537
                                                                 ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK)))
537
 
538
 
538
/** @brief  Disable the specified SmartCard interrupt.
539
/** @brief  Disable the specified SmartCard interrupt.
539
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
540
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
540
  *         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).
541
  * @param  __INTERRUPT__ specifies the SMARTCARD interrupt to disable.
542
  * @param  __INTERRUPT__ specifies the SMARTCARD interrupt to disable.
542
  *          This parameter can be one of the following values:
543
  *          This parameter can be one of the following values:
543
  *            @arg SMARTCARD_IT_TXE:  Transmit Data Register empty interrupt
544
  *            @arg SMARTCARD_IT_TXE:  Transmit Data Register empty interrupt
544
  *            @arg SMARTCARD_IT_TC:   Transmission complete interrupt
545
  *            @arg SMARTCARD_IT_TC:   Transmission complete interrupt
545
  *            @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
546
  *            @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
546
  *            @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
547
  *            @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
547
  *            @arg SMARTCARD_IT_PE:   Parity Error interrupt
548
  *            @arg SMARTCARD_IT_PE:   Parity Error interrupt
548
  *            @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)
549
  * @retval None
550
  * @retval None
550
  */
551
  */
551
#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)): \
552
                                                                 ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & SMARTCARD_IT_MASK)))
553
                                                                 ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & SMARTCARD_IT_MASK)))
553
 
554
 
554
/** @brief  Checks whether the specified SmartCard interrupt has occurred or not.
555
/** @brief  Checks whether the specified SmartCard interrupt has occurred or not.
555
  * @param  __HANDLE__ specifies the SmartCard Handle.
556
  * @param  __HANDLE__ specifies the SmartCard Handle.
556
  * @param  __IT__ specifies the SMARTCARD interrupt source to check.
557
  * @param  __IT__ specifies the SMARTCARD interrupt source to check.
557
  *          This parameter can be one of the following values:
558
  *          This parameter can be one of the following values:
558
  *            @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
559
  *            @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
559
  *            @arg SMARTCARD_IT_TC:  Transmission complete interrupt
560
  *            @arg SMARTCARD_IT_TC:  Transmission complete interrupt
560
  *            @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
561
  *            @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
561
  *            @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
562
  *            @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
562
  *            @arg SMARTCARD_IT_ERR: Error interrupt
563
  *            @arg SMARTCARD_IT_ERR: Error interrupt
563
  *            @arg SMARTCARD_IT_PE: Parity Error interrupt
564
  *            @arg SMARTCARD_IT_PE: Parity Error interrupt
564
  * @retval The new state of __IT__ (TRUE or FALSE).
565
  * @retval The new state of __IT__ (TRUE or FALSE).
565
  */
566
  */
566
#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))
567
 
568
 
568
/** @brief  Macro to enable the SMARTCARD's one bit sample method
569
/** @brief  Macro to enable the SMARTCARD's one bit sample method
569
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
570
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
570
  * @retval None
571
  * @retval None
571
  */
572
  */
572
#define __HAL_SMARTCARD_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
573
#define __HAL_SMARTCARD_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
573
 
574
 
574
/** @brief  Macro to disable the SMARTCARD's one bit sample method
575
/** @brief  Macro to disable the SMARTCARD's one bit sample method
575
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
576
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
576
  * @retval None
577
  * @retval None
577
  */
578
  */
578
#define __HAL_SMARTCARD_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT))
579
#define __HAL_SMARTCARD_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT))
579
 
580
 
580
/** @brief  Enable the USART associated to the SMARTCARD Handle
581
/** @brief  Enable the USART associated to the SMARTCARD Handle
581
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
582
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
582
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
583
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
583
  * @retval None
584
  * @retval None
584
  */
585
  */
585
#define __HAL_SMARTCARD_ENABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR1 |=  USART_CR1_UE)
586
#define __HAL_SMARTCARD_ENABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR1 |=  USART_CR1_UE)
586
 
587
 
587
/** @brief  Disable the USART associated to the SMARTCARD Handle
588
/** @brief  Disable the USART associated to the SMARTCARD Handle
588
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
589
  * @param  __HANDLE__ specifies the SMARTCARD Handle.
589
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
590
  *         SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
590
  * @retval None
591
  * @retval None
591
  */
592
  */
592
#define __HAL_SMARTCARD_DISABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR1 &=  ~USART_CR1_UE)
593
#define __HAL_SMARTCARD_DISABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR1 &=  ~USART_CR1_UE)
593
 
594
 
594
/** @brief  Macros to enable the SmartCard DMA request.
595
/** @brief  Macros to enable the SmartCard DMA request.
595
  * @param  __HANDLE__ specifies the SmartCard Handle.
596
  * @param  __HANDLE__ specifies the SmartCard Handle.
596
  * @param  __REQUEST__ specifies the SmartCard DMA request.
597
  * @param  __REQUEST__ specifies the SmartCard DMA request.
597
  *          This parameter can be one of the following values:
598
  *          This parameter can be one of the following values:
598
  *            @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request
599
  *            @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request
599
  *            @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request
600
  *            @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request
600
  * @retval None
601
  * @retval None
601
  */
602
  */
602
#define __HAL_SMARTCARD_DMA_REQUEST_ENABLE(__HANDLE__, __REQUEST__)    ((__HANDLE__)->Instance->CR3 |=  (__REQUEST__))
603
#define __HAL_SMARTCARD_DMA_REQUEST_ENABLE(__HANDLE__, __REQUEST__)    ((__HANDLE__)->Instance->CR3 |=  (__REQUEST__))
603
 
604
 
604
/** @brief  Macros to disable the SmartCard DMA request.
605
/** @brief  Macros to disable the SmartCard DMA request.
605
  * @param  __HANDLE__ specifies the SmartCard Handle.
606
  * @param  __HANDLE__ specifies the SmartCard Handle.
606
  * @param  __REQUEST__ specifies the SmartCard DMA request.
607
  * @param  __REQUEST__ specifies the SmartCard DMA request.
607
  *          This parameter can be one of the following values:
608
  *          This parameter can be one of the following values:
608
  *            @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request
609
  *            @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request
609
  *            @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request
610
  *            @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request
610
  * @retval None
611
  * @retval None
611
  */
612
  */
612
#define __HAL_SMARTCARD_DMA_REQUEST_DISABLE(__HANDLE__, __REQUEST__)   ((__HANDLE__)->Instance->CR3 &=  ~(__REQUEST__))
613
#define __HAL_SMARTCARD_DMA_REQUEST_DISABLE(__HANDLE__, __REQUEST__)   ((__HANDLE__)->Instance->CR3 &=  ~(__REQUEST__))
613
 
614
 
614
/**
615
/**
615
  * @}
616
  * @}
616
  */
617
  */
617
 
618
 
618
/* Exported functions --------------------------------------------------------*/
619
/* Exported functions --------------------------------------------------------*/
619
/** @addtogroup SMARTCARD_Exported_Functions
620
/** @addtogroup SMARTCARD_Exported_Functions
620
  * @{
621
  * @{
621
  */
622
  */
622
 
623
 
623
/** @addtogroup SMARTCARD_Exported_Functions_Group1
624
/** @addtogroup SMARTCARD_Exported_Functions_Group1
624
  * @{
625
  * @{
625
  */
626
  */
626
/* Initialization/de-initialization functions  **********************************/
627
/* Initialization/de-initialization functions  **********************************/
627
HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc);
628
HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc);
628
HAL_StatusTypeDef HAL_SMARTCARD_ReInit(SMARTCARD_HandleTypeDef *hsc);
629
HAL_StatusTypeDef HAL_SMARTCARD_ReInit(SMARTCARD_HandleTypeDef *hsc);
629
HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc);
630
HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc);
630
void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc);
631
void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc);
631
void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc);
632
void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc);
632
#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
633
#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
633
/* Callbacks Register/UnRegister functions  ***********************************/
634
/* Callbacks Register/UnRegister functions  ***********************************/
634
HAL_StatusTypeDef HAL_SMARTCARD_RegisterCallback(SMARTCARD_HandleTypeDef *hsc, HAL_SMARTCARD_CallbackIDTypeDef CallbackID, pSMARTCARD_CallbackTypeDef pCallback);
635
HAL_StatusTypeDef HAL_SMARTCARD_RegisterCallback(SMARTCARD_HandleTypeDef *hsc, HAL_SMARTCARD_CallbackIDTypeDef CallbackID, pSMARTCARD_CallbackTypeDef pCallback);
635
HAL_StatusTypeDef HAL_SMARTCARD_UnRegisterCallback(SMARTCARD_HandleTypeDef *hsc, HAL_SMARTCARD_CallbackIDTypeDef CallbackID);
636
HAL_StatusTypeDef HAL_SMARTCARD_UnRegisterCallback(SMARTCARD_HandleTypeDef *hsc, HAL_SMARTCARD_CallbackIDTypeDef CallbackID);
636
#endif /* USE_HAL_SMARTCARD_REGISTER_CALLBACKS */
637
#endif /* USE_HAL_SMARTCARD_REGISTER_CALLBACKS */
637
/**
638
/**
638
  * @}
639
  * @}
639
  */
640
  */
640
 
641
 
641
/** @addtogroup SMARTCARD_Exported_Functions_Group2
642
/** @addtogroup SMARTCARD_Exported_Functions_Group2
642
  * @{
643
  * @{
643
  */
644
  */
644
/* IO operation functions *******************************************************/
645
/* IO operation functions *******************************************************/
645
HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, const uint8_t *pData, uint16_t Size, uint32_t Timeout);
646
HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout);
646
HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout);
647
HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout);
647
HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc, const uint8_t *pData, uint16_t Size);
648
HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
648
HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
649
HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
649
HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, const uint8_t *pData, uint16_t Size);
650
HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
650
HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
651
HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
651
/* Transfer Abort functions */
652
/* Transfer Abort functions */
652
HAL_StatusTypeDef HAL_SMARTCARD_Abort(SMARTCARD_HandleTypeDef *hsc);
653
HAL_StatusTypeDef HAL_SMARTCARD_Abort(SMARTCARD_HandleTypeDef *hsc);
653
HAL_StatusTypeDef HAL_SMARTCARD_AbortTransmit(SMARTCARD_HandleTypeDef *hsc);
654
HAL_StatusTypeDef HAL_SMARTCARD_AbortTransmit(SMARTCARD_HandleTypeDef *hsc);
654
HAL_StatusTypeDef HAL_SMARTCARD_AbortReceive(SMARTCARD_HandleTypeDef *hsc);
655
HAL_StatusTypeDef HAL_SMARTCARD_AbortReceive(SMARTCARD_HandleTypeDef *hsc);
655
HAL_StatusTypeDef HAL_SMARTCARD_Abort_IT(SMARTCARD_HandleTypeDef *hsc);
656
HAL_StatusTypeDef HAL_SMARTCARD_Abort_IT(SMARTCARD_HandleTypeDef *hsc);
656
HAL_StatusTypeDef HAL_SMARTCARD_AbortTransmit_IT(SMARTCARD_HandleTypeDef *hsc);
657
HAL_StatusTypeDef HAL_SMARTCARD_AbortTransmit_IT(SMARTCARD_HandleTypeDef *hsc);
657
HAL_StatusTypeDef HAL_SMARTCARD_AbortReceive_IT(SMARTCARD_HandleTypeDef *hsc);
658
HAL_StatusTypeDef HAL_SMARTCARD_AbortReceive_IT(SMARTCARD_HandleTypeDef *hsc);
658
 
659
 
659
void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsc);
660
void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsc);
660
void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc);
661
void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc);
661
void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc);
662
void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc);
662
void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc);
663
void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc);
663
void HAL_SMARTCARD_AbortCpltCallback(SMARTCARD_HandleTypeDef *hsc);
664
void HAL_SMARTCARD_AbortCpltCallback(SMARTCARD_HandleTypeDef *hsc);
664
void HAL_SMARTCARD_AbortTransmitCpltCallback(SMARTCARD_HandleTypeDef *hsc);
665
void HAL_SMARTCARD_AbortTransmitCpltCallback(SMARTCARD_HandleTypeDef *hsc);
665
void HAL_SMARTCARD_AbortReceiveCpltCallback(SMARTCARD_HandleTypeDef *hsc);
666
void HAL_SMARTCARD_AbortReceiveCpltCallback(SMARTCARD_HandleTypeDef *hsc);
666
/**
667
/**
667
  * @}
668
  * @}
668
  */
669
  */
669
 
670
 
670
/** @addtogroup SMARTCARD_Exported_Functions_Group3
671
/** @addtogroup SMARTCARD_Exported_Functions_Group3
671
  * @{
672
  * @{
672
  */
673
  */
673
/* Peripheral State functions  **************************************************/
674
/* Peripheral State functions  **************************************************/
674
HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(const SMARTCARD_HandleTypeDef *hsc);
675
HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsc);
675
uint32_t HAL_SMARTCARD_GetError(const SMARTCARD_HandleTypeDef *hsc);
676
uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsc);
676
/**
677
/**
677
  * @}
678
  * @}
678
  */
679
  */
679
 
680
 
680
/**
681
/**
681
  * @}
682
  * @}
682
  */
683
  */
683
/* Private types -------------------------------------------------------------*/
684
/* Private types -------------------------------------------------------------*/
684
/* Private variables ---------------------------------------------------------*/
685
/* Private variables ---------------------------------------------------------*/
685
/* Private constants ---------------------------------------------------------*/
686
/* Private constants ---------------------------------------------------------*/
686
/** @defgroup SMARTCARD_Private_Constants SMARTCARD Private Constants
687
/** @defgroup SMARTCARD_Private_Constants SMARTCARD Private Constants
687
  * @{
688
  * @{
688
  */
689
  */
689
 
690
 
690
/** @brief SMARTCARD interruptions flag mask
691
/** @brief SMARTCARD interruptions flag mask
691
  *
692
  *
692
  */
693
  */
693
#define SMARTCARD_IT_MASK                   ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \
694
#define SMARTCARD_IT_MASK                   ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \
694
                                                        USART_CR1_IDLEIE | USART_CR3_EIE )
695
                                                        USART_CR1_IDLEIE | USART_CR3_EIE )
695
 
696
 
696
#define SMARTCARD_CR1_REG_INDEX             1U
697
#define SMARTCARD_CR1_REG_INDEX             1U
697
#define SMARTCARD_CR3_REG_INDEX             3U
698
#define SMARTCARD_CR3_REG_INDEX             3U
698
/**
699
/**
699
  * @}
700
  * @}
700
  */
701
  */
701
 
702
 
702
/* Private macros --------------------------------------------------------*/
703
/* Private macros --------------------------------------------------------*/
703
/** @defgroup SMARTCARD_Private_Macros   SMARTCARD Private Macros
704
/** @defgroup SMARTCARD_Private_Macros   SMARTCARD Private Macros
704
  * @{
705
  * @{
705
  */
706
  */
706
#define IS_SMARTCARD_WORD_LENGTH(LENGTH)    ((LENGTH) == SMARTCARD_WORDLENGTH_9B)
707
#define IS_SMARTCARD_WORD_LENGTH(LENGTH)    ((LENGTH) == SMARTCARD_WORDLENGTH_9B)
707
#define IS_SMARTCARD_STOPBITS(STOPBITS)     (((STOPBITS) == SMARTCARD_STOPBITS_0_5) || \
708
#define IS_SMARTCARD_STOPBITS(STOPBITS)     (((STOPBITS) == SMARTCARD_STOPBITS_0_5) || \
708
                                             ((STOPBITS) == SMARTCARD_STOPBITS_1_5))
709
                                             ((STOPBITS) == SMARTCARD_STOPBITS_1_5))
709
#define IS_SMARTCARD_PARITY(PARITY)         (((PARITY) == SMARTCARD_PARITY_EVEN) || \
710
#define IS_SMARTCARD_PARITY(PARITY)         (((PARITY) == SMARTCARD_PARITY_EVEN) || \
710
                                             ((PARITY) == SMARTCARD_PARITY_ODD))
711
                                             ((PARITY) == SMARTCARD_PARITY_ODD))
711
#define IS_SMARTCARD_MODE(MODE)             ((((MODE) & 0x0000FFF3U) == 0x00U) && ((MODE) != 0x000000U))
712
#define IS_SMARTCARD_MODE(MODE)             ((((MODE) & 0x0000FFF3U) == 0x00U) && ((MODE) != 0x000000U))
712
#define IS_SMARTCARD_POLARITY(CPOL)         (((CPOL) == SMARTCARD_POLARITY_LOW) || ((CPOL) == SMARTCARD_POLARITY_HIGH))
713
#define IS_SMARTCARD_POLARITY(CPOL)         (((CPOL) == SMARTCARD_POLARITY_LOW) || ((CPOL) == SMARTCARD_POLARITY_HIGH))
713
#define IS_SMARTCARD_PHASE(CPHA)            (((CPHA) == SMARTCARD_PHASE_1EDGE) || ((CPHA) == SMARTCARD_PHASE_2EDGE))
714
#define IS_SMARTCARD_PHASE(CPHA)            (((CPHA) == SMARTCARD_PHASE_1EDGE) || ((CPHA) == SMARTCARD_PHASE_2EDGE))
714
#define IS_SMARTCARD_LASTBIT(LASTBIT)       (((LASTBIT) == SMARTCARD_LASTBIT_DISABLE) || \
715
#define IS_SMARTCARD_LASTBIT(LASTBIT)       (((LASTBIT) == SMARTCARD_LASTBIT_DISABLE) || \
715
                                             ((LASTBIT) == SMARTCARD_LASTBIT_ENABLE))
716
                                             ((LASTBIT) == SMARTCARD_LASTBIT_ENABLE))
716
#define IS_SMARTCARD_NACK_STATE(NACK)       (((NACK) == SMARTCARD_NACK_ENABLE) || \
717
#define IS_SMARTCARD_NACK_STATE(NACK)       (((NACK) == SMARTCARD_NACK_ENABLE) || \
717
                                             ((NACK) == SMARTCARD_NACK_DISABLE))
718
                                             ((NACK) == SMARTCARD_NACK_DISABLE))
718
#define IS_SMARTCARD_BAUDRATE(BAUDRATE)     ((BAUDRATE) < 2000001U)
719
#define IS_SMARTCARD_BAUDRATE(BAUDRATE)     ((BAUDRATE) < 2000001U)
719
 
720
 
720
#define SMARTCARD_DIV(__PCLK__, __BAUD__)                (((__PCLK__)*25U)/(4U*(__BAUD__)))
721
#define SMARTCARD_DIV(__PCLK__, __BAUD__)                (((__PCLK__)*25U)/(4U*(__BAUD__)))
721
#define SMARTCARD_DIVMANT(__PCLK__, __BAUD__)            (SMARTCARD_DIV((__PCLK__), (__BAUD__))/100U)
722
#define SMARTCARD_DIVMANT(__PCLK__, __BAUD__)            (SMARTCARD_DIV((__PCLK__), (__BAUD__))/100U)
722
#define SMARTCARD_DIVFRAQ(__PCLK__, __BAUD__)            ((((SMARTCARD_DIV((__PCLK__), (__BAUD__)) - (SMARTCARD_DIVMANT((__PCLK__), (__BAUD__)) * 100U)) * 16U) + 50U) / 100U)
723
#define SMARTCARD_DIVFRAQ(__PCLK__, __BAUD__)            ((((SMARTCARD_DIV((__PCLK__), (__BAUD__)) - (SMARTCARD_DIVMANT((__PCLK__), (__BAUD__)) * 100U)) * 16U) + 50U) / 100U)
723
/* SMARTCARD BRR = mantissa + overflow + fraction
724
/* SMARTCARD BRR = mantissa + overflow + fraction
724
            = (SMARTCARD DIVMANT << 4) + (SMARTCARD DIVFRAQ & 0xF0) + (SMARTCARD DIVFRAQ & 0x0FU) */
725
            = (SMARTCARD DIVMANT << 4) + (SMARTCARD DIVFRAQ & 0xF0) + (SMARTCARD DIVFRAQ & 0x0FU) */
725
#define SMARTCARD_BRR(__PCLK__, __BAUD__)       (((SMARTCARD_DIVMANT((__PCLK__), (__BAUD__)) << 4U) + \
726
#define SMARTCARD_BRR(__PCLK__, __BAUD__)       (((SMARTCARD_DIVMANT((__PCLK__), (__BAUD__)) << 4U) + \
726
                                                 (SMARTCARD_DIVFRAQ((__PCLK__), (__BAUD__)) & 0xF0U)) + \
727
                                                 (SMARTCARD_DIVFRAQ((__PCLK__), (__BAUD__)) & 0xF0U)) + \
727
                                                 (SMARTCARD_DIVFRAQ((__PCLK__), (__BAUD__)) & 0x0FU))
728
                                                 (SMARTCARD_DIVFRAQ((__PCLK__), (__BAUD__)) & 0x0FU))
728
 
729
 
729
/**
730
/**
730
  * @}
731
  * @}
731
  */
732
  */
732
 
733
 
733
/* Private functions ---------------------------------------------------------*/
734
/* Private functions ---------------------------------------------------------*/
734
/** @defgroup SMARTCARD_Private_Functions SMARTCARD Private Functions
735
/** @defgroup SMARTCARD_Private_Functions SMARTCARD Private Functions
735
  * @{
736
  * @{
736
  */
737
  */
737
 
738
 
738
/**
739
/**
739
  * @}
740
  * @}
740
  */
741
  */
741
 
742
 
742
/**
743
/**
743
  * @}
744
  * @}
744
  */
745
  */
745
 
746
 
746
/**
747
/**
747
  * @}
748
  * @}
748
  */
749
  */
749
 
750
 
750
#ifdef __cplusplus
751
#ifdef __cplusplus
751
}
752
}
752
#endif
753
#endif
753
 
754
 
754
#endif /* __STM32L1xx_HAL_SMARTCARD_H */
755
#endif /* __STM32L1xx_HAL_SMARTCARD_H */
755
 
756
 
-
 
757
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
-