?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik /*******************************************************************************
2 File Information:
3 FileName: usb_function_hid.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 Company’s 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 Summary:
36 This file contains all of functions, macros, definitions, variables,
37 datatypes, etc. that are required for usage with the HID function
38 driver. This file should be included in projects that use the HID
39 \function driver. This file should also be included into the
40 usb_descriptors.c file and any other user file that requires access to the
41 HID interface.
42  
43  
44  
45 This file is located in the "\<Install Directory\>\\Microchip\\Include\\USB"
46 directory.
47  
48 Description:
49 USB HID Function Driver File
50  
51 This file contains all of functions, macros, definitions, variables,
52 datatypes, etc. that are required for usage with the HID function
53 driver. This file should be included in projects that use the HID
54 \function driver. This file should also be included into the
55 usb_descriptors.c file and any other user file that requires access to the
56 HID interface.
57  
58 This file is located in the "\<Install Directory\>\\Microchip\\Include\\USB"
59 directory.
60  
61 When including this file in a new project, this file can either be
62 referenced from the directory in which it was installed or copied
63 directly into the user application folder. If the first method is
64 chosen to keep the file located in the folder in which it is installed
65 then include paths need to be added so that the library and the
66 application both know where to reference each others files. If the
67 application folder is located in the same folder as the Microchip
68 folder (like the current demo folders), then the following include
69 paths need to be added to the application's project:
70  
71 ..\\..\\Microchip\\Include
72 .
73  
74 If a different directory structure is used, modify the paths as
75 required. An example using absolute paths instead of relative paths
76 would be the following:
77  
78 C:\\Microchip Solutions\\Microchip\\Include
79  
80 C:\\Microchip Solutions\\My Demo Application
81  
82  
83 Change History:
84 Rev Description
85 ---- ------------------------------------------
86 1.0 Initial release
87 2.1 Updated for simplicity and to use common
88 coding style
89 2.6 Minor changes in defintions
90 2.6a- No change
91 2.7a
92 *******************************************************************/
93 #ifndef HID_H
94 #define HID_H
95 //DOM-IGNORE-END
96  
97 /** INCLUDES *******************************************************/
98  
99 /** DEFINITIONS ****************************************************/
100  
101 /* Class-Specific Requests */
102 #define GET_REPORT 0x01
103 #define GET_IDLE 0x02
104 #define GET_PROTOCOL 0x03
105 #define SET_REPORT 0x09
106 #define SET_IDLE 0x0A
107 #define SET_PROTOCOL 0x0B
108  
109 /* Class Descriptor Types */
110 #define DSC_HID 0x21
111 #define DSC_RPT 0x22
112 #define DSC_PHY 0x23
113  
114 /* Protocol Selection */
115 #define BOOT_PROTOCOL 0x00
116 #define RPT_PROTOCOL 0x01
117  
118 /* HID Interface Class Code */
119 #define HID_INTF 0x03
120  
121 /* HID Interface Class SubClass Codes */
122 #define BOOT_INTF_SUBCLASS 0x01
123  
124 /* HID Interface Class Protocol Codes */
125 #define HID_PROTOCOL_NONE 0x00
126 #define HID_PROTOCOL_KEYBOARD 0x01
127 #define HID_PROTOCOL_MOUSE 0x02
128  
129  
130 /********************************************************************
131 Function:
132 BOOL HIDTxHandleBusy(USB_HANDLE handle)
133  
134 Summary:
135 Retreives the status of the buffer ownership
136  
137 Description:
138 Retreives the status of the buffer ownership. This function will
139 indicate if the previous transfer is complete or not.
140  
141 This function will take the input handle (pointer to a BDT entry) and
142 will check the UOWN bit. If the UOWN bit is set then that indicates
143 that the transfer is not complete and the USB module still owns the data
144 memory. If the UOWN bit is clear that means that the transfer is
145 complete and that the CPU now owns the data memory.
146  
147 For more information about the BDT, please refer to the appropriate
148 datasheet for the device in use.
149  
150 Typical Usage:
151 <code>
152 //make sure that the last transfer isn't busy by checking the handle
153 if(!HIDTxHandleBusy(USBInHandle))
154 {
155 //Send the data contained in the ToSendDataBuffer[] array out on
156 // endpoint HID_EP
157 USBInHandle = HIDTxPacket(HID_EP,(BYTE*)&ToSendDataBuffer[0],sizeof(ToSendDataBuffer));
158 }
159 </code>
160  
161 PreCondition:
162 None.
163  
164 Parameters:
165 USB_HANDLE handle - the handle for the transfer in question.
166 The handle is returned by the HIDTxPacket() and HIDRxPacket()
167 functions. Please insure that USB_HANDLE objects are initialized
168 to NULL.
169  
170 Return Values:
171 TRUE - the HID handle is still busy
172 FALSE - the HID handle is not busy and is ready to send
173 additional data.
174  
175 Remarks:
176 None
177  
178 *******************************************************************/
179 #define HIDTxHandleBusy(handle) USBHandleBusy(handle)
180  
181 /********************************************************************
182 Function:
183 BOOL HIDRxHandleBusy(USB_HANDLE handle)
184  
185 Summary:
186 Retreives the status of the buffer ownership
187  
188 Description:
189 Retreives the status of the buffer ownership. This function will
190 indicate if the previous transfer is complete or not.
191  
192 This function will take the input handle (pointer to a BDT entry) and
193 will check the UOWN bit. If the UOWN bit is set then that indicates
194 that the transfer is not complete and the USB module still owns the data
195 memory. If the UOWN bit is clear that means that the transfer is
196 complete and that the CPU now owns the data memory.
197  
198 For more information about the BDT, please refer to the appropriate
199 datasheet for the device in use.
200  
201 Typical Usage:
202 <code>
203 if(!HIDRxHandleBusy(USBOutHandle))
204 {
205 //The data is available in the buffer that was specified when the
206 // HIDRxPacket() was called.
207 }
208 </code>
209  
210 PreCondition:
211 None
212  
213 Parameters:
214 None
215  
216 Return Values:
217 TRUE - the HID handle is still busy
218 FALSE - the HID handle is not busy and is ready to receive
219 additional data.
220  
221 Remarks:
222 None
223  
224 *******************************************************************/
225 #define HIDRxHandleBusy(handle) USBHandleBusy(handle)
226  
227 /********************************************************************
228 Function:
229 USB_HANDLE HIDTxPacket(BYTE ep, BYTE* data, WORD len)
230  
231 Summary:
232 Sends the specified data out the specified endpoint
233  
234 Description:
235 This function sends the specified data out the specified
236 endpoint and returns a handle to the transfer information.
237  
238 Typical Usage:
239 <code>
240 //make sure that the last transfer isn't busy by checking the handle
241 if(!HIDTxHandleBusy(USBInHandle))
242 {
243 //Send the data contained in the ToSendDataBuffer[] array out on
244 // endpoint HID_EP
245 USBInHandle = HIDTxPacket(HID_EP,(BYTE*)&ToSendDataBuffer[0],sizeof(ToSendDataBuffer));
246 }
247 </code>
248  
249 PreCondition:
250 None
251  
252 Parameters:
253 ep - the endpoint you want to send the data out of
254 data - pointer to the data that you wish to send
255 len - the length of the data that you wish to send
256  
257 Return Values:
258 USB_HANDLE - a handle for the transfer. This information
259 should be kept to track the status of the transfer
260  
261 Remarks:
262 None
263  
264 *******************************************************************/
265 #define HIDTxPacket USBTxOnePacket
266  
267 /********************************************************************
268 Function:
269 USB_HANDLE HIDRxPacket(BYTE ep, BYTE* data, WORD len)
270  
271 Summary:
272 Receives the specified data out the specified endpoint
273  
274 Description:
275 Receives the specified data out the specified endpoint.
276  
277 Typical Usage:
278 <code>
279 //Read 64-bytes from endpoint HID_EP, into the ReceivedDataBuffer array.
280 // Make sure to save the return handle so that we can check it later
281 // to determine when the transfer is complete.
282 USBOutHandle = HIDRxPacket(HID_EP,(BYTE*)&ReceivedDataBuffer,64);
283 </code>
284  
285 PreCondition:
286 None
287  
288 Parameters:
289 ep - the endpoint you want to receive the data into
290 data - pointer to where the data will go when it arrives
291 len - the length of the data that you wish to receive
292  
293 Return Values:
294 USB_HANDLE - a handle for the transfer. This information
295 should be kept to track the status of the transfer
296  
297 Remarks:
298 None
299  
300 *******************************************************************/
301 #define HIDRxPacket USBRxOnePacket
302  
303 // Section: STRUCTURES *********************************************/
304  
305 //USB HID Descriptor header as detailed in section
306 //"6.2.1 HID Descriptor" of the HID class definition specification
307 typedef struct _USB_HID_DSC_HEADER
308 {
309 BYTE bDescriptorType; //offset 9
310 WORD wDscLength; //offset 10
311 } USB_HID_DSC_HEADER;
312  
313 //USB HID Descriptor header as detailed in section
314 //"6.2.1 HID Descriptor" of the HID class definition specification
315 typedef struct _USB_HID_DSC
316 {
317 BYTE bLength; //offset 0
318 BYTE bDescriptorType; //offset 1
319 WORD bcdHID; //offset 2
320 BYTE bCountryCode; //offset 4
321 BYTE bNumDsc; //offset 5
322  
323  
324 //USB_HID_DSC_HEADER hid_dsc_header[HID_NUM_OF_DSC];
325 /* HID_NUM_OF_DSC is defined in usbcfg.h */
326  
327 } USB_HID_DSC;
328  
329 /** Section: EXTERNS ********************************************************/
330 extern volatile unsigned char hid_report_in[HID_INT_IN_EP_SIZE];
331 extern volatile unsigned char hid_report_out[HID_INT_OUT_EP_SIZE];
332 extern volatile CTRL_TRF_SETUP SetupPkt;
333 extern ROM BYTE configDescriptor1[];
334 extern volatile BYTE CtrlTrfData[USB_EP0_BUFF_SIZE];
335  
336 #if !defined(__USB_DESCRIPTORS_C)
337 extern ROM struct{BYTE report[HID_RPT01_SIZE];}hid_rpt01;
338 #endif
339  
340 /** Section: PUBLIC PROTOTYPES **********************************************/
341 void USBCheckHIDRequest(void);
342  
343 #endif //HID_H
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3