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 | e24b9ac | 2015-04-10 17:44:49 +0200 | [diff] [blame] | 30 | #include "board.h" |
| 31 | |
Christina Quast | 53b2105 | 2014-12-09 15:34:35 +0100 | [diff] [blame] | 32 | //------------------------------------------------------------------------------ |
| 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 Quast | e24b9ac | 2015-04-10 17:44:49 +0200 | [diff] [blame] | 72 | extern void ISO7816_Init( Usart_info *base_usart, bool master_clock ); |
| 73 | extern void ISO7816_Set_Reset_Pin(const Pin *pPinIso7816RstMC); |
| 74 | extern uint32_t ISO7816_SendChar( uint8_t CharToSend, Usart_info *usart ); |
| 75 | extern uint32_t ISO7816_GetChar( uint8_t *pCharToReceive, Usart_info *usart); |
| 76 | |
Christina Quast | 53b2105 | 2014-12-09 15:34:35 +0100 | [diff] [blame] | 77 | extern void ISO7816_IccPowerOff(void); |
Christina Quast | 73c2b64 | 2015-04-07 13:49:26 +0200 | [diff] [blame] | 78 | extern uint32_t ISO7816_XfrBlockTPDU_T0(const uint8_t *pAPDU, |
Kévin Redon | 33d1eb7 | 2018-07-08 13:58:12 +0200 | [diff] [blame] | 79 | uint8_t *pMessage, |
| 80 | uint16_t wLength, |
| 81 | uint16_t *retlen); |
Christina Quast | 53b2105 | 2014-12-09 15:34:35 +0100 | [diff] [blame] | 82 | extern void ISO7816_Escape( void ); |
| 83 | extern void ISO7816_RestartClock(void); |
| 84 | extern void ISO7816_StopClock( void ); |
| 85 | extern void ISO7816_toAPDU( void ); |
Christina Quast | 8d0f4a6 | 2015-01-15 14:53:38 +0100 | [diff] [blame] | 86 | extern uint32_t ISO7816_Datablock_ATR( uint8_t* pAtr, uint8_t* pLength ); |
Christina Quast | 53b2105 | 2014-12-09 15:34:35 +0100 | [diff] [blame] | 87 | extern void ISO7816_SetDataRateandClockFrequency( uint32_t dwClockFrequency, uint32_t dwDataRate ); |
| 88 | extern uint8_t ISO7816_StatusReset( void ); |
| 89 | extern void ISO7816_cold_reset( void ); |
| 90 | extern void ISO7816_warm_reset( void ); |
| 91 | extern void ISO7816_Decode_ATR( uint8_t* pAtr ); |
| 92 | |
| 93 | #endif /* ISO7816_4_H */ |
| 94 | |