Logo
MSP430USBDevelopersPackage_5_20_06_02
UsbHid.h
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 /*
33  * ======== UsbHid.h ========
34  */
35 #include <stdint.h>
36 
37 #ifndef _UsbHid_H_
38 #define _UsbHid_H_
39 
40 #ifdef __cplusplus
41 extern "C"
42 {
43 #endif
44 
45 /*----------------------------------------------------------------------------
46  * The following function names and macro names are deprecated. These were
47  * updated to new names to follow OneMCU naming convention.
48  +---------------------------------------------------------------------------*/
49 #ifndef DEPRECATED
50 #define kUSBHID_sendStarted USBHID_SEND_STARTED
51 #define kUSBHID_sendComplete USBHID_SEND_COMPLETE
52 #define kUSBHID_intfBusyError USBHID_INTERFACE_BUSY_ERROR
53 #define kUSBHID_receiveStarted USBHID_RECEIVE_STARTED
54 #define kUSBHID_receiveCompleted USBHID_RECEIVE_COMPLETED
55 #define kUSBHID_receiveInProgress USBHID_RECEIVE_IN_PROGRESS
56 #define kUSBHID_generalError USBHID_GENERAL_ERROR
57 #define kUSBHID_busNotAvailable USBHID_BUS_NOT_AVAILABLE
58 #define kUSBHID_waitingForSend USBHID_WAITING_FOR_SEND
59 #define kUSBHID_waitingForReceive USBHID_WAITING_FOR_RECEIVE
60 #define kUSBHID_dataWaiting USBHID_DATA_WAITING
61 #define kUSB_allHidEvents USBHID_ALL_HID_EVENTS
62 #define kUSBHID_noDataWaiting USBHID_NO_DATA_WAITING
63 
64 #define USBHID_intfStatus USBHID_getInterfaceStatus
65 #define USBHID_bytesInUSBBuffer USBHID_getBytesInUSBBuffer
66 
67 #endif
68 
69 
70 
71 #define USBHID_SEND_STARTED 0x01
72 #define USBHID_SEND_COMPLETE 0x02
73 #define USBHID_INTERFACE_BUSY_ERROR 0x03
74 #define USBHID_RECEIVE_STARTED 0x04
75 #define USBHID_RECEIVE_COMPLETED 0x05
76 #define USBHID_RECEIVE_IN_PROGRESS 0x06
77 #define USBHID_GENERAL_ERROR 0x07
78 #define USBHID_BUS_NOT_AVAILABLE 0x08
79 #define HID_BOOT_PROTOCOL 0x00
80 #define HID_REPORT_PROTOCOL 0x01
81 //returned by USBHID_rejectData() if no data pending
82 #define USBHID_NO_DATA_WAITING 1
83 #define USBHID_WAITING_FOR_SEND 0x01
84 #define USBHID_WAITING_FOR_RECEIVE 0x02
85 #define USBHID_DATA_WAITING 0x04
86 #define USBHID_BUS_NOT_AVAILABLE 0x08
87 #define USBHID_ALL_HID_EVENTS 0xFF
88 
89 #define USBHID_handleGetReport USBHID_handleEP0GetReport
90 #define USBHID_handleSetReport USBHID_handleEP0SetReport
91 #define USBHID_handleSetReportDataAvailable USBHID_handleEP0SetReportDataAvailable
92 #define USBHID_handleSetReportDataAvailable USBHID_handleEP0SetReportDataAvailable
93 
94 
95 /*----------------------------------------------------------------------------
96  * These functions can be used in application
97  +----------------------------------------------------------------------------*/
98 
99 //*****************************************************************************
100 //
103 //
104 //******************************************************************************
105 
106 //*****************************************************************************
107 //
130 //
131 //*****************************************************************************
132 extern uint8_t USBHID_sendReport (const uint8_t * reportData, uint8_t intfNum);
133 
134 //*****************************************************************************
135 //
162 //
163 //*****************************************************************************
164 uint8_t USBHID_receiveReport (uint8_t * reportData, uint8_t intfNum);
165 
166 //*****************************************************************************
167 //
208 //
209 //*****************************************************************************
210 uint8_t USBHID_sendData (const uint8_t* data, uint16_t size, uint8_t intfNum);
211 
212 
213 //*****************************************************************************
214 //
254 //
255 //*****************************************************************************
256 uint8_t USBHID_receiveData (uint8_t* data, uint16_t size, uint8_t intfNum);
257 
258 
259 //*****************************************************************************
260 //
283 //
284 //*****************************************************************************
285 uint8_t USBHID_abortReceive (uint16_t* size, uint8_t intfNum);
286 
287 
288 //*****************************************************************************
289 //
303 //
304 //*****************************************************************************
305 uint8_t USBHID_rejectData (uint8_t intfNum);
306 
307 
308 //*****************************************************************************
309 //
327 //
328 //*****************************************************************************
329 uint8_t USBHID_abortSend (uint16_t* size, uint8_t intfNum);
330 
331 //*****************************************************************************
332 //
365 //
366 //*****************************************************************************
367 uint8_t USBHID_getInterfaceStatus (uint8_t intfNum, uint16_t* bytesSent, uint16_t* bytesReceived);
368 
369 //*****************************************************************************
370 //
383 //
384 //*****************************************************************************
385 uint8_t USBHID_getBytesInUSBBuffer (uint8_t intfNum);
386 
387 //******************************************************************************
388 //
389 // Close the Doxygen group.
391 //
392 //******************************************************************************
393 
394 /*----------------------------------------------------------------------------
395  * Event-Handling routines
396  +----------------------------------------------------------------------------*/
397 
398 //*****************************************************************************
399 //
402 //
403 //******************************************************************************
404 
405 //*****************************************************************************
406 //
436 //
437 //*****************************************************************************
438 uint8_t USBHID_handleDataReceived (uint8_t intfNum);
439 
440 //*****************************************************************************
441 //
459 //
460 //*****************************************************************************
461 uint8_t USBHID_handleSendCompleted (uint8_t intfNum);
462 
463 //*****************************************************************************
464 //
484 //
485 //*****************************************************************************
486 uint8_t USBHID_handleReceiveCompleted (uint8_t intfNum);
487 
488 
489 //*****************************************************************************
490 //
506 //
507 //*****************************************************************************
508 uint8_t USBHID_handleBootProtocol (uint8_t protocol, uint8_t intfnum);
509 
510 //*****************************************************************************
511 //
527 //
528 //*****************************************************************************
529 uint8_t *USBHID_handleEP0SetReport (uint8_t reportType, uint8_t reportId,
530  uint16_t requestedLength,
531  uint8_t intfnum);
532 //*****************************************************************************
533 //
543 //
544 //*****************************************************************************
545 uint8_t USBHID_handleEP0SetReportDataAvailable (uint8_t intfnum);
546 
547 //*****************************************************************************
548 //
563 //
564 //*****************************************************************************
565 uint8_t *USBHID_handleEP0GetReport (uint8_t reportType, uint8_t reportId,
566  uint16_t requestedLength,
567  uint8_t intfnum);
568 
569 //******************************************************************************
570 //
571 // Close the Doxygen group.
573 //
574 //******************************************************************************
575 
576 #ifdef __cplusplus
577 }
578 #endif
579 #endif //_UsbHid_H_
uint8_t USBHID_handleReceiveCompleted(uint8_t intfNum)
uint8_t USBHID_getBytesInUSBBuffer(uint8_t intfNum)
uint8_t USBHID_handleBootProtocol(uint8_t protocol, uint8_t intfnum)
uint8_t USBHID_rejectData(uint8_t intfNum)
uint8_t USBHID_receiveReport(uint8_t *reportData, uint8_t intfNum)
uint8_t USBHID_handleSendCompleted(uint8_t intfNum)
uint8_t USBHID_getInterfaceStatus(uint8_t intfNum, uint16_t *bytesSent, uint16_t *bytesReceived)
uint8_t USBHID_handleDataReceived(uint8_t intfNum)
uint8_t * USBHID_handleEP0SetReport(uint8_t reportType, uint8_t reportId, uint16_t requestedLength, uint8_t intfnum)
uint8_t USBHID_abortSend(uint16_t *size, uint8_t intfNum)
uint8_t * USBHID_handleEP0GetReport(uint8_t reportType, uint8_t reportId, uint16_t requestedLength, uint8_t intfnum)
uint8_t USBHID_sendData(const uint8_t *data, uint16_t size, uint8_t intfNum)
uint8_t USBHID_handleEP0SetReportDataAvailable(uint8_t intfnum)
uint8_t USBHID_sendReport(const uint8_t *reportData, uint8_t intfNum)
uint8_t USBHID_abortReceive(uint16_t *size, uint8_t intfNum)
uint8_t USBHID_receiveData(uint8_t *data, uint16_t size, uint8_t intfNum)