blob: 7c371b224097797525f153a9ab9e484e20a1ca97 [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 Quaste24b9ac2015-04-10 17:44:49 +020030#include "board.h"
31
Christina Quast53b21052014-12-09 15:34:35 +010032//------------------------------------------------------------------------------
33/** \file
34 *
35 * \section Purpose
36 *
37 * Definition of methods for ISO7816 driver.
38 *
39 * \section Usage
40 *
41 * -# ISO7816_Init
42 * -# ISO7816_IccPowerOff
43 * -# ISO7816_XfrBlockTPDU_T0
44 * -# ISO7816_Escape
45 * -# ISO7816_RestartClock
46 * -# ISO7816_StopClock
47 * -# ISO7816_toAPDU
48 * -# ISO7816_Datablock_ATR
49 * -# ISO7816_SetDataRateandClockFrequency
50 * -# ISO7816_StatusReset
51 * -# ISO7816_cold_reset
52 * -# ISO7816_warm_reset
53 * -# ISO7816_Decode_ATR
54 *----------------------------------------------------------------------------*/
55
56#ifndef ISO7816_4_H
57#define ISO7816_4_H
58
59/*------------------------------------------------------------------------------
60 * Constants Definition
61 *----------------------------------------------------------------------------*/
62
63/** Size max of Answer To Reset */
64#define ATR_SIZE_MAX 55
65
66/** NULL byte to restart byte procedure */
67#define ISO_NULL_VAL 0x60
68
69/*------------------------------------------------------------------------------
70 * Exported functions
71 *----------------------------------------------------------------------------*/
Christina Quaste24b9ac2015-04-10 17:44:49 +020072extern void ISO7816_Init( Usart_info *base_usart, bool master_clock );
73extern void ISO7816_Set_Reset_Pin(const Pin *pPinIso7816RstMC);
74extern uint32_t ISO7816_SendChar( uint8_t CharToSend, Usart_info *usart );
75extern uint32_t ISO7816_GetChar( uint8_t *pCharToReceive, Usart_info *usart);
76
Christina Quast53b21052014-12-09 15:34:35 +010077extern void ISO7816_IccPowerOff(void);
Christina Quast73c2b642015-04-07 13:49:26 +020078extern uint32_t ISO7816_XfrBlockTPDU_T0(const uint8_t *pAPDU,
Christina Quast53b21052014-12-09 15:34:35 +010079 uint8_t *pMessage,
Christina Quast73c2b642015-04-07 13:49:26 +020080 uint16_t wLength,
81 uint16_t *retlen);
Christina Quast53b21052014-12-09 15:34:35 +010082extern void ISO7816_Escape( void );
83extern void ISO7816_RestartClock(void);
84extern void ISO7816_StopClock( void );
85extern void ISO7816_toAPDU( void );
Christina Quast8d0f4a62015-01-15 14:53:38 +010086extern uint32_t ISO7816_Datablock_ATR( uint8_t* pAtr, uint8_t* pLength );
Christina Quast53b21052014-12-09 15:34:35 +010087extern void ISO7816_SetDataRateandClockFrequency( uint32_t dwClockFrequency, uint32_t dwDataRate );
88extern uint8_t ISO7816_StatusReset( void );
89extern void ISO7816_cold_reset( void );
90extern void ISO7816_warm_reset( void );
91extern void ISO7816_Decode_ATR( uint8_t* pAtr );
92
93#endif /* ISO7816_4_H */
94