3 Copyright (C) Dean Camera, 2020.
5 dean [at] fourwalledcubicle [dot] com
10 Copyright 2020 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11 Copyright 2020 Filipe Rodrigues (filipepazrodrigues [at] gmail [dot] com)
13 Permission to use, copy, modify, distribute, and sell this
14 software and its documentation for any purpose is hereby granted
15 without fee, provided that the above copyright notice appear in
16 all copies and that both that the copyright notice and this
17 permission notice and warranty disclaimer appear in supporting
18 documentation, and that the name of the author not be used in
19 advertising or publicity pertaining to distribution of the
20 software without specific, written prior permission.
22 The author disclaims all warranties with regard to this
23 software, including all implied warranties of merchantability
24 and fitness. In no event shall the author be liable for any
25 special, indirect or consequential damages or any damages
26 whatsoever resulting from loss of use, data or profits, whether
27 in an action of contract, negligence or other tortious action,
28 arising out of or in connection with the use or performance of
33 * \brief Common definitions and declarations for the library USB CCID Class driver.
35 * Common definitions and declarations for the library USB CCID Class driver.
37 * \note This file should not be included directly. It is automatically included as needed by the USB module driver
38 * dispatch header located in LUFA/Drivers/USB.h.
41 /** \ingroup Group_USBClassCCID
42 * \defgroup Group_USBClassCCIDCommon Common Class Definitions
44 * \section Sec_USBClassCCIDCommon_ModDescription Module Description
45 * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
51 #ifndef _CCID_CLASS_COMMON_H_
52 #define _CCID_CLASS_COMMON_H_
55 #include "../../Core/StdDescriptors.h"
57 /* Enable C linkage for C++ Compilers: */
58 #if defined(__cplusplus)
62 /* Preprocessor Checks: */
63 #if !defined(__INCLUDE_FROM_CCID_DRIVER)
64 #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
68 #define CCID_CURRENT_SPEC_RELEASE_NUMBER 0x0110
69 #define CCID_VOLTAGESUPPORT_5V 0
70 #define CCID_VOLTAGESUPPORT_3V (1 << 0)
71 #define CCID_VOLTAGESUPPORT_1V8 (1 << 1)
73 #define CCID_PROTOCOLS_T0 (1 << 0)
74 #define CCID_PROTOCOLS_T1 (1 << 1)
76 #define CCID_PROTOCOLNUM_T0 0
77 #define CCID_PROTOCOLNUM_T1 (1 << 0)
79 #define CCID_ICCSTATUS_PRESENTANDACTIVE 0
80 #define CCID_ICCSTATUS_PRESENTANDINACTIVE (1 << 0)
81 #define CCID_ICCSTATUS_NOICCPRESENT (1 << 1)
83 #define CCID_COMMANDSTATUS_PROCESSEDWITHOUTERROR 0
84 #define CCID_COMMANDSTATUS_ERROR 1
85 #define CCID_COMMANDSTATUS_FAILED (1 << 6)
86 #define CCID_COMMANDSTATUS_TIMEEXTENSIONREQUESTED (2 << 6)
87 #define CCID_COMMANDSTATUS_RFU (3 << 6)
89 #define CCID_ERROR_RFU_START 0x80
90 #define CCID_ERROR_NO_ERROR 0x80
91 #define CCID_ERROR_NOT_SUPPORTED 0
92 #define CCID_ERROR_CMD_ABORTED 0xFF
93 #define CCID_ERROR_CMD_NOT_ABORTED 0xFF
95 #define CCID_ERROR_PARAMETERS_PROTOCOL_NOT_SUPPORTED 0x7
97 #define CCID_ERROR_SLOT_NOT_FOUND 5
99 #define CCID_DESCRIPTOR_CLOCK_KHZ(khz) (khz)
100 #define CCID_DESCRIPTOR_CLOCK_MHZ(mhz) ((mhz) * 1000)
104 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the CCID
107 enum CCID_Descriptor_ClassSubclassProtocol_t
109 CCID_CSCP_CCIDClass
= 0x0b, /**< Descriptor Class value indicating that the device or interface
110 * belongs to the CCID class.
112 CCID_CSCP_NoSpecificSubclass
= 0x00, /**< Descriptor Subclass value indicating that the device or interface
113 * belongs to no specific subclass of the CCID class.
115 CCID_CSCP_NoSpecificProtocol
= 0x00, /**< Descriptor Protocol value indicating that the device or interface
116 * belongs to no specific protocol of the CCID class.
120 /** Enum for possible bulk messages between PC and Reader */
121 enum CCID_BulkOutMessages_t
123 CCID_PC_to_RDR_IccPowerOn
= 0x62,
124 CCID_PC_to_RDR_IccPowerOff
= 0x63,
125 CCID_PC_to_RDR_GetSlotStatus
= 0x65,
126 CCID_PC_to_RDR_XfrBlock
= 0x6f,
127 CCID_PC_to_RDR_GetParameters
= 0x6c,
128 CCID_PC_to_RDR_ResetParameters
= 0x6d,
129 CCID_PC_to_RDR_SetParameters
= 0x61,
130 CCID_PC_to_RDR_Escape
= 0x6b,
131 CCID_PC_to_RDR_IccClock
= 0x6e,
132 CCID_PC_to_RDR_T0APDU
= 0x6a,
133 CCID_PC_to_RDR_Secure
= 0x69,
134 CCID_PC_to_RDR_Mechanical
= 0x71,
135 CCID_PC_to_RDR_Abort
= 0x72,
136 CCID_PC_to_RDR_SetDataRateAndClockFrequency
= 0x73,
138 CCID_RDR_to_PC_DataBlock
= 0x80,
139 CCID_RDR_to_PC_SlotStatus
= 0x81,
140 CCID_RDR_to_PC_Parameters
= 0x82,
141 CCID_RDR_to_PC_Escape
= 0x83,
142 CCID_RDR_to_PC_DataRateAndClockFrequency
= 0x84,
145 /** Enum for the CCID class specific control requests that can be issued by the USB bus host. */
146 enum CCID_ClassRequests_t
149 CCID_GET_CLOCK_FREQUENCIES
= 0x2,
150 CCID_GET_DATA_RATES
= 0x3,
153 /** Enum for the CCID class specific descriptor types. */
154 enum CCID_DescriptorTypes_t
156 CCID_DTYPE_Functional
= 0x21, /**< CCID class specific Interface functional descriptor. */
159 enum CCID_Features_Auto_t
161 CCID_Features_Auto_None
= 0x0,
162 CCID_Features_Auto_ParameterConfiguration
= 0x2,
163 CCID_Features_Auto_ICCActivation
= 0x4,
164 CCID_Features_Auto_VoltageSelection
= 0x8,
166 CCID_Features_Auto_ICCClockFrequencyChange
= 0x10,
167 CCID_Features_Auto_ICCBaudRateChange
= 0x20,
168 CCID_Features_Auto_ParameterNegotiation
= 0x40,
169 CCID_Features_Auto_PPS
= 0x80,
172 enum CCID_Features_ExchangeLevel_t
174 CCID_Features_ExchangeLevel_TPDU
= 0x00010000,
175 CCID_Features_ExchangeLevel_ShortAPDU
= 0x00020000,
176 CCID_Features_ExchangeLevel_ShortExtendedAPDU
= 0x00040000
182 USB_Descriptor_Header_t Header
; /**< Regular descriptor header containing the descriptor's type and length. */
185 uint8_t MaxSlotIndex
;
186 uint8_t VoltageSupport
;
188 uint32_t DefaultClock
;
189 uint32_t MaximumClock
;
190 uint8_t NumClockSupported
;
192 uint32_t MaxDataRate
;
193 uint8_t NumDataRatesSupported
;
195 uint32_t SynchProtocols
;
198 uint32_t MaxCCIDMessageLength
;
199 uint8_t ClassGetResponse
;
200 uint8_t ClassEnvelope
;
203 uint8_t MaxCCIDBusySlots
;
204 } ATTR_PACKED USB_CCID_Descriptor_t
;
208 uint8_t FindexDindex
;
211 uint8_t WaitingIntegerT0
;
213 } ATTR_PACKED USB_CCID_ProtocolData_T0_t
;
217 uint8_t FindexDindex
;
220 uint8_t WaitingIntegerT1
;
224 } ATTR_PACKED USB_CCID_ProtocolData_T1_t
;
227 /** Enum for a common bulk message header. */
234 } ATTR_PACKED USB_CCID_BulkMessage_Header_t
;
238 USB_CCID_BulkMessage_Header_t CCIDHeader
;
243 } ATTR_PACKED USB_CCID_RDR_to_PC_DataBlock_t
;
247 USB_CCID_BulkMessage_Header_t CCIDHeader
;
251 } ATTR_PACKED USB_CCID_RDR_to_PC_SlotStatus_t
;
255 USB_CCID_BulkMessage_Header_t CCIDHeader
;
261 USB_CCID_ProtocolData_T0_t T0
;
262 USB_CCID_ProtocolData_T1_t T1
;
264 } ATTR_PACKED USB_CCID_RDR_to_PC_Parameters_t
;
268 USB_CCID_BulkMessage_Header_t CCIDHeader
;
273 } ATTR_PACKED USB_CCID_RDR_to_PC_Escape_t
;
277 USB_CCID_BulkMessage_Header_t CCIDHeader
;
281 uint32_t ClockFrequency
;
283 } ATTR_PACKED USB_CCID_RDR_to_PC_DataRateAndClockFrequency_t
;
285 /* Disable C linkage for C++ Compilers: */
286 #if defined(__cplusplus)