blob: 88497a416205f274d9e73916a02781d38a71fe08 [file] [log] [blame]
Christina Quastdb7b1ab2015-03-03 12:34:36 +01001/* ----------------------------------------------------------------------------
2 * ATMEL Microcontroller Software Support
3 * ----------------------------------------------------------------------------
4 * Copyright (c) 2008, 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 */
29
30//------------------------------------------------------------------------------
31// Title: cciddriverdescriptors.h
32//
33// About: Purpose
34// Definitions of the descriptors required by the ccid device driver.
35// DWG_Smart-Card_CCID_Rev110.pdf
36//------------------------------------------------------------------------------
37
38#ifndef CCID_DRIVER_DESCRIPTORS_H
39#define CCID_DRIVER_DESCRIPTORS_H
40
41//------------------------------------------------------------------------------
42// Definitions
43//------------------------------------------------------------------------------
44
45//------------------------------------------------------------------------------
46// Constants: Endpoints
47// CCID_EPT_DATA_OUT endpoint data out bulk 1
48// CCID_EPT_DATA_IN endpoint data in bulk 2
49// CCID_EPT_NOTIFICATION endpoint data interupt 3
50//------------------------------------------------------------------------------
51#define CCID_EPT_DATA_OUT 1
52#define CCID_EPT_DATA_IN 2
53#define CCID_EPT_NOTIFICATION 3
54
55//------------------------------------------------------------------------------
56// USB-ICC protocol
57//------------------------------------------------------------------------------
58// CCID specification version 1.10
59#define CCID1_10 0x0110
60
61#define SMART_CARD_DEVICE_CLASS 0x0B
62// Smart Card Device Class Descriptor Type
63#define CCID_DECRIPTOR_TYPE 0x21
64
65// Table 5.3-1 Summary of CCID Class Specific Request
66#define CCIDGenericRequest_ABORT 0x01
67#define CCIDGenericRequest_GET_CLOCK_FREQUENCIES 0x02
68#define CCIDGenericRequest_GET_DATA_RATES 0x03
69
70// 6.1 Command Pipe, Bulk-OUT Messages
71#define PC_TO_RDR_ICCPOWERON 0x62
72#define PC_TO_RDR_ICCPOWEROFF 0x63
73#define PC_TO_RDR_GETSLOTSTATUS 0x65
74#define PC_TO_RDR_XFRBLOCK 0x6F
75#define PC_TO_RDR_GETPARAMETERS 0x6C
76#define PC_TO_RDR_RESETPARAMETERS 0x6D
77#define PC_TO_RDR_SETPARAMETERS 0x61
78#define PC_TO_RDR_ESCAPE 0x6B
79#define PC_TO_RDR_ICCCLOCK 0x6E
80#define PC_TO_RDR_T0APDU 0x6A
81#define PC_TO_RDR_SECURE 0x69
82#define PC_TO_RDR_MECHANICAL 0x71
83#define PC_TO_RDR_ABORT 0x72
84#define PC_TO_RDR_SETDATARATEANDCLOCKFREQUENCY 0x73
85
86// 6.2 Response Pipe, Bulk-IN Messages
87#define RDR_TO_PC_DATABLOCK 0x80
88#define RDR_TO_PC_SLOTSTATUS 0x81
89#define RDR_TO_PC_PARAMETERS 0x82
90#define RDR_TO_PC_ESCAPE 0x83
91#define RDR_TO_PC_DATARATEANDCLOCKFREQUENCY 0x84
92
93// 6.3 Interrupt-IN Messages
94#define RDR_TO_PC_NOTIFYSLOTCHANGE 0x50
95#define RDR_TO_PC_HARDWAREERROR 0x51
96
97// Table 6.2-2 Slot error register when bmCommandStatus = 1
98#define CMD_ABORTED 0xFF
99#define ICC_MUTE 0xFE
100#define XFR_PARITY_ERROR 0xFD
101#define XFR_OVERRUN 0xFC
102#define HW_ERROR 0xFB
103#define BAD_ATR_TS 0xF8
104#define BAD_ATR_TCK 0xF7
105#define ICC_PROTOCOL_NOT_SUPPORTED 0xF6
106#define ICC_CLASS_NOT_SUPPORTED 0xF5
107#define PROCEDURE_BYTE_CONFLICT 0xF4
108#define DEACTIVATED_PROTOCOL 0xF3
109#define BUSY_WITH_AUTO_SEQUENCE 0xF2
110#define PIN_TIMEOUT 0xF0
111#define PIN_CANCELLED 0xEF
112#define CMD_SLOT_BUSY 0xE0
113// User defined 0xC0 to 0x81
114// Reserved for futur use 0x80
115// not supported incorrect message parameter 0x7F to 0x01
116// Command not supported 0x00
117
118// CCID rev 1.1, p.27
119#define VOLTS_AUTO 0x00
120#define VOLTS_5_0 0x01
121#define VOLTS_3_0 0x02
122#define VOLTS_1_8 0x03
123
124// 6.3.1 RDR_to_PC_NotifySlotChange
125#define ICC_NOT_PRESENT 0x00
126#define ICC_PRESENT 0x01
127#define ICC_CHANGE 0x02
128#define ICC_INSERTED_EVENT 0x01
129//FIXME: #define ICC_INSERTED_EVENT ICC_PRESENT+ICC_CHANGE
130
131// ICCD: Table 6.1-8 Bitmap for bStatus field
132#define ICC_BS_PRESENT_ACTIVATED 0x00 // USB-ICC is present and activated
133#define ICC_BS_PRESENT_NOTACTIVATED 0x01 // USB-ICC is present but not activated
134#define ICC_BS_NOTPRESENT 0x02 // USB-ICC is virtually not present
135#define ICC_BS_RFU 0x03 // RFU
136#define ICC_CS_NO_ERROR (0x00<<6) // Processed without error
137#define ICC_CS_FAILED (0x01<<6) // Failed, error condition given by bError
138#define ICC_CS_TIME_EXT (0x02<<6) // Time extension is requested
139#define ICC_CS_RFU (0x03<<6) // RFU
140
141/*
142#define NO_ERROR 0x00
143#define NO_EXTRA_BYTES 0x00
144#define CCID_FLAG_INITIAL_VALUE 0x05
145#define CCID_EVENT_SIZE 0x02
146#define STATUS_MASK 0x41
147*/
148//------------------------------------------------------------------------------
149// Structures
150//------------------------------------------------------------------------------
151
152#endif //#ifndef CCID_DRIVER_DESCRIPTORS_H
153