/** ****************************************************************************** * @file SMARTCARD/SMARTCARD_T0/Inc/smartcard.h * @author MCD Application Team * @brief This file contains all the functions prototypes for the Smartcard * firmware library. ****************************************************************************** * @attention * * Copyright (c) 2017 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... *//* Define to prevent recursive inclusion -------------------------------------*/#ifndef__SMARTCARD_H#define__SMARTCARD_H/* Includes ------------------------------------------------------------------*/#include"stm32f4xx.h"#include"platform_config.h"Includes/* Exported constants --------------------------------------------------------*/#defineT0_PROTOCOL0x00/* T0 protocol */#defineDIRECT0x3B/* Direct bit convention */#defineINDIRECT0x3F/* Indirect bit convention */#defineSETUP_LENGTH20#defineHIST_LENGTH20#defineLC_MAX20#defineSC_RECEIVE_TIMEOUT400/* Direction to reader */#defineSC_TRANSMIT_TIMEOUT200/* Direction to transmit *//* SC Tree Structure ----------------------------------------------------------- MasterFile ________|___________ | | | System UserData Note------------------------------------------------------------------------------*//* ... *//* SC ADPU Command: Operation Code -------------------------------------------*/#defineSC_CLA_GSM110xA0SC ADPU Command: Operation Code/*------------------------ Data Area Management Commands ---------------------*/#defineSC_SELECT_FILE0xA4#defineSC_GET_RESPONCE0xC0#defineSC_STATUS0xF2#defineSC_UPDATE_BINARY0xD6#defineSC_READ_BINARY0xB0#defineSC_WRITE_BINARY0xD0#defineSC_UPDATE_RECORD0xDC#defineSC_READ_RECORD0xB2------------------------ Data Area Management Commands/*-------------------------- Administrative Commands -------------------------*/#defineSC_CREATE_FILE0xE0-------------------------- Administrative Commands/*-------------------------- Safety Management Commands ----------------------*/#defineSC_VERIFY0x20#defineSC_CHANGE0x24#defineSC_DISABLE0x26#defineSC_ENABLE0x28#defineSC_UNBLOCK0x2C#defineSC_EXTERNAL_AUTH0x82#defineSC_GET_CHALLENGE0x84-------------------------- Safety Management Commands/*-------------------------- Answer to reset Commands ------------------------*/#defineSC_GET_A2R0x00-------------------------- Answer to reset Commands/* SC STATUS: Status Code ----------------------------------------------------*/#defineSC_EF_SELECTED0x9F#defineSC_DF_SELECTED0x9F#defineSC_OP_TERMINATED0x9000/* Smartcard Voltage */#defineSC_VOLTAGE_5V0#defineSC_VOLTAGE_3V131 defines/* Exported types ------------------------------------------------------------*/typedefenum{SC_POWER_ON=0x00,SC_RESET_LOW=0x01,SC_RESET_HIGH=0x02,SC_ACTIVE=0x03,SC_ACTIVE_ON_T0=0x04,SC_POWER_OFF=0x05...}SC_State;Exported types/* ATR structure - Answer To Reset -------------------------------------------*/typedefstruct{uint8_tTS;/* Bit Convention */uint8_tT0;/* High nibble = Number of setup byte; low nibble = Number of historical byte */uint8_tT[SETUP_LENGTH];/* Setup array */uint8_tH[HIST_LENGTH];/* Historical array */uint8_tTlength;/* Setup array dimension */uint8_tHlength;/* Historical array dimension */...}SC_ATR;ATR structure - Answer To Reset/* ADPU-Header command structure ---------------------------------------------*/typedefstruct{uint8_tCLA;/* Command class */uint8_tINS;/* Operation code */uint8_tP1;/* Selection Mode */uint8_tP2;/* Selection Option */...}SC_Header;ADPU-Header command structure/* ADPU-Body command structure -----------------------------------------------*/typedefstruct{uint8_tLC;/* Data field length */uint8_tData[LC_MAX];/* Command parameters */uint8_tLE;/* Expected length of data to be returned */...}SC_Body;ADPU-Body command structure/* ADPU Command structure ----------------------------------------------------*/typedefstruct{SC_HeaderHeader;SC_BodyBody;...}SC_ADPU_Commands;ADPU Command structure/* SC response structure -----------------------------------------------------*/typedefstruct{uint8_tData[LC_MAX];/* Data returned from the card */uint8_tSW1;/* Command Processing status */uint8_tSW2;/* Command Processing qualification */...}SC_ADPU_Response;SC response structure/* Exported macro ------------------------------------------------------------*//* Exported functions ------------------------------------------------------- *//* APPLICATION LAYER ---------------------------------------------------------*/voidSC_Handler(SC_State*SCState,SC_ADPU_Commands*SC_ADPU,SC_ADPU_Response*SC_Response);voidSC_PowerCmd(FunctionalStateNewState);voidSC_Reset(GPIO_PinStateResetState);voidSC_IOConfig(void);voidSC_ParityErrorHandler(void);voidSC_PTSConfig(void);APPLICATION LAYER/* ... */#endif/* __SMARTCARD_H */