blob: 662a280b551dbdd6c2863b7bd0410ca70c7189ca [file] [log] [blame]
Christina Quast53b21052014-12-09 15:34:35 +01001/* ----------------------------------------------------------------------------
2 * ATMEL Microcontroller Software Support
3 * ----------------------------------------------------------------------------
4 * Copyright (c) 2009, Atmel Corporation
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * - Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the disclaimer below.
13 *
14 * Atmel's name may not be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * ----------------------------------------------------------------------------
28 */
Christina Quast3eab56e2015-04-10 15:38:49 +020029#include <stdbool.h>
Christina Quast53b21052014-12-09 15:34:35 +010030//------------------------------------------------------------------------------
31/** \file
32 *
33 * \section Purpose
34 *
35 * Definition of methods for ISO7816 driver.
36 *
37 * \section Usage
38 *
39 * -# ISO7816_Init
40 * -# ISO7816_IccPowerOff
41 * -# ISO7816_XfrBlockTPDU_T0
42 * -# ISO7816_Escape
43 * -# ISO7816_RestartClock
44 * -# ISO7816_StopClock
45 * -# ISO7816_toAPDU
46 * -# ISO7816_Datablock_ATR
47 * -# ISO7816_SetDataRateandClockFrequency
48 * -# ISO7816_StatusReset
49 * -# ISO7816_cold_reset
50 * -# ISO7816_warm_reset
51 * -# ISO7816_Decode_ATR
52 *----------------------------------------------------------------------------*/
53
54#ifndef ISO7816_4_H
55#define ISO7816_4_H
56
57/*------------------------------------------------------------------------------
58 * Constants Definition
59 *----------------------------------------------------------------------------*/
60
61/** Size max of Answer To Reset */
62#define ATR_SIZE_MAX 55
63
64/** NULL byte to restart byte procedure */
65#define ISO_NULL_VAL 0x60
66
67/*------------------------------------------------------------------------------
68 * Exported functions
69 *----------------------------------------------------------------------------*/
Christina Quast3eab56e2015-04-10 15:38:49 +020070extern void ISO7816_Init( const Pin *pPinIso7816RstMC, Usart *base_usart, bool master_clock );
Christina Quast53b21052014-12-09 15:34:35 +010071extern void ISO7816_IccPowerOff(void);
Christina Quast73c2b642015-04-07 13:49:26 +020072extern uint32_t ISO7816_XfrBlockTPDU_T0(const uint8_t *pAPDU,
Christina Quast53b21052014-12-09 15:34:35 +010073 uint8_t *pMessage,
Christina Quast73c2b642015-04-07 13:49:26 +020074 uint16_t wLength,
75 uint16_t *retlen);
Christina Quast53b21052014-12-09 15:34:35 +010076extern void ISO7816_Escape( void );
77extern void ISO7816_RestartClock(void);
78extern void ISO7816_StopClock( void );
79extern void ISO7816_toAPDU( void );
Christina Quast8d0f4a62015-01-15 14:53:38 +010080extern uint32_t ISO7816_Datablock_ATR( uint8_t* pAtr, uint8_t* pLength );
Christina Quast53b21052014-12-09 15:34:35 +010081extern void ISO7816_SetDataRateandClockFrequency( uint32_t dwClockFrequency, uint32_t dwDataRate );
82extern uint8_t ISO7816_StatusReset( void );
83extern void ISO7816_cold_reset( void );
84extern void ISO7816_warm_reset( void );
85extern void ISO7816_Decode_ATR( uint8_t* pAtr );
86
87#endif /* ISO7816_4_H */
88