Select one of the symbols to view example projects that use it.
 
Outline
#define __SMARTCARD_H
Includes
#include "stm32f4xx.h"
#include "platform_config.h"
#define T0_PROTOCOL
#define DIRECT
#define INDIRECT
#define SETUP_LENGTH
#define HIST_LENGTH
#define LC_MAX
#define SC_RECEIVE_TIMEOUT
#define SC_TRANSMIT_TIMEOUT
SC ADPU Command: Operation Code
#define SC_CLA_GSM11
------------------------ Data Area Management Commands
#define SC_SELECT_FILE
#define SC_GET_RESPONCE
#define SC_STATUS
#define SC_UPDATE_BINARY
#define SC_READ_BINARY
#define SC_WRITE_BINARY
#define SC_UPDATE_RECORD
#define SC_READ_RECORD
-------------------------- Administrative Commands
#define SC_CREATE_FILE
-------------------------- Safety Management Commands
#define SC_VERIFY
#define SC_CHANGE
#define SC_DISABLE
#define SC_ENABLE
#define SC_UNBLOCK
#define SC_EXTERNAL_AUTH
#define SC_GET_CHALLENGE
-------------------------- Answer to reset Commands
#define SC_GET_A2R
#define SC_EF_SELECTED
#define SC_DF_SELECTED
#define SC_OP_TERMINATED
#define SC_VOLTAGE_5V
#define SC_VOLTAGE_3V
Exported types
SC_State
ATR structure - Answer To Reset
SC_ATR
ADPU-Header command structure
SC_Header
ADPU-Body command structure
SC_Body
ADPU Command structure
SC_ADPU_Commands
SC response structure
SC_ADPU_Response
APPLICATION LAYER
SC_Handler(SC_State *, SC_ADPU_Commands *, SC_ADPU_Response *);
SC_PowerCmd(FunctionalState);
SC_Reset(GPIO_PinState);
SC_IOConfig();
SC_ParityErrorHandler();
SC_PTSConfig();
Files
loading...
CodeScopeSTM32 Libraries and SamplesSMARTCARD_T0Inc/smartcard.h
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @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 --------------------------------------------------------*/ #define T0_PROTOCOL 0x00 /* T0 protocol */ #define DIRECT 0x3B /* Direct bit convention */ #define INDIRECT 0x3F /* Indirect bit convention */ #define SETUP_LENGTH 20 #define HIST_LENGTH 20 #define LC_MAX 20 #define SC_RECEIVE_TIMEOUT 400 /* Direction to reader */ #define SC_TRANSMIT_TIMEOUT 200 /* Direction to transmit */ /* SC Tree Structure ----------------------------------------------------------- MasterFile ________|___________ | | | System UserData Note ------------------------------------------------------------------------------*//* ... */ /* SC ADPU Command: Operation Code -------------------------------------------*/ #define SC_CLA_GSM11 0xA0 SC ADPU Command: Operation Code /*------------------------ Data Area Management Commands ---------------------*/ #define SC_SELECT_FILE 0xA4 #define SC_GET_RESPONCE 0xC0 #define SC_STATUS 0xF2 #define SC_UPDATE_BINARY 0xD6 #define SC_READ_BINARY 0xB0 #define SC_WRITE_BINARY 0xD0 #define SC_UPDATE_RECORD 0xDC #define SC_READ_RECORD 0xB2 ------------------------ Data Area Management Commands /*-------------------------- Administrative Commands -------------------------*/ #define SC_CREATE_FILE 0xE0 -------------------------- Administrative Commands /*-------------------------- Safety Management Commands ----------------------*/ #define SC_VERIFY 0x20 #define SC_CHANGE 0x24 #define SC_DISABLE 0x26 #define SC_ENABLE 0x28 #define SC_UNBLOCK 0x2C #define SC_EXTERNAL_AUTH 0x82 #define SC_GET_CHALLENGE 0x84 -------------------------- Safety Management Commands /*-------------------------- Answer to reset Commands ------------------------*/ #define SC_GET_A2R 0x00 -------------------------- Answer to reset Commands /* SC STATUS: Status Code ----------------------------------------------------*/ #define SC_EF_SELECTED 0x9F #define SC_DF_SELECTED 0x9F #define SC_OP_TERMINATED 0x9000 /* Smartcard Voltage */ #define SC_VOLTAGE_5V 0 #define SC_VOLTAGE_3V 1 31 defines /* Exported types ------------------------------------------------------------*/ typedef enum { 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 -------------------------------------------*/ typedef struct { uint8_t TS; /* Bit Convention */ uint8_t T0; /* High nibble = Number of setup byte; low nibble = Number of historical byte */ uint8_t T[SETUP_LENGTH]; /* Setup array */ uint8_t H[HIST_LENGTH]; /* Historical array */ uint8_t Tlength; /* Setup array dimension */ uint8_t Hlength; /* Historical array dimension */ ...} SC_ATR; ATR structure - Answer To Reset /* ADPU-Header command structure ---------------------------------------------*/ typedef struct { uint8_t CLA; /* Command class */ uint8_t INS; /* Operation code */ uint8_t P1; /* Selection Mode */ uint8_t P2; /* Selection Option */ ...} SC_Header; ADPU-Header command structure /* ADPU-Body command structure -----------------------------------------------*/ typedef struct { uint8_t LC; /* Data field length */ uint8_t Data[LC_MAX]; /* Command parameters */ uint8_t LE; /* Expected length of data to be returned */ ...} SC_Body; ADPU-Body command structure /* ADPU Command structure ----------------------------------------------------*/ typedef struct { SC_Header Header; SC_Body Body; ...} SC_ADPU_Commands; ADPU Command structure /* SC response structure -----------------------------------------------------*/ typedef struct { uint8_t Data[LC_MAX]; /* Data returned from the card */ uint8_t SW1; /* Command Processing status */ uint8_t SW2; /* Command Processing qualification */ ...} SC_ADPU_Response; SC response structure /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ /* APPLICATION LAYER ---------------------------------------------------------*/ void SC_Handler(SC_State *SCState, SC_ADPU_Commands *SC_ADPU, SC_ADPU_Response *SC_Response); void SC_PowerCmd(FunctionalState NewState); void SC_Reset(GPIO_PinState ResetState); void SC_IOConfig(void); void SC_ParityErrorHandler(void); void SC_PTSConfig(void); APPLICATION LAYER /* ... */#endif /* __SMARTCARD_H */