1 |
/*---------------------------------------------------------------------------- |
---|
2 |
* U S B - K e r n e l |
---|
3 |
*---------------------------------------------------------------------------- |
---|
4 |
* Name: HIDUSER.C |
---|
5 |
* Purpose: HID Custom User Module |
---|
6 |
* Version: V1.10 |
---|
7 |
*---------------------------------------------------------------------------- |
---|
8 |
* This file is part of the uVision/ARM development tools. |
---|
9 |
* This software may only be used under the terms of a valid, current, |
---|
10 |
* end user licence from KEIL for a compatible version of KEIL software |
---|
11 |
* development tools. Nothing else gives you the right to use it. |
---|
12 |
* |
---|
13 |
* Copyright (c) 2005-2006 Keil Software. |
---|
14 |
*---------------------------------------------------------------------------*/ |
---|
15 |
|
---|
16 |
#include "type.h" |
---|
17 |
|
---|
18 |
#include "usb.h" |
---|
19 |
#include "hid.h" |
---|
20 |
#include "usbcfg.h" |
---|
21 |
#include "usbcore.h" |
---|
22 |
#include "hiduser.h" |
---|
23 |
|
---|
24 |
#include "demo.h" |
---|
25 |
|
---|
26 |
|
---|
27 |
BYTE HID_Protocol; |
---|
28 |
BYTE HID_IdleTime[HID_REPORT_NUM]; |
---|
29 |
|
---|
30 |
|
---|
31 |
/* |
---|
32 |
* HID Get Report Request Callback |
---|
33 |
* Called automatically on HID Get Report Request |
---|
34 |
* Parameters: None (global SetupPacket and EP0Buf) |
---|
35 |
* Return Value: TRUE - Success, FALSE - Error |
---|
36 |
*/ |
---|
37 |
|
---|
38 |
BOOL HID_GetReport (void) { |
---|
39 |
|
---|
40 |
/* ReportID = SetupPacket.wValue.WB.L; */ |
---|
41 |
switch (SetupPacket.wValue.WB.H) { |
---|
42 |
case HID_REPORT_INPUT: |
---|
43 |
GetInReport(); |
---|
44 |
EP0Buf[0] = InReport; |
---|
45 |
break; |
---|
46 |
case HID_REPORT_OUTPUT: |
---|
47 |
return (FALSE); /* Not Supported */ |
---|
48 |
case HID_REPORT_FEATURE: |
---|
49 |
/* EP0Buf[] = ...; */ |
---|
50 |
/* break; */ |
---|
51 |
return (FALSE); /* Not Supported */ |
---|
52 |
} |
---|
53 |
return (TRUE); |
---|
54 |
} |
---|
55 |
|
---|
56 |
|
---|
57 |
/* |
---|
58 |
* HID Set Report Request Callback |
---|
59 |
* Called automatically on HID Set Report Request |
---|
60 |
* Parameters: None (global SetupPacket and EP0Buf) |
---|
61 |
* Return Value: TRUE - Success, FALSE - Error |
---|
62 |
*/ |
---|
63 |
|
---|
64 |
BOOL HID_SetReport (void) { |
---|
65 |
|
---|
66 |
/* ReportID = SetupPacket.wValue.WB.L; */ |
---|
67 |
switch (SetupPacket.wValue.WB.H) { |
---|
68 |
case HID_REPORT_INPUT: |
---|
69 |
return (FALSE); /* Not Supported */ |
---|
70 |
case HID_REPORT_OUTPUT: |
---|
71 |
OutReport = EP0Buf[0]; |
---|
72 |
SetOutReport(); |
---|
73 |
break; |
---|
74 |
case HID_REPORT_FEATURE: |
---|
75 |
return (FALSE); /* Not Supported */ |
---|
76 |
} |
---|
77 |
return (TRUE); |
---|
78 |
} |
---|
79 |
|
---|
80 |
|
---|
81 |
/* |
---|
82 |
* HID Get Idle Request Callback |
---|
83 |
* Called automatically on HID Get Idle Request |
---|
84 |
* Parameters: None (global SetupPacket and EP0Buf) |
---|
85 |
* Return Value: TRUE - Success, FALSE - Error |
---|
86 |
*/ |
---|
87 |
|
---|
88 |
BOOL HID_GetIdle (void) { |
---|
89 |
|
---|
90 |
EP0Buf[0] = HID_IdleTime[SetupPacket.wValue.WB.L]; |
---|
91 |
return (TRUE); |
---|
92 |
} |
---|
93 |
|
---|
94 |
|
---|
95 |
/* |
---|
96 |
* HID Set Idle Request Callback |
---|
97 |
* Called automatically on HID Set Idle Request |
---|
98 |
* Parameters: None (global SetupPacket) |
---|
99 |
* Return Value: TRUE - Success, FALSE - Error |
---|
100 |
*/ |
---|
101 |
|
---|
102 |
BOOL HID_SetIdle (void) { |
---|
103 |
|
---|
104 |
HID_IdleTime[SetupPacket.wValue.WB.L] = SetupPacket.wValue.WB.H; |
---|
105 |
|
---|
106 |
/* Idle Handling if needed */ |
---|
107 |
/* ... */ |
---|
108 |
|
---|
109 |
return (TRUE); |
---|
110 |
} |
---|
111 |
|
---|
112 |
|
---|
113 |
/* |
---|
114 |
* HID Get Protocol Request Callback |
---|
115 |
* Called automatically on HID Get Protocol Request |
---|
116 |
* Parameters: None (global SetupPacket) |
---|
117 |
* Return Value: TRUE - Success, FALSE - Error |
---|
118 |
*/ |
---|
119 |
|
---|
120 |
BOOL HID_GetProtocol (void) { |
---|
121 |
|
---|
122 |
EP0Buf[0] = HID_Protocol; |
---|
123 |
return (TRUE); |
---|
124 |
} |
---|
125 |
|
---|
126 |
|
---|
127 |
/* |
---|
128 |
* HID Set Protocol Request Callback |
---|
129 |
* Called automatically on HID Set Protocol Request |
---|
130 |
* Parameters: None (global SetupPacket) |
---|
131 |
* Return Value: TRUE - Success, FALSE - Error |
---|
132 |
*/ |
---|
133 |
|
---|
134 |
BOOL HID_SetProtocol (void) { |
---|
135 |
|
---|
136 |
HID_Protocol = SetupPacket.wValue.WB.L; |
---|
137 |
|
---|
138 |
/* Protocol Handling if needed */ |
---|
139 |
/* ... */ |
---|
140 |
|
---|
141 |
return (TRUE); |
---|
142 |
} |
---|