Line No. | Rev | Author | Line |
---|---|---|---|
1 | 32 | kaklik | /******************************************************************************* |
2 | File Information: |
||
3 | FileName: usb_function_ccid.h |
||
4 | Dependencies: See INCLUDES section |
||
5 | Processor: PIC18 or PIC24 USB Microcontrollers |
||
6 | Hardware: The code is natively intended to be used on the following |
||
7 | hardware platforms: PICDEM FS USB Demo Board, |
||
8 | PIC18F87J50 FS USB Plug-In Module, or |
||
9 | Explorer 16 + PIC24 USB PIM. The firmware may be |
||
10 | modified for use on other USB platforms by editing the |
||
11 | HardwareProfile.h file. |
||
12 | Complier: Microchip C18 (for PIC18) or C30 (for PIC24) |
||
13 | Company: Microchip Technology, Inc. |
||
14 | |||
15 | Software License Agreement: |
||
16 | |||
17 | The software supplied herewith by Microchip Technology Incorporated |
||
18 | (the Company) for its PIC® Microcontroller is intended and |
||
19 | supplied to you, the Companys customer, for use solely and |
||
20 | exclusively on Microchip PIC Microcontroller products. The |
||
21 | software is owned by the Company and/or its supplier, and is |
||
22 | protected under applicable copyright laws. All rights are reserved. |
||
23 | Any use in violation of the foregoing restrictions may subject the |
||
24 | user to criminal sanctions under applicable laws, as well as to |
||
25 | civil liability for the breach of the terms and conditions of this |
||
26 | license. |
||
27 | |||
28 | THIS SOFTWARE IS PROVIDED IN AN AS IS CONDITION. NO WARRANTIES, |
||
29 | WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED |
||
30 | TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
||
31 | PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, |
||
32 | IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR |
||
33 | CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
||
34 | |||
35 | Change History: |
||
36 | Rev Date Description |
||
37 | 0.1 2/June/2009 Draft |
||
38 | |||
39 | Summary: |
||
40 | This file contains all of functions, macros, definitions, variables, |
||
41 | datatypes, etc. that are required for usage with the AUDIO function |
||
42 | driver. This file should be included in projects that use the Audio |
||
43 | \function driver. This file should also be included into the |
||
44 | usb_descriptors.c file and any other user file that requires access to the |
||
45 | HID interface. |
||
46 | |||
47 | |||
48 | |||
49 | This file is located in the "\<Install Directory\>\\Microchip\\Include\\USB" |
||
50 | directory. |
||
51 | |||
52 | Description: |
||
53 | USB AUDIO Function Driver File |
||
54 | |||
55 | This file contains all of functions, macros, definitions, variables, |
||
56 | datatypes, etc. that are required for usage with the AUDIO function |
||
57 | driver. This file should be included in projects that use the AUDIO |
||
58 | \function driver. This file should also be included into the |
||
59 | usb_descriptors.c file and any other user file that requires access to the |
||
60 | AUDIO interface. |
||
61 | |||
62 | This file is located in the "\<Install Directory\>\\Microchip\\Include\\USB" |
||
63 | directory. |
||
64 | |||
65 | When including this file in a new project, this file can either be |
||
66 | referenced from the directory in which it was installed or copied |
||
67 | directly into the user application folder. If the first method is |
||
68 | chosen to keep the file located in the folder in which it is installed |
||
69 | then include paths need to be added so that the library and the |
||
70 | application both know where to reference each others files. If the |
||
71 | application folder is located in the same folder as the Microchip |
||
72 | folder (like the current demo folders), then the following include |
||
73 | paths need to be added to the application's project: |
||
74 | |||
75 | . |
||
76 | |||
77 | ..\\..\\Microchip\\Include |
||
78 | |||
79 | If a different directory structure is used, modify the paths as |
||
80 | required. An example using absolute paths instead of relative paths |
||
81 | would be the following: |
||
82 | |||
83 | C:\\Microchip Solutions\\Microchip\\Include |
||
84 | |||
85 | C:\\Microchip Solutions\\My Demo Application |
||
86 | *******************************************************************/ |
||
87 | |||
88 | /******************************************************************** |
||
89 | Change History: |
||
90 | Rev Description |
||
91 | ---- ----------- |
||
92 | 2.6 Initial Release |
||
93 | |||
94 | 2.6a- No Change |
||
95 | 2.7a |
||
96 | ********************************************************************/ |
||
97 | |||
98 | #ifndef CCID_H |
||
99 | #define CCID_H |
||
100 | |||
101 | /** I N C L U D E S *******************************************************/ |
||
102 | |||
103 | |||
104 | /** DEFINITIONS ****************************************************/ |
||
105 | /* CCID Bulk OUT transfer states */ |
||
106 | #define USB_CCID_BULK_OUT_FIRST_PACKET 0 |
||
107 | #define USB_CCID_BULK_OUT_SUBSEQUENT_PACKET 1 |
||
108 | |||
109 | /* CCID Bulk IN transfer states */ |
||
110 | #define USB_CCID_BULK_IN_READY 0 |
||
111 | #define USB_CCID_BULK_IN_BUSY 1 |
||
112 | #define USB_CCID_BULK_IN_BUSY_ZLP 2 // ZLP: Zero Length Packet |
||
113 | #define USB_CCID_BULK_IN_COMPLETING 3 |
||
114 | |||
115 | /****** CCID Class-Specific Request Codes ************/ |
||
116 | #define USB_CCID_ABORT 0x01 |
||
117 | #define USB_CCID_GET_CLOCK_FREQUENCIES 0x02 |
||
118 | #define USB_CCID_GET_DATA_RATES 0x03 |
||
119 | |||
120 | // CCID Commands/response |
||
121 | #define USB_CCID_PC_TO_RDR_ICC_POWER_ON 0x62 |
||
122 | #define USB_CCID_PC_TO_RDR_ICC_POWER_OFF 0x63 |
||
123 | #define USB_CCID_PC_TO_RDR_GET_SLOT_STATUS 0x65 |
||
124 | #define USB_CCID_PC_TO_RDR_XFR_BLOCK 0x6F |
||
125 | #define USB_CCID_PC_TO_RDR_GET_PARAMETERS 0x6C |
||
126 | #define USB_CCID_PC_TO_RDR_RESET_PARAMETERS 0x6D |
||
127 | #define USB_CCID_PC_TO_RDR_SET_PARAMETERS 0x61 |
||
128 | #define USB_CCID_PC_TO_RDR_ESCAPE 0x6B |
||
129 | #define USB_CCID_PC_TO_RDR_ICC_CLOCK 0x6E |
||
130 | #define USB_CCID_PC_TO_RDR_T0APDU 0x6A |
||
131 | #define USB_CCID_PC_TO_RDR_SECURE 0x69 |
||
132 | #define USB_CCID_PC_TO_RDR_MECHANICAL 0x71 |
||
133 | #define USB_CCID_PC_TO_RDR_ABORT 0x72 |
||
134 | #define USB_CCID_PC_TO_RDR_SET_DATA_RATE_AND_CLOCK_FREQUENCY 0x73 |
||
135 | |||
136 | #define USB_CCID_RDR_TO_PC_DATA_BLOCK 0x80 |
||
137 | #define USB_CCID_RDR_TO_PC_SLOT_STATUS 0x81 |
||
138 | #define USB_CCID_RDR_TO_PC_PARAMETERS 0x82 |
||
139 | #define USB_CCID_RDR_TO_PC_ESCAPE 0x83 |
||
140 | #define USB_CCID_RDR_TO_PC_DATA_RATE_AND_CLOCK_FREQUENCY 0x84 |
||
141 | |||
142 | //CCID Errors |
||
143 | #define USB_CCID_CMD_ABORTED 0xFF |
||
144 | #define USB_CCID_ICC_MUTE 0xFE |
||
145 | #define USB_CCID_XFR_PARITY_ERROR 0xFD |
||
146 | #define USB_CCID_XFR_OVERRUN 0xFC |
||
147 | #define USB_CCID_HW_ERROR 0xFB |
||
148 | #define USB_CCID_BAD_ATR_TS 0xF8 |
||
149 | #define USB_CCID_BAD_ATR_TCK 0xF7 |
||
150 | #define USB_CCID_ICC_PROTOCOL_NOT_SUPPORTED 0xF6 |
||
151 | #define USB_CCID_ICC_CLASS_NOT_SUPPORTED 0xF5 |
||
152 | #define USB_CCID_PROCEDURE_BYTE_CONFLICT 0xF4 |
||
153 | #define USB_CCID_DEACTIVATED_PROTOCOL 0xF3 |
||
154 | #define USB_CCID_BUSY_WITH_AUTO_SEQUENCE 0xF2 |
||
155 | #define USB_CCID_PIN_TIMEOUT 0xF0 |
||
156 | #define USB_CCID_PIN_CANCELLED 0xEF |
||
157 | #define USB_CCID_CMD_SLOT_BUSY 0xE0 |
||
158 | #define USB_CCID_CMD_NOT_SUPPORTED 0x00 |
||
159 | |||
160 | |||
161 | /****************************************************************************** |
||
162 | Function: |
||
163 | void mUSBCCIDBulkInRam(BYTE *pData, BYTE len) |
||
164 | |||
165 | Description: |
||
166 | Use this macro to transfer data located in data memory. |
||
167 | Use this macro when: |
||
168 | 1. Data stream is not null-terminated |
||
169 | 2. Transfer length is known |
||
170 | Remember: usbCcidBulkInTrfState must == USB_CCID_BULK_IN_READY |
||
171 | Unexpected behavior will occur if this function is called when |
||
172 | usbCcidBulkInTrfState != USB_CCID_BULK_IN_READY |
||
173 | |||
174 | PreCondition: |
||
175 | usbCcidBulkInTrfState must be in the USB_CCID_BULK_IN_READY state. |
||
176 | |||
177 | Paramters: |
||
178 | pDdata : Pointer to the starting location of data bytes |
||
179 | len : Number of bytes to be transferred |
||
180 | |||
181 | Return Values: |
||
182 | None |
||
183 | |||
184 | Remarks: |
||
185 | This macro only handles the setup of the transfer. The |
||
186 | actual transfer is handled by USBCCIDBulkInService(). |
||
187 | |||
188 | *****************************************************************************/ |
||
189 | #define mUSBCCIDBulkInRam(pData,len) \ |
||
190 | { \ |
||
191 | pCCIDSrc.bRam = pData; \ |
||
192 | usbCcidBulkInLen = len; \ |
||
193 | usbCcidBulkInTrfState = USB_CCID_BULK_IN_BUSY; \ |
||
194 | } |
||
195 | |||
196 | |||
197 | /** E X T E R N S ************************************************************/ |
||
198 | extern volatile CTRL_TRF_SETUP SetupPkt; |
||
199 | |||
200 | |||
201 | extern USB_HANDLE usbCcidBulkOutHandle; |
||
202 | extern USB_HANDLE usbCcidBulkInHandle; |
||
203 | extern USB_HANDLE usbCcidInterruptInHandle; |
||
204 | extern unsigned char usbCcidBulkOutEndpoint[USB_EP_SIZE]; //User application buffer for receiving and holding OUT packets sent from the host |
||
205 | extern unsigned char usbCcidBulkInEndpoint[USB_EP_SIZE]; //User application buffer for sending IN packets to the host |
||
206 | |||
207 | /** Section: PUBLIC PROTOTYPES **********************************************/ |
||
208 | void USBCheckCCIDRequest(void); |
||
209 | void USBCCIDInitEP(void); |
||
210 | void USBCCIDBulkInService(void); |
||
211 | void USBCCIDSendDataToHost(BYTE *pData, WORD len); |
||
212 | |||
213 | /** Section: STRUCTURES **********************************************/ |
||
214 | typedef union { |
||
215 | BYTE CCID_BulkOutBuffer[271]; |
||
216 | BYTE CCID_BulkInBuffer[267]; |
||
217 | } USB_CCID_BUFFER; |
||
218 | |||
219 | #endif //CCID_H |
Powered by WebSVN v2.8.3