gr55xx_hal_iso7816.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file gr55xx_hal_iso7816.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of ISO7816 HAL library.
7 *
8 ****************************************************************************************
9 * @attention
10 #####Copyright (c) 2019 GOODIX
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 * Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 * Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 * Neither the name of GOODIX nor the names of its contributors may be used
21 to endorse or promote products derived from this software without
22 specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
35 ****************************************************************************************
36 */
37
38 /** @addtogroup PERIPHERAL Peripheral Driver
39 * @{
40 */
41
42 /** @addtogroup HAL_DRIVER HAL Driver
43 * @{
44 */
45
46 /** @defgroup HAL_ISO7816 ISO7816
47 * @brief ISO7816 HAL module driver.
48 * @{
49 */
50
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_ISO7816_H__
53 #define __GR55xx_HAL_ISO7816_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_iso7816.h"
61 #include "gr55xx_hal_def.h"
62
63 /* Exported types ------------------------------------------------------------*/
64 /** @addtogroup HAL_ISO7816_ENUMERATIONS Enumerations
65 * @{
66 */
67
68 /** @defgroup HAL_ISO7816_state HAL ISO7816 State
69 * @{
70 */
71 /**
72 * @brief HAL ISO7816 State Enumerations definition
73 */
74 typedef enum
75 {
76 HAL_ISO7816_STATE_RESET = 0x00U, /**< Peripheral not initialized */
77 HAL_ISO7816_STATE_READY = 0x20U, /**< Peripheral initialized and ready for use */
78 HAL_ISO7816_STATE_BUSY = 0x24U, /**< An internal process is ongoing */
79 HAL_ISO7816_STATE_BUSY_TX = 0x21U, /**< Data Transmission process is ongoing */
80 HAL_ISO7816_STATE_BUSY_RX = 0x22U, /**< Data Reception process is ongoing */
81 HAL_ISO7816_STATE_BUSY_TX_RX = 0x23U, /**< Data Transmission and Reception process is ongoing */
82 HAL_ISO7816_STATE_ABORT = 0x08U, /**< Peripheral with abort request ongoing */
83 HAL_ISO7816_STATE_TIMEOUT = 0xA0U, /**< Timeout state */
84 HAL_ISO7816_STATE_ERROR = 0xE0U /**< Peripheral in error */
85 } hal_iso7816_state_t;
86
87 /** @} */
88
89 /** @} */
90
91 /** @addtogroup HAL_ISO7816_STRUCTURES Structures
92 * @{
93 */
94
95 /** @defgroup ISO7816_Configuration ISO7816 Configuration
96 * @{
97 */
98 /**
99 * @brief ISO7816 init structure definition
100 */
101 typedef struct
102 {
103 uint32_t clk_div; /*!< clk_div is used for dividing the system clock,
104 and IOS7816 output clock is equal to (system clock)/(clk_div+1).*/
105 uint32_t wait_time; /*!< Specifies the guard time value in terms of number of baud clocks */
106 uint16_t guard_time; /*!< Specifies the maximum card response time (leading edge to leading edge) */
107 uint8_t detect_coding; /*!< Specifies whether automatically detect coding convention during ATR receiption. */
108 } iso7816_init_t;
109
110 /** @} */
111
112
113 /** @defgroup ISO7816_handle Handle
114 * @{
115 */
116
117 /**
118 * @brief ISO7816 handle Structure definition
119 */
120 typedef struct _iso7816_handle_t
121 {
122 iso7816_regs_t *p_instance; /**< ISO7816 registers base address */
123 iso7816_init_t init; /**< ISO7816 configuration parameters */
124 uint8_t *p_tx_rx_buffer; /**< Pointer to ISO7816 Tx&Rx transfer Buffer */
125 uint16_t buffer_size; /**< ISO7816 Tx Transfer size */
126 uint16_t tx_xfer_size; /**< ISO7816 Tx Transfer size */
127 __IO uint16_t tx_xfer_count; /**< ISO7816 Tx Transfer Counter */
128 uint16_t rx_xfer_size; /**< ISO7816 Rx Transfer size */
129 __IO uint16_t rx_xfer_count; /**< ISO7816 Rx Transfer Counter */
130 __IO hal_lock_t lock; /**< Locking object */
131 __IO hal_iso7816_state_t state; /**< ISO7816 communication state */
132 __IO hal_iso7816_state_t tx_state; /**< ISO7816 state information related to Tx operations. */
133 __IO hal_iso7816_state_t rx_state; /**< ISO7816 state information related to Rx operations. */
134 __IO uint32_t previous_action; /**< ISO7816 previous_action */
135 __IO uint32_t error_code; /**< ISO7816 error code */
136 uint32_t retention[6]; /**< ISO7816 important register information. */
137 } iso7816_handle_t;
138 /** @} */
139
140 /** @} */
141
142 /** @addtogroup HAL_ISO7816_CALLBACK_STRUCTURES Callback Structures
143 * @{
144 */
145
146 /** @defgroup ISO7816_Callback ISO7816 Callback
147 * @{
148 */
149
150 /**
151 * @brief HAL_ISO7816 Callback function definition
152 */
153
154 typedef struct _hal_iso7816_callback
155 {
156 void (*iso7816_msp_init)(iso7816_handle_t *p_iso7816); /**< ISO7816 init MSP callback */
157 void (*iso7816_msp_deinit)(iso7816_handle_t *p_iso7816); /**< ISO7816 de-init MSP callback */
158 void (*iso7816_error_callback)(iso7816_handle_t *p_iso7816); /**< ISO7816 error callback */
159 void (*iso7816_abort_cplt_callback)(iso7816_handle_t *p_iso7816); /**< ISO7816 abort completed callback */
160 void (*iso7816_presence_callback)(iso7816_handle_t *p_iso7816); /**< ISO7816 card presence state changed callback */
161 void (*iso7816_atr_cplt_callback)(iso7816_handle_t *p_iso7816); /**< ISO7816 reseive atr completed callback */
162 void (*iso7816_tx_cplt_callback)(iso7816_handle_t *p_iso7816); /**< ISO7816 rx transfer completed callback */
163 void (*iso7816_rx_cplt_callback)(iso7816_handle_t *p_iso7816); /**< ISO7816 tx transfer completed callback */
164 void (*iso7816_tx_rx_cplt_callback)(iso7816_handle_t *p_iso7816); /**< ISO7816 tx/rx transfer completed callback */
165 } hal_iso7816_callback_t;
166
167 /** @} */
168
169 /** @} */
170
171 /**
172 * @defgroup HAL_ISO7816_MACRO Defines
173 * @{
174 */
175
176 /* Exported constants --------------------------------------------------------*/
177 /** @defgroup ISO7816_Exported_Constants ISO7816 Exported Constants
178 * @{
179 */
180
181 /** @defgroup ISO7816_ACTION Action state
182 * @{
183 */
184 #define HAL_ISO7816_ACTION_NONE LL_ISO7816_ACTION_NONE /**< Do Nothing. */
185 #define HAL_ISO7816_ACTION_OFF LL_ISO7816_ACTION_OFF /**< Switch Off. */
186 #define HAL_ISO7816_ACTION_STOPCLK LL_ISO7816_ACTION_STOPCLK /**< Stop the clock. */
187 #define HAL_ISO7816_ACTION_ON LL_ISO7816_ACTION_ON /**< Switch on and receive ATR. */
188 #define HAL_ISO7816_ACTION_WARMRST LL_ISO7816_ACTION_WARMRST /**< Trigger warm reset and receive ATR.*/
189 #define HAL_ISO7816_ACTION_RX LL_ISO7816_ACTION_RX /**< Receive. */
190 #define HAL_ISO7816_ACTION_TX LL_ISO7816_ACTION_TX /**< Transmit. */
191 #define HAL_ISO7816_ACTION_TXRX LL_ISO7816_ACTION_TXRX /**< Transmit, followed by RX. */
192 /** @} */
193
194 /** @defgroup ISO7816_Interrupt_definition ISO7816 Interrupt Definition
195 * @{
196 */
197 #define HAL_ISO7816_INTR_TEST LL_ISO7816_INTR_TEST /**< Test interrupt */
198 #define HAL_ISO7816_INTR_PRESENCE LL_ISO7816_INTR_PRESENCE /**< Source presence interrupt */
199 #define HAL_ISO7816_INTR_STATE_ERR LL_ISO7816_INTR_STATE_ERR /**< Source state error interrupt */
200 #define HAL_ISO7816_INTR_DMA_ERR LL_ISO7816_INTR_DMA_ERR /**< Source dma error interrupt */
201 #define HAL_ISO7816_INTR_RETRY_ERR LL_ISO7816_INTR_RETRY_ERR /**< Source retry error interrupt */
202 #define HAL_ISO7816_INTR_RX_ERR LL_ISO7816_INTR_RX_ERR /**< Source rx error interrupt */
203 #define HAL_ISO7816_INTR_DONE LL_ISO7816_INTR_DONE /**< Source done error interrupt */
204 /** @} */
205
206
207 /** @defgroup ISO7816_HAL_CARD_PRESENCE Card Presence Defines
208 * @{
209 */
210 #define HAL_ISO7816_CARD_ABSENT LL_ISO7816_CARD_ABSENT /**< SIM Card is absent. */
211 #define HAL_ISO7816_CARD_PRESENT LL_ISO7816_CARD_PRESENT /**< SIM Card is present. */
212 /** @} */
213
214 /** @defgroup ISO7816_HAL_IO_STATES IO States Defines
215 * @{
216 */
217 #define HAL_ISO7816_IO_STATE_OFF LL_ISO7816_IO_STATE_OFF /**< Off */
218 #define HAL_ISO7816_IO_STATE_IDLE LL_ISO7816_IO_STATE_IDLE /**< Idle */
219 #define HAL_ISO7816_IO_STATE_RX_WAIT LL_ISO7816_IO_STATE_RX_WAIT /**< Receive Wait */
220 #define HAL_ISO7816_IO_STATE_RX LL_ISO7816_IO_STATE_RX /**< Receive */
221 #define HAL_ISO7816_IO_STATE_TX LL_ISO7816_IO_STATE_TX /**< Transmit */
222 #define HAL_ISO7816_IO_STATE_TX_GUARD LL_ISO7816_IO_STATE_TX_GUARD /**< Transmit Guard */
223 /** @} */
224
225 /** @defgroup ISO7816_HAL_PWR_STATES Power States Defines
226 * @{
227 */
228 #define HAL_ISO7816_PWR_STATE_OFF LL_ISO7816_PWR_STATE_OFF /**< Off */
229 #define HAL_ISO7816_PWR_STATE_PWRUP_VCC LL_ISO7816_PWR_STATE_PWRUP_VCC /**< Power up VCC */
230 #define HAL_ISO7816_PWR_STATE_PWRUP_RST LL_ISO7816_PWR_STATE_PWRUP_RST /**< Power up reset */
231 #define HAL_ISO7816_PWR_STATE_PWRDN_RST LL_ISO7816_PWR_STATE_PWRDN_RST /**< Power Down reset */
232 #define HAL_ISO7816_PWR_STATE_PWRDN_VCC LL_ISO7816_PWR_STATE_PWRDN_VCC /**< Power Down VCC */
233 #define HAL_ISO7816_PWR_STATE_STOP_PRE LL_ISO7816_PWR_STATE_STOP_PRE /**< Preparing Clock Stop */
234 #define HAL_ISO7816_PWR_STATE_STOP LL_ISO7816_PWR_STATE_STOP /**< Clock Stopped */
235 #define HAL_ISO7816_PWR_STATE_STOP_POST LL_ISO7816_PWR_STATE_STOP_POST /**< Exiting Clock Stop */
236 #define HAL_ISO7816_PWR_STATE_IDLE LL_ISO7816_PWR_STATE_IDLE /**< Idle */
237 #define HAL_ISO7816_PWR_STATE_RX_TS0 LL_ISO7816_PWR_STATE_RX_TS0 /**< RX TS Character */
238 #define HAL_ISO7816_PWR_STATE_RX_TS1 LL_ISO7816_PWR_STATE_RX_TS1 /**< RX TS Character */
239 #define HAL_ISO7816_PWR_STATE_RX LL_ISO7816_PWR_STATE_RX /**< Receive */
240 #define HAL_ISO7816_PWR_STATE_TX LL_ISO7816_PWR_STATE_TX /**< Transmit */
241 #define HAL_ISO7816_PWR_STATE_TX_RX LL_ISO7816_PWR_STATE_TX_RX /**< Transmit and Receive */
242 /** @} */
243
244 /** @defgroup ISO7816_Error_Code ISO7816 Error Code
245 * @{
246 */
247 #define HAL_ISO7816_ERROR_NONE ((uint32_t)0x00000000) /**< No error */
248 #define HAL_ISO7816_ERROR_TIMEOUT ((uint32_t)0x00000001) /**< Timeout error */
249 #define HAL_ISO7816_ERROR_TRANSFER ((uint32_t)0x00000002) /**< Transfer error */
250 #define HAL_ISO7816_ERROR_INVALID_PARAM ((uint32_t)0x00000008) /**< Invalid parameters error */
251 /** @} */
252
253 /**
254 * @brief ISO7816_default_config InitStruct default configuration
255 */
256 #define ISO7816_DEFAULT_CONFIG \
257 { \
258 .clk_div = 0x2F, \
259 .wait_time = 0x6B, \
260 .guard_time = 0x00, \
261 .detect_coding = ENABLE, \
262 }
263
264 /** @} */
265
266 /* Exported macro ------------------------------------------------------------*/
267 /** @defgroup ISO7816_Exported_Macros ISO7816 Exported Macros
268 * @{
269 */
270
271 /** @brief Enable the specified ISO7816 interrupts.
272 * @param __HANDLE__ Specifies the ISO7816 Handle.
273 * @param __INTERRUPT__ Specifies the interrupt source to enable.
274 * This parameter can be one of the following values:
275 * @arg @ref HAL_ISO7816_INTR_TEST Test interrupt
276 * @arg @ref HAL_ISO7816_INTR_PRESENCE Presence interrupt
277 * @arg @ref HAL_ISO7816_INTR_STATE_ERR State error interrupt
278 * @arg @ref HAL_ISO7816_INTR_DMA_ERR DMA error interrupt
279 * @arg @ref HAL_ISO7816_INTR_RETRY_ERR Retry error interrupt
280 * @arg @ref HAL_ISO7816_INTR_RX_ERR Rx error interrupt
281 * @arg @ref HAL_ISO7816_INTR_DONE Done error interrupt
282 * @retval None
283 */
284 #define __HAL_ISO7816_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->INT_MASK, (__INTERRUPT__))
285
286 /** @brief Disable the specified ISO7816 interrupts.
287 * @param __HANDLE__ Specifies the ISO7816 handle.
288 * @param __INTERRUPT__ Specifies the interrupt source to disable.
289 * This parameter can be one of the following values:
290 * @arg @ref HAL_ISO7816_INTR_TEST Test interrupt
291 * @arg @ref HAL_ISO7816_INTR_PRESENCE Presence interrupt
292 * @arg @ref HAL_ISO7816_INTR_STATE_ERR State error interrupt
293 * @arg @ref HAL_ISO7816_INTR_DMA_ERR DMA error interrupt
294 * @arg @ref HAL_ISO7816_INTR_RETRY_ERR Retry error interrupt
295 * @arg @ref HAL_ISO7816_INTR_RX_ERR Rx error interrupt
296 * @arg @ref HAL_ISO7816_INTR_DONE Done error interrupt
297 * @retval None
298 */
299 #define __HAL_ISO7816_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->INT_MASK, (__INTERRUPT__))
300
301 /** @brief Get the ISO7816 interrupt flags.
302 * @param __ISO7816_REGS ISO7816 Register.
303 * @retval ISO78116 Interrupt definitions.
304 */
305 #define __HAL_ISO7816_IT_GET_IT_FLAG(__ISO7816_REGS) ll_iso7816_get_it_flag(__ISO7816_REGS)
306
307 /** @} */
308
309 /** @} */
310
311 /* Exported functions --------------------------------------------------------*/
312 /** @addtogroup HAL_ISO7816_DRIVER_FUNCTIONS Functions
313 * @{
314 */
315 /**
316 * @brief Transimit data in blocking mode
317 *
318 * @param p_iso7816 Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816.
319 * @param tx_size Bytes of data to transmit
320 * @param timeout Timeout duration
321 * @retval ::HAL_OK: Operation is OK.
322 * @retval ::HAL_ERROR: Parameter error or operation not supported.
323 * @retval ::HAL_BUSY: Driver is busy.
324 * @retval ::HAL_TIMEOUT: Timeout occurred.
325 */
326 hal_status_t hal_iso7816_transmit(iso7816_handle_t *p_iso7816, uint16_t tx_size, uint32_t timeout);
327
328 /**
329 * @brief Receive data in blocking mode
330 *
331 * @param p_iso7816 Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816.
332 * @param rx_size Bytes of data to receive
333 * @param timeout Timeout duration
334 * @retval ::HAL_OK: Operation is OK.
335 * @retval ::HAL_ERROR: Parameter error or operation not supported.
336 * @retval ::HAL_BUSY: Driver is busy.
337 * @retval ::HAL_TIMEOUT: Timeout occurred.
338 */
339 hal_status_t hal_iso7816_receive(iso7816_handle_t *p_iso7816, uint16_t rx_size, uint32_t timeout);
340
341 /**
342 * @brief Transimit and receive data in blocking mode
343 *
344 * @param p_iso7816 Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816.
345 * @param tx_size Bytes of data to transmit
346 * @param rx_size Bytes of data to receive
347 * @param timeout Timeout duration
348 * @retval ::HAL_OK: Operation is OK.
349 * @retval ::HAL_ERROR: Parameter error or operation not supported.
350 * @retval ::HAL_BUSY: Driver is busy.
351 * @retval ::HAL_TIMEOUT: Timeout occurred.
352 */
353 hal_status_t hal_iso7816_transmit_receive(iso7816_handle_t *p_iso7816, uint16_t tx_size,uint16_t rx_size, uint32_t timeout);
354
355 /**
356 * @brief Transimit data in non-blocking mode with Interrupt
357 *
358 * @param p_iso7816 Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816.
359 * @param tx_size Bytes of data to transmit
360 * @retval ::HAL_OK: Operation is OK.
361 * @retval ::HAL_ERROR: Parameter error or operation not supported.
362 * @retval ::HAL_BUSY: Driver is busy.
363 * @retval ::HAL_TIMEOUT: Timeout occurred.
364 */
365 hal_status_t hal_iso7816_transmit_it(iso7816_handle_t *p_iso7816, uint16_t tx_size);
366
367 /**
368 * @brief Receive data in non-blocking mode with Interrupt
369 *
370 * @param p_iso7816 Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816.
371 * @param rx_size Bytes of data to receive
372 * @retval ::HAL_OK: Operation is OK.
373 * @retval ::HAL_ERROR: Parameter error or operation not supported.
374 * @retval ::HAL_BUSY: Driver is busy.
375 * @retval ::HAL_TIMEOUT: Timeout occurred.
376 */
377 hal_status_t hal_iso7816_receive_it(iso7816_handle_t *p_iso7816, uint16_t rx_size);
378
379 /**
380 * @brief Transimit and receive data in non-blocking mode with Interrupt
381 *
382 * @param p_iso7816: Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816.
383 * @param tx_size: Bytes of data to transfer.
384 * @param rx_size: Bytes of data to receive.
385 * @retval ::HAL_OK: Operation is OK.
386 * @retval ::HAL_ERROR: Parameter error or operation not supported.
387 * @retval ::HAL_BUSY: Driver is busy.
388 * @retval ::HAL_TIMEOUT: Timeout occurred.
389 */
390
391 hal_status_t hal_iso7816_transmit_receive_it(iso7816_handle_t *p_iso7816, uint16_t tx_size, uint16_t rx_size);
392
393 /**
394 * @brief Transfer Abort functions
395 *
396 * @param p_iso7816 Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816.
397 * @retval ::HAL_OK: Operation is OK.
398 * @retval ::HAL_ERROR: Parameter error or operation not supported.
399 * @retval ::HAL_BUSY: Driver is busy.
400 * @retval ::HAL_TIMEOUT: Timeout occurred.
401 */
402 hal_status_t hal_iso7816_abort(iso7816_handle_t *p_iso7816);
403
404 /**
405 ****************************************************************************************
406 * @brief Initializes the ISO7816 according to the specified parameters
407 * in the iso7816_init_t and initialize the associated handle.
408 * @param[in] p_iso7816: Pointer to an ISO7816 handle which contains the configuration
409 * information for the specified ISO7816.
410 * @retval ::HAL_OK: Operation is OK.
411 * @retval ::HAL_ERROR: Parameter error or operation not supported.
412 * @retval ::HAL_BUSY: Driver is busy.
413 * @retval ::HAL_TIMEOUT: Timeout occurred.
414 ****************************************************************************************
415 */
416 hal_status_t hal_iso7816_init(iso7816_handle_t *p_iso7816);
417
418 /**
419 ****************************************************************************************
420 * @brief De-initializes the ISO7816 according to the specified parameters
421 * in the iso7816_init_t and initialize the associated handle.
422 * @param[in] p_iso7816: Pointer to an ISO7816 handle which contains the configuration
423 * information for the specified ISO7816.
424 * @retval ::HAL_OK: Operation is OK.
425 * @retval ::HAL_ERROR: Parameter error or operation not supported.
426 * @retval ::HAL_BUSY: Driver is busy.
427 * @retval ::HAL_TIMEOUT: Timeout occurred.
428 ****************************************************************************************
429 */
430 hal_status_t hal_iso7816_deinit(iso7816_handle_t *p_iso7816);
431
432 /**
433 ****************************************************************************************
434 * @brief Initialize the ISO7816 MSP.
435 * @note This function should not be modified. When the callback is needed,
436 * the hal_iso7816_msp_init could be implemented in the user file.
437 * @param[in] p_iso7816: Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816.
438 ****************************************************************************************
439 */
440 void hal_iso7816_msp_init(iso7816_handle_t *p_iso7816);
441
442 /**
443 ****************************************************************************************
444 * @brief De-initialize the ISO7816 MSP.
445 * @note This function should not be modified. When the callback is needed,
446 * the hal_iso7816_msp_deinit could be implemented in the user file.
447 * @param[in] p_iso7816: Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816.
448 ****************************************************************************************
449 */
450 void hal_iso7816_msp_deinit(iso7816_handle_t *p_iso7816);
451 /**
452 ****************************************************************************************
453 * @brief Handle ISO7816 interrupt request.
454 * @param[in] p_iso7816: Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816.
455 ****************************************************************************************
456 */
457 void hal_iso7816_irq_handler(iso7816_handle_t *p_iso7816);
458
459
460 /**
461 ****************************************************************************************
462 * @brief Card presence state changed callback.
463 * @param[in] p_iso7816: Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816 module.
464 ****************************************************************************************
465 */
466 void hal_iso7816_presence_callback(iso7816_handle_t *p_iso7816);
467
468 /**
469 ****************************************************************************************
470 * @brief Receive ART completed callback.
471 * @param[in] p_iso7816: Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816 module.
472 ****************************************************************************************
473 */
474 void hal_iso7816_atr_cplt_callback(iso7816_handle_t *p_iso7816);
475
476 /**
477 ****************************************************************************************
478 * @brief Rx Transfer completed callback.
479 * @param[in] p_iso7816: Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816 module.
480 ****************************************************************************************
481 */
482 void hal_iso7816_rx_cplt_callback(iso7816_handle_t *p_iso7816);
483
484 /**
485 ****************************************************************************************
486 * @brief Tx Transfer completed callback.
487 * @param[in] p_iso7816: Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816 module.
488 ****************************************************************************************
489 */
490 void hal_iso7816_tx_cplt_callback(iso7816_handle_t *p_iso7816);
491
492 /**
493 ****************************************************************************************
494 * @brief Tx and Rx Transfer completed callback.
495 * @param[in] p_iso7816: Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816 module.
496 ****************************************************************************************
497 */
498 void hal_iso7816_tx_rx_cplt_callback(iso7816_handle_t *p_iso7816);
499
500 /**
501 ****************************************************************************************
502 * @brief ISO7816 error callback.
503 * @param[in] p_iso7816: Pointer to an ISO7816 handle which contains the configuration information for the specified ISO7816 module.
504 ****************************************************************************************
505 */
506 void hal_iso7816_error_callback(iso7816_handle_t *p_iso7816);
507
508 /**
509 ****************************************************************************************
510 * @brief ISO7816 Abort Completed callback.
511 * @param[in] p_iso7816: ISO7816 handle.
512 ****************************************************************************************
513 */
514 void hal_iso7816_abort_cplt_callback(iso7816_handle_t *p_iso7816);
515
516 /**
517 ****************************************************************************************
518 * @brief Return the ISO7816 handle state.
519 * @param[in] p_iso7816: ISO7816 handle.
520 * @retval ::HAL_ISO7816_STATE_RESET
521 * @retval ::HAL_ISO7816_STATE_READY
522 * @retval ::HAL_ISO7816_STATE_BUSY
523 * @retval ::HAL_ISO7816_STATE_BUSY_TX
524 * @retval ::HAL_ISO7816_STATE_BUSY_RX
525 * @retval ::HAL_ISO7816_STATE_BUSY_TX_RX
526 * @retval ::HAL_ISO7816_STATE_ABORT
527 * @retval ::HAL_ISO7816_STATE_TIMEOUT
528 * @retval ::HAL_ISO7816_STATE_ERROR
529 ****************************************************************************************
530 */
531 hal_iso7816_state_t hal_iso7816_get_state(iso7816_handle_t *p_iso7816);
532
533 /**
534 * @brief Request ISO7816 to go to the next action.
535 * @param p_iso7816: ISO7816 handle.
536 * @param action: This parameter can be one of the following values:
537 * @arg @ref HAL_ISO7816_ACTION_NONE
538 * @arg @ref HAL_ISO7816_ACTION_OFF
539 * @arg @ref HAL_ISO7816_ACTION_STOPCLK
540 * @arg @ref HAL_ISO7816_ACTION_ON
541 * @arg @ref HAL_ISO7816_ACTION_WARMRST
542 * @arg @ref HAL_ISO7816_ACTION_RX
543 * @arg @ref HAL_ISO7816_ACTION_TX
544 * @arg @ref HAL_ISO7816_ACTION_TXRX
545 * @retval ::HAL_OK: Operation is OK.
546 * @retval ::HAL_ERROR: Parameter error or operation not supported.
547 * @retval ::HAL_BUSY: Driver is busy.
548 */
549 hal_status_t hal_iso7816_set_action(iso7816_handle_t *p_iso7816, uint32_t action);
550
551 /**
552 * @brief Get ISO7816 Power States.
553 * @param p_iso7816: ISO7816 handle.
554 * @retval Returned value can be one of the following values:
555 * @arg @ref HAL_ISO7816_PWR_STATE_OFF
556 * @arg @ref HAL_ISO7816_PWR_STATE_PWRUP_VCC
557 * @arg @ref HAL_ISO7816_PWR_STATE_PWRUP_RST
558 * @arg @ref HAL_ISO7816_PWR_STATE_PWRDN_RST
559 * @arg @ref HAL_ISO7816_PWR_STATE_PWRDN_VCC
560 * @arg @ref HAL_ISO7816_PWR_STATE_STOP_PRE
561 * @arg @ref HAL_ISO7816_PWR_STATE_STOP
562 * @arg @ref HAL_ISO7816_PWR_STATE_STOP_POST
563 * @arg @ref HAL_ISO7816_PWR_STATE_IDLE
564 * @arg @ref HAL_ISO7816_PWR_STATE_RX_TS0
565 * @arg @ref HAL_ISO7816_PWR_STATE_RX_TS1
566 * @arg @ref HAL_ISO7816_PWR_STATE_RX
567 * @arg @ref HAL_ISO7816_PWR_STATE_TX
568 * @arg @ref HAL_ISO7816_PWR_STATE_TX_RX
569 */
570 uint32_t hal_iso7816_get_power_states(iso7816_handle_t *p_iso7816);
571
572 /**
573 * @brief Set divide ISO7816 clock.
574 * @note Divide SIM clock by this value+1 to define ETU length. The reset value
575 * is the one, needed for theATR.
576 * @param p_iso7816: ISO7816 handle.
577 * @param divide This parameter should range between 0x0 and 0x3FF.
578 * @retval None.
579 */
580 hal_status_t hal_iso7816_set_etudiv(iso7816_handle_t *p_iso7816, uint32_t divide);
581
582 /**
583 ****************************************************************************************
584 * @brief Return the ISO7816 error code.
585 * @param[in] p_iso7816: ISO7816 handle.
586 * @return ISO7816 Error Code
587 ****************************************************************************************
588 */
589 uint32_t hal_iso7816_get_error(iso7816_handle_t *p_iso7816);
590
591 /**
592 ****************************************************************************************
593 * @brief Suspend some registers related to ISO7816 configuration before sleep.
594 * @param[in] p_iso7816: ISO7816 handle.
595 * @retval ::HAL_OK: Operation is OK.
596 * @retval ::HAL_ERROR: Parameter error or operation not supported.
597 * @retval ::HAL_BUSY: Driver is busy.
598 * @retval ::HAL_TIMEOUT: Timeout occurred.
599 ****************************************************************************************
600 */
601 hal_status_t hal_iso7816_suspend_reg(iso7816_handle_t *p_iso7816);
602
603 /**
604 ****************************************************************************************
605 * @brief Restore some registers related to ISO7816 configuration after sleep.
606 * This function must be used in conjunction with the hal_iso7816_suspend_reg().
607 * @param[in] p_iso7816: ISO7816 handle.
608 * @retval ::HAL_OK: Operation is OK.
609 * @retval ::HAL_ERROR: Parameter error or operation not supported.
610 * @retval ::HAL_BUSY: Driver is busy.
611 * @retval ::HAL_TIMEOUT: Timeout occurred.
612 ****************************************************************************************
613 */
614 hal_status_t hal_iso7816_resume_reg(iso7816_handle_t *p_iso7816);
615
616
617 /** @} */
618
619 #ifdef __cplusplus
620 }
621 #endif
622
623 #endif /* __GR55xx_HAL_ISO7816_H__ */
624
625 /** @} */
626
627 /** @} */
628
629 /** @} */
hal_iso7816_suspend_reg
hal_status_t hal_iso7816_suspend_reg(iso7816_handle_t *p_iso7816)
Suspend some registers related to ISO7816 configuration before sleep.
hal_iso7816_transmit_receive_it
hal_status_t hal_iso7816_transmit_receive_it(iso7816_handle_t *p_iso7816, uint16_t tx_size, uint16_t rx_size)
Transimit and receive data in non-blocking mode with Interrupt.
iso7816_init_t::clk_div
uint32_t clk_div
Definition: gr55xx_hal_iso7816.h:103
hal_iso7816_abort_cplt_callback
void hal_iso7816_abort_cplt_callback(iso7816_handle_t *p_iso7816)
ISO7816 Abort Completed callback.
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
hal_iso7816_get_error
uint32_t hal_iso7816_get_error(iso7816_handle_t *p_iso7816)
Return the ISO7816 error code.
_iso7816_handle_t
ISO7816 handle Structure definition.
Definition: gr55xx_hal_iso7816.h:121
_iso7816_handle_t::rx_state
__IO hal_iso7816_state_t rx_state
Definition: gr55xx_hal_iso7816.h:133
hal_iso7816_receive
hal_status_t hal_iso7816_receive(iso7816_handle_t *p_iso7816, uint16_t rx_size, uint32_t timeout)
Receive data in blocking mode.
hal_iso7816_transmit_it
hal_status_t hal_iso7816_transmit_it(iso7816_handle_t *p_iso7816, uint16_t tx_size)
Transimit data in non-blocking mode with Interrupt.
iso7816_init_t::detect_coding
uint8_t detect_coding
Definition: gr55xx_hal_iso7816.h:107
hal_iso7816_get_power_states
uint32_t hal_iso7816_get_power_states(iso7816_handle_t *p_iso7816)
Get ISO7816 Power States.
hal_iso7816_resume_reg
hal_status_t hal_iso7816_resume_reg(iso7816_handle_t *p_iso7816)
Restore some registers related to ISO7816 configuration after sleep. This function must be used in co...
_hal_iso7816_callback::iso7816_error_callback
void(* iso7816_error_callback)(iso7816_handle_t *p_iso7816)
Definition: gr55xx_hal_iso7816.h:158
hal_iso7816_receive_it
hal_status_t hal_iso7816_receive_it(iso7816_handle_t *p_iso7816, uint16_t rx_size)
Receive data in non-blocking mode with Interrupt.
_hal_iso7816_callback::iso7816_tx_rx_cplt_callback
void(* iso7816_tx_rx_cplt_callback)(iso7816_handle_t *p_iso7816)
Definition: gr55xx_hal_iso7816.h:164
_iso7816_handle_t::buffer_size
uint16_t buffer_size
Definition: gr55xx_hal_iso7816.h:125
_hal_iso7816_callback::iso7816_presence_callback
void(* iso7816_presence_callback)(iso7816_handle_t *p_iso7816)
Definition: gr55xx_hal_iso7816.h:160
HAL_ISO7816_STATE_READY
@ HAL_ISO7816_STATE_READY
Definition: gr55xx_hal_iso7816.h:77
_hal_iso7816_callback::iso7816_tx_cplt_callback
void(* iso7816_tx_cplt_callback)(iso7816_handle_t *p_iso7816)
Definition: gr55xx_hal_iso7816.h:162
hal_iso7816_msp_deinit
void hal_iso7816_msp_deinit(iso7816_handle_t *p_iso7816)
De-initialize the ISO7816 MSP.
HAL_ISO7816_STATE_ERROR
@ HAL_ISO7816_STATE_ERROR
Definition: gr55xx_hal_iso7816.h:84
_iso7816_handle_t::state
__IO hal_iso7816_state_t state
Definition: gr55xx_hal_iso7816.h:131
_hal_iso7816_callback::iso7816_rx_cplt_callback
void(* iso7816_rx_cplt_callback)(iso7816_handle_t *p_iso7816)
Definition: gr55xx_hal_iso7816.h:163
HAL_ISO7816_STATE_ABORT
@ HAL_ISO7816_STATE_ABORT
Definition: gr55xx_hal_iso7816.h:82
hal_iso7816_get_state
hal_iso7816_state_t hal_iso7816_get_state(iso7816_handle_t *p_iso7816)
Return the ISO7816 handle state.
hal_iso7816_abort
hal_status_t hal_iso7816_abort(iso7816_handle_t *p_iso7816)
Transfer Abort functions.
_iso7816_handle_t::error_code
__IO uint32_t error_code
Definition: gr55xx_hal_iso7816.h:135
_hal_iso7816_callback::iso7816_msp_deinit
void(* iso7816_msp_deinit)(iso7816_handle_t *p_iso7816)
Definition: gr55xx_hal_iso7816.h:157
hal_iso7816_msp_init
void hal_iso7816_msp_init(iso7816_handle_t *p_iso7816)
Initialize the ISO7816 MSP.
hal_iso7816_atr_cplt_callback
void hal_iso7816_atr_cplt_callback(iso7816_handle_t *p_iso7816)
Receive ART completed callback.
hal_iso7816_transmit_receive
hal_status_t hal_iso7816_transmit_receive(iso7816_handle_t *p_iso7816, uint16_t tx_size, uint16_t rx_size, uint32_t timeout)
Transimit and receive data in blocking mode.
HAL_ISO7816_STATE_TIMEOUT
@ HAL_ISO7816_STATE_TIMEOUT
Definition: gr55xx_hal_iso7816.h:83
hal_iso7816_irq_handler
void hal_iso7816_irq_handler(iso7816_handle_t *p_iso7816)
Handle ISO7816 interrupt request.
_hal_iso7816_callback::iso7816_msp_init
void(* iso7816_msp_init)(iso7816_handle_t *p_iso7816)
Definition: gr55xx_hal_iso7816.h:156
gr55xx_ll_iso7816.h
Header file containing functions prototypes of ISO7816 LL library.
hal_iso7816_init
hal_status_t hal_iso7816_init(iso7816_handle_t *p_iso7816)
Initializes the ISO7816 according to the specified parameters in the iso7816_init_t and initialize th...
iso7816_init_t::guard_time
uint16_t guard_time
Definition: gr55xx_hal_iso7816.h:106
HAL_ISO7816_STATE_BUSY_TX_RX
@ HAL_ISO7816_STATE_BUSY_TX_RX
Definition: gr55xx_hal_iso7816.h:81
HAL_ISO7816_STATE_BUSY_RX
@ HAL_ISO7816_STATE_BUSY_RX
Definition: gr55xx_hal_iso7816.h:80
HAL_ISO7816_STATE_BUSY
@ HAL_ISO7816_STATE_BUSY
Definition: gr55xx_hal_iso7816.h:78
_iso7816_handle_t::retention
uint32_t retention[6]
Definition: gr55xx_hal_iso7816.h:136
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
_iso7816_handle_t::lock
__IO hal_lock_t lock
Definition: gr55xx_hal_iso7816.h:130
_iso7816_handle_t::previous_action
__IO uint32_t previous_action
Definition: gr55xx_hal_iso7816.h:134
hal_iso7816_set_etudiv
hal_status_t hal_iso7816_set_etudiv(iso7816_handle_t *p_iso7816, uint32_t divide)
Set divide ISO7816 clock.
iso7816_init_t::wait_time
uint32_t wait_time
Definition: gr55xx_hal_iso7816.h:105
_iso7816_handle_t::tx_xfer_size
uint16_t tx_xfer_size
Definition: gr55xx_hal_iso7816.h:126
hal_iso7816_rx_cplt_callback
void hal_iso7816_rx_cplt_callback(iso7816_handle_t *p_iso7816)
Rx Transfer completed callback.
_iso7816_handle_t::init
iso7816_init_t init
Definition: gr55xx_hal_iso7816.h:123
_iso7816_handle_t::rx_xfer_size
uint16_t rx_xfer_size
Definition: gr55xx_hal_iso7816.h:128
hal_iso7816_deinit
hal_status_t hal_iso7816_deinit(iso7816_handle_t *p_iso7816)
De-initializes the ISO7816 according to the specified parameters in the iso7816_init_t and initialize...
_iso7816_handle_t::tx_xfer_count
__IO uint16_t tx_xfer_count
Definition: gr55xx_hal_iso7816.h:127
hal_iso7816_tx_cplt_callback
void hal_iso7816_tx_cplt_callback(iso7816_handle_t *p_iso7816)
Tx Transfer completed callback.
hal_iso7816_state_t
hal_iso7816_state_t
HAL ISO7816 State Enumerations definition.
Definition: gr55xx_hal_iso7816.h:75
_iso7816_handle_t::tx_state
__IO hal_iso7816_state_t tx_state
Definition: gr55xx_hal_iso7816.h:132
hal_iso7816_presence_callback
void hal_iso7816_presence_callback(iso7816_handle_t *p_iso7816)
Card presence state changed callback.
HAL_ISO7816_STATE_RESET
@ HAL_ISO7816_STATE_RESET
Definition: gr55xx_hal_iso7816.h:76
_iso7816_handle_t::rx_xfer_count
__IO uint16_t rx_xfer_count
Definition: gr55xx_hal_iso7816.h:129
hal_iso7816_tx_rx_cplt_callback
void hal_iso7816_tx_rx_cplt_callback(iso7816_handle_t *p_iso7816)
Tx and Rx Transfer completed callback.
_hal_iso7816_callback
HAL_ISO7816 Callback function definition.
Definition: gr55xx_hal_iso7816.h:155
iso7816_init_t
ISO7816 init structure definition.
Definition: gr55xx_hal_iso7816.h:102
hal_iso7816_transmit
hal_status_t hal_iso7816_transmit(iso7816_handle_t *p_iso7816, uint16_t tx_size, uint32_t timeout)
Transimit data in blocking mode.
_iso7816_handle_t::p_tx_rx_buffer
uint8_t * p_tx_rx_buffer
Definition: gr55xx_hal_iso7816.h:124
_iso7816_handle_t::p_instance
iso7816_regs_t * p_instance
Definition: gr55xx_hal_iso7816.h:122
hal_iso7816_callback_t
struct _hal_iso7816_callback hal_iso7816_callback_t
HAL_ISO7816 Callback function definition.
HAL_ISO7816_STATE_BUSY_TX
@ HAL_ISO7816_STATE_BUSY_TX
Definition: gr55xx_hal_iso7816.h:79
_hal_iso7816_callback::iso7816_abort_cplt_callback
void(* iso7816_abort_cplt_callback)(iso7816_handle_t *p_iso7816)
Definition: gr55xx_hal_iso7816.h:159
hal_iso7816_error_callback
void hal_iso7816_error_callback(iso7816_handle_t *p_iso7816)
ISO7816 error callback.
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
_hal_iso7816_callback::iso7816_atr_cplt_callback
void(* iso7816_atr_cplt_callback)(iso7816_handle_t *p_iso7816)
Definition: gr55xx_hal_iso7816.h:161
iso7816_handle_t
struct _iso7816_handle_t iso7816_handle_t
ISO7816 handle Structure definition.
hal_iso7816_set_action
hal_status_t hal_iso7816_set_action(iso7816_handle_t *p_iso7816, uint32_t action)
Request ISO7816 to go to the next action.