Christina Quast | 53b2105 | 2014-12-09 15:34:35 +0100 | [diff] [blame] | 1 | /* ---------------------------------------------------------------------------- |
| 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 Quast | 3eab56e | 2015-04-10 15:38:49 +0200 | [diff] [blame^] | 29 | #include <stdbool.h> |
Christina Quast | 53b2105 | 2014-12-09 15:34:35 +0100 | [diff] [blame] | 30 | //------------------------------------------------------------------------------ |
| 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 Quast | 3eab56e | 2015-04-10 15:38:49 +0200 | [diff] [blame^] | 70 | extern void ISO7816_Init( const Pin *pPinIso7816RstMC, Usart *base_usart, bool master_clock ); |
Christina Quast | 53b2105 | 2014-12-09 15:34:35 +0100 | [diff] [blame] | 71 | extern void ISO7816_IccPowerOff(void); |
Christina Quast | 73c2b64 | 2015-04-07 13:49:26 +0200 | [diff] [blame] | 72 | extern uint32_t ISO7816_XfrBlockTPDU_T0(const uint8_t *pAPDU, |
Christina Quast | 53b2105 | 2014-12-09 15:34:35 +0100 | [diff] [blame] | 73 | uint8_t *pMessage, |
Christina Quast | 73c2b64 | 2015-04-07 13:49:26 +0200 | [diff] [blame] | 74 | uint16_t wLength, |
| 75 | uint16_t *retlen); |
Christina Quast | 53b2105 | 2014-12-09 15:34:35 +0100 | [diff] [blame] | 76 | extern void ISO7816_Escape( void ); |
| 77 | extern void ISO7816_RestartClock(void); |
| 78 | extern void ISO7816_StopClock( void ); |
| 79 | extern void ISO7816_toAPDU( void ); |
Christina Quast | 8d0f4a6 | 2015-01-15 14:53:38 +0100 | [diff] [blame] | 80 | extern uint32_t ISO7816_Datablock_ATR( uint8_t* pAtr, uint8_t* pLength ); |
Christina Quast | 53b2105 | 2014-12-09 15:34:35 +0100 | [diff] [blame] | 81 | extern void ISO7816_SetDataRateandClockFrequency( uint32_t dwClockFrequency, uint32_t dwDataRate ); |
| 82 | extern uint8_t ISO7816_StatusReset( void ); |
| 83 | extern void ISO7816_cold_reset( void ); |
| 84 | extern void ISO7816_warm_reset( void ); |
| 85 | extern void ISO7816_Decode_ATR( uint8_t* pAtr ); |
| 86 | |
| 87 | #endif /* ISO7816_4_H */ |
| 88 | |