USBLib API Guide  1.00.00.01
usbdhidmouse.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // usbdhidmouse.h - Public header file for the USB HID Mouse device class
4 // driver
5 //
6 // Copyright (c) 2008-2017 Texas Instruments Incorporated. All rights reserved.
7 // Software License Agreement
8 //
9 // Texas Instruments (TI) is supplying this software for use solely and
10 // exclusively on TI's microcontroller products. The software is owned by
11 // TI and/or its suppliers, and is protected under applicable copyright
12 // laws. You may not combine this software with "viral" open-source
13 // software in order to form a larger program.
14 //
15 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
16 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
17 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
19 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
20 // DAMAGES, FOR ANY REASON WHATSOEVER.
21 //
22 //*****************************************************************************
23 
24 #ifndef __USBDHIDMOUSE_H__
25 #define __USBDHIDMOUSE_H__
26 
27 //*****************************************************************************
28 //
29 // If building with a C++ compiler, make all of the definitions in this header
30 // have a C binding.
31 //
32 //*****************************************************************************
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37 
38 //*****************************************************************************
39 //
42 //
43 //*****************************************************************************
44 
45 //*****************************************************************************
46 //
47 // PRIVATE
48 //
49 // The first few sections of this header are private defines that are used by
50 // the USB HID mouse code and are here only to help with the application
51 // allocating the correct amount of memory for the HID mouse device code.
52 //
53 //*****************************************************************************
54 
55 //*****************************************************************************
56 //
57 // PRIVATE
58 //
59 // The size of the mouse input report sent to the host.
60 //
61 //*****************************************************************************
62 #define MOUSE_REPORT_SIZE 3
63 
64 //*****************************************************************************
65 //
66 // PRIVATE
67 //
68 // This enumeration holds the various states that the mouse can be in during
69 // normal operation.
70 //
71 //*****************************************************************************
72 typedef enum
73 {
74  //
75  // Unconfigured.
76  //
78 
79  //
80  // No keys to send and not waiting on data.
81  //
83 
84  //
85  // Waiting on report data from the host.
86  //
88 
89  //
90  // Waiting on data to be sent out.
91  //
93 }
95 
96 //*****************************************************************************
97 //
98 // PRIVATE
99 //
100 // This structure provides the private instance data structure for the USB
101 // HID Mouse device. This structure forms the RAM workspace used by each
102 // instance of the mouse.
103 //
104 //*****************************************************************************
105 typedef struct
106 {
107  //
108  // The USB configuration number set by the host or 0 of the device is
109  // currently unconfigured.
110  //
112 
113  //
114  // The protocol requested by the host, USB_HID_PROTOCOL_BOOT or
115  // USB_HID_PROTOCOL_REPORT.
116  //
117  uint8_t ui8Protocol;
118 
119  //
120  // A buffer used to hold the last input report sent to the host.
121  //
122  uint8_t pui8Report[MOUSE_REPORT_SIZE];
123 
124  //
125  // The current state of the mouse interrupt IN endpoint.
126  //
127  volatile tMouseState iMouseState;
128 
129  //
130  // The idle timeout control structure for our input report. This is
131  // required by the lower level HID driver.
132  //
134 
135  //
136  // This is needed for the lower level HID driver.
137  //
139 }
141 
142 //*****************************************************************************
143 //
146 //
147 //*****************************************************************************
148 typedef struct
149 {
150  //
152  //
153  const uint16_t ui16VID;
154 
155  //
157  //
158  const uint16_t ui16PID;
159 
160  //
162  //
163  const uint16_t ui16MaxPowermA;
164 
165  //
169  //
170  const uint8_t ui8PwrAttributes;
171 
172  //
175  //
177 
178  //
181  //
182  void *pvCBData;
183 
184  //
195  //
196  const uint8_t * const *ppui8StringDescriptors;
197 
198  //
201  //
202  const uint32_t ui32NumStringDescriptors;
203 
204  //
208  //
210 }
212 
213 
214 
215 //*****************************************************************************
216 //
222 //
223 //*****************************************************************************
224 typedef struct
225 {
226 
227  //
229  //
230  uint8_t buttons;
231 
232  //
234  //
235  uint8_t dX;
236 
237  //
239  //
240  uint8_t dY;
241 
242 
243 }PACKED
244 tMouseDescriptorReport;
245 //*****************************************************************************
246 //
248 //
249 //*****************************************************************************
250 #define MOUSE_SUCCESS 0
251 
252 //*****************************************************************************
253 //
257 //
258 //*****************************************************************************
259 #define MOUSE_ERR_TX_ERROR 2
260 
261 //*****************************************************************************
262 //
266 //
267 //*****************************************************************************
268 #define MOUSE_ERR_NOT_CONFIGURED \
269  4
270 
271 //*****************************************************************************
272 //
275 //
276 //*****************************************************************************
277 #define MOUSE_REPORT_BUTTON_1 0x01
278 
279 //*****************************************************************************
280 //
283 //
284 //*****************************************************************************
285 #define MOUSE_REPORT_BUTTON_2 0x02
286 
287 //*****************************************************************************
288 //
291 //
292 //*****************************************************************************
293 #define MOUSE_REPORT_BUTTON_3 0x04
294 
295 //*****************************************************************************
296 //
297 // API Function Prototypes
298 //
299 //*****************************************************************************
300 extern void *USBDHIDMouseInit(uint32_t ui32Index,
301  tUSBDHIDMouseDevice *psMouseDevice);
302 extern void *USBDHIDMouseCompositeInit(uint32_t ui32Index,
303  tUSBDHIDMouseDevice *psMouseDevice,
304  tCompositeEntry *psCompEntry);
305 extern void USBDHIDMouseTerm(void *pvMouseDevice);
306 extern void *USBDHIDMouseSetCBData(void *pvMouseDevice, void *pvCBData);
307 extern uint32_t USBDHIDMouseStateChange(void *pvMouseDevice, int8_t i8DeltaX,
308  int8_t i8DeltaY, uint8_t ui8Buttons);
309 extern void USBDHIDMousePowerStatusSet(void *pvMouseDevice,
310  uint8_t ui8Power);
311 extern bool USBDHIDMouseRemoteWakeupRequest(void *pvMouseDevice);
312 
313 //*****************************************************************************
314 //
315 // Close the Doxygen group.
317 //
318 //*****************************************************************************
319 
320 //*****************************************************************************
321 //
322 // Mark the end of the C bindings section for C++ compilers.
323 //
324 //*****************************************************************************
325 #ifdef __cplusplus
326 }
327 #endif
328 
329 #endif // __USBDHIDMOUSE_H__
Definition: usbdhid.h:798
const uint8_t ui8PwrAttributes
Definition: usbdhidmouse.h:170
void * USBDHIDMouseSetCBData(void *pvMouseDevice, void *pvCBData)
Definition: usbdhidmouse.c:775
void USBDHIDMouseTerm(void *pvMouseDevice)
Definition: usbdhidmouse.c:725
const uint8_t *const * ppui8StringDescriptors
Definition: usbdhidmouse.h:196
const uint16_t ui16VID
The vendor ID that this device is to present in the device descriptor.
Definition: usbdhidmouse.h:153
const tUSBCallback pfnCallback
Definition: usbdhidmouse.h:176
uint8_t ui8USBConfigured
Definition: usbdhidmouse.h:111
tUSBDHIDDevice sHIDDevice
Definition: usbdhidmouse.h:138
Definition: usbdevice.h:135
uint8_t buttons
8-bit value. Mouse buttons
Definition: usbdhidmouse.h:230
Definition: usbdhid.h:839
Definition: usbdhidmouse.h:87
void * pvCBData
Definition: usbdhidmouse.h:182
uint8_t dY
8-bit value. Mouse movement in Y-coordinate
Definition: usbdhidmouse.h:240
uint32_t USBDHIDMouseStateChange(void *pvMouseDevice, int8_t i8DeltaX, int8_t i8DeltaY, uint8_t ui8Buttons)
Definition: usbdhidmouse.c:836
const uint32_t ui32NumStringDescriptors
Definition: usbdhidmouse.h:202
uint8_t dX
8-bit value. Mouse movement in X-coordinate
Definition: usbdhidmouse.h:235
const uint16_t ui16MaxPowermA
The maximum power consumption of the device, expressed in milliamps.
Definition: usbdhidmouse.h:163
uint8_t ui8Protocol
Definition: usbdhidmouse.h:117
tHIDMouseInstance sPrivateData
Definition: usbdhidmouse.h:209
void * USBDHIDMouseInit(uint32_t ui32Index, tUSBDHIDMouseDevice *psMouseDevice)
Definition: usbdhidmouse.c:571
uint32_t(* tUSBCallback)(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgParam, void *pvMsgData)
Definition: usblib.h:1220
bool USBDHIDMouseRemoteWakeupRequest(void *pvMouseDevice)
Definition: usbdhidmouse.c:976
Definition: usbdhidmouse.h:77
volatile tMouseState iMouseState
Definition: usbdhidmouse.h:127
Definition: usbdhidmouse.h:92
tMouseState
Definition: usbdhidmouse.h:72
#define MOUSE_REPORT_SIZE
Definition: usbdhidmouse.h:62
void USBDHIDMousePowerStatusSet(void *pvMouseDevice, uint8_t ui8Power)
Definition: usbdhidmouse.c:932
Definition: usbdhidmouse.h:82
Definition: usbdhidmouse.h:105
Definition: usbdhidmouse.h:148
tHIDReportIdle sReportIdle
Definition: usbdhidmouse.h:133
const uint16_t ui16PID
The product ID that this device is to present in the device descriptor.
Definition: usbdhidmouse.h:158
void * USBDHIDMouseCompositeInit(uint32_t ui32Index, tUSBDHIDMouseDevice *psMouseDevice, tCompositeEntry *psCompEntry)
Definition: usbdhidmouse.c:642
USB_CDC_GET/SET_LINE_CODING request-specific data.
Definition: usbdhidgamepad.h:217
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale