gr55xx_ll_iso7816.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file gr55xx_ll_iso7816.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of ISO7816 LL 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 LL_DRIVER LL Driver
43  * @{
44  */
45 
46 /** @defgroup LL_ISO7816 ISO7816
47  * @brief ISO7816 LL module driver.
48  * @{
49  */
50 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_LL_ISO7816_H__
53 #define __GR55xx_LL_ISO7816_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx.h"
61 
62 #if defined (ISO7816)
63 /** @defgroup ISO7816_LL_STRUCTURES Structures
64  * @{
65  */
66 /* Exported types ------------------------------------------------------------*/
67 /** @defgroup ISO7816_LL_ES_INIT ISO7816 Exported init structure
68  * @{
69  */
70 
71 /**
72  * @brief LL ISO7816 init Structure definition
73  */
74 typedef struct _ll_iso7816_init
75 {
76  uint32_t clk_div; /*!< clk_div is used for dividing the system clock,
77  and IOS7816 output clock is equal to (system clock)/(clk_div+1).*/
78  uint32_t wait_time; /*!< Specifies the guard time value in terms of number of baud clocks */
79  uint16_t guard_time; /*!< Specifies the maximum card response time (leading edge to leading edge) */
80  uint8_t detect_coding; /*!< Specifies whether automatically detect coding convention during ATR receiption. */
82 
83 /** @} */
84 
85 /** @} */
86 
87 /**
88  * @defgroup ISO7816_LL_MACRO Defines
89  * @{
90  */
91 
92 /* Exported constants --------------------------------------------------------*/
93 /** @defgroup ISO7816_LL_Exported_Constants ISO7816 Exported Constants
94  * @{
95  */
96 
97 /** @defgroup ISO7816_LL_EC_ACTION Action state.
98  * @{
99  */
100 #define LL_ISO7816_ACTION_NONE 0x00000000U /**< Do Nothing. */
101 #define LL_ISO7816_ACTION_OFF 0x00000001U /**< Switch Off. */
102 #define LL_ISO7816_ACTION_STOPCLK 0x00000002U /**< Stop the clock. */
103 #define LL_ISO7816_ACTION_ON 0x00000003U /**< Switch on and receive ATR. */
104 #define LL_ISO7816_ACTION_WARMRST 0x00000004U /**< Trigger warm reset and receive ATR.*/
105 #define LL_ISO7816_ACTION_RX 0x00000005U /**< Receive. */
106 #define LL_ISO7816_ACTION_TX 0x00000006U /**< Transmit. */
107 #define LL_ISO7816_ACTION_TXRX 0x00000007U /**< Transmit, followed by RX. */
108 /** @} */
109 
110 /** @defgroup ISO7816_LL_EC_IT IT Defines
111  * @brief Interrupt definitions which can be used with LL_ISO7816_ReadReg and LL_ISO7816_WriteReg functions
112  * @{
113  */
114 #define LL_ISO7816_INTR_TEST ISO7816_STAT_IRQ_TEST /**< Test interrupt */
115 #define LL_ISO7816_INTR_PRESENCE ISO7816_STAT_IRQ_PRESENCE /**< Source presence interrupt */
116 #define LL_ISO7816_INTR_STATE_ERR ISO7816_STAT_IRQ_STAT_ERR /**< Source state error interrupt */
117 #define LL_ISO7816_INTR_DMA_ERR ISO7816_STAT_IRQ_DMA_ERR /**< Source dma error interrupt */
118 #define LL_ISO7816_INTR_RETRY_ERR ISO7816_STAT_IRQ_RETRY_ERR /**< Source retry error interrupt */
119 #define LL_ISO7816_INTR_RX_ERR ISO7816_STAT_IRQ_RX_ERR /**< Source rx error interrupt */
120 #define LL_ISO7816_INTR_DONE ISO7816_STAT_IRQ_DONE /**< Source done error interrupt */
121 
122 #define LL_ISO7816_INTR_MASK_ALL ISO7816_INTR_ALL /**< All interrupt */
123 /** @} */
124 
125 /** @defgroup ISO7816_LL_EC_PRESENCE Card Presence Defines
126  * @{
127  */
128 #define LL_ISO7816_CARD_ABSENT 0x00000000U /**< SIM Card is absent. */
129 #define LL_ISO7816_CARD_PRESENT 0x00000001U /**< SIM Card is present. */
130 /** @} */
131 
132 /** @defgroup ISO7816_LL_EC_IO_STATES IO States Defines
133  * @{
134  */
135 #define LL_ISO7816_IO_STATE_OFF (0x0UL << ISO7816_STAT_IO_STAT_POS) /**< Off */
136 #define LL_ISO7816_IO_STATE_IDLE (0x1UL << ISO7816_STAT_IO_STAT_POS) /**< Idle */
137 #define LL_ISO7816_IO_STATE_RX_WAIT (0x4UL << ISO7816_STAT_IO_STAT_POS) /**< Receive Wait */
138 #define LL_ISO7816_IO_STATE_RX (0x5UL << ISO7816_STAT_IO_STAT_POS) /**< Receive */
139 #define LL_ISO7816_IO_STATE_TX (0x6UL << ISO7816_STAT_IO_STAT_POS) /**< Transmit */
140 #define LL_ISO7816_IO_STATE_TX_GUARD (0x7UL << ISO7816_STAT_IO_STAT_POS) /**< Transmit Guard */
141 /** @} */
142 
143 /** @defgroup ISO7816_LL_EC_PWR_STATES Power States Defines
144  * @{
145  */
146 #define LL_ISO7816_PWR_STATE_OFF (0x0UL << ISO7816_STAT_PWR_STAT_POS) /**< Off */
147 #define LL_ISO7816_PWR_STATE_PWRUP_VCC (0x1UL << ISO7816_STAT_PWR_STAT_POS) /**< Power up VCC */
148 #define LL_ISO7816_PWR_STATE_PWRUP_RST (0x2UL << ISO7816_STAT_PWR_STAT_POS) /**< Power up reset */
149 #define LL_ISO7816_PWR_STATE_PWRDN_RST (0x3UL << ISO7816_STAT_PWR_STAT_POS) /**< Power Down reset */
150 #define LL_ISO7816_PWR_STATE_PWRDN_VCC (0x4UL << ISO7816_STAT_PWR_STAT_POS) /**< Power Down VCC */
151 #define LL_ISO7816_PWR_STATE_STOP_PRE (0x5UL << ISO7816_STAT_PWR_STAT_POS) /**< Preparing Clock Stop */
152 #define LL_ISO7816_PWR_STATE_STOP (0x6UL << ISO7816_STAT_PWR_STAT_POS) /**< Clock Stopped */
153 #define LL_ISO7816_PWR_STATE_STOP_POST (0x7UL << ISO7816_STAT_PWR_STAT_POS) /**< Exiting Clock Stop */
154 #define LL_ISO7816_PWR_STATE_IDLE (0x8UL << ISO7816_STAT_PWR_STAT_POS) /**< Idle */
155 #define LL_ISO7816_PWR_STATE_RX_TS0 (0x9UL << ISO7816_STAT_PWR_STAT_POS) /**< RX TS Character */
156 #define LL_ISO7816_PWR_STATE_RX_TS1 (0xAUL << ISO7816_STAT_PWR_STAT_POS) /**< RX TS Character */
157 #define LL_ISO7816_PWR_STATE_RX (0xBUL << ISO7816_STAT_PWR_STAT_POS) /**< Receive */
158 #define LL_ISO7816_PWR_STATE_TX (0xCUL << ISO7816_STAT_PWR_STAT_POS) /**< Transmit */
159 #define LL_ISO7816_PWR_STATE_TX_RX (0xDUL << ISO7816_STAT_PWR_STAT_POS) /**< Transmit and Receive */
160 /** @} */
161 
162 /** @defgroup ISO7816_LL_EC_CLKSTOP Clock Stop Select Defines
163  * @{
164  */
165 #define LL_ISO7816_CLKSTOP_LOW (0x00000000UL) /**< Stop the clock at low level. */
166 #define LL_ISO7816_CLKSTOP_HIGH (0x80000000UL) /**< Stop the clock at high level. */
167 /** @} */
168 
169 /** @defgroup ISO7816_LL_EC_CODING Coding Convention Defines
170  * @{
171  */
172 #define LL_ISO7816_CODING_DEFAULT (0x00000000UL) /**< High=1, LSB first. */
173 #define LL_ISO7816_CODING_INVERSE (0x00000001UL) /**< High=0, MSB first. */
174 /** @} */
175 
176 /** @} */
177 
178 /* Exported macro ------------------------------------------------------------*/
179 /** @defgroup ISO7816_LL_Exported_Macros ISO7816 Exported Macros
180  * @{
181  */
182 
183 /** @defgroup ISO7816_LL_EM_WRITE_READ Common Write and read registers Macros
184  * @{
185  */
186 
187 /**
188  * @brief Write a value in ISO7816 register
189  * @param __instance__ ISO7816 instance
190  * @param __REG__ Register to be written
191  * @param __VALUE__ Value to be written in the register
192  * @retval None.
193  */
194 #define LL_ISO7816_WriteReg(__instance__, __REG__, __VALUE__) WRITE_REG(__instance__->__REG__, (__VALUE__))
195 
196 /**
197  * @brief Read a value in ISO7816 register
198  * @param __instance__ ISO7816 instance
199  * @param __REG__ Register to be read
200  * @retval Register value
201  */
202 #define LL_ISO7816_ReadReg(__instance__, __REG__) READ_REG(__instance__->__REG__)
203 
204 /** @} */
205 
206 /** @} */
207 
208 /** @} */
209 
210 
211 /* Private types -------------------------------------------------------------*/
212 /* Private variables ---------------------------------------------------------*/
213 /* Private constants ---------------------------------------------------------*/
214 /* Private macros ------------------------------------------------------------*/
215 /* Exported functions --------------------------------------------------------*/
216 /** @defgroup ISO7816_LL_DRIVER_FUNCTIONS Functions
217  * @{
218  */
219 
220 /** @defgroup ISO7816_LL_EF_Configuration Configuration
221  * @{
222  */
223 /**
224  * @brief Request ISO7816 to go to the next action.
225  *
226  * Register|BitsName
227  * --------|--------
228  * CTRL | ACTION
229  *
230  * @param ISO7816x ISO7816 instance.
231  * @param action This parameter can be one of the following values:
232  * @arg @ref LL_ISO7816_ACTION_NONE
233  * @arg @ref LL_ISO7816_ACTION_OFF
234  * @arg @ref LL_ISO7816_ACTION_STOPCLK
235  * @arg @ref LL_ISO7816_ACTION_ON
236  * @arg @ref LL_ISO7816_ACTION_WARMRST
237  * @arg @ref LL_ISO7816_ACTION_RX
238  * @arg @ref LL_ISO7816_ACTION_TX
239  * @arg @ref LL_ISO7816_ACTION_TXRX
240  * @retval None.
241  */
242 __STATIC_INLINE void ll_iso7816_set_action(iso7816_regs_t *ISO7816x, uint32_t action)
243 {
244  WRITE_REG(ISO7816x->CTRL, action);
245 }
246 
247 /**
248  * @brief Get ISO7816 states.
249  *
250  * Register|BitsName
251  * --------|--------
252  * CTRL | ACTION
253  *
254  * @param ISO7816x ISO7816 instance.
255  * @retval ISO7816 states
256  */
257 __STATIC_INLINE uint32_t ll_iso7816_is_busy(iso7816_regs_t *ISO7816x)
258 {
259  return (READ_BITS(ISO7816x->STAT, ISO7816_STAT_BUSY) == (ISO7816_STAT_BUSY));
260 }
261 
262 /**
263  * @brief Clear Transmit Retries Maximum.
264  *
265  * Register|BitsName
266  * --------|--------
267  * CTRL | TX_RETRY_MAX_CLR
268  *
269  * @param ISO7816x ISO7816 instance.
270  * @retval None.
271  */
272 __STATIC_INLINE void ll_iso7816_clear_tx_retry_max(iso7816_regs_t *ISO7816x)
273 {
274  WRITE_REG(ISO7816x->CTRL, ISO7816_CTRL_TX_RETYR_MC);
275 }
276 
277 /**
278  * @brief Clear Receive Retries Maximum.
279  *
280  * Register|BitsName
281  * --------|--------
282  * CTRL | RX_RETRY_MAX_CLR
283  *
284  * @param ISO7816x ISO7816 instance.
285  * @retval None.
286  */
287 __STATIC_INLINE void ll_iso7816_clear_rx_retry_max(iso7816_regs_t *ISO7816x)
288 {
289  WRITE_REG(ISO7816x->CTRL, ISO7816_CTRL_RX_RETYR_MC);
290 }
291 
292 /**
293  * @brief Check Card presence.
294  *
295  * Register|BitsName
296  * --------|--------
297  * STAT | PRESENCE
298  *
299  * @param ISO7816x ISO7816 instance.
300  * @retval Returned value can be one of the following values:
301  * @arg @ref LL_ISO7816_CARD_ABSENT
302  * @arg @ref LL_ISO7816_CARD_PRESENT
303  */
304 __STATIC_INLINE uint32_t ll_iso7816_check_card_presence(iso7816_regs_t *ISO7816x)
305 {
306  return (uint32_t)(READ_BITS(ISO7816x->STAT, ISO7816_STAT_PRESENCE_STAT) >> ISO7816_STAT_PRESENCE_STAT_POS);
307 }
308 
309 /**
310  * @brief Get Maximum number of seen transmit retries after error signaling by ISO7816.
311  *
312  * Register|BitsName
313  * --------|--------
314  * STAT | TX_RETRY_MAX
315  *
316  * @param ISO7816x ISO7816 instance.
317  * @retval Value range between 0x1 and 0x7.
318  */
319 __STATIC_INLINE uint32_t ll_iso7816_get_tx_retry_max(iso7816_regs_t *ISO7816x)
320 {
321  return (uint32_t)(READ_BITS(ISO7816x->STAT, ISO7816_STAT_TX_RETRY_MAX) >> ISO7816_STAT_RX_RETRY_MAX_POS);
322 }
323 
324 /**
325  * @brief Get Maximum number of seen receive retries after error signaling by ISO7816.
326  *
327  * Register|BitsName
328  * --------|--------
329  * STAT | RX_RETRY_MAX
330  *
331  * @param ISO7816x ISO7816 instance.
332  * @retval Value range between 0x1 and 0x7.
333  */
334 __STATIC_INLINE uint32_t ll_iso7816_get_rx_retry_max(iso7816_regs_t *ISO7816x)
335 {
336  return (uint32_t)(READ_BITS(ISO7816x->STAT, ISO7816_STAT_RX_RETRY_MAX) >> ISO7816_STAT_RX_RETRY_MAX_POS);
337 }
338 
339 /**
340  * @brief Get ISO7816 IO States.
341  *
342  * Register|BitsName
343  * --------|--------
344  * STAT | IO_STATE
345  *
346  * @param ISO7816x ISO7816 instance.
347  * @retval Returned value can be one or combination of the following values:
348  * @arg @ref LL_ISO7816_IO_STATE_OFF
349  * @arg @ref LL_ISO7816_IO_STATE_IDLE
350  * @arg @ref LL_ISO7816_IO_STATE_RX_WAIT
351  * @arg @ref LL_ISO7816_IO_STATE_RX
352  * @arg @ref LL_ISO7816_IO_STATE_TX
353  * @arg @ref LL_ISO7816_IO_STATE_TX_GUARD
354  */
355 __STATIC_INLINE uint32_t ll_iso7816_get_io_states(iso7816_regs_t *ISO7816x)
356 {
357  return (uint32_t)(READ_BITS(ISO7816x->STAT, ISO7816_STAT_IO_STAT) >> ISO7816_STAT_IO_STAT_POS);
358 }
359 
360 /**
361  * @brief Get ISO7816 Power States.
362  *
363  * Register|BitsName
364  * --------|--------
365  * STAT | PWR_STATE
366  *
367  * @param ISO7816x ISO7816 instance.
368  * @retval Returned value can be one of the following values:
369  * @arg @ref LL_ISO7816_PWR_STATE_OFF
370  * @arg @ref LL_ISO7816_PWR_STATE_PWRUP_VCC
371  * @arg @ref LL_ISO7816_PWR_STATE_PWRUP_RST
372  * @arg @ref LL_ISO7816_PWR_STATE_PWRDN_RST
373  * @arg @ref LL_ISO7816_PWR_STATE_PWRDN_VCC
374  * @arg @ref LL_ISO7816_PWR_STATE_STOP_PRE
375  * @arg @ref LL_ISO7816_PWR_STATE_STOP
376  * @arg @ref LL_ISO7816_PWR_STATE_STOP_POST
377  * @arg @ref LL_ISO7816_PWR_STATE_IDLE
378  * @arg @ref LL_ISO7816_PWR_STATE_RX_TS0
379  * @arg @ref LL_ISO7816_PWR_STATE_RX_TS1
380  * @arg @ref LL_ISO7816_PWR_STATE_RX
381  * @arg @ref LL_ISO7816_PWR_STATE_TX
382  * @arg @ref LL_ISO7816_PWR_STATE_TX_RX
383  */
384 __STATIC_INLINE uint32_t ll_iso7816_get_power_states(iso7816_regs_t *ISO7816x)
385 {
386  return (uint32_t)(READ_BITS(ISO7816x->STAT, ISO7816_STAT_PWR_STAT));
387 }
388 
389 /**
390  * @brief Set value of the clock output during stopped Clock.
391  *
392  * Register|BitsName
393  * --------|--------
394  * CLK_CFG | CLK_STOP_SEL
395  *
396  * @param ISO7816x ISO7816 instance.
397  * @param level This parameter can be one of the following values:
398  * @arg @ref LL_ISO7816_CLKSTOP_LOW
399  * @arg @ref LL_ISO7816_CLKSTOP_HIGH
400  * @retval None.
401  */
402 __STATIC_INLINE void ll_iso7816_set_clkstop_level(iso7816_regs_t *ISO7816x, uint32_t level)
403 {
404  MODIFY_REG(ISO7816x->CLK_CFG, ISO7816_CLK_CFG_CLK_STOP_SEL, level);
405 }
406 
407 /**
408  * @brief Get value of the clock output during stopped Clock.
409  *
410  * Register|BitsName
411  * --------|--------
412  * CLK_CFG | CLK_STOP_SEL
413  *
414  * @param ISO7816x ISO7816 instance.
415  * @retval Returned value can be one of the following values:
416  * @arg @ref LL_ISO7816_CLKSTOP_LOW
417  * @arg @ref LL_ISO7816_CLKSTOP_HIGH
418  */
419 __STATIC_INLINE uint32_t ll_iso7816_get_clkstop_level(iso7816_regs_t *ISO7816x)
420 {
421  return (uint32_t)(READ_BITS(ISO7816x->CLK_CFG, ISO7816_CLK_CFG_CLK_STOP_SEL));
422 }
423 
424 /**
425  * @brief Set clock division.
426  * @note Divide system clock by this value+1.
427  *
428  * Register|BitsName
429  * --------|--------
430  * CLK_CFG | CLK_DIV
431  *
432  * @param ISO7816x ISO7816 instance
433  * @param value This parameter should range between 0x0 and 0xFF.
434  * @retval None.
435  */
436 __STATIC_INLINE void ll_iso7816_set_clkdiv(iso7816_regs_t *ISO7816x, uint32_t value)
437 {
438  MODIFY_REG(ISO7816x->CLK_CFG, ISO7816_CLK_CFG_CLK_DIV, value << ISO7816_CLK_CFG_CLK_DIV_POS);
439 }
440 
441 /**
442  * @brief Get clock division.
443  *
444  * Register|BitsName
445  * --------|--------
446  * CLK_CFG | CLK_DIV
447  *
448  * @param ISO7816x ISO7816 instance
449  * @retval Returned value should range between 0x0 and 0xFF.
450  */
451 __STATIC_INLINE uint32_t ll_iso7816_get_clkdiv(iso7816_regs_t *ISO7816x)
452 {
453  return (uint32_t)(READ_BITS(ISO7816x->CLK_CFG, ISO7816_CLK_CFG_CLK_DIV) >> ISO7816_CLK_CFG_CLK_DIV_POS);
454 }
455 
456 /**
457  * @brief Set divide ISO7816 clock.
458  * @note Divide SIM clock by this value+1 to define ETU length. The reset value
459  * is the one, needed for theATR.
460  *
461  * Register|BitsName
462  * --------|--------
463  * CLK_CFG | ETU_DIV
464  *
465  * @param ISO7816x ISO7816 instance
466  * @param divide This parameter should range between 0x0 and 0x3FF.
467  * @retval None.
468  */
469 __STATIC_INLINE void ll_iso7816_set_etudiv(iso7816_regs_t *ISO7816x, uint32_t divide)
470 {
471  MODIFY_REG(ISO7816x->CLK_CFG, ISO7816_CLK_CFG_ETU_DIV, divide);
472 }
473 
474 /**
475  * @brief Get divide ISO7816 clock.
476  *
477  * Register|BitsName
478  * --------|--------
479  * CLK_CFG | ETU_DIV
480  *
481  * @param ISO7816x ISO7816 instance
482  * @retval Returned value should range between 0x0 and 0x3FF.
483  */
484 __STATIC_INLINE uint32_t ll_iso7816_get_etudiv(iso7816_regs_t *ISO7816x)
485 {
486  return (uint32_t)(READ_BITS(ISO7816x->CLK_CFG, ISO7816_CLK_CFG_ETU_DIV));
487 }
488 
489 /**
490  * @brief Set ISO7816 wait_time in ETU.
491 
492  * @note Time between the leading edges of two consecutive characters
493  *
494  * Register|BitsName
495  * --------|--------
496  * TIMES | WAIT_TIME
497  *
498  * @param ISO7816x ISO7816 instance
499  * @param wait_time This parameter should range between 0x0 and 0x3FFF.
500  * @retval None.
501  */
502 __STATIC_INLINE void ll_iso7816_set_waittime(iso7816_regs_t *ISO7816x, uint32_t wait_time)
503 {
504  MODIFY_REG(ISO7816x->TIMES_CFG, ISO7816_TIMES_CFG_WAIT_TIME, wait_time << ISO7816_TIMES_CFG_WAIT_TIME_POS);
505 }
506 
507 /**
508  * @brief Get maximum card response time(leading edge to leading edge)
509  *
510  * Register|BitsName
511  * --------|--------
512  * TIMES | WAIT_TIME
513  *
514  * @param ISO7816x ISO7816 instance
515  * @retval Returned value should range between 0x0 and 0x3FFFF.
516  */
517 __STATIC_INLINE uint32_t ll_iso7816_get_waittime(iso7816_regs_t *ISO7816x)
518 {
519  return (uint32_t)(READ_BITS(ISO7816x->TIMES_CFG, ISO7816_TIMES_CFG_WAIT_TIME) >> ISO7816_TIMES_CFG_WAIT_TIME_POS);
520 }
521 
522 /**
523  * @brief Set ISO7816 guard_time in ETU.
524 
525  * @note Set time between the leading edges of two consecutive characters
526  *
527  * Register|BitsName
528  * --------|--------
529  * TIMES | GUARD_TIME
530  *
531  * @param ISO7816x ISO7816 instance
532  * @param guardtime Time between the leading edges of two consecutive characters
533  * @retval None.
534  */
535 __STATIC_INLINE void ll_iso7816_set_guardtime(iso7816_regs_t *ISO7816x, uint32_t guardtime)
536 {
537  MODIFY_REG(ISO7816x->TIMES_CFG, ISO7816_TIMES_CFG_GUARD_TIME, guardtime);
538 }
539 /**
540  * @brief Get time between the leading edges of two consecutive characters.
541  *
542  * Register|BitsName
543  * --------|--------
544  * TIMES | GUARDTIME
545  *
546  * @param ISO7816x ISO7816 instance
547  * @retval Returned value should range between 0x0 and 0x3FF.
548  */
549 __STATIC_INLINE uint32_t ll_iso7816_get_guardtime(iso7816_regs_t *ISO7816x)
550 {
551  return (uint32_t)(READ_BITS(ISO7816x->TIMES_CFG, ISO7816_TIMES_CFG_GUARD_TIME));
552 }
553 
554 /**
555  * @brief Set maximum number of issued retries before giving up.
556  *
557  * Register|BitsName
558  * --------|--------
559  * DATA_CFG| RETRY_LIMIT
560  *
561  * @param ISO7816x ISO7816 instance
562  * @param number This parameter should range between 0x0 and 0x7.
563  * @retval None.
564  */
565 __STATIC_INLINE void ll_iso7816_set_retry_limit(iso7816_regs_t *ISO7816x, uint32_t number)
566 {
567  MODIFY_REG(ISO7816x->DATA_CFG, ISO7816_DATA_CFG_RETRY_LIMIT, number << ISO7816_DATA_CFG_RETRY_LIMIT_POS);
568 }
569 
570 /**
571  * @brief Get maximum number of issued retries before giving up.
572  *
573  * Register|BitsName
574  * --------|--------
575  * DATA_CFG| RETRY_LIMIT
576  *
577  * @param ISO7816x ISO7816 instance
578  * @retval Returned value should range between 0x0 and 0x7.
579  */
580 __STATIC_INLINE uint32_t ll_iso7816_get_retry_limit(iso7816_regs_t *ISO7816x)
581 {
582  return (uint32_t)(READ_BITS(ISO7816x->DATA_CFG, ISO7816_DATA_CFG_RETRY_LIMIT) >> ISO7816_DATA_CFG_RETRY_LIMIT_POS);
583 }
584 
585 /**
586  * @brief Enable coding detection.
587  *
588  * Register|BitsName
589  * --------|--------
590  * DATA_CFG| DETECT_CODING
591  *
592  * @param ISO7816x ISO7816 instance.
593  * @retval None.
594  */
595 __STATIC_INLINE void ll_iso7816_enable_coding_detection(iso7816_regs_t *ISO7816x)
596 {
597  SET_BITS(ISO7816x->DATA_CFG, ISO7816_DATA_CFG_DETECT_CODING);
598 }
599 
600 /**
601  * @brief Disable coding detection.
602  *
603  * Register|BitsName
604  * --------|--------
605  * DATA_CFG| DETECT_CODING
606  *
607  * @param ISO7816x ISO7816 instance.
608  * @retval None.
609  */
610 __STATIC_INLINE void ll_iso7816_disable_coding_detection(iso7816_regs_t *ISO7816x)
611 {
612  CLEAR_BITS(ISO7816x->DATA_CFG, ISO7816_DATA_CFG_DETECT_CODING);
613 }
614 
615 /**
616  * @brief Set coding convention.
617  *
618  * Register|BitsName
619  * --------|--------
620  * DATA_CFG| CODING
621  *
622  * @param ISO7816x ISO7816 instance.
623  * @param convention This parameter can be one of the following values:
624  * @arg @ref LL_ISO7816_CODING_DEFAULT
625  * @arg @ref LL_ISO7816_CODING_INVERSE
626  * @retval None.
627  */
628 __STATIC_INLINE void ll_iso7816_set_coding_convention(iso7816_regs_t *ISO7816x, uint32_t convention)
629 {
630  MODIFY_REG(ISO7816x->DATA_CFG, ISO7816_DATA_CFG_CODING, convention);
631 }
632 
633 /**
634  * @brief Get coding convention.
635  *
636  * Register|BitsName
637  * --------|--------
638  * DATA_CFG| CODING
639  *
640  * @param ISO7816x ISO7816 instance
641  * @retval Returned value can be one of the following values:
642  * @arg @ref LL_ISO7816_CODING_DEFAULT
643  * @arg @ref LL_ISO7816_CODING_INVERSE
644  */
645 __STATIC_INLINE uint32_t ll_iso7816_get_coding_convention(iso7816_regs_t *ISO7816x)
646 {
647  return (uint32_t)(READ_BITS(ISO7816x->DATA_CFG, ISO7816_DATA_CFG_CODING));
648 }
649 
650 /**
651  * @brief Get current address relative to base_addr.
652  *
653  * Register|BitsName
654  * --------|--------
655  * ADDR | ADDR
656  *
657  * @param ISO7816x ISO7816 instance
658  * @retval Value between 0x0 and 0x3FFFF.
659  */
660 __STATIC_INLINE uint32_t ll_iso7816_get_current_addr(iso7816_regs_t *ISO7816x)
661 {
662  return (uint32_t)(READ_BITS(ISO7816x->ADDR, ISO7816_ADDR_ADDR) >> ISO7816_ADDR_ADDR_POS);
663 }
664 
665 /**
666  * @brief Get address fraction.
667  *
668  * Register|BitsName
669  * --------|--------
670  * ADDR | ADDR_FRAC
671  *
672  * @param ISO7816x ISO7816 instance
673  * @retval Value between 0x0 and 0x3.
674  */
675 __STATIC_INLINE uint32_t ll_iso7816_get_current_addr_frac(iso7816_regs_t *ISO7816x)
676 {
677  return (uint32_t)(READ_BITS(ISO7816x->ADDR, ISO7816_ADDR_ADDR_FRAC));
678 }
679 
680 /**
681  * @brief Set start address for RX and TX buffer.
682  *
683  * Register |BitsName
684  * ---------|--------
685  * STRT_ADDR| BASE_ADDR+START_ADDR
686  *
687  * @param ISO7816x ISO7816 instance
688  * @param addr This parameter should range between 0x0 and 0xFFFFFFFF.
689  * @retval None.
690  */
691 __STATIC_INLINE void ll_iso7816_set_buffer_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
692 {
693  WRITE_REG(ISO7816x->START_ADDR, addr);
694 }
695 
696 /**
697  * @brief Get start address for RX and TX buffer.
698  *
699  * Register |BitsName
700  * ---------|--------
701  * STRT_ADDR| BASE_ADDR+START_ADDR
702  *
703  * @param ISO7816x ISO7816 instance
704  * @retval Start address for RX and TX buffer.
705  */
706 __STATIC_INLINE uint32_t ll_iso7816_get_buffer_addr(iso7816_regs_t *ISO7816x)
707 {
708  return (uint32_t)(READ_REG(ISO7816x->START_ADDR));
709 }
710 
711 /**
712  * @brief Set base address for RX and TX buffer.
713  *
714  * Register |BitsName
715  * ---------|--------
716  * STRT_ADDR| BASE_ADDR
717  *
718  * @param ISO7816x ISO7816 instance
719  * @param addr This parameter should range between 0x0 and 0xFFF.
720  * @retval None.
721  */
722 __STATIC_INLINE void ll_iso7816_set_base_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
723 {
724  MODIFY_REG(ISO7816x->START_ADDR, ISO7816_START_ADDR_BASE_ADDR, addr << ISO7816_START_ADDR_BASE_ADDR_POS);
725 }
726 
727 /**
728  * @brief Get base address for RX and TX buffer.
729  *
730  * Register |BitsName
731  * ---------|--------
732  * STRT_ADDR| BASE_ADDR
733  *
734  * @param ISO7816x ISO7816 instance
735  * @retval Value between 0x0 and 0xFFF.
736  */
737 __STATIC_INLINE uint32_t ll_iso7816_get_base_addr(iso7816_regs_t *ISO7816x)
738 {
739  return (uint32_t)(READ_BITS(ISO7816x->START_ADDR, ISO7816_START_ADDR_BASE_ADDR) >> ISO7816_START_ADDR_BASE_ADDR_POS);
740 }
741 
742 /**
743  * @brief Set start address for RX and TX buffer, relative to base_addr.
744  *
745  * Register |BitsName
746  * ---------|--------
747  * STRT_ADDR| STRT_ADDR
748  *
749  * @param ISO7816x ISO7816 instance
750  * @param addr This parameter should range between 0x0 and 0x3FFFF.
751  * @retval None.
752  */
753 __STATIC_INLINE void ll_iso7816_set_start_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
754 {
755  MODIFY_REG(ISO7816x->START_ADDR, ISO7816_START_ADDR_START_ADDR, addr << ISO7816_START_ADDR_START_ADDR_POS);
756 }
757 
758 /**
759  * @brief Get start address for RX and TX buffer, relative to base_addr.
760  *
761  * Register |BitsName
762  * ---------|--------
763  * STRT_ADDR| STRT_ADDR
764  *
765  * @param ISO7816x ISO7816 instance
766  * @retval Value between 0x0 and 0x3FFFF.
767  */
768 __STATIC_INLINE uint32_t ll_iso7816_get_start_addr(iso7816_regs_t *ISO7816x)
769 {
770  return (uint32_t)(READ_BITS(ISO7816x->START_ADDR, ISO7816_START_ADDR_START_ADDR) >> ISO7816_START_ADDR_START_ADDR_POS);
771 }
772 
773 /**
774  * @brief Set end address of receive buffer, relative to base_addr.
775  *
776  * Register | BitsName
777  * -----------|--------
778  * RX_END_ADDR| RX_END_ADDR+
779  *
780  * @param ISO7816x ISO7816 instance
781  * @param addr This parameter should range between 0x0 and 0x3FFFF.
782  * @retval None.
783  */
784 __STATIC_INLINE void ll_iso7816_set_rx_end_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
785 {
786  MODIFY_REG(ISO7816x->RX_END_ADDR, ISO7816_RX_END_ADDR_RX_END_ADDR, addr << ISO7816_RX_END_ADDR_RX_END_ADDR_POS);
787 }
788 
789 /**
790  * @brief Set RX endbyte address of receive buffer, relative to base_addr.
791  *
792  * Register | BitsName
793  * -----------|--------
794  * RX_END_ADDR| RX_END_ADDR+RX_END_AF
795  *
796  * @param ISO7816x ISO7816 instance
797  * @param addr This parameter should range between 0x0 and 0x3FFFF.
798  * @retval None.
799  */
800 __STATIC_INLINE void ll_iso7816_set_rx_endbyte_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
801 {
802  WRITE_REG(ISO7816x->RX_END_ADDR, addr);
803 }
804 
805 /**
806  * @brief Get RX end address of receive buffer, relative to base_addr.
807  *
808  * Register | BitsName
809  * -----------|--------
810  * RX_END_ADDR| RX_END_ADDR
811  *
812  * @param ISO7816x ISO7816 instance
813  * @retval Value between 0x0 and 0x3FFFF.
814  */
815 __STATIC_INLINE uint32_t ll_iso7816_get_rx_end_addr(iso7816_regs_t *ISO7816x)
816 {
817  return (uint32_t)(READ_BITS(ISO7816x->RX_END_ADDR, ISO7816_RX_END_ADDR_RX_END_ADDR) >> ISO7816_RX_END_ADDR_RX_END_ADDR_POS);
818 }
819 
820 /**
821  * @brief Set RX end address fraction.
822  *
823  * Register | BitsName
824  * -----------|--------
825  * RX_END_ADDR| RX_END_AF
826  *
827  * @param ISO7816x ISO7816 instance
828  * @param frac This parameter should range between 0x0 and 0x3.
829  * @retval None.
830  */
831 __STATIC_INLINE void ll_iso7816_set_rx_end_addr_frac(iso7816_regs_t *ISO7816x, uint32_t frac)
832 {
833  MODIFY_REG(ISO7816x->RX_END_ADDR, ISO7816_RX_END_ADDR_RX_END_AF, frac);
834 }
835 
836 /**
837  * @brief Set TX endbyte address of buffer, relative to base_addr.
838  *
839  * Register | BitsName
840  * -----------|--------
841  * TX_END_ADDR| TX_END_ADDR+TX_END_AF
842  *
843  * @param ISO7816x ISO7816 instance
844  * @param addr This parameter should range between 0x0 and 0x3FFFF.
845  * @retval None.
846  */
847 __STATIC_INLINE void ll_iso7816_set_tx_endbyte_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
848 {
849  WRITE_REG(ISO7816x->TX_END_ADDR, addr);
850 }
851 
852 /**
853  * @brief Get TX endbyte address of buffer, relative to base_addr.
854  *
855  * Register | BitsName
856  * -----------|--------
857  * TX_END_ADDR| TX_END_ADDR+TX_END_AF
858  *
859  * @param ISO7816x ISO7816 instance
860  * @retval TX endbyte address.
861  */
862 __STATIC_INLINE uint32_t ll_iso7816_get_tx_endbyte_addr(iso7816_regs_t *ISO7816x)
863 {
864  return READ_REG(ISO7816x->TX_END_ADDR);
865 }
866 
867 /**
868  * @brief Get RX endbyte address of buffer, relative to base_addr.
869  *
870  * Register | BitsName
871  * -----------|--------
872  * TX_END_ADDR| TX_END_ADDR+TX_END_AF
873  *
874  * @param ISO7816x ISO7816 instance
875  * @retval RX endbyte address.
876  */
877 __STATIC_INLINE uint32_t ll_iso7816_get_rx_endbyte_addr(iso7816_regs_t *ISO7816x)
878 {
879  return READ_REG(ISO7816x->RX_END_ADDR);
880 }
881 
882 /**
883  * @brief Get RX end address fraction.
884  *
885  * Register | BitsName
886  * -----------|--------
887  * RX_END_ADDR| RX_END_AF
888  *
889  * @param ISO7816x ISO7816 instance
890  * @retval Value between 0x0 and 0x3.
891  */
892 __STATIC_INLINE uint32_t ll_iso7816_get_rx_end_addr_frac(iso7816_regs_t *ISO7816x)
893 {
894  return (uint32_t)(READ_BITS(ISO7816x->RX_END_ADDR, ISO7816_RX_END_ADDR_RX_END_AF));
895 }
896 
897 /**
898  * @brief Set end address of transmit buffer, relative to base_addr.
899  *
900  * Register | BitsName
901  * -----------|--------
902  * TX_END_ADDR| TX_END_ADDR
903  *
904  * @param ISO7816x ISO7816 instance
905  * @param addr This parameter should range between 0x0 and 0x3FFFF.
906  * @retval None.
907  */
908 __STATIC_INLINE void ll_iso7816_set_tx_end_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
909 {
910  MODIFY_REG(ISO7816x->TX_END_ADDR, ISO7816_TX_END_ADDR_TX_END_ADDR, addr << ISO7816_TX_END_ADDR_TX_END_ADDR_POS);
911 }
912 
913 /**
914  * @brief Get end address of transmit buffer, relative to base_addr.
915  *
916  * Register | BitsName
917  * -----------|--------
918  * TX_END_ADDR| TX_END_ADDR
919  *
920  * @param ISO7816x ISO7816 instance
921  * @retval Value between 0x0 and 0x3FFFF.
922  */
923 __STATIC_INLINE uint32_t ll_iso7816_get_tx_end_addr(iso7816_regs_t *ISO7816x)
924 {
925  return (uint32_t)(READ_BITS(ISO7816x->TX_END_ADDR, ISO7816_TX_END_ADDR_TX_END_ADDR) >> ISO7816_TX_END_ADDR_TX_END_ADDR_POS);
926 }
927 
928 /**
929  * @brief Set TX end address fraction.
930  *
931  * Register | BitsName
932  * -----------|--------
933  * TX_END_ADDR| TX_END_AF
934  *
935  * @param ISO7816x ISO7816 instance
936  * @param frac This parameter should range between 0x0 and 0x3.
937  * @retval None.
938  */
939 __STATIC_INLINE void ll_iso7816_set_tx_end_addr_frac(iso7816_regs_t *ISO7816x, uint32_t frac)
940 {
941  MODIFY_REG(ISO7816x->TX_END_ADDR, ISO7816_TX_END_ADDR_TX_END_AF, frac);
942 }
943 
944 /**
945  * @brief Get TX end address fraction.
946  *
947  * Register | BitsName
948  * -----------|--------
949  * TX_END_ADDR| TX_END_AF
950  *
951  * @param ISO7816x ISO7816 instance
952  * @retval Value between 0x0 and 0x3.
953  */
954 __STATIC_INLINE uint32_t ll_iso7816_get_tx_end_addr_frac(iso7816_regs_t *ISO7816x)
955 {
956  return (uint32_t)(READ_BITS(ISO7816x->TX_END_ADDR, ISO7816_TX_END_ADDR_TX_END_AF));
957 }
958 
959 /** @} */
960 
961 /** @defgroup ISO7816_LL_EF_IT_Management IT_Management
962  * @{
963  */
964 
965 /**
966  * @brief Get ISO7816 interrupt flags
967  *
968  * Register|BitsName
969  * --------|--------
970  * STAT | STAT_TEST
971  * STAT | STAT_PRESENCE
972  * STAT | STAT_STATE_ERR
973  * STAT | STAT_DMA_ERR
974  * STAT | STAT_RETRY_ERR
975  * STAT | STAT_RX_ERR
976  * STAT | STAT_DONE
977  *
978  * @param ISO7816x ISO7816 instance.
979  * @retval Returned value can be one or combination of the following values:
980  * @arg @ref LL_ISO7816_INTR_TEST
981  * @arg @ref LL_ISO7816_INTR_PRESENCE
982  * @arg @ref LL_ISO7816_INTR_STATE_ERR
983  * @arg @ref LL_ISO7816_INTR_DMA_ERR
984  * @arg @ref LL_ISO7816_INTR_RETRY_ERR
985  * @arg @ref LL_ISO7816_INTR_RX_ERR
986  * @arg @ref LL_ISO7816_INTR_DONE
987 */
988 __STATIC_INLINE uint32_t ll_iso7816_get_it_flag(iso7816_regs_t *ISO7816x)
989 {
990  return (uint32_t)(READ_REG(ISO7816x->STAT) & ISO7816_INTR_ALL);
991 }
992 
993 /**
994  * @brief Indicate the status of STAT_TEST flag.
995  *
996  * Register|BitsName
997  * --------|--------
998  * STAT | STAT_TEST
999  *
1000  * @param ISO7816x ISO7816 instance.
1001  * @retval State of bit (1 or 0).
1002  */
1003 __STATIC_INLINE uint32_t ll_iso7816_is_active_flag_test(iso7816_regs_t *ISO7816x)
1004 {
1005  return (READ_BITS(ISO7816x->STAT, ISO7816_STAT_IRQ_TEST) == (ISO7816_STAT_IRQ_TEST));
1006 }
1007 
1008 /**
1009  * @brief Indicate the status of STAT_PRESENCE flag.
1010  *
1011  * Register|BitsName
1012  * --------|--------
1013  * STAT | STAT_PRESENCE
1014  *
1015  * @param ISO7816x ISO7816 instance.
1016  * @retval State of bit (1 or 0).
1017  */
1018 __STATIC_INLINE uint32_t ll_iso7816_is_active_flag_presence(iso7816_regs_t *ISO7816x)
1019 {
1020  return (READ_BITS(ISO7816x->STAT, ISO7816_STAT_IRQ_PRESENCE) == (ISO7816_STAT_IRQ_PRESENCE));
1021 }
1022 
1023 /**
1024  * @brief Indicate the status of STAT_STATE_ERR flag.
1025  *
1026  * Register|BitsName
1027  * --------|--------
1028  * STAT | STAT_STATE_ERR
1029  *
1030  * @param ISO7816x ISO7816 instance.
1031  * @retval State of bit (1 or 0).
1032  */
1033 __STATIC_INLINE uint32_t ll_iso7816_is_active_flag_state_err(iso7816_regs_t *ISO7816x)
1034 {
1035  return (READ_BITS(ISO7816x->STAT, ISO7816_STAT_IRQ_STAT_ERR) == (ISO7816_STAT_IRQ_STAT_ERR));
1036 }
1037 
1038 /**
1039  * @brief Indicate the status of STAT_DMA_ERR flag.
1040  *
1041  * Register|BitsName
1042  * --------|--------
1043  * STAT | STAT_DMA_ERR
1044  *
1045  * @param ISO7816x ISO7816 instance.
1046  * @retval State of bit (1 or 0).
1047  */
1048 __STATIC_INLINE uint32_t ll_iso7816_is_active_flag_dma_err(iso7816_regs_t *ISO7816x)
1049 {
1050  return (READ_BITS(ISO7816x->STAT, ISO7816_STAT_IRQ_DMA_ERR) == (ISO7816_STAT_IRQ_DMA_ERR));
1051 }
1052 
1053 /**
1054  * @brief Indicate the status of STAT_RETRY_ERR flag.
1055  *
1056  * Register|BitsName
1057  * --------|--------
1058  * STAT | STAT_RETRY_ERR
1059  *
1060  * @param ISO7816x ISO7816 instance.
1061  * @retval State of bit (1 or 0).
1062  */
1063 __STATIC_INLINE uint32_t ll_iso7816_is_active_flag_retry_err(iso7816_regs_t *ISO7816x)
1064 {
1065  return (READ_BITS(ISO7816x->STAT, ISO7816_STAT_IRQ_RETRY_ERR) == (ISO7816_STAT_IRQ_RETRY_ERR));
1066 }
1067 
1068 /**
1069  * @brief Indicate the status of STAT_RX_ERR flag.
1070  *
1071  * Register|BitsName
1072  * --------|--------
1073  * STAT | STAT_RX_ERR
1074  *
1075  * @param ISO7816x ISO7816 instance.
1076  * @retval State of bit (1 or 0).
1077  */
1078 __STATIC_INLINE uint32_t ll_iso7816_is_active_flag_rx_err(iso7816_regs_t *ISO7816x)
1079 {
1080  return (READ_BITS(ISO7816x->STAT, ISO7816_STAT_IRQ_RX_ERR) == (ISO7816_STAT_IRQ_RX_ERR));
1081 }
1082 
1083 /**
1084  * @brief Indicate the status of STAT_DONE flag.
1085  *
1086  * Register|BitsName
1087  * --------|--------
1088  * STAT | STAT_DONE
1089  *
1090  * @param ISO7816x ISO7816 instance.
1091  * @retval State of bit (1 or 0).
1092  */
1093 __STATIC_INLINE uint32_t ll_iso7816_is_active_flag_done(iso7816_regs_t *ISO7816x)
1094 {
1095  return (READ_BITS(ISO7816x->STAT, ISO7816_STAT_IRQ_DONE) == (ISO7816_STAT_IRQ_DONE));
1096 }
1097 
1098 /**
1099  * @brief Clear the combined interrupt, all individual interrupts, and the STAT register
1100  *
1101  * Register|BitsName
1102  * --------|--------
1103  * STAT | STAT_TEST
1104  * STAT | STAT_PRESENCE
1105  * STAT | STAT_STATE_ERR
1106  * STAT | STAT_DMA_ERR
1107  * STAT | STAT_RETRY_ERR
1108  * STAT | STAT_RX_ERR
1109  * STAT | STAT_DONE
1110  *
1111  * @param ISO7816x ISO7816 instance.
1112  * @retval None.
1113  */
1114 __STATIC_INLINE void ll_iso7816_clear_flag_all_intr(iso7816_regs_t *ISO7816x)
1115 {
1116  WRITE_REG(ISO7816x->CTRL, ISO7816_INTR_ALL);
1117 }
1118 
1119 /**
1120  * @brief Clear test flag.
1121  *
1122  * Register|BitsName
1123  * --------|--------
1124  * CTRL | CTRL_TEST
1125  *
1126  * @param ISO7816x ISO7816 instance.
1127  * @retval None.
1128  */
1129 __STATIC_INLINE void ll_iso7816_clear_flag_test(iso7816_regs_t *ISO7816x)
1130 {
1131  WRITE_REG(ISO7816x->CTRL, ISO7816_CTRL_IRQ_TEST_CLR);
1132 }
1133 
1134 /**
1135  * @brief Clear presence flag.
1136  *
1137  * Register|BitsName
1138  * --------|--------
1139  * CTRL | CTRL_PRESENCE
1140  *
1141  * @param ISO7816x ISO7816 instance.
1142  * @retval None.
1143  */
1144 __STATIC_INLINE void ll_iso7816_clear_flag_presence(iso7816_regs_t *ISO7816x)
1145 {
1146  WRITE_REG(ISO7816x->CTRL, ISO7816_CTRL_IRQ_PRESENCE_CLR);
1147 }
1148 
1149 /**
1150  * @brief Clear state error flag.
1151  *
1152  * Register|BitsName
1153  * --------|--------
1154  * CTRL | CTRL_STATE_ERR
1155  *
1156  * @param ISO7816x ISO7816 instance.
1157  * @retval None.
1158  */
1159 __STATIC_INLINE void ll_iso7816_clear_flag_state_err(iso7816_regs_t *ISO7816x)
1160 {
1161  WRITE_REG(ISO7816x->CTRL, ISO7816_CTRL_IRQ_STAT_EC);
1162 }
1163 
1164 /**
1165  * @brief Clear dma error flag.
1166  *
1167  * Register|BitsName
1168  * --------|--------
1169  * CTRL | CTRL_DMA_ERR
1170  *
1171  * @param ISO7816x ISO7816 instance.
1172  * @retval None.
1173  */
1174 __STATIC_INLINE void ll_iso7816_clear_flag_dma_err(iso7816_regs_t *ISO7816x)
1175 {
1176  WRITE_REG(ISO7816x->CTRL, ISO7816_CTRL_IRQ_DMA_EC);
1177 }
1178 
1179 /**
1180  * @brief Clear retry error flag.
1181  *
1182  * Register|BitsName
1183  * --------|--------
1184  * CTRL | CTRL_RETRY_ERR
1185  *
1186  * @param ISO7816x ISO7816 instance.
1187  * @retval None.
1188  */
1189 __STATIC_INLINE void ll_iso7816_clear_flag_retry_err(iso7816_regs_t *ISO7816x)
1190 {
1191  WRITE_REG(ISO7816x->CTRL, ISO7816_CTRL_IRQ_RETYR_EC);
1192 }
1193 
1194 /**
1195  * @brief Clear RX error flag.
1196  *
1197  * Register|BitsName
1198  * --------|--------
1199  * CTRL | CTRL_RX_ERR
1200  *
1201  * @param ISO7816x ISO7816 instance.
1202  * @retval None.
1203  */
1204 __STATIC_INLINE void ll_iso7816_clear_flag_rx_err(iso7816_regs_t *ISO7816x)
1205 {
1206  WRITE_REG(ISO7816x->CTRL, ISO7816_CTRL_IRQ_RX_EC);
1207 }
1208 
1209 /**
1210  * @brief Clear done flag.
1211  *
1212  * Register|BitsName
1213  * --------|--------
1214  * CTRL | CTRL_DONE
1215  *
1216  * @param ISO7816x ISO7816 instance.
1217  * @retval None.
1218  */
1219 __STATIC_INLINE void ll_iso7816_clear_flag_done(iso7816_regs_t *ISO7816x)
1220 {
1221  WRITE_REG(ISO7816x->CTRL, ISO7816_CTRL_IRQ_DONE_CLR);
1222 }
1223 
1224 /** @} */
1225 
1226 
1227 /** @defgroup ISO7816_LL_Init ISO7816 Initialization and de-initialization functions
1228  * @{
1229  */
1230 
1231 /**
1232  * @brief Initialize the ISO7816 registers according to the specified parameters in p_iso7816_init.
1233  * @param ISO7816x ISO7816 instance.
1234  * @param p_iso7816_init pointer to a @ref ll_iso7816_init_t structure.
1235  * @retval An ErrorStatus enumeration value:
1236  * - SUCCESS: ISO7816 registers are initialized
1237  * - ERROR: Not applicable
1238  */
1239 error_status_t ll_iso7816_init(iso7816_regs_t *ISO7816x, ll_iso7816_init_t *p_iso7816_init);
1240 
1241 /**
1242  * @brief De-initialize the ISO7816 registers to their default reset values.
1243  * @param ISO7816x ISO7816 instance.
1244  * @retval An ErrorStatus enumeration value:
1245  * - SUCCESS: ISO7816 registers are de-initialized
1246  * - ERROR: ISO7816 registers are not de-initialized
1247  */
1248 error_status_t ll_iso7816_deinit(iso7816_regs_t *ISO7816x);
1249 
1250 /** @} */
1251 /** @} */
1252 
1253 #endif /* ISO7816 */
1254 
1255 #ifdef __cplusplus
1256 }
1257 #endif
1258 
1259 #endif /* __GR55xx_LL_ISO7816_H__ */
1260 
1261 /** @} */
1262 
1263 /** @} */
1264 
1265 /** @} */
1266 
ll_iso7816_get_tx_retry_max
__STATIC_INLINE uint32_t ll_iso7816_get_tx_retry_max(iso7816_regs_t *ISO7816x)
Get Maximum number of seen transmit retries after error signaling by ISO7816.
Definition: gr55xx_ll_iso7816.h:319
ll_iso7816_get_it_flag
__STATIC_INLINE uint32_t ll_iso7816_get_it_flag(iso7816_regs_t *ISO7816x)
Get ISO7816 interrupt flags.
Definition: gr55xx_ll_iso7816.h:988
_ll_iso7816_init::detect_coding
uint8_t detect_coding
Definition: gr55xx_ll_iso7816.h:80
ll_iso7816_clear_flag_all_intr
__STATIC_INLINE void ll_iso7816_clear_flag_all_intr(iso7816_regs_t *ISO7816x)
Clear the combined interrupt, all individual interrupts, and the STAT register.
Definition: gr55xx_ll_iso7816.h:1114
ll_iso7816_get_tx_endbyte_addr
__STATIC_INLINE uint32_t ll_iso7816_get_tx_endbyte_addr(iso7816_regs_t *ISO7816x)
Get TX endbyte address of buffer, relative to base_addr.
Definition: gr55xx_ll_iso7816.h:862
ll_iso7816_get_current_addr_frac
__STATIC_INLINE uint32_t ll_iso7816_get_current_addr_frac(iso7816_regs_t *ISO7816x)
Get address fraction.
Definition: gr55xx_ll_iso7816.h:675
ll_iso7816_clear_flag_retry_err
__STATIC_INLINE void ll_iso7816_clear_flag_retry_err(iso7816_regs_t *ISO7816x)
Clear retry error flag.
Definition: gr55xx_ll_iso7816.h:1189
ll_iso7816_is_active_flag_retry_err
__STATIC_INLINE uint32_t ll_iso7816_is_active_flag_retry_err(iso7816_regs_t *ISO7816x)
Indicate the status of STAT_RETRY_ERR flag.
Definition: gr55xx_ll_iso7816.h:1063
ll_iso7816_set_tx_end_addr
__STATIC_INLINE void ll_iso7816_set_tx_end_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
Set end address of transmit buffer, relative to base_addr.
Definition: gr55xx_ll_iso7816.h:908
_ll_iso7816_init
LL ISO7816 init Structure definition.
Definition: gr55xx_ll_iso7816.h:75
ll_iso7816_is_active_flag_state_err
__STATIC_INLINE uint32_t ll_iso7816_is_active_flag_state_err(iso7816_regs_t *ISO7816x)
Indicate the status of STAT_STATE_ERR flag.
Definition: gr55xx_ll_iso7816.h:1033
ll_iso7816_set_coding_convention
__STATIC_INLINE void ll_iso7816_set_coding_convention(iso7816_regs_t *ISO7816x, uint32_t convention)
Set coding convention.
Definition: gr55xx_ll_iso7816.h:628
ll_iso7816_get_start_addr
__STATIC_INLINE uint32_t ll_iso7816_get_start_addr(iso7816_regs_t *ISO7816x)
Get start address for RX and TX buffer, relative to base_addr.
Definition: gr55xx_ll_iso7816.h:768
ll_iso7816_get_buffer_addr
__STATIC_INLINE uint32_t ll_iso7816_get_buffer_addr(iso7816_regs_t *ISO7816x)
Get start address for RX and TX buffer.
Definition: gr55xx_ll_iso7816.h:706
ll_iso7816_get_coding_convention
__STATIC_INLINE uint32_t ll_iso7816_get_coding_convention(iso7816_regs_t *ISO7816x)
Get coding convention.
Definition: gr55xx_ll_iso7816.h:645
ll_iso7816_clear_flag_rx_err
__STATIC_INLINE void ll_iso7816_clear_flag_rx_err(iso7816_regs_t *ISO7816x)
Clear RX error flag.
Definition: gr55xx_ll_iso7816.h:1204
ll_iso7816_set_action
__STATIC_INLINE void ll_iso7816_set_action(iso7816_regs_t *ISO7816x, uint32_t action)
Request ISO7816 to go to the next action.
Definition: gr55xx_ll_iso7816.h:242
ll_iso7816_get_rx_end_addr_frac
__STATIC_INLINE uint32_t ll_iso7816_get_rx_end_addr_frac(iso7816_regs_t *ISO7816x)
Get RX end address fraction.
Definition: gr55xx_ll_iso7816.h:892
ll_iso7816_get_guardtime
__STATIC_INLINE uint32_t ll_iso7816_get_guardtime(iso7816_regs_t *ISO7816x)
Get time between the leading edges of two consecutive characters.
Definition: gr55xx_ll_iso7816.h:549
ll_iso7816_set_base_addr
__STATIC_INLINE void ll_iso7816_set_base_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
Set base address for RX and TX buffer.
Definition: gr55xx_ll_iso7816.h:722
ll_iso7816_get_waittime
__STATIC_INLINE uint32_t ll_iso7816_get_waittime(iso7816_regs_t *ISO7816x)
Get maximum card response time(leading edge to leading edge)
Definition: gr55xx_ll_iso7816.h:517
ll_iso7816_get_tx_end_addr_frac
__STATIC_INLINE uint32_t ll_iso7816_get_tx_end_addr_frac(iso7816_regs_t *ISO7816x)
Get TX end address fraction.
Definition: gr55xx_ll_iso7816.h:954
ll_iso7816_is_active_flag_presence
__STATIC_INLINE uint32_t ll_iso7816_is_active_flag_presence(iso7816_regs_t *ISO7816x)
Indicate the status of STAT_PRESENCE flag.
Definition: gr55xx_ll_iso7816.h:1018
ll_iso7816_get_tx_end_addr
__STATIC_INLINE uint32_t ll_iso7816_get_tx_end_addr(iso7816_regs_t *ISO7816x)
Get end address of transmit buffer, relative to base_addr.
Definition: gr55xx_ll_iso7816.h:923
ll_iso7816_set_rx_endbyte_addr
__STATIC_INLINE void ll_iso7816_set_rx_endbyte_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
Set RX endbyte address of receive buffer, relative to base_addr.
Definition: gr55xx_ll_iso7816.h:800
_ll_iso7816_init::clk_div
uint32_t clk_div
Definition: gr55xx_ll_iso7816.h:76
ll_iso7816_clear_rx_retry_max
__STATIC_INLINE void ll_iso7816_clear_rx_retry_max(iso7816_regs_t *ISO7816x)
Clear Receive Retries Maximum.
Definition: gr55xx_ll_iso7816.h:287
ll_iso7816_is_active_flag_dma_err
__STATIC_INLINE uint32_t ll_iso7816_is_active_flag_dma_err(iso7816_regs_t *ISO7816x)
Indicate the status of STAT_DMA_ERR flag.
Definition: gr55xx_ll_iso7816.h:1048
ll_iso7816_deinit
error_status_t ll_iso7816_deinit(iso7816_regs_t *ISO7816x)
De-initialize the ISO7816 registers to their default reset values.
ll_iso7816_get_etudiv
__STATIC_INLINE uint32_t ll_iso7816_get_etudiv(iso7816_regs_t *ISO7816x)
Get divide ISO7816 clock.
Definition: gr55xx_ll_iso7816.h:484
ll_iso7816_is_busy
__STATIC_INLINE uint32_t ll_iso7816_is_busy(iso7816_regs_t *ISO7816x)
Get ISO7816 states.
Definition: gr55xx_ll_iso7816.h:257
ll_iso7816_set_rx_end_addr_frac
__STATIC_INLINE void ll_iso7816_set_rx_end_addr_frac(iso7816_regs_t *ISO7816x, uint32_t frac)
Set RX end address fraction.
Definition: gr55xx_ll_iso7816.h:831
ll_iso7816_set_rx_end_addr
__STATIC_INLINE void ll_iso7816_set_rx_end_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
Set end address of receive buffer, relative to base_addr.
Definition: gr55xx_ll_iso7816.h:784
ll_iso7816_set_tx_end_addr_frac
__STATIC_INLINE void ll_iso7816_set_tx_end_addr_frac(iso7816_regs_t *ISO7816x, uint32_t frac)
Set TX end address fraction.
Definition: gr55xx_ll_iso7816.h:939
ll_iso7816_get_base_addr
__STATIC_INLINE uint32_t ll_iso7816_get_base_addr(iso7816_regs_t *ISO7816x)
Get base address for RX and TX buffer.
Definition: gr55xx_ll_iso7816.h:737
ll_iso7816_set_waittime
__STATIC_INLINE void ll_iso7816_set_waittime(iso7816_regs_t *ISO7816x, uint32_t wait_time)
Set ISO7816 wait_time in ETU.
Definition: gr55xx_ll_iso7816.h:502
ll_iso7816_get_power_states
__STATIC_INLINE uint32_t ll_iso7816_get_power_states(iso7816_regs_t *ISO7816x)
Get ISO7816 Power States.
Definition: gr55xx_ll_iso7816.h:384
_ll_iso7816_init::guard_time
uint16_t guard_time
Definition: gr55xx_ll_iso7816.h:79
ll_iso7816_clear_flag_test
__STATIC_INLINE void ll_iso7816_clear_flag_test(iso7816_regs_t *ISO7816x)
Clear test flag.
Definition: gr55xx_ll_iso7816.h:1129
ll_iso7816_get_current_addr
__STATIC_INLINE uint32_t ll_iso7816_get_current_addr(iso7816_regs_t *ISO7816x)
Get current address relative to base_addr.
Definition: gr55xx_ll_iso7816.h:660
ll_iso7816_set_tx_endbyte_addr
__STATIC_INLINE void ll_iso7816_set_tx_endbyte_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
Set TX endbyte address of buffer, relative to base_addr.
Definition: gr55xx_ll_iso7816.h:847
ll_iso7816_set_guardtime
__STATIC_INLINE void ll_iso7816_set_guardtime(iso7816_regs_t *ISO7816x, uint32_t guardtime)
Set ISO7816 guard_time in ETU.
Definition: gr55xx_ll_iso7816.h:535
ll_iso7816_clear_flag_state_err
__STATIC_INLINE void ll_iso7816_clear_flag_state_err(iso7816_regs_t *ISO7816x)
Clear state error flag.
Definition: gr55xx_ll_iso7816.h:1159
ll_iso7816_set_retry_limit
__STATIC_INLINE void ll_iso7816_set_retry_limit(iso7816_regs_t *ISO7816x, uint32_t number)
Set maximum number of issued retries before giving up.
Definition: gr55xx_ll_iso7816.h:565
ll_iso7816_get_rx_endbyte_addr
__STATIC_INLINE uint32_t ll_iso7816_get_rx_endbyte_addr(iso7816_regs_t *ISO7816x)
Get RX endbyte address of buffer, relative to base_addr.
Definition: gr55xx_ll_iso7816.h:877
ll_iso7816_init
error_status_t ll_iso7816_init(iso7816_regs_t *ISO7816x, ll_iso7816_init_t *p_iso7816_init)
Initialize the ISO7816 registers according to the specified parameters in p_iso7816_init.
ll_iso7816_init_t
struct _ll_iso7816_init ll_iso7816_init_t
LL ISO7816 init Structure definition.
ll_iso7816_clear_flag_presence
__STATIC_INLINE void ll_iso7816_clear_flag_presence(iso7816_regs_t *ISO7816x)
Clear presence flag.
Definition: gr55xx_ll_iso7816.h:1144
ll_iso7816_enable_coding_detection
__STATIC_INLINE void ll_iso7816_enable_coding_detection(iso7816_regs_t *ISO7816x)
Enable coding detection.
Definition: gr55xx_ll_iso7816.h:595
_ll_iso7816_init::wait_time
uint32_t wait_time
Definition: gr55xx_ll_iso7816.h:78
ll_iso7816_set_start_addr
__STATIC_INLINE void ll_iso7816_set_start_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
Set start address for RX and TX buffer, relative to base_addr.
Definition: gr55xx_ll_iso7816.h:753
ll_iso7816_get_io_states
__STATIC_INLINE uint32_t ll_iso7816_get_io_states(iso7816_regs_t *ISO7816x)
Get ISO7816 IO States.
Definition: gr55xx_ll_iso7816.h:355
ll_iso7816_is_active_flag_rx_err
__STATIC_INLINE uint32_t ll_iso7816_is_active_flag_rx_err(iso7816_regs_t *ISO7816x)
Indicate the status of STAT_RX_ERR flag.
Definition: gr55xx_ll_iso7816.h:1078
ll_iso7816_get_clkdiv
__STATIC_INLINE uint32_t ll_iso7816_get_clkdiv(iso7816_regs_t *ISO7816x)
Get clock division.
Definition: gr55xx_ll_iso7816.h:451
ll_iso7816_check_card_presence
__STATIC_INLINE uint32_t ll_iso7816_check_card_presence(iso7816_regs_t *ISO7816x)
Check Card presence.
Definition: gr55xx_ll_iso7816.h:304
ll_iso7816_set_buffer_addr
__STATIC_INLINE void ll_iso7816_set_buffer_addr(iso7816_regs_t *ISO7816x, uint32_t addr)
Set start address for RX and TX buffer.
Definition: gr55xx_ll_iso7816.h:691
ll_iso7816_clear_flag_done
__STATIC_INLINE void ll_iso7816_clear_flag_done(iso7816_regs_t *ISO7816x)
Clear done flag.
Definition: gr55xx_ll_iso7816.h:1219
ll_iso7816_disable_coding_detection
__STATIC_INLINE void ll_iso7816_disable_coding_detection(iso7816_regs_t *ISO7816x)
Disable coding detection.
Definition: gr55xx_ll_iso7816.h:610
ll_iso7816_clear_flag_dma_err
__STATIC_INLINE void ll_iso7816_clear_flag_dma_err(iso7816_regs_t *ISO7816x)
Clear dma error flag.
Definition: gr55xx_ll_iso7816.h:1174
ll_iso7816_set_clkstop_level
__STATIC_INLINE void ll_iso7816_set_clkstop_level(iso7816_regs_t *ISO7816x, uint32_t level)
Set value of the clock output during stopped Clock.
Definition: gr55xx_ll_iso7816.h:402
ll_iso7816_get_rx_retry_max
__STATIC_INLINE uint32_t ll_iso7816_get_rx_retry_max(iso7816_regs_t *ISO7816x)
Get Maximum number of seen receive retries after error signaling by ISO7816.
Definition: gr55xx_ll_iso7816.h:334
ll_iso7816_is_active_flag_done
__STATIC_INLINE uint32_t ll_iso7816_is_active_flag_done(iso7816_regs_t *ISO7816x)
Indicate the status of STAT_DONE flag.
Definition: gr55xx_ll_iso7816.h:1093
ll_iso7816_set_clkdiv
__STATIC_INLINE void ll_iso7816_set_clkdiv(iso7816_regs_t *ISO7816x, uint32_t value)
Set clock division.
Definition: gr55xx_ll_iso7816.h:436
ll_iso7816_get_retry_limit
__STATIC_INLINE uint32_t ll_iso7816_get_retry_limit(iso7816_regs_t *ISO7816x)
Get maximum number of issued retries before giving up.
Definition: gr55xx_ll_iso7816.h:580
ll_iso7816_is_active_flag_test
__STATIC_INLINE uint32_t ll_iso7816_is_active_flag_test(iso7816_regs_t *ISO7816x)
Indicate the status of STAT_TEST flag.
Definition: gr55xx_ll_iso7816.h:1003
ll_iso7816_get_clkstop_level
__STATIC_INLINE uint32_t ll_iso7816_get_clkstop_level(iso7816_regs_t *ISO7816x)
Get value of the clock output during stopped Clock.
Definition: gr55xx_ll_iso7816.h:419
ll_iso7816_clear_tx_retry_max
__STATIC_INLINE void ll_iso7816_clear_tx_retry_max(iso7816_regs_t *ISO7816x)
Clear Transmit Retries Maximum.
Definition: gr55xx_ll_iso7816.h:272
ll_iso7816_set_etudiv
__STATIC_INLINE void ll_iso7816_set_etudiv(iso7816_regs_t *ISO7816x, uint32_t divide)
Set divide ISO7816 clock.
Definition: gr55xx_ll_iso7816.h:469
ll_iso7816_get_rx_end_addr
__STATIC_INLINE uint32_t ll_iso7816_get_rx_end_addr(iso7816_regs_t *ISO7816x)
Get RX end address of receive buffer, relative to base_addr.
Definition: gr55xx_ll_iso7816.h:815