3 Copyright (C) Dean Camera, 2018.
5 dean [at] fourwalledcubicle [dot] com
10 Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11 Copyright 2018 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_FAILED (1 << 6)
85 #define CCID_COMMANDSTATUS_TIMEEXTENSIONREQUESTED (2 << 6)
86 #define CCID_COMMANDSTATUS_RFU (3 << 6)
88 #define CCID_ERROR_RFU_START 0x80
89 #define CCID_ERROR_NO_ERROR 0x80
90 #define CCID_ERROR_NOT_SUPPORTED 0
91 #define CCID_ERROR_CMD_ABORTED 0xFF
92 #define CCID_ERROR_CMD_NOT_ABORTED 0xFF
94 #define CCID_ERROR_SLOT_NOT_FOUND 5
96 #define CCID_DESCRIPTOR_CLOCK_KHZ(khz) (khz)
97 #define CCID_DESCRIPTOR_CLOCK_MHZ(mhz) ((mhz) * 1000)
101 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the CCID
104 enum CCID_Descriptor_ClassSubclassProtocol_t
106 CCID_CSCP_CCIDClass
= 0x0b, /**< Descriptor Class value indicating that the device or interface
107 * belongs to the CCID class.
109 CCID_CSCP_NoSpecificSubclass
= 0x00, /**< Descriptor Subclass value indicating that the device or interface
110 * belongs to no specific subclass of the CCID class.
112 CCID_CSCP_NoSpecificProtocol
= 0x00, /**< Descriptor Protocol value indicating that the device or interface
113 * belongs to no specific protocol of the CCID class.
117 /** Enum for possible bulk messages between PC and Reader */
118 enum CCID_BulkOutMessages_t
120 CCID_PC_to_RDR_IccPowerOn
= 0x62,
121 CCID_PC_to_RDR_IccPowerOff
= 0x63,
122 CCID_PC_to_RDR_GetSlotStatus
= 0x65,
123 CCID_PC_to_RDR_XfrBlock
= 0x6f,
124 CCID_PC_to_RDR_GetParameters
= 0x6c,
125 CCID_PC_to_RDR_ResetParameters
= 0x6d,
126 CCID_PC_to_RDR_SetParameters
= 0x61,
127 CCID_PC_to_RDR_Escape
= 0x6b,
128 CCID_PC_to_RDR_IccClock
= 0x6e,
129 CCID_PC_to_RDR_T0APDU
= 0x6a,
130 CCID_PC_to_RDR_Secure
= 0x69,
131 CCID_PC_to_RDR_Mechanical
= 0x71,
132 CCID_PC_to_RDR_Abort
= 0x72,
133 CCID_PC_to_RDR_SetDataRateAndClockFrequency
= 0x73,
135 CCID_RDR_to_PC_DataBlock
= 0x80,
136 CCID_RDR_to_PC_SlotStatus
= 0x81,
137 CCID_RDR_to_PC_Parameters
= 0x82,
138 CCID_RDR_to_PC_Escape
= 0x83,
139 CCID_RDR_to_PC_DataRateAndClockFrequency
= 0x84,
142 /** Enum for the CCID class specific control requests that can be issued by the USB bus host. */
143 enum CCID_ClassRequests_t
146 CCID_GET_CLOCK_FREQUENCIES
= 0x2,
147 CCID_GET_DATA_RATES
= 0x3,
150 /** Enum for the CCID class specific descriptor types. */
151 enum CCID_DescriptorTypes_t
153 CCID_DTYPE_Functional
= 0x21, /**< CCID class specific Interface functional descriptor. */
159 USB_Descriptor_Header_t Header
; /**< Regular descriptor header containing the descriptor's type and length. */
162 uint8_t MaxSlotIndex
;
163 uint8_t VoltageSupport
;
165 uint32_t DefaultClock
;
166 uint32_t MaximumClock
;
167 uint8_t NumClockSupported
;
169 uint32_t MaxDataRate
;
170 uint8_t NumDataRatesSupported
;
172 uint32_t SynchProtocols
;
175 uint32_t MaxCCIDMessageLength
;
176 uint8_t ClassGetResponse
;
177 uint8_t ClassEnvelope
;
180 uint8_t MaxCCIDBusySlots
;
181 } ATTR_PACKED USB_CCID_Descriptor_t
;
185 uint8_t FindexDindex
;
188 uint8_t WaitingIntegerT0
;
190 } ATTR_PACKED USB_CCID_ProtocolData_T0_t
;
194 uint8_t FindexDindex
;
197 uint8_t WaitingIntegerT1
;
201 } ATTR_PACKED USB_CCID_ProtocolData_T1_t
;
204 /** Enum for a common bulk message header. */
211 } ATTR_PACKED USB_CCID_BulkMessage_Header_t
;
215 USB_CCID_BulkMessage_Header_t CCIDHeader
;
220 } ATTR_PACKED USB_CCID_RDR_to_PC_DataBlock_t
;
224 USB_CCID_BulkMessage_Header_t CCIDHeader
;
228 } ATTR_PACKED USB_CCID_RDR_to_PC_SlotStatus_t
;
232 USB_CCID_BulkMessage_Header_t CCIDHeader
;
237 USB_CCID_ProtocolData_T0_t T0
;
238 USB_CCID_ProtocolData_T1_t T1
;
240 } ATTR_PACKED USB_CCID_RDR_to_PC_Parameters_t
;
244 USB_CCID_BulkMessage_Header_t CCIDHeader
;
249 } ATTR_PACKED USB_CCID_RDR_to_PC_Escape_t
;
253 USB_CCID_BulkMessage_Header_t CCIDHeader
;
257 uint32_t ClockFrequency
;
259 } ATTR_PACKED USB_CCID_RDR_to_PC_DataRateAndClockFrequency_t
;
261 /* Disable C linkage for C++ Compilers: */
262 #if defined(__cplusplus)