summaryrefslogtreecommitdiff
path: root/tinyusb/class
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-10-24 15:32:54 +0700
committerhathach <[email protected]>2013-10-24 15:32:54 +0700
commitb71ffe3d5a7b97010b7ac2096271e03dcb35c2dd (patch)
tree512a6798926f074a93701a10a31a6e6721b78e02 /tinyusb/class
parent2076e57d7072bb77c116c3cea51f640081da4aab (diff)
change TUSB_CFG_CONTROLLER0/1_MODE to TUSB_CFG_CONTROLLER_0/1_MODE for clearance
adding configuration docs for tinyusb_config.h document HID mouse & keyboard API
Diffstat (limited to 'tinyusb/class')
-rw-r--r--tinyusb/class/cdc.h686
-rw-r--r--tinyusb/class/hid.h1010
-rw-r--r--tinyusb/class/hid_host.c608
-rw-r--r--tinyusb/class/hid_host.h332
4 files changed, 1365 insertions, 1271 deletions
diff --git a/tinyusb/class/cdc.h b/tinyusb/class/cdc.h
index faa6310fa..7bbeb714f 100644
--- a/tinyusb/class/cdc.h
+++ b/tinyusb/class/cdc.h
@@ -1,343 +1,343 @@
-/**************************************************************************/
-/*!
- @file cdc.h
- @author hathach (tinyusb.org)
-
- @section LICENSE
-
- Software License Agreement (BSD License)
-
- Copyright (c) 2013, hathach (tinyusb.org)
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holders nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This file is part of the tinyusb stack.
-*/
-/**************************************************************************/
-
-/** \file
- * \brief CDC Class Driver
- *
- * \note TBD
- */
-
-/**
- * \addtogroup Group_ClassDriver Class Driver
- * @{
- * \defgroup Group_CDC Communication Device Class
- * @{
- */
-
-#ifndef _TUSB_CDC_H__
-#define _TUSB_CDC_H__
-
-#include "common/common.h"
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-//--------------------------------------------------------------------+
-// CDC COMMUNICATION INTERFACE CLASS
-//--------------------------------------------------------------------+
-enum {
- CDC_COMM_SUBCLASS_DIRECT_LINE_CONTROL_MODEL = 0x01 ,
- CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL ,
- CDC_COMM_SUBCLASS_TELEPHONE_CONTROL_MODEL ,
- CDC_COMM_SUBCLASS_MULTICHANNEL_CONTROL_MODEL ,
- CDC_COMM_SUBCLASS_CAPI_CONTROL_MODEL ,
- CDC_COMM_SUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL ,
- CDC_COMM_SUBCLASS_ATM_NETWORKING_CONTROL_MODEL ,
- CDC_COMM_SUBCLASS_WIRELESS_HANDSET_CONTROL_MODEL ,
- CDC_COMM_SUBCLASS_DEVICE_MANAGEMENT ,
- CDC_COMM_SUBCLASS_MOBILE_DIRECT_LINE_MODEL ,
- CDC_COMM_SUBCLASS_OBEX ,
- CDC_COMM_SUBCLASS_ETHERNET_EMULATION_MODEL
-};
-
-enum {
- CDC_COMM_PROTOCOL_ATCOMMAND = 0x01 , // ITU-T V2.50
- CDC_COMM_PROTOCOL_ATCOMMAND_PCCA_101 ,
- CDC_COMM_PROTOCOL_ATCOMMAND_PCCA_101_AND_ANNEXO ,
- CDC_COMM_PROTOCOL_ATCOMMAND_GSM_707 ,
- CDC_COMM_PROTOCOL_ATCOMMAND_3GPP_27007 ,
- CDC_COMM_PROTOCOL_ATCOMMAND_CDMA , // defined by TIA
- CDC_COMM_PROTOCOL_ETHERNET_EMULATION_MODEL
-};
-
-//------------- SubType Descriptor in COMM Functional Descriptor -------------//
-enum {
- CDC_FUNC_DESC_HEADER = 0x00 ,
- CDC_FUNC_DESC_CALL_MANAGEMENT = 0x01 ,
- CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT = 0x02 ,
- CDC_FUNC_DESC_DIRECT_LINE_MANAGEMENT = 0x03 ,
- CDC_FUNC_DESC_TELEPHONE_RINGER = 0x04 ,
- CDC_FUNC_DESC_TELEPHONE_CALL_AND_LINE_STATE_REPORTING_CAPACITY = 0x05 ,
- CDC_FUNC_DESC_UNION = 0x06 ,
- CDC_FUNC_DESC_COUNTRY_SELECTION = 0x07 ,
- CDC_FUNC_DESC_TELEPHONE_OPERATIONAL_MODES = 0x08 ,
- CDC_FUNC_DESC_USB_TERMINAL = 0x09 ,
- CDC_FUNC_DESC_NETWORK_CHANNEL_TERMINAL = 0x0A ,
- CDC_FUNC_DESC_PROTOCOL_UNIT = 0x0B ,
- CDC_FUNC_DESC_EXTENSION_UNIT = 0x0C ,
- CDC_FUNC_DESC_MULTICHANEL_MANAGEMENT = 0x0D ,
- CDC_FUNC_DESC_CAPI_CONTROL_MANAGEMENT = 0x0E ,
- CDC_FUNC_DESC_ETHERNET_NETWORKING = 0x0F ,
- CDC_FUNC_DESC_ATM_NETWORKING = 0x10 ,
- CDC_FUNC_DESC_WIRELESS_HANDSET_CONTROL_MODEL = 0x11 ,
- CDC_FUNC_DESC_MOBILE_DIRECT_LINE_MODEL = 0x12 ,
- CDC_FUNC_DESC_MOBILE_DIRECT_LINE_MODEL_DETAIL = 0x13 ,
- CDC_FUNC_DESC_DEVICE_MANAGEMENT_MODEL = 0x14 ,
- CDC_FUNC_DESC_OBEX = 0x15 ,
- CDC_FUNC_DESC_COMMAND_SET = 0x16 ,
- CDC_FUNC_DESC_COMMAND_SET_DETAIL = 0x17 ,
- CDC_FUNC_DESC_TELEPHONE_CONTROL_MODEL = 0x18 ,
- CDC_FUNC_DESC_OBEX_SERVICE_IDENTIFIER = 0x19
-};
-
-//--------------------------------------------------------------------+
-// CDC DATA INTERFACE CLASS
-//--------------------------------------------------------------------+
-
-// SUBCLASS code of Data Interface is not used and should/must be zero
-
-enum{
- CDC_DATA_PROTOCOL_ISDN_BRI = 0x30,
- CDC_DATA_PROTOCOL_HDLC = 0x31,
- CDC_DATA_PROTOCOL_TRANSPARENT = 0x32,
- CDC_DATA_PROTOCOL_Q921_MANAGEMENT = 0x50,
- CDC_DATA_PROTOCOL_Q921_DATA_LINK = 0x51,
- CDC_DATA_PROTOCOL_Q921_TEI_MULTIPLEXOR = 0x52,
- CDC_DATA_PROTOCOL_V42BIS_DATA_COMPRESSION = 0x90,
- CDC_DATA_PROTOCOL_EURO_ISDN = 0x91,
- CDC_DATA_PROTOCOL_V24_RATE_ADAPTION_TO_ISDN = 0x92,
- CDC_DATA_PROTOCOL_CAPI_COMMAND = 0x93,
- CDC_DATA_PROTOCOL_HOST_BASED_DRIVER = 0xFD,
- CDC_DATA_PROTOCOL_IN_PROTOCOL_UNIT_FUNCTIONAL_DESCRIPTOR = 0xFE
-};
-
-//--------------------------------------------------------------------+
-// MANAGEMENT ELEMENT REQUEST (CONTROL ENDPOINT)
-//--------------------------------------------------------------------+
-typedef enum {
- SEND_ENCAPSULATED_COMMAND = 0x00,
- GET_ENCAPSULATED_RESPONSE = 0x01,
-
- SET_COMM_FEATURE = 0x02,
- GET_COMM_FEATURE = 0x03,
- CLEAR_COMM_FEATURE = 0x04,
-
- SET_AUX_LINE_STATE = 0x10,
- SET_HOOK_STATE = 0x11,
- PULSE_SETUP = 0x12,
- SEND_PULSE = 0x13,
- SET_PULSE_TIME = 0x14,
- RING_AUX_JACK = 0x15,
-
- SET_LINE_CODING = 0x20,
- GET_LINE_CODING = 0x21,
- SET_CONTROL_LINE_STATE = 0x22,
- SEND_BREAK = 0x23,
-
- SET_RINGER_PARMS = 0x30,
- GET_RINGER_PARMS = 0x31,
- SET_OPERATION_PARMS = 0x32,
- GET_OPERATION_PARMS = 0x33,
- SET_LINE_PARMS = 0x34,
- GET_LINE_PARMS = 0x35,
- DIAL_DIGITS = 0x36,
- SET_UNIT_PARAMETER = 0x37,
- GET_UNIT_PARAMETER = 0x38,
- CLEAR_UNIT_PARAMETER = 0x39,
- GET_PROFILE = 0x3A,
-
- SET_ETHERNET_MULTICAST_FILTERS = 0x40,
- SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x41,
- GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x42,
- SET_ETHERNET_PACKET_FILTER = 0x43,
- GET_ETHERNET_STATISTIC = 0x44,
-
- SET_ATM_DATA_FORMAT = 0x50,
- GET_ATM_DEVICE_STATISTICS = 0x51,
- SET_ATM_DEFAULT_VC = 0x52,
- GET_ATM_VC_STATISTICS = 0x53,
-
- MDLM_SEMANTIC_MODEL = 0x60,
-}cdc_management_request_t;
-
-//--------------------------------------------------------------------+
-// MANAGEMENT ELEMENENT NOTIFICATION (NOTIFICATION ENDPOINT)
-//--------------------------------------------------------------------+
-typedef enum {
- NETWORK_CONNECTION = 0x00,
- RESPONSE_AVAILABLE = 0x01,
-
- AUX_JACK_HOOK_STATE = 0x08,
- RING_DETECT = 0x09,
-
- SERIAL_STATE = 0x20,
-
- CALL_STATE_CHANGE = 0x28,
- LINE_STATE_CHANGE = 0x29,
- CONNECTION_SPEED_CHANGE = 0x2A,
- MDLM_SEMANTIC_MODEL_NOTIFICATION = 0x40,
-}cdc_notification_request_t;
-
-//--------------------------------------------------------------------+
-// FUNCTIONAL DESCRIPTOR
-//--------------------------------------------------------------------+
-typedef ATTR_PACKED_STRUCT(struct) {
- uint8_t bLength ; ///< Size of this descriptor in bytes.
- uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
- uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
- uint16_t bcdCDC ; ///< CDC release number in Binary-Coded Decimal
-}cdc_desc_func_header_t;
-
-typedef ATTR_PACKED_STRUCT(struct) {
- uint8_t bLength ; ///< Size of this descriptor in bytes.
- uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
- uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
- uint8_t bControlInterface ; ///< Interface number of Communication Interface
- uint8_t bSubordinateInterface ; ///< Array of Interface number of Data Interface
-}cdc_desc_func_union_t;
-
-#define cdc_desc_func_union_n_t(no_slave)\
- ATTR_PACKED_STRUCT(struct) { \
- uint8_t bLength ;\
- uint8_t bDescriptorType ;\
- uint8_t bDescriptorSubType ;\
- uint8_t bControlInterface ;\
- uint8_t bSubordinateInterface[no_slave] ;\
-}
-
-typedef ATTR_PACKED_STRUCT(struct) {
- uint8_t bLength ; ///< Size of this descriptor in bytes.
- uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
- uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
- uint8_t iCountryCodeRelDate ; ///< Index of a string giving the release date for the implemented ISO 3166 Country Codes.
- uint16_t wCountryCode[] ; ///< Country code in the format as defined in [ISO3166], release date as specified inoffset 3 for the first supported country.
-}cdc_desc_func_country_selection_t;
-
-#define cdc_desc_func_country_selection_n_t(no_country) \
- ATTR_PACKED_STRUCT(struct) {\
- uint8_t bLength ;\
- uint8_t bDescriptorType ;\
- uint8_t bDescriptorSubType ;\
- uint8_t iCountryCodeRelDate ;\
- uint16_t wCountryCode[no_country] ;\
-}
-
-//--------------------------------------------------------------------+
-// PUBLIC SWITCHED TELEPHONE NETWORK (PSTN) SUBCLASS
-//--------------------------------------------------------------------+
-typedef ATTR_PACKED_STRUCT(struct) {
- uint8_t bLength ; ///< Size of this descriptor in bytes.
- uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
- uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
-
- struct {
- uint8_t handle_call : 1; ///< 0 - Device sends/receives call management information only over the Communications Class interface. 1 - Device can send/receive call management information over a Data Class interface.
- uint8_t send_recv_call : 1; ///< 0 - Device does not handle call management itself. 1 - Device handles call management itself.
- uint8_t : 0;
- } bmCapabilities;
-
- uint8_t bDataInterface;
-}cdc_desc_func_call_management_t;
-
-typedef ATTR_PACKED_STRUCT(struct) {
- uint8_t support_comm_request : 1; ///< Device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature.
- uint8_t support_line_request : 1; ///< Device supports the request combination of Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State.
- uint8_t support_send_break : 1; ///< Device supports the request Send_Break
- uint8_t support_notification_network_connection : 1; ///< Device supports the notification Network_Connection.
- uint8_t : 0;
-}cdc_acm_capability_t;
-
-STATIC_ASSERT(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compiler");
-
-typedef ATTR_PACKED_STRUCT(struct) {
- uint8_t bLength ; ///< Size of this descriptor in bytes.
- uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
- uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
- cdc_acm_capability_t bmCapabilities ;
-}cdc_desc_func_abstract_control_management_t;
-
-typedef ATTR_PACKED_STRUCT(struct) {
- uint8_t bLength ; ///< Size of this descriptor in bytes.
- uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
- uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
- struct {
- uint8_t require_pulse_setup : 1; ///< Device requires extra Pulse_Setup request during pulse dialing sequence to disengage holding circuit.
- uint8_t support_aux_request : 1; ///< Device supports the request combination of Set_Aux_Line_State, Ring_Aux_Jack, and notification Aux_Jack_Hook_State.
- uint8_t support_pulse_request : 1; ///< Device supports the request combination of Pulse_Setup, Send_Pulse, and Set_Pulse_Time.
- uint8_t : 0;
- } bmCapabilities;
-}cdc_desc_func_direct_line_management_t;
-
-typedef ATTR_PACKED_STRUCT(struct) {
- uint8_t bLength ; ///< Size of this descriptor in bytes.
- uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
- uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
- uint8_t bRingerVolSteps ;
- uint8_t bNumRingerPatterns ;
-}cdc_desc_func_telephone_ringer_t;
-
-typedef ATTR_PACKED_STRUCT(struct) {
- uint8_t bLength ; ///< Size of this descriptor in bytes.
- uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
- uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
- struct {
- uint8_t simple_mode : 1;
- uint8_t standalone_mode : 1;
- uint8_t computer_centric_mode : 1;
- uint8_t : 0;
- } bmCapabilities;
-}cdc_desc_func_telephone_operational_modes_t;
-
-typedef ATTR_PACKED_STRUCT(struct) {
- uint8_t bLength ; ///< Size of this descriptor in bytes.
- uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
- uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
- struct {
- uint32_t interrupted_dialtone : 1; ///< 0 : Reports only dialtone (does not differentiate between normal and interrupted dialtone). 1 : Reports interrupted dialtone in addition to normal dialtone
- uint32_t ringback_busy_fastbusy : 1; ///< 0 : Reports only dialing state. 1 : Reports ringback, busy, and fast busy states.
- uint32_t caller_id : 1; ///< 0 : Does not report caller ID. 1 : Reports caller ID information.
- uint32_t incoming_distinctive : 1; ///< 0 : Reports only incoming ringing. 1 : Reports incoming distinctive ringing patterns.
- uint32_t dual_tone_multi_freq : 1; ///< 0 : Cannot report dual tone multi-frequency (DTMF) digits input remotely over the telephone line. 1 : Can report DTMF digits input remotely over the telephone line.
- uint32_t line_state_change : 1; ///< 0 : Does not support line state change notification. 1 : Does support line state change notification
- uint32_t : 0;
- } bmCapabilities;
-}cdc_desc_func_telephone_call_state_reporting_capabilities_t;
-
-static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc) ATTR_PURE ATTR_ALWAYS_INLINE;
-static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc)
-{
- return p_desc[2];
-}
-
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif
+/**************************************************************************/
+/*!
+ @file cdc.h
+ @author hathach (tinyusb.org)
+
+ @section LICENSE
+
+ Software License Agreement (BSD License)
+
+ Copyright (c) 2013, hathach (tinyusb.org)
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holders nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This file is part of the tinyusb stack.
+*/
+/**************************************************************************/
+
+/** \file
+ * \brief CDC Class Driver
+ *
+ * \note TBD
+ */
+
+/**
+ * \addtogroup ClassDriver Class Driver
+ * @{
+ * \defgroup ClassDriver_CDC Communication Device Class
+ * @{
+ */
+
+#ifndef _TUSB_CDC_H__
+#define _TUSB_CDC_H__
+
+#include "common/common.h"
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+//--------------------------------------------------------------------+
+// CDC COMMUNICATION INTERFACE CLASS
+//--------------------------------------------------------------------+
+enum {
+ CDC_COMM_SUBCLASS_DIRECT_LINE_CONTROL_MODEL = 0x01 ,
+ CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL ,
+ CDC_COMM_SUBCLASS_TELEPHONE_CONTROL_MODEL ,
+ CDC_COMM_SUBCLASS_MULTICHANNEL_CONTROL_MODEL ,
+ CDC_COMM_SUBCLASS_CAPI_CONTROL_MODEL ,
+ CDC_COMM_SUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL ,
+ CDC_COMM_SUBCLASS_ATM_NETWORKING_CONTROL_MODEL ,
+ CDC_COMM_SUBCLASS_WIRELESS_HANDSET_CONTROL_MODEL ,
+ CDC_COMM_SUBCLASS_DEVICE_MANAGEMENT ,
+ CDC_COMM_SUBCLASS_MOBILE_DIRECT_LINE_MODEL ,
+ CDC_COMM_SUBCLASS_OBEX ,
+ CDC_COMM_SUBCLASS_ETHERNET_EMULATION_MODEL
+};
+
+enum {
+ CDC_COMM_PROTOCOL_ATCOMMAND = 0x01 , // ITU-T V2.50
+ CDC_COMM_PROTOCOL_ATCOMMAND_PCCA_101 ,
+ CDC_COMM_PROTOCOL_ATCOMMAND_PCCA_101_AND_ANNEXO ,
+ CDC_COMM_PROTOCOL_ATCOMMAND_GSM_707 ,
+ CDC_COMM_PROTOCOL_ATCOMMAND_3GPP_27007 ,
+ CDC_COMM_PROTOCOL_ATCOMMAND_CDMA , // defined by TIA
+ CDC_COMM_PROTOCOL_ETHERNET_EMULATION_MODEL
+};
+
+//------------- SubType Descriptor in COMM Functional Descriptor -------------//
+enum {
+ CDC_FUNC_DESC_HEADER = 0x00 ,
+ CDC_FUNC_DESC_CALL_MANAGEMENT = 0x01 ,
+ CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT = 0x02 ,
+ CDC_FUNC_DESC_DIRECT_LINE_MANAGEMENT = 0x03 ,
+ CDC_FUNC_DESC_TELEPHONE_RINGER = 0x04 ,
+ CDC_FUNC_DESC_TELEPHONE_CALL_AND_LINE_STATE_REPORTING_CAPACITY = 0x05 ,
+ CDC_FUNC_DESC_UNION = 0x06 ,
+ CDC_FUNC_DESC_COUNTRY_SELECTION = 0x07 ,
+ CDC_FUNC_DESC_TELEPHONE_OPERATIONAL_MODES = 0x08 ,
+ CDC_FUNC_DESC_USB_TERMINAL = 0x09 ,
+ CDC_FUNC_DESC_NETWORK_CHANNEL_TERMINAL = 0x0A ,
+ CDC_FUNC_DESC_PROTOCOL_UNIT = 0x0B ,
+ CDC_FUNC_DESC_EXTENSION_UNIT = 0x0C ,
+ CDC_FUNC_DESC_MULTICHANEL_MANAGEMENT = 0x0D ,
+ CDC_FUNC_DESC_CAPI_CONTROL_MANAGEMENT = 0x0E ,
+ CDC_FUNC_DESC_ETHERNET_NETWORKING = 0x0F ,
+ CDC_FUNC_DESC_ATM_NETWORKING = 0x10 ,
+ CDC_FUNC_DESC_WIRELESS_HANDSET_CONTROL_MODEL = 0x11 ,
+ CDC_FUNC_DESC_MOBILE_DIRECT_LINE_MODEL = 0x12 ,
+ CDC_FUNC_DESC_MOBILE_DIRECT_LINE_MODEL_DETAIL = 0x13 ,
+ CDC_FUNC_DESC_DEVICE_MANAGEMENT_MODEL = 0x14 ,
+ CDC_FUNC_DESC_OBEX = 0x15 ,
+ CDC_FUNC_DESC_COMMAND_SET = 0x16 ,
+ CDC_FUNC_DESC_COMMAND_SET_DETAIL = 0x17 ,
+ CDC_FUNC_DESC_TELEPHONE_CONTROL_MODEL = 0x18 ,
+ CDC_FUNC_DESC_OBEX_SERVICE_IDENTIFIER = 0x19
+};
+
+//--------------------------------------------------------------------+
+// CDC DATA INTERFACE CLASS
+//--------------------------------------------------------------------+
+
+// SUBCLASS code of Data Interface is not used and should/must be zero
+
+enum{
+ CDC_DATA_PROTOCOL_ISDN_BRI = 0x30,
+ CDC_DATA_PROTOCOL_HDLC = 0x31,
+ CDC_DATA_PROTOCOL_TRANSPARENT = 0x32,
+ CDC_DATA_PROTOCOL_Q921_MANAGEMENT = 0x50,
+ CDC_DATA_PROTOCOL_Q921_DATA_LINK = 0x51,
+ CDC_DATA_PROTOCOL_Q921_TEI_MULTIPLEXOR = 0x52,
+ CDC_DATA_PROTOCOL_V42BIS_DATA_COMPRESSION = 0x90,
+ CDC_DATA_PROTOCOL_EURO_ISDN = 0x91,
+ CDC_DATA_PROTOCOL_V24_RATE_ADAPTION_TO_ISDN = 0x92,
+ CDC_DATA_PROTOCOL_CAPI_COMMAND = 0x93,
+ CDC_DATA_PROTOCOL_HOST_BASED_DRIVER = 0xFD,
+ CDC_DATA_PROTOCOL_IN_PROTOCOL_UNIT_FUNCTIONAL_DESCRIPTOR = 0xFE
+};
+
+//--------------------------------------------------------------------+
+// MANAGEMENT ELEMENT REQUEST (CONTROL ENDPOINT)
+//--------------------------------------------------------------------+
+typedef enum {
+ SEND_ENCAPSULATED_COMMAND = 0x00,
+ GET_ENCAPSULATED_RESPONSE = 0x01,
+
+ SET_COMM_FEATURE = 0x02,
+ GET_COMM_FEATURE = 0x03,
+ CLEAR_COMM_FEATURE = 0x04,
+
+ SET_AUX_LINE_STATE = 0x10,
+ SET_HOOK_STATE = 0x11,
+ PULSE_SETUP = 0x12,
+ SEND_PULSE = 0x13,
+ SET_PULSE_TIME = 0x14,
+ RING_AUX_JACK = 0x15,
+
+ SET_LINE_CODING = 0x20,
+ GET_LINE_CODING = 0x21,
+ SET_CONTROL_LINE_STATE = 0x22,
+ SEND_BREAK = 0x23,
+
+ SET_RINGER_PARMS = 0x30,
+ GET_RINGER_PARMS = 0x31,
+ SET_OPERATION_PARMS = 0x32,
+ GET_OPERATION_PARMS = 0x33,
+ SET_LINE_PARMS = 0x34,
+ GET_LINE_PARMS = 0x35,
+ DIAL_DIGITS = 0x36,
+ SET_UNIT_PARAMETER = 0x37,
+ GET_UNIT_PARAMETER = 0x38,
+ CLEAR_UNIT_PARAMETER = 0x39,
+ GET_PROFILE = 0x3A,
+
+ SET_ETHERNET_MULTICAST_FILTERS = 0x40,
+ SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x41,
+ GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x42,
+ SET_ETHERNET_PACKET_FILTER = 0x43,
+ GET_ETHERNET_STATISTIC = 0x44,
+
+ SET_ATM_DATA_FORMAT = 0x50,
+ GET_ATM_DEVICE_STATISTICS = 0x51,
+ SET_ATM_DEFAULT_VC = 0x52,
+ GET_ATM_VC_STATISTICS = 0x53,
+
+ MDLM_SEMANTIC_MODEL = 0x60,
+}cdc_management_request_t;
+
+//--------------------------------------------------------------------+
+// MANAGEMENT ELEMENENT NOTIFICATION (NOTIFICATION ENDPOINT)
+//--------------------------------------------------------------------+
+typedef enum {
+ NETWORK_CONNECTION = 0x00,
+ RESPONSE_AVAILABLE = 0x01,
+
+ AUX_JACK_HOOK_STATE = 0x08,
+ RING_DETECT = 0x09,
+
+ SERIAL_STATE = 0x20,
+
+ CALL_STATE_CHANGE = 0x28,
+ LINE_STATE_CHANGE = 0x29,
+ CONNECTION_SPEED_CHANGE = 0x2A,
+ MDLM_SEMANTIC_MODEL_NOTIFICATION = 0x40,
+}cdc_notification_request_t;
+
+//--------------------------------------------------------------------+
+// FUNCTIONAL DESCRIPTOR
+//--------------------------------------------------------------------+
+typedef ATTR_PACKED_STRUCT(struct) {
+ uint8_t bLength ; ///< Size of this descriptor in bytes.
+ uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
+ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
+ uint16_t bcdCDC ; ///< CDC release number in Binary-Coded Decimal
+}cdc_desc_func_header_t;
+
+typedef ATTR_PACKED_STRUCT(struct) {
+ uint8_t bLength ; ///< Size of this descriptor in bytes.
+ uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
+ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
+ uint8_t bControlInterface ; ///< Interface number of Communication Interface
+ uint8_t bSubordinateInterface ; ///< Array of Interface number of Data Interface
+}cdc_desc_func_union_t;
+
+#define cdc_desc_func_union_n_t(no_slave)\
+ ATTR_PACKED_STRUCT(struct) { \
+ uint8_t bLength ;\
+ uint8_t bDescriptorType ;\
+ uint8_t bDescriptorSubType ;\
+ uint8_t bControlInterface ;\
+ uint8_t bSubordinateInterface[no_slave] ;\
+}
+
+typedef ATTR_PACKED_STRUCT(struct) {
+ uint8_t bLength ; ///< Size of this descriptor in bytes.
+ uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
+ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
+ uint8_t iCountryCodeRelDate ; ///< Index of a string giving the release date for the implemented ISO 3166 Country Codes.
+ uint16_t wCountryCode[] ; ///< Country code in the format as defined in [ISO3166], release date as specified inoffset 3 for the first supported country.
+}cdc_desc_func_country_selection_t;
+
+#define cdc_desc_func_country_selection_n_t(no_country) \
+ ATTR_PACKED_STRUCT(struct) {\
+ uint8_t bLength ;\
+ uint8_t bDescriptorType ;\
+ uint8_t bDescriptorSubType ;\
+ uint8_t iCountryCodeRelDate ;\
+ uint16_t wCountryCode[no_country] ;\
+}
+
+//--------------------------------------------------------------------+
+// PUBLIC SWITCHED TELEPHONE NETWORK (PSTN) SUBCLASS
+//--------------------------------------------------------------------+
+typedef ATTR_PACKED_STRUCT(struct) {
+ uint8_t bLength ; ///< Size of this descriptor in bytes.
+ uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
+ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
+
+ struct {
+ uint8_t handle_call : 1; ///< 0 - Device sends/receives call management information only over the Communications Class interface. 1 - Device can send/receive call management information over a Data Class interface.
+ uint8_t send_recv_call : 1; ///< 0 - Device does not handle call management itself. 1 - Device handles call management itself.
+ uint8_t : 0;
+ } bmCapabilities;
+
+ uint8_t bDataInterface;
+}cdc_desc_func_call_management_t;
+
+typedef ATTR_PACKED_STRUCT(struct) {
+ uint8_t support_comm_request : 1; ///< Device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature.
+ uint8_t support_line_request : 1; ///< Device supports the request combination of Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State.
+ uint8_t support_send_break : 1; ///< Device supports the request Send_Break
+ uint8_t support_notification_network_connection : 1; ///< Device supports the notification Network_Connection.
+ uint8_t : 0;
+}cdc_acm_capability_t;
+
+STATIC_ASSERT(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compiler");
+
+typedef ATTR_PACKED_STRUCT(struct) {
+ uint8_t bLength ; ///< Size of this descriptor in bytes.
+ uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
+ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
+ cdc_acm_capability_t bmCapabilities ;
+}cdc_desc_func_abstract_control_management_t;
+
+typedef ATTR_PACKED_STRUCT(struct) {
+ uint8_t bLength ; ///< Size of this descriptor in bytes.
+ uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
+ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
+ struct {
+ uint8_t require_pulse_setup : 1; ///< Device requires extra Pulse_Setup request during pulse dialing sequence to disengage holding circuit.
+ uint8_t support_aux_request : 1; ///< Device supports the request combination of Set_Aux_Line_State, Ring_Aux_Jack, and notification Aux_Jack_Hook_State.
+ uint8_t support_pulse_request : 1; ///< Device supports the request combination of Pulse_Setup, Send_Pulse, and Set_Pulse_Time.
+ uint8_t : 0;
+ } bmCapabilities;
+}cdc_desc_func_direct_line_management_t;
+
+typedef ATTR_PACKED_STRUCT(struct) {
+ uint8_t bLength ; ///< Size of this descriptor in bytes.
+ uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
+ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
+ uint8_t bRingerVolSteps ;
+ uint8_t bNumRingerPatterns ;
+}cdc_desc_func_telephone_ringer_t;
+
+typedef ATTR_PACKED_STRUCT(struct) {
+ uint8_t bLength ; ///< Size of this descriptor in bytes.
+ uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
+ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
+ struct {
+ uint8_t simple_mode : 1;
+ uint8_t standalone_mode : 1;
+ uint8_t computer_centric_mode : 1;
+ uint8_t : 0;
+ } bmCapabilities;
+}cdc_desc_func_telephone_operational_modes_t;
+
+typedef ATTR_PACKED_STRUCT(struct) {
+ uint8_t bLength ; ///< Size of this descriptor in bytes.
+ uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
+ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
+ struct {
+ uint32_t interrupted_dialtone : 1; ///< 0 : Reports only dialtone (does not differentiate between normal and interrupted dialtone). 1 : Reports interrupted dialtone in addition to normal dialtone
+ uint32_t ringback_busy_fastbusy : 1; ///< 0 : Reports only dialing state. 1 : Reports ringback, busy, and fast busy states.
+ uint32_t caller_id : 1; ///< 0 : Does not report caller ID. 1 : Reports caller ID information.
+ uint32_t incoming_distinctive : 1; ///< 0 : Reports only incoming ringing. 1 : Reports incoming distinctive ringing patterns.
+ uint32_t dual_tone_multi_freq : 1; ///< 0 : Cannot report dual tone multi-frequency (DTMF) digits input remotely over the telephone line. 1 : Can report DTMF digits input remotely over the telephone line.
+ uint32_t line_state_change : 1; ///< 0 : Does not support line state change notification. 1 : Does support line state change notification
+ uint32_t : 0;
+ } bmCapabilities;
+}cdc_desc_func_telephone_call_state_reporting_capabilities_t;
+
+static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc) ATTR_PURE ATTR_ALWAYS_INLINE;
+static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc)
+{
+ return p_desc[2];
+}
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/tinyusb/class/hid.h b/tinyusb/class/hid.h
index 6a983648b..636cdac8b 100644
--- a/tinyusb/class/hid.h
+++ b/tinyusb/class/hid.h
@@ -1,505 +1,505 @@
-/**************************************************************************/
-/*!
- @file hid.h
- @author hathach (tinyusb.org)
-
- @section LICENSE
-
- Software License Agreement (BSD License)
-
- Copyright (c) 2013, hathach (tinyusb.org)
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holders nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This file is part of the tinyusb stack.
-*/
-/**************************************************************************/
-
-/**
- * \addtogroup Group_ClassDriver Class Driver
- * @{
- * \defgroup Group_HID Human Interface Device
- * @{
- */
-
-#ifndef _TUSB_HID_H_
-#define _TUSB_HID_H_
-
-#include "common/common.h"
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-enum {
- HID_SUBCLASS_NONE = 0,
- HID_SUBCLASS_BOOT = 1
-};
-
-enum {
- HID_PROTOCOL_NONE = 0,
- HID_PROTOCOL_KEYBOARD = 1,
- HID_PROTOCOL_MOUSE = 2
-};
-
-enum {
- HID_DESC_TYPE_HID = 0x21,
- HID_DESC_TYPE_REPORT = 0x22,
- HID_DESC_TYPE_PHYSICAL = 0x23
-};
-
-enum {
- HID_REQUEST_REPORT_INPUT = 1,
- HID_REQUEST_REPORT_OUTPUT,
- HID_REQUEST_REPORT_FEATURE
-};
-
-enum {
- HID_REQUEST_CONTROL_GET_REPORT = 0x01,
- HID_REQUEST_CONTROL_GET_IDLE = 0x02,
- HID_REQUEST_CONTROL_GET_PROTOCOL = 0x03,
- HID_REQUEST_CONTROL_SET_REPORT = 0x09,
- HID_REQUEST_CONTROL_SET_IDLE = 0x0a,
- HID_REQUEST_CONTROL_SET_PROTOCOL = 0x0b
-};
-
-typedef ATTR_PACKED_STRUCT(struct) {
- uint8_t bLength; /**< Numeric expression that is the total size of the HID descriptor */
- uint8_t bDescriptorType; /**< Constant name specifying type of HID descriptor. */
-
- uint16_t bcdHID; /**< Numeric expression identifying the HID Class Specification release */
- uint8_t bCountryCode; /**< Numeric expression identifying country code of the localized hardware. */
- uint8_t bNumDescriptors; /**< Numeric expression specifying the number of class descriptors */
-
- uint8_t bReportType; /**< Type of HID class report. */
- uint16_t wReportLength; /**< the total size of the Report descriptor. */
-} tusb_hid_descriptor_hid_t;
-
-/**
- * \brief Standard HID Boot Protocol Mouse Report.
- *
- * Type define for a standard Boot Protocol Mouse report
- */
-typedef ATTR_PACKED_STRUCT(struct)
-{
- uint8_t buttons; /**< buttons mask for currently pressed buttons in the mouse. */
- int8_t x; /**< Current delta x movement of the mouse. */
- int8_t y; /**< Current delta y movement on the mouse. */
- int8_t wheel; /**< Current delta wheel movement on the mouse. */
-} tusb_mouse_report_t;
-
-/**
- * \brief Standard HID Boot Protocol Keyboard Report.
- *
- * Type define for a standard Boot Protocol Keyboard report
- */
-typedef ATTR_PACKED_STRUCT(struct)
-{
- uint8_t modifier; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of HID_KEYBOARD_MODIFER_* masks). */
- uint8_t reserved; /**< Reserved for OEM use, always set to 0. */
- uint8_t keycode[6]; /**< Key codes of the currently pressed keys. */
-} tusb_keyboard_report_t;
-
-/**
- * \brief buttons codes for HID mouse
- */
-enum {
- MOUSE_BUTTON_LEFT = BIT_(0),
- MOUSE_BUTTON_RIGHT = BIT_(1),
- MOUSE_BUTTON_MIDDLE = BIT_(2)
-};
-
-/**
- * \brief KB modifier codes for HID KB
- */
-enum {
- KEYBOARD_MODIFIER_LEFTCTRL = BIT_(0),
- KEYBOARD_MODIFIER_LEFTSHIFT = BIT_(1),
- KEYBOARD_MODIFIER_LEFTALT = BIT_(2),
- KEYBOARD_MODIFIER_LEFTGUI = BIT_(3),
- KEYBOARD_MODIFIER_RIGHTCTRL = BIT_(4),
- KEYBOARD_MODIFIER_RIGHTSHIFT = BIT_(5),
- KEYBOARD_MODIFIER_RIGHTALT = BIT_(6),
- KEYBOARD_MODIFIER_RIGHTGUI = BIT_(7)
-};
-
-#define HID_KEYCODE_TABLE(ENTRY) \
- ENTRY( 0x04, 'a', 'A' )\
- ENTRY( 0x05, 'b', 'B' )\
- ENTRY( 0x06, 'c', 'C' )\
- ENTRY( 0x07, 'd', 'D' )\
- ENTRY( 0x08, 'e', 'E' )\
- ENTRY( 0x09, 'f', 'F' )\
- ENTRY( 0x0a, 'g', 'G' )\
- ENTRY( 0x0b, 'h', 'H' )\
- ENTRY( 0x0c, 'i', 'I' )\
- ENTRY( 0x0d, 'j', 'J' )\
- ENTRY( 0x0e, 'k', 'K' )\
- ENTRY( 0x0f, 'l', 'L' )\
- \
- ENTRY( 0x10, 'm', 'M' )\
- ENTRY( 0x11, 'n', 'N' )\
- ENTRY( 0x12, 'o', 'O' )\
- ENTRY( 0x13, 'p', 'P' )\
- ENTRY( 0x14, 'q', 'Q' )\
- ENTRY( 0x15, 'r', 'R' )\
- ENTRY( 0x16, 's', 'S' )\
- ENTRY( 0x17, 't', 'T' )\
- ENTRY( 0x18, 'u', 'U' )\
- ENTRY( 0x19, 'v', 'V' )\
- ENTRY( 0x1a, 'w', 'W' )\
- ENTRY( 0x1b, 'x', 'X' )\
- ENTRY( 0x1c, 'y', 'Y' )\
- ENTRY( 0x1d, 'z', 'Z' )\
- ENTRY( 0x1e, '1', '!' )\
- ENTRY( 0x1f, '2', '@' )\
- \
- ENTRY( 0x20, '3', '#' )\
- ENTRY( 0x21, '4', '$' )\
- ENTRY( 0x22, '5', '%' )\
- ENTRY( 0x23, '6', '^' )\
- ENTRY( 0x24, '7', '&' )\
- ENTRY( 0x25, '8', '*' )\
- ENTRY( 0x26, '9', '(' )\
- ENTRY( 0x27, '0', ')' )\
- ENTRY( 0x28, '\r', '\r' )\
- ENTRY( 0x29, '\e', '\e' )\
- ENTRY( 0x2a, '\b', '\b' )\
- ENTRY( 0x2b, '\t', '\t' )\
- ENTRY( 0x2c, ' ', ' ' )\
- ENTRY( 0x2d, '-', '_' )\
- ENTRY( 0x2e, '=', '+' )\
- ENTRY( 0x2f, '[', '{' )\
- \
- ENTRY( 0x30, ']', '}' )\
- ENTRY( 0x31, '\\', '|' )\
- ENTRY( 0x32, '#', '~' ) /* TODO non-US keyboard */ \
- ENTRY( 0x33, ';', ':' )\
- ENTRY( 0x34, '\'', '\"' )\
- ENTRY( 0x35, 0, 0 )\
- ENTRY( 0x36, ',', '<' )\
- ENTRY( 0x37, '.', '>' )\
- ENTRY( 0x38, '/', '?' )\
- ENTRY( 0x39, 0, 0 ) /* TODO CapsLock, non-locking key implementation*/ \
- \
- ENTRY( 0x54, '/', '/' )\
- ENTRY( 0x55, '*', '*' )\
- ENTRY( 0x56, '-', '-' )\
- ENTRY( 0x57, '+', '+' )\
- ENTRY( 0x58, '\r', '\r' )\
- ENTRY( 0x59, '1', 0 ) /* numpad1 & end */ \
- ENTRY( 0x5a, '2', 0 )\
- ENTRY( 0x5b, '3', 0 )\
- ENTRY( 0x5c, '4', 0 )\
- ENTRY( 0x5d, '5', '5' )\
- ENTRY( 0x5e, '6', 0 )\
- ENTRY( 0x5f, '7', 0 )\
- ENTRY( 0x60, '8', 0 )\
- ENTRY( 0x61, '9', 0 )\
- ENTRY( 0x62, '0', 0 )\
- ENTRY( 0x63, '0', 0 )\
- \
- ENTRY( 0x67, '=', '=' )\
-
-// TODO HID complete keycode table
-
-//enum
-//{
-// KEYBOARD_KEYCODE_A = 0x04,
-// KEYBOARD_KEYCODE_Z = 0x1d,
-//
-// KEYBOARD_KEYCODE_1 = 0x1e,
-// KEYBOARD_KEYCODE_0 = 0x27,
-//
-// KEYBOARD_KEYCODE_ENTER = 0x28,
-// KEYBOARD_KEYCODE_ESCAPE = 0x29,
-// KEYBOARD_KEYCODE_BACKSPACE = 0x2a,
-// KEYBOARD_KEYCODE_TAB = 0x2b,
-// KEYBOARD_KEYCODE_SPACEBAR = 0x2c,
-//
-//};
-
-/**
- * \brief Local Country code for HID
- */
-enum USB_HID_LOCAL_CODE
-{
- HID_Local_NotSupported = 0,
- HID_Local_Arabic,
- HID_Local_Belgian,
- HID_Local_Canadian_Bilingual,
- HID_Local_Canadian_French,
- HID_Local_Czech_Republic,
- HID_Local_Danish,
- HID_Local_Finnish,
- HID_Local_French,
- HID_Local_German,
- HID_Local_Greek,
- HID_Local_Hebrew,
- HID_Local_Hungary,
- HID_Local_International,
- HID_Local_Italian,
- HID_Local_Japan_Katakana,
- HID_Local_Korean,
- HID_Local_Latin_American,
- HID_Local_Netherlands_Dutch,
- HID_Local_Norwegian,
- HID_Local_Persian_Farsi,
- HID_Local_Poland,
- HID_Local_Portuguese,
- HID_Local_Russia,
- HID_Local_Slovakia,
- HID_Local_Spanish,
- HID_Local_Swedish,
- HID_Local_Swiss_French,
- HID_Local_Swiss_German,
- HID_Local_Switzerland,
- HID_Local_Taiwan,
- HID_Local_Turkish_Q,
- HID_Local_UK,
- HID_Local_US,
- HID_Local_Yugoslavia,
- HID_Local_Turkish_F
-};
-
-//--------------------------------------------------------------------+
-// REPORT DESCRIPTOR
-//--------------------------------------------------------------------+
-//------------- ITEM & TAG -------------//
-#define HID_REPORT_DATA_0(data)
-#define HID_REPORT_DATA_1(data) , data
-#define HID_REPORT_DATA_2(data) , U16_TO_U8S_LE(data)
-#define HID_REPORT_DATA_3(data) , U32_TO_U8S_LE(data)
-
-#define HID_REPORT_ITEM(data, tag, type, size) \
- (((tag) << 4) | ((type) << 2) | (size)) HID_REPORT_DATA_##size(data)
-
-#define RI_TYPE_MAIN 0
-#define RI_TYPE_GLOBAL 1
-#define RI_TYPE_LOCAL 2
-
-//------------- MAIN ITEMS 6.2.2.4 -------------//
-#define HID_INPUT(x) HID_REPORT_ITEM(x, 8, RI_TYPE_MAIN, 1)
-#define HID_OUTPUT(x) HID_REPORT_ITEM(x, 9, RI_TYPE_MAIN, 1)
-#define HID_COLLECTION(x) HID_REPORT_ITEM(x, 10, RI_TYPE_MAIN, 1)
-#define HID_FEATURE(x) HID_REPORT_ITEM(x, 11, RI_TYPE_MAIN, 1)
-#define HID_COLLECTION_END HID_REPORT_ITEM(x, 12, RI_TYPE_MAIN, 0)
-
-//------------- INPUT, OUTPUT, FEATURE 6.2.2.5 -------------//
-#define HID_DATA (0<<0)
-#define HID_CONSTANT (1<<0)
-
-#define HID_ARRAY (0<<1)
-#define HID_VARIABLE (1<<1)
-
-#define HID_ABSOLUTE (0<<2)
-#define HID_RELATIVE (1<<2)
-
-#define HID_WRAP_NO (0<<3)
-#define HID_WRAP (1<<3)
-
-#define HID_LINEAR (0<<4)
-#define HID_NONLINEAR (1<<4)
-
-#define HID_PREFERRED_STATE (0<<5)
-#define HID_PREFERRED_NO (1<<5)
-
-#define HID_NO_NULL_POSITION (0<<6)
-#define HID_NULL_STATE (1<<6)
-
-#define HID_NON_VOLATILE (0<<7)
-#define HID_VOLATILE (1<<7)
-
-#define HID_BITFIELD (0<<8)
-#define HID_BUFFERED_BYTES (1<<8)
-
-//------------- COLLECTION ITEM 6.2.2.6 -------------//
-enum {
- HID_COLLECTION_PHYSICAL = 0,
- HID_COLLECTION_APPLICATION,
- HID_COLLECTION_LOGICAL,
- HID_COLLECTION_REPORT,
- HID_COLLECTION_NAMED_ARRAY,
- HID_COLLECTION_USAGE_SWITCH,
- HID_COLLECTION_USAGE_MODIFIER
-};
-
-//------------- GLOBAL ITEMS 6.2.2.7 -------------//
-#define HID_USAGE_PAGE(x) HID_REPORT_ITEM(x, 0, RI_TYPE_GLOBAL, 1)
-#define HID_USAGE_PAGE_N(x, n) HID_REPORT_ITEM(x, 0, RI_TYPE_GLOBAL, n)
-
-#define HID_LOGICAL_MIN(x) HID_REPORT_ITEM(x, 1, RI_TYPE_GLOBAL, 1)
-#define HID_LOGICAL_MIN_N(x, n) HID_REPORT_ITEM(x, 1, RI_TYPE_GLOBAL, n)
-
-#define HID_LOGICAL_MAX(x) HID_REPORT_ITEM(x, 2, RI_TYPE_GLOBAL, 1)
-#define HID_LOGICAL_MAX_N(x, n) HID_REPORT_ITEM(x, 2, RI_TYPE_GLOBAL, n)
-
-#define HID_PHYSICAL_MIN(x) HID_REPORT_ITEM(x, 3, RI_TYPE_GLOBAL, 1)
-#define HID_PHYSICAL_MIN_N(x, n) HID_REPORT_ITEM(x, 3, RI_TYPE_GLOBAL, n)
-
-#define HID_PHYSICAL_MAX(x) HID_REPORT_ITEM(x, 4, RI_TYPE_GLOBAL, 1)
-#define HID_PHYSICAL_MAX_N(x, n) HID_REPORT_ITEM(x, 4, RI_TYPE_GLOBAL, n)
-
-#define HID_UNIT_EXPONENT(x) HID_REPORT_ITEM(x, 5, RI_TYPE_GLOBAL, 1)
-#define HID_UNIT_EXPONENT_N(x, n) HID_REPORT_ITEM(x, 5, RI_TYPE_GLOBAL, n)
-
-#define HID_UNIT(x) HID_REPORT_ITEM(x, 6, RI_TYPE_GLOBAL, 1)
-#define HID_UNIT_N(x, n) HID_REPORT_ITEM(x, 6, RI_TYPE_GLOBAL, n)
-
-#define HID_REPORT_SIZE(x) HID_REPORT_ITEM(x, 7, RI_TYPE_GLOBAL, 1)
-#define HID_REPORT_SIZE_N(x, n) HID_REPORT_ITEM(x, 7, RI_TYPE_GLOBAL, n)
-
-#define HID_REPORT_ID(x) HID_REPORT_ITEM(x, 8, RI_TYPE_GLOBAL, 1)
-#define HID_REPORT_ID_N(x) HID_REPORT_ITEM(x, 8, RI_TYPE_GLOBAL, n)
-
-#define HID_REPORT_COUNT(x) HID_REPORT_ITEM(x, 9, RI_TYPE_GLOBAL, 1)
-#define HID_REPORT_COUNT_N(x, n) HID_REPORT_ITEM(x, 9, RI_TYPE_GLOBAL, n)
-
-#define HID_PUSH HID_REPORT_ITEM(x, 10, RI_TYPE_GLOBAL, 0)
-#define HID_POP HID_REPORT_ITEM(x, 11, RI_TYPE_GLOBAL, 0)
-
-//------------- LOCAL ITEMS 6.2.2.8 -------------//
-#define HID_USAGE(x) HID_REPORT_ITEM(x, 0, RI_TYPE_LOCAL, 1)
-#define HID_USAGE_N(x, n) HID_REPORT_ITEM(x, 0, RI_TYPE_LOCAL, n)
-
-#define HID_USAGE_MIN(x) HID_REPORT_ITEM(x, 1, RI_TYPE_LOCAL, 1)
-#define HID_USAGE_MIN_N(x, n) HID_REPORT_ITEM(x, 1, RI_TYPE_LOCAL, n)
-
-#define HID_USAGE_MAX(x) HID_REPORT_ITEM(x, 2, RI_TYPE_LOCAL, 1)
-#define HID_USAGE_MAX_N(x, n) HID_REPORT_ITEM(x, 2, RI_TYPE_LOCAL, n)
-
-//--------------------------------------------------------------------+
-// Usage Table
-//--------------------------------------------------------------------+
-
-/// HID Usage Table - Table 1: Usage Page Summary
-enum {
- HID_USAGE_PAGE_DESKTOP = 0x01,
- HID_USAGE_PAGE_SIMULATE = 0x02,
- HID_USAGE_PAGE_VIRTUAL_REALITY = 0x03,
- HID_USAGE_PAGE_SPORT = 0x04,
- HID_USAGE_PAGE_GAME = 0x05,
- HID_USAGE_PAGE_GENERIC_DEVICE = 0x06,
- HID_USAGE_PAGE_KEYBOARD = 0x07,
- HID_USAGE_PAGE_LED = 0x08,
- HID_USAGE_PAGE_BUTTON = 0x09,
- HID_USAGE_PAGE_ORDINAL = 0x0a,
- HID_USAGE_PAGE_TELEPHONY = 0x0b,
- HID_USAGE_PAGE_CONSUMER = 0x0c,
- HID_USAGE_PAGE_DIGITIZER = 0x0d,
- HID_USAGE_PAGE_PID = 0x0f,
- HID_USAGE_PAGE_UNICODE = 0x10,
- HID_USAGE_PAGE_ALPHA_DISPLAY = 0x14,
- HID_USAGE_PAGE_MEDICAL = 0x40,
- HID_USAGE_PAGE_MONITOR = 0x80, //0x80 - 0x83
- HID_USAGE_PAGE_POWER = 0x84, // 0x084 - 0x87
- HID_USAGE_PAGE_BARCODE_SCANNER = 0x8c,
- HID_USAGE_PAGE_SCALE = 0x8d,
- HID_USAGE_PAGE_MSR = 0x8e,
- HID_USAGE_PAGE_CAMERA = 0x90,
- HID_USAGE_PAGE_ARCADE = 0x91,
- HID_USAGE_PAGE_VENDOR = 0xFFFF // 0xFF00 - 0xFFFF
-};
-
-/// HID Usage Table - Table 6: Generic Desktop Page
-enum {
- HID_USAGE_DESKTOP_POINTER = 0x01,
- HID_USAGE_DESKTOP_MOUSE = 0x02,
- HID_USAGE_DESKTOP_JOYSTICK = 0x04,
- HID_USAGE_DESKTOP_GAMEPAD = 0x05,
- HID_USAGE_DESKTOP_KEYBOARD = 0x06,
- HID_USAGE_DESKTOP_KEYPAD = 0x07,
- HID_USAGE_DESKTOP_MULTI_AXIS_CONTROLLER = 0x08,
- HID_USAGE_DESKTOP_TABLET_PC_SYSTEM = 0x09,
- HID_USAGE_DESKTOP_X = 0x30,
- HID_USAGE_DESKTOP_Y = 0x31,
- HID_USAGE_DESKTOP_Z = 0x32,
- HID_USAGE_DESKTOP_RX = 0x33,
- HID_USAGE_DESKTOP_RY = 0x34,
- HID_USAGE_DESKTOP_RZ = 0x35,
- HID_USAGE_DESKTOP_SLIDER = 0x36,
- HID_USAGE_DESKTOP_DIAL = 0x37,
- HID_USAGE_DESKTOP_WHEEL = 0x38,
- HID_USAGE_DESKTOP_HAT_SWITCH = 0x39,
- HID_USAGE_DESKTOP_COUNTED_BUFFER = 0x3a,
- HID_USAGE_DESKTOP_BYTE_COUNT = 0x3b,
- HID_USAGE_DESKTOP_MOTION_WAKEUP = 0x3c,
- HID_USAGE_DESKTOP_START = 0x3d,
- HID_USAGE_DESKTOP_SELECT = 0x3e,
- HID_USAGE_DESKTOP_VX = 0x40,
- HID_USAGE_DESKTOP_VY = 0x41,
- HID_USAGE_DESKTOP_VZ = 0x42,
- HID_USAGE_DESKTOP_VBRX = 0x43,
- HID_USAGE_DESKTOP_VBRY = 0x44,
- HID_USAGE_DESKTOP_VBRZ = 0x45,
- HID_USAGE_DESKTOP_VNO = 0x46,
- HID_USAGE_DESKTOP_FEATURE_NOTIFICATION = 0x47,
- HID_USAGE_DESKTOP_RESOLUTION_MULTIPLIER = 0x48,
- HID_USAGE_DESKTOP_SYSTEM_CONTROL = 0x80,
- HID_USAGE_DESKTOP_SYSTEM_POWER_DOWN = 0x81,
- HID_USAGE_DESKTOP_SYSTEM_SLEEP = 0x82,
- HID_USAGE_DESKTOP_SYSTEM_WAKE_UP = 0x83,
- HID_USAGE_DESKTOP_SYSTEM_CONTEXT_MENU = 0x84,
- HID_USAGE_DESKTOP_SYSTEM_MAIN_MENU = 0x85,
- HID_USAGE_DESKTOP_SYSTEM_APP_MENU = 0x86,
- HID_USAGE_DESKTOP_SYSTEM_MENU_HELP = 0x87,
- HID_USAGE_DESKTOP_SYSTEM_MENU_EXIT = 0x88,
- HID_USAGE_DESKTOP_SYSTEM_MENU_SELECT = 0x89,
- HID_USAGE_DESKTOP_SYSTEM_MENU_RIGHT = 0x8A,
- HID_USAGE_DESKTOP_SYSTEM_MENU_LEFT = 0x8B,
- HID_USAGE_DESKTOP_SYSTEM_MENU_UP = 0x8C,
- HID_USAGE_DESKTOP_SYSTEM_MENU_DOWN = 0x8D,
- HID_USAGE_DESKTOP_SYSTEM_COLD_RESTART = 0x8E,
- HID_USAGE_DESKTOP_SYSTEM_WARM_RESTART = 0x8F,
- HID_USAGE_DESKTOP_DPAD_UP = 0x90,
- HID_USAGE_DESKTOP_DPAD_DOWN = 0x91,
- HID_USAGE_DESKTOP_DPAD_RIGHT = 0x92,
- HID_USAGE_DESKTOP_DPAD_LEFT = 0x93,
- HID_USAGE_DESKTOP_SYSTEM_DOCK = 0xA0,
- HID_USAGE_DESKTOP_SYSTEM_UNDOCK = 0xA1,
- HID_USAGE_DESKTOP_SYSTEM_SETUP = 0xA2,
- HID_USAGE_DESKTOP_SYSTEM_BREAK = 0xA3,
- HID_USAGE_DESKTOP_SYSTEM_DEBUGGER_BREAK = 0xA4,
- HID_USAGE_DESKTOP_APPLICATION_BREAK = 0xA5,
- HID_USAGE_DESKTOP_APPLICATION_DEBUGGER_BREAK = 0xA6,
- HID_USAGE_DESKTOP_SYSTEM_SPEAKER_MUTE = 0xA7,
- HID_USAGE_DESKTOP_SYSTEM_HIBERNATE = 0xA8,
- HID_USAGE_DESKTOP_SYSTEM_DISPLAY_INVERT = 0xB0,
- HID_USAGE_DESKTOP_SYSTEM_DISPLAY_INTERNAL = 0xB1,
- HID_USAGE_DESKTOP_SYSTEM_DISPLAY_EXTERNAL = 0xB2,
- HID_USAGE_DESKTOP_SYSTEM_DISPLAY_BOTH = 0xB3,
- HID_USAGE_DESKTOP_SYSTEM_DISPLAY_DUAL = 0xB4,
- HID_USAGE_DESKTOP_SYSTEM_DISPLAY_TOGGLE_INT_EXT = 0xB5,
- HID_USAGE_DESKTOP_SYSTEM_DISPLAY_SWAP_PRIMARY_SECONDARY = 0xB6,
- HID_USAGE_DESKTOP_SYSTEM_DISPLAY_LCD_AUTOSCALE = 0xB7
-};
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* _TUSB_HID_H__ */
-
-/// @}
-/// @}
+/**************************************************************************/
+/*!
+ @file hid.h
+ @author hathach (tinyusb.org)
+
+ @section LICENSE
+
+ Software License Agreement (BSD License)
+
+ Copyright (c) 2013, hathach (tinyusb.org)
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holders nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This file is part of the tinyusb stack.
+*/
+/**************************************************************************/
+
+/**
+ * \addtogroup ClassDriver Class Driver
+ * @{
+ * \defgroup ClassDriver_HID Human Interface Device (HID)
+ * @{
+ */
+
+#ifndef _TUSB_HID_H_
+#define _TUSB_HID_H_
+
+#include "common/common.h"
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+enum {
+ HID_SUBCLASS_NONE = 0,
+ HID_SUBCLASS_BOOT = 1
+};
+
+enum {
+ HID_PROTOCOL_NONE = 0,
+ HID_PROTOCOL_KEYBOARD = 1,
+ HID_PROTOCOL_MOUSE = 2
+};
+
+enum {
+ HID_DESC_TYPE_HID = 0x21,
+ HID_DESC_TYPE_REPORT = 0x22,
+ HID_DESC_TYPE_PHYSICAL = 0x23
+};
+
+enum {
+ HID_REQUEST_REPORT_INPUT = 1,
+ HID_REQUEST_REPORT_OUTPUT,
+ HID_REQUEST_REPORT_FEATURE
+};
+
+enum {
+ HID_REQUEST_CONTROL_GET_REPORT = 0x01,
+ HID_REQUEST_CONTROL_GET_IDLE = 0x02,
+ HID_REQUEST_CONTROL_GET_PROTOCOL = 0x03,
+ HID_REQUEST_CONTROL_SET_REPORT = 0x09,
+ HID_REQUEST_CONTROL_SET_IDLE = 0x0a,
+ HID_REQUEST_CONTROL_SET_PROTOCOL = 0x0b
+};
+
+typedef ATTR_PACKED_STRUCT(struct) {
+ uint8_t bLength; /**< Numeric expression that is the total size of the HID descriptor */
+ uint8_t bDescriptorType; /**< Constant name specifying type of HID descriptor. */
+
+ uint16_t bcdHID; /**< Numeric expression identifying the HID Class Specification release */
+ uint8_t bCountryCode; /**< Numeric expression identifying country code of the localized hardware. */
+ uint8_t bNumDescriptors; /**< Numeric expression specifying the number of class descriptors */
+
+ uint8_t bReportType; /**< Type of HID class report. */
+ uint16_t wReportLength; /**< the total size of the Report descriptor. */
+} tusb_hid_descriptor_hid_t;
+
+/**
+ * \brief Standard HID Boot Protocol Mouse Report.
+ *
+ * Type define for a standard Boot Protocol Mouse report
+ */
+typedef ATTR_PACKED_STRUCT(struct)
+{
+ uint8_t buttons; /**< buttons mask for currently pressed buttons in the mouse. */
+ int8_t x; /**< Current delta x movement of the mouse. */
+ int8_t y; /**< Current delta y movement on the mouse. */
+ int8_t wheel; /**< Current delta wheel movement on the mouse. */
+} tusb_mouse_report_t;
+
+/**
+ * \brief Standard HID Boot Protocol Keyboard Report.
+ *
+ * Type define for a standard Boot Protocol Keyboard report
+ */
+typedef ATTR_PACKED_STRUCT(struct)
+{
+ uint8_t modifier; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of HID_KEYBOARD_MODIFER_* masks). */
+ uint8_t reserved; /**< Reserved for OEM use, always set to 0. */
+ uint8_t keycode[6]; /**< Key codes of the currently pressed keys. */
+} tusb_keyboard_report_t;
+
+/**
+ * \brief buttons codes for HID mouse
+ */
+enum {
+ MOUSE_BUTTON_LEFT = BIT_(0),
+ MOUSE_BUTTON_RIGHT = BIT_(1),
+ MOUSE_BUTTON_MIDDLE = BIT_(2)
+};
+
+/**
+ * \brief KB modifier codes for HID KB
+ */
+enum {
+ KEYBOARD_MODIFIER_LEFTCTRL = BIT_(0),
+ KEYBOARD_MODIFIER_LEFTSHIFT = BIT_(1),
+ KEYBOARD_MODIFIER_LEFTALT = BIT_(2),
+ KEYBOARD_MODIFIER_LEFTGUI = BIT_(3),
+ KEYBOARD_MODIFIER_RIGHTCTRL = BIT_(4),
+ KEYBOARD_MODIFIER_RIGHTSHIFT = BIT_(5),
+ KEYBOARD_MODIFIER_RIGHTALT = BIT_(6),
+ KEYBOARD_MODIFIER_RIGHTGUI = BIT_(7)
+};
+
+#define HID_KEYCODE_TABLE(ENTRY) \
+ ENTRY( 0x04, 'a', 'A' )\
+ ENTRY( 0x05, 'b', 'B' )\
+ ENTRY( 0x06, 'c', 'C' )\
+ ENTRY( 0x07, 'd', 'D' )\
+ ENTRY( 0x08, 'e', 'E' )\
+ ENTRY( 0x09, 'f', 'F' )\
+ ENTRY( 0x0a, 'g', 'G' )\
+ ENTRY( 0x0b, 'h', 'H' )\
+ ENTRY( 0x0c, 'i', 'I' )\
+ ENTRY( 0x0d, 'j', 'J' )\
+ ENTRY( 0x0e, 'k', 'K' )\
+ ENTRY( 0x0f, 'l', 'L' )\
+ \
+ ENTRY( 0x10, 'm', 'M' )\
+ ENTRY( 0x11, 'n', 'N' )\
+ ENTRY( 0x12, 'o', 'O' )\
+ ENTRY( 0x13, 'p', 'P' )\
+ ENTRY( 0x14, 'q', 'Q' )\
+ ENTRY( 0x15, 'r', 'R' )\
+ ENTRY( 0x16, 's', 'S' )\
+ ENTRY( 0x17, 't', 'T' )\
+ ENTRY( 0x18, 'u', 'U' )\
+ ENTRY( 0x19, 'v', 'V' )\
+ ENTRY( 0x1a, 'w', 'W' )\
+ ENTRY( 0x1b, 'x', 'X' )\
+ ENTRY( 0x1c, 'y', 'Y' )\
+ ENTRY( 0x1d, 'z', 'Z' )\
+ ENTRY( 0x1e, '1', '!' )\
+ ENTRY( 0x1f, '2', '@' )\
+ \
+ ENTRY( 0x20, '3', '#' )\
+ ENTRY( 0x21, '4', '$' )\
+ ENTRY( 0x22, '5', '%' )\
+ ENTRY( 0x23, '6', '^' )\
+ ENTRY( 0x24, '7', '&' )\
+ ENTRY( 0x25, '8', '*' )\
+ ENTRY( 0x26, '9', '(' )\
+ ENTRY( 0x27, '0', ')' )\
+ ENTRY( 0x28, '\r', '\r' )\
+ ENTRY( 0x29, '\e', '\e' )\
+ ENTRY( 0x2a, '\b', '\b' )\
+ ENTRY( 0x2b, '\t', '\t' )\
+ ENTRY( 0x2c, ' ', ' ' )\
+ ENTRY( 0x2d, '-', '_' )\
+ ENTRY( 0x2e, '=', '+' )\
+ ENTRY( 0x2f, '[', '{' )\
+ \
+ ENTRY( 0x30, ']', '}' )\
+ ENTRY( 0x31, '\\', '|' )\
+ ENTRY( 0x32, '#', '~' ) /* TODO non-US keyboard */ \
+ ENTRY( 0x33, ';', ':' )\
+ ENTRY( 0x34, '\'', '\"' )\
+ ENTRY( 0x35, 0, 0 )\
+ ENTRY( 0x36, ',', '<' )\
+ ENTRY( 0x37, '.', '>' )\
+ ENTRY( 0x38, '/', '?' )\
+ ENTRY( 0x39, 0, 0 ) /* TODO CapsLock, non-locking key implementation*/ \
+ \
+ ENTRY( 0x54, '/', '/' )\
+ ENTRY( 0x55, '*', '*' )\
+ ENTRY( 0x56, '-', '-' )\
+ ENTRY( 0x57, '+', '+' )\
+ ENTRY( 0x58, '\r', '\r' )\
+ ENTRY( 0x59, '1', 0 ) /* numpad1 & end */ \
+ ENTRY( 0x5a, '2', 0 )\
+ ENTRY( 0x5b, '3', 0 )\
+ ENTRY( 0x5c, '4', 0 )\
+ ENTRY( 0x5d, '5', '5' )\
+ ENTRY( 0x5e, '6', 0 )\
+ ENTRY( 0x5f, '7', 0 )\
+ ENTRY( 0x60, '8', 0 )\
+ ENTRY( 0x61, '9', 0 )\
+ ENTRY( 0x62, '0', 0 )\
+ ENTRY( 0x63, '0', 0 )\
+ \
+ ENTRY( 0x67, '=', '=' )\
+
+// TODO HID complete keycode table
+
+//enum
+//{
+// KEYBOARD_KEYCODE_A = 0x04,
+// KEYBOARD_KEYCODE_Z = 0x1d,
+//
+// KEYBOARD_KEYCODE_1 = 0x1e,
+// KEYBOARD_KEYCODE_0 = 0x27,
+//
+// KEYBOARD_KEYCODE_ENTER = 0x28,
+// KEYBOARD_KEYCODE_ESCAPE = 0x29,
+// KEYBOARD_KEYCODE_BACKSPACE = 0x2a,
+// KEYBOARD_KEYCODE_TAB = 0x2b,
+// KEYBOARD_KEYCODE_SPACEBAR = 0x2c,
+//
+//};
+
+/**
+ * \brief Local Country code for HID
+ */
+enum USB_HID_LOCAL_CODE
+{
+ HID_Local_NotSupported = 0,
+ HID_Local_Arabic,
+ HID_Local_Belgian,
+ HID_Local_Canadian_Bilingual,
+ HID_Local_Canadian_French,
+ HID_Local_Czech_Republic,
+ HID_Local_Danish,
+ HID_Local_Finnish,
+ HID_Local_French,
+ HID_Local_German,
+ HID_Local_Greek,
+ HID_Local_Hebrew,
+ HID_Local_Hungary,
+ HID_Local_International,
+ HID_Local_Italian,
+ HID_Local_Japan_Katakana,
+ HID_Local_Korean,
+ HID_Local_Latin_American,
+ HID_Local_Netherlands_Dutch,
+ HID_Local_Norwegian,
+ HID_Local_Persian_Farsi,
+ HID_Local_Poland,
+ HID_Local_Portuguese,
+ HID_Local_Russia,
+ HID_Local_Slovakia,
+ HID_Local_Spanish,
+ HID_Local_Swedish,
+ HID_Local_Swiss_French,
+ HID_Local_Swiss_German,
+ HID_Local_Switzerland,
+ HID_Local_Taiwan,
+ HID_Local_Turkish_Q,
+ HID_Local_UK,
+ HID_Local_US,
+ HID_Local_Yugoslavia,
+ HID_Local_Turkish_F
+};
+
+//--------------------------------------------------------------------+
+// REPORT DESCRIPTOR
+//--------------------------------------------------------------------+
+//------------- ITEM & TAG -------------//
+#define HID_REPORT_DATA_0(data)
+#define HID_REPORT_DATA_1(data) , data
+#define HID_REPORT_DATA_2(data) , U16_TO_U8S_LE(data)
+#define HID_REPORT_DATA_3(data) , U32_TO_U8S_LE(data)
+
+#define HID_REPORT_ITEM(data, tag, type, size) \
+ (((tag) << 4) | ((type) << 2) | (size)) HID_REPORT_DATA_##size(data)
+
+#define RI_TYPE_MAIN 0
+#define RI_TYPE_GLOBAL 1
+#define RI_TYPE_LOCAL 2
+
+//------------- MAIN ITEMS 6.2.2.4 -------------//
+#define HID_INPUT(x) HID_REPORT_ITEM(x, 8, RI_TYPE_MAIN, 1)
+#define HID_OUTPUT(x) HID_REPORT_ITEM(x, 9, RI_TYPE_MAIN, 1)
+#define HID_COLLECTION(x) HID_REPORT_ITEM(x, 10, RI_TYPE_MAIN, 1)
+#define HID_FEATURE(x) HID_REPORT_ITEM(x, 11, RI_TYPE_MAIN, 1)
+#define HID_COLLECTION_END HID_REPORT_ITEM(x, 12, RI_TYPE_MAIN, 0)
+
+//------------- INPUT, OUTPUT, FEATURE 6.2.2.5 -------------//
+#define HID_DATA (0<<0)
+#define HID_CONSTANT (1<<0)
+
+#define HID_ARRAY (0<<1)
+#define HID_VARIABLE (1<<1)
+
+#define HID_ABSOLUTE (0<<2)
+#define HID_RELATIVE (1<<2)
+
+#define HID_WRAP_NO (0<<3)
+#define HID_WRAP (1<<3)
+
+#define HID_LINEAR (0<<4)
+#define HID_NONLINEAR (1<<4)
+
+#define HID_PREFERRED_STATE (0<<5)
+#define HID_PREFERRED_NO (1<<5)
+
+#define HID_NO_NULL_POSITION (0<<6)
+#define HID_NULL_STATE (1<<6)
+
+#define HID_NON_VOLATILE (0<<7)
+#define HID_VOLATILE (1<<7)
+
+#define HID_BITFIELD (0<<8)
+#define HID_BUFFERED_BYTES (1<<8)
+
+//------------- COLLECTION ITEM 6.2.2.6 -------------//
+enum {
+ HID_COLLECTION_PHYSICAL = 0,
+ HID_COLLECTION_APPLICATION,
+ HID_COLLECTION_LOGICAL,
+ HID_COLLECTION_REPORT,
+ HID_COLLECTION_NAMED_ARRAY,
+ HID_COLLECTION_USAGE_SWITCH,
+ HID_COLLECTION_USAGE_MODIFIER
+};
+
+//------------- GLOBAL ITEMS 6.2.2.7 -------------//
+#define HID_USAGE_PAGE(x) HID_REPORT_ITEM(x, 0, RI_TYPE_GLOBAL, 1)
+#define HID_USAGE_PAGE_N(x, n) HID_REPORT_ITEM(x, 0, RI_TYPE_GLOBAL, n)
+
+#define HID_LOGICAL_MIN(x) HID_REPORT_ITEM(x, 1, RI_TYPE_GLOBAL, 1)
+#define HID_LOGICAL_MIN_N(x, n) HID_REPORT_ITEM(x, 1, RI_TYPE_GLOBAL, n)
+
+#define HID_LOGICAL_MAX(x) HID_REPORT_ITEM(x, 2, RI_TYPE_GLOBAL, 1)
+#define HID_LOGICAL_MAX_N(x, n) HID_REPORT_ITEM(x, 2, RI_TYPE_GLOBAL, n)
+
+#define HID_PHYSICAL_MIN(x) HID_REPORT_ITEM(x, 3, RI_TYPE_GLOBAL, 1)
+#define HID_PHYSICAL_MIN_N(x, n) HID_REPORT_ITEM(x, 3, RI_TYPE_GLOBAL, n)
+
+#define HID_PHYSICAL_MAX(x) HID_REPORT_ITEM(x, 4, RI_TYPE_GLOBAL, 1)
+#define HID_PHYSICAL_MAX_N(x, n) HID_REPORT_ITEM(x, 4, RI_TYPE_GLOBAL, n)
+
+#define HID_UNIT_EXPONENT(x) HID_REPORT_ITEM(x, 5, RI_TYPE_GLOBAL, 1)
+#define HID_UNIT_EXPONENT_N(x, n) HID_REPORT_ITEM(x, 5, RI_TYPE_GLOBAL, n)
+
+#define HID_UNIT(x) HID_REPORT_ITEM(x, 6, RI_TYPE_GLOBAL, 1)
+#define HID_UNIT_N(x, n) HID_REPORT_ITEM(x, 6, RI_TYPE_GLOBAL, n)
+
+#define HID_REPORT_SIZE(x) HID_REPORT_ITEM(x, 7, RI_TYPE_GLOBAL, 1)
+#define HID_REPORT_SIZE_N(x, n) HID_REPORT_ITEM(x, 7, RI_TYPE_GLOBAL, n)
+
+#define HID_REPORT_ID(x) HID_REPORT_ITEM(x, 8, RI_TYPE_GLOBAL, 1)
+#define HID_REPORT_ID_N(x) HID_REPORT_ITEM(x, 8, RI_TYPE_GLOBAL, n)
+
+#define HID_REPORT_COUNT(x) HID_REPORT_ITEM(x, 9, RI_TYPE_GLOBAL, 1)
+#define HID_REPORT_COUNT_N(x, n) HID_REPORT_ITEM(x, 9, RI_TYPE_GLOBAL, n)
+
+#define HID_PUSH HID_REPORT_ITEM(x, 10, RI_TYPE_GLOBAL, 0)
+#define HID_POP HID_REPORT_ITEM(x, 11, RI_TYPE_GLOBAL, 0)
+
+//------------- LOCAL ITEMS 6.2.2.8 -------------//
+#define HID_USAGE(x) HID_REPORT_ITEM(x, 0, RI_TYPE_LOCAL, 1)
+#define HID_USAGE_N(x, n) HID_REPORT_ITEM(x, 0, RI_TYPE_LOCAL, n)
+
+#define HID_USAGE_MIN(x) HID_REPORT_ITEM(x, 1, RI_TYPE_LOCAL, 1)
+#define HID_USAGE_MIN_N(x, n) HID_REPORT_ITEM(x, 1, RI_TYPE_LOCAL, n)
+
+#define HID_USAGE_MAX(x) HID_REPORT_ITEM(x, 2, RI_TYPE_LOCAL, 1)
+#define HID_USAGE_MAX_N(x, n) HID_REPORT_ITEM(x, 2, RI_TYPE_LOCAL, n)
+
+//--------------------------------------------------------------------+
+// Usage Table
+//--------------------------------------------------------------------+
+
+/// HID Usage Table - Table 1: Usage Page Summary
+enum {
+ HID_USAGE_PAGE_DESKTOP = 0x01,
+ HID_USAGE_PAGE_SIMULATE = 0x02,
+ HID_USAGE_PAGE_VIRTUAL_REALITY = 0x03,
+ HID_USAGE_PAGE_SPORT = 0x04,
+ HID_USAGE_PAGE_GAME = 0x05,
+ HID_USAGE_PAGE_GENERIC_DEVICE = 0x06,
+ HID_USAGE_PAGE_KEYBOARD = 0x07,
+ HID_USAGE_PAGE_LED = 0x08,
+ HID_USAGE_PAGE_BUTTON = 0x09,
+ HID_USAGE_PAGE_ORDINAL = 0x0a,
+ HID_USAGE_PAGE_TELEPHONY = 0x0b,
+ HID_USAGE_PAGE_CONSUMER = 0x0c,
+ HID_USAGE_PAGE_DIGITIZER = 0x0d,
+ HID_USAGE_PAGE_PID = 0x0f,
+ HID_USAGE_PAGE_UNICODE = 0x10,
+ HID_USAGE_PAGE_ALPHA_DISPLAY = 0x14,
+ HID_USAGE_PAGE_MEDICAL = 0x40,
+ HID_USAGE_PAGE_MONITOR = 0x80, //0x80 - 0x83
+ HID_USAGE_PAGE_POWER = 0x84, // 0x084 - 0x87
+ HID_USAGE_PAGE_BARCODE_SCANNER = 0x8c,
+ HID_USAGE_PAGE_SCALE = 0x8d,
+ HID_USAGE_PAGE_MSR = 0x8e,
+ HID_USAGE_PAGE_CAMERA = 0x90,
+ HID_USAGE_PAGE_ARCADE = 0x91,
+ HID_USAGE_PAGE_VENDOR = 0xFFFF // 0xFF00 - 0xFFFF
+};
+
+/// HID Usage Table - Table 6: Generic Desktop Page
+enum {
+ HID_USAGE_DESKTOP_POINTER = 0x01,
+ HID_USAGE_DESKTOP_MOUSE = 0x02,
+ HID_USAGE_DESKTOP_JOYSTICK = 0x04,
+ HID_USAGE_DESKTOP_GAMEPAD = 0x05,
+ HID_USAGE_DESKTOP_KEYBOARD = 0x06,
+ HID_USAGE_DESKTOP_KEYPAD = 0x07,
+ HID_USAGE_DESKTOP_MULTI_AXIS_CONTROLLER = 0x08,
+ HID_USAGE_DESKTOP_TABLET_PC_SYSTEM = 0x09,
+ HID_USAGE_DESKTOP_X = 0x30,
+ HID_USAGE_DESKTOP_Y = 0x31,
+ HID_USAGE_DESKTOP_Z = 0x32,
+ HID_USAGE_DESKTOP_RX = 0x33,
+ HID_USAGE_DESKTOP_RY = 0x34,
+ HID_USAGE_DESKTOP_RZ = 0x35,
+ HID_USAGE_DESKTOP_SLIDER = 0x36,
+ HID_USAGE_DESKTOP_DIAL = 0x37,
+ HID_USAGE_DESKTOP_WHEEL = 0x38,
+ HID_USAGE_DESKTOP_HAT_SWITCH = 0x39,
+ HID_USAGE_DESKTOP_COUNTED_BUFFER = 0x3a,
+ HID_USAGE_DESKTOP_BYTE_COUNT = 0x3b,
+ HID_USAGE_DESKTOP_MOTION_WAKEUP = 0x3c,
+ HID_USAGE_DESKTOP_START = 0x3d,
+ HID_USAGE_DESKTOP_SELECT = 0x3e,
+ HID_USAGE_DESKTOP_VX = 0x40,
+ HID_USAGE_DESKTOP_VY = 0x41,
+ HID_USAGE_DESKTOP_VZ = 0x42,
+ HID_USAGE_DESKTOP_VBRX = 0x43,
+ HID_USAGE_DESKTOP_VBRY = 0x44,
+ HID_USAGE_DESKTOP_VBRZ = 0x45,
+ HID_USAGE_DESKTOP_VNO = 0x46,
+ HID_USAGE_DESKTOP_FEATURE_NOTIFICATION = 0x47,
+ HID_USAGE_DESKTOP_RESOLUTION_MULTIPLIER = 0x48,
+ HID_USAGE_DESKTOP_SYSTEM_CONTROL = 0x80,
+ HID_USAGE_DESKTOP_SYSTEM_POWER_DOWN = 0x81,
+ HID_USAGE_DESKTOP_SYSTEM_SLEEP = 0x82,
+ HID_USAGE_DESKTOP_SYSTEM_WAKE_UP = 0x83,
+ HID_USAGE_DESKTOP_SYSTEM_CONTEXT_MENU = 0x84,
+ HID_USAGE_DESKTOP_SYSTEM_MAIN_MENU = 0x85,
+ HID_USAGE_DESKTOP_SYSTEM_APP_MENU = 0x86,
+ HID_USAGE_DESKTOP_SYSTEM_MENU_HELP = 0x87,
+ HID_USAGE_DESKTOP_SYSTEM_MENU_EXIT = 0x88,
+ HID_USAGE_DESKTOP_SYSTEM_MENU_SELECT = 0x89,
+ HID_USAGE_DESKTOP_SYSTEM_MENU_RIGHT = 0x8A,
+ HID_USAGE_DESKTOP_SYSTEM_MENU_LEFT = 0x8B,
+ HID_USAGE_DESKTOP_SYSTEM_MENU_UP = 0x8C,
+ HID_USAGE_DESKTOP_SYSTEM_MENU_DOWN = 0x8D,
+ HID_USAGE_DESKTOP_SYSTEM_COLD_RESTART = 0x8E,
+ HID_USAGE_DESKTOP_SYSTEM_WARM_RESTART = 0x8F,
+ HID_USAGE_DESKTOP_DPAD_UP = 0x90,
+ HID_USAGE_DESKTOP_DPAD_DOWN = 0x91,
+ HID_USAGE_DESKTOP_DPAD_RIGHT = 0x92,
+ HID_USAGE_DESKTOP_DPAD_LEFT = 0x93,
+ HID_USAGE_DESKTOP_SYSTEM_DOCK = 0xA0,
+ HID_USAGE_DESKTOP_SYSTEM_UNDOCK = 0xA1,
+ HID_USAGE_DESKTOP_SYSTEM_SETUP = 0xA2,
+ HID_USAGE_DESKTOP_SYSTEM_BREAK = 0xA3,
+ HID_USAGE_DESKTOP_SYSTEM_DEBUGGER_BREAK = 0xA4,
+ HID_USAGE_DESKTOP_APPLICATION_BREAK = 0xA5,
+ HID_USAGE_DESKTOP_APPLICATION_DEBUGGER_BREAK = 0xA6,
+ HID_USAGE_DESKTOP_SYSTEM_SPEAKER_MUTE = 0xA7,
+ HID_USAGE_DESKTOP_SYSTEM_HIBERNATE = 0xA8,
+ HID_USAGE_DESKTOP_SYSTEM_DISPLAY_INVERT = 0xB0,
+ HID_USAGE_DESKTOP_SYSTEM_DISPLAY_INTERNAL = 0xB1,
+ HID_USAGE_DESKTOP_SYSTEM_DISPLAY_EXTERNAL = 0xB2,
+ HID_USAGE_DESKTOP_SYSTEM_DISPLAY_BOTH = 0xB3,
+ HID_USAGE_DESKTOP_SYSTEM_DISPLAY_DUAL = 0xB4,
+ HID_USAGE_DESKTOP_SYSTEM_DISPLAY_TOGGLE_INT_EXT = 0xB5,
+ HID_USAGE_DESKTOP_SYSTEM_DISPLAY_SWAP_PRIMARY_SECONDARY = 0xB6,
+ HID_USAGE_DESKTOP_SYSTEM_DISPLAY_LCD_AUTOSCALE = 0xB7
+};
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* _TUSB_HID_H__ */
+
+/// @}
+/// @}
diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c
index 0c7d4dc0a..e61590eab 100644
--- a/tinyusb/class/hid_host.c
+++ b/tinyusb/class/hid_host.c
@@ -1,304 +1,304 @@
-/**************************************************************************/
-/*!
- @file hid_host.c
- @author hathach (tinyusb.org)
-
- @section LICENSE
-
- Software License Agreement (BSD License)
-
- Copyright (c) 2013, hathach (tinyusb.org)
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holders nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This file is part of the tinyusb stack.
-*/
-/**************************************************************************/
-
-#include "tusb_option.h"
-
-#if (MODE_HOST_SUPPORTED && HOST_CLASS_HID)
-
-#define _TINY_USB_SOURCE_FILE_
-//--------------------------------------------------------------------+
-// INCLUDE
-//--------------------------------------------------------------------+
-#include "common/common.h"
-#include "hid_host.h"
-
-//--------------------------------------------------------------------+
-// MACRO CONSTANT TYPEDEF
-//--------------------------------------------------------------------+
-
-//--------------------------------------------------------------------+
-// HID Interface common functions
-//--------------------------------------------------------------------+
-static inline tusb_error_t hidh_interface_open(uint8_t dev_addr, uint8_t interface_number, tusb_descriptor_endpoint_t const *p_endpoint_desc, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE;
-static inline tusb_error_t hidh_interface_open(uint8_t dev_addr, uint8_t interface_number, tusb_descriptor_endpoint_t const *p_endpoint_desc, hidh_interface_info_t *p_hid)
-{
- p_hid->pipe_hdl = hcd_pipe_open(dev_addr, p_endpoint_desc, TUSB_CLASS_HID);
- p_hid->report_size = p_endpoint_desc->wMaxPacketSize.size; // TODO get size from report descriptor
- p_hid->interface_number = interface_number;
-
- ASSERT (pipehandle_is_valid(p_hid->pipe_hdl), TUSB_ERROR_HCD_FAILED);
-
- return TUSB_ERROR_NONE;
-}
-
-static inline void hidh_interface_close(uint8_t dev_addr, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE;
-static inline void hidh_interface_close(uint8_t dev_addr, hidh_interface_info_t *p_hid)
-{
- (void) hcd_pipe_close(p_hid->pipe_hdl);
- memclr_(p_hid, sizeof(hidh_interface_info_t));
-}
-
-// called from public API need to validate parameters
-tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE;
-tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_interface_info_t *p_hid)
-{
- //------------- parameters validation -------------//
- // TODO change to use is configured function
- ASSERT_INT (TUSB_DEVICE_STATE_CONFIGURED, tusbh_device_get_state(dev_addr), TUSB_ERROR_DEVICE_NOT_READY);
- ASSERT_PTR (report, TUSB_ERROR_INVALID_PARA);
- ASSERT_FALSE(hcd_pipe_is_busy(p_hid->pipe_hdl), TUSB_ERROR_INTERFACE_IS_BUSY);
-
- ASSERT_STATUS( hcd_pipe_xfer(p_hid->pipe_hdl, report, p_hid->report_size, true) ) ;
-
- return TUSB_ERROR_NONE;
-}
-
-//--------------------------------------------------------------------+
-// KEYBOARD
-//--------------------------------------------------------------------+
-#if TUSB_CFG_HOST_HID_KEYBOARD
-
-#define EXPAND_KEYCODE_TO_ASCII(keycode, ascii, shift_modified) \
- [0][keycode] = ascii,\
- [1][keycode] = shift_modified,\
-
-// TODO size of table should be a macro for application to check boundary
-uint8_t const hid_keycode_to_ascii_tbl[2][128] =
-{
- HID_KEYCODE_TABLE(EXPAND_KEYCODE_TO_ASCII)
-};
-
-STATIC_VAR hidh_interface_info_t keyboardh_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
-
-//------------- KEYBOARD PUBLIC API (parameter validation required) -------------//
-bool tusbh_hid_keyboard_is_mounted(uint8_t dev_addr)
-{
- return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(keyboardh_data[dev_addr-1].pipe_hdl);
-}
-
-tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, void* report)
-{
- return hidh_interface_get_report(dev_addr, report, &keyboardh_data[dev_addr-1]);
-}
-
-bool tusbh_hid_keyboard_is_busy(uint8_t dev_addr)
-{
- return tusbh_hid_keyboard_is_mounted(dev_addr) &&
- hcd_pipe_is_busy( keyboardh_data[dev_addr-1].pipe_hdl );
-}
-
-#endif
-
-//--------------------------------------------------------------------+
-// MOUSE
-//--------------------------------------------------------------------+
-#if TUSB_CFG_HOST_HID_MOUSE
-
-STATIC_VAR hidh_interface_info_t mouseh_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
-
-//------------- Public API -------------//
-bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr)
-{
- return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(mouseh_data[dev_addr-1].pipe_hdl);
-}
-
-bool tusbh_hid_mouse_is_busy(uint8_t dev_addr)
-{
- return tusbh_hid_mouse_is_mounted(dev_addr) &&
- hcd_pipe_is_busy( mouseh_data[dev_addr-1].pipe_hdl );
-}
-
-tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, void * report)
-{
- return hidh_interface_get_report(dev_addr, report, &mouseh_data[dev_addr-1]);
-}
-
-#endif
-
-//--------------------------------------------------------------------+
-// GENERIC
-//--------------------------------------------------------------------+
-#if TUSB_CFG_HOST_HID_GENERIC
-
-//STATIC_ struct {
-// hidh_interface_info_t
-//} generic_data[TUSB_CFG_HOST_DEVICE_MAX];
-
-#endif
-
-//--------------------------------------------------------------------+
-// CLASS-USBH API (don't require to verify parameters)
-//--------------------------------------------------------------------+
-void hidh_init(void)
-{
-#if TUSB_CFG_HOST_HID_KEYBOARD
- memclr_(&keyboardh_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
-#endif
-
-#if TUSB_CFG_HOST_HID_MOUSE
- memclr_(&mouseh_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
-#endif
-
-#if TUSB_CFG_HOST_HID_GENERIC
- hidh_generic_init();
-#endif
-}
-
-#if 0
-uint8_t report_descriptor[256] TUSB_CFG_ATTR_USBRAM;
-#endif
-
-tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length)
-{
- tusb_error_t error;
- uint8_t const *p_desc = (uint8_t const *) p_interface_desc;
-
- //------------- HID descriptor -------------//
- p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
- tusb_hid_descriptor_hid_t const *p_desc_hid = (tusb_hid_descriptor_hid_t const *) p_desc;
- ASSERT_INT(HID_DESC_TYPE_HID, p_desc_hid->bDescriptorType, TUSB_ERROR_INVALID_PARA);
-
- //------------- Endpoint Descriptor -------------//
- p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
- tusb_descriptor_endpoint_t const * p_endpoint_desc = (tusb_descriptor_endpoint_t const *) p_desc;
- ASSERT_INT(TUSB_DESC_TYPE_ENDPOINT, p_endpoint_desc->bDescriptorType, TUSB_ERROR_INVALID_PARA);
-
- OSAL_SUBTASK_BEGIN
-
- //------------- SET IDLE (0) request -------------//
- OSAL_SUBTASK_INVOKED_AND_WAIT(
- usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_HOST_TO_DEV, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_INTERFACE),
- HID_REQUEST_CONTROL_SET_IDLE, 0, p_interface_desc->bInterfaceNumber,
- 0, NULL ),
- error
- );
-
-#if 0
- //------------- Get Report Descriptor TODO HID parser -------------//
- if ( p_desc_hid->bNumDescriptors )
- {
- OSAL_SUBTASK_INVOKED_AND_WAIT(
- usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_STANDARD, TUSB_REQUEST_RECIPIENT_INTERFACE),
- TUSB_REQUEST_GET_DESCRIPTOR, (p_desc_hid->bReportType << 8), 0,
- p_desc_hid->wReportLength, report_descriptor ),
- error
- );
- // if error in getting report descriptor --> treating like there is none
- }
-#endif
-
- if ( HID_SUBCLASS_BOOT == p_interface_desc->bInterfaceSubClass )
- {
- #if TUSB_CFG_HOST_HID_KEYBOARD
- if ( HID_PROTOCOL_KEYBOARD == p_interface_desc->bInterfaceProtocol)
- {
- SUBTASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &keyboardh_data[dev_addr-1]) );
- tusbh_hid_keyboard_mounted_cb(dev_addr);
- } else
- #endif
-
- #if TUSB_CFG_HOST_HID_MOUSE
- if ( HID_PROTOCOL_MOUSE == p_interface_desc->bInterfaceProtocol)
- {
- SUBTASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &mouseh_data[dev_addr-1]) );
- tusbh_hid_mouse_mounted_cb(dev_addr);
- } else
- #endif
-
- {
- SUBTASK_EXIT(TUSB_ERROR_HIDH_NOT_SUPPORTED_PROTOCOL); // exit & restart task
- }
- }else
- {
- SUBTASK_EXIT(TUSB_ERROR_HIDH_NOT_SUPPORTED_SUBCLASS); // exit & restart task
- }
-
- *p_length = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t);
-
- OSAL_SUBTASK_END
-}
-
-void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes)
-{
-#if TUSB_CFG_HOST_HID_KEYBOARD
- if ( pipehandle_is_equal(pipe_hdl, keyboardh_data[pipe_hdl.dev_addr-1].pipe_hdl) )
- {
- tusbh_hid_keyboard_isr(pipe_hdl.dev_addr, event);
- return;
- }
-#endif
-
-#if TUSB_CFG_HOST_HID_MOUSE
- if ( pipehandle_is_equal(pipe_hdl, mouseh_data[pipe_hdl.dev_addr-1].pipe_hdl) )
- {
- tusbh_hid_mouse_isr(pipe_hdl.dev_addr, event);
- return;
- }
-#endif
-
-#if TUSB_CFG_HOST_HID_GENERIC
-
-#endif
-}
-
-void hidh_close(uint8_t dev_addr)
-{
-#if TUSB_CFG_HOST_HID_KEYBOARD
- if ( pipehandle_is_valid( keyboardh_data[dev_addr-1].pipe_hdl ) )
- {
- hidh_interface_close(dev_addr, &keyboardh_data[dev_addr-1]);
- tusbh_hid_keyboard_unmounted_cb(dev_addr);
- }
-#endif
-
-#if TUSB_CFG_HOST_HID_MOUSE
- if( pipehandle_is_valid( mouseh_data[dev_addr-1].pipe_hdl ) )
- {
- hidh_interface_close(dev_addr, &mouseh_data[dev_addr-1]);
- tusbh_hid_mouse_unmounted_cb( dev_addr );
- }
-#endif
-
-#if TUSB_CFG_HOST_HID_GENERIC
- hidh_generic_close(dev_addr);
-#endif
-}
-
-
-
-#endif
+/**************************************************************************/
+/*!
+ @file hid_host.c
+ @author hathach (tinyusb.org)
+
+ @section LICENSE
+
+ Software License Agreement (BSD License)
+
+ Copyright (c) 2013, hathach (tinyusb.org)
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holders nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This file is part of the tinyusb stack.
+*/
+/**************************************************************************/
+
+#include "tusb_option.h"
+
+#if (MODE_HOST_SUPPORTED && HOST_CLASS_HID)
+
+#define _TINY_USB_SOURCE_FILE_
+//--------------------------------------------------------------------+
+// INCLUDE
+//--------------------------------------------------------------------+
+#include "common/common.h"
+#include "hid_host.h"
+
+//--------------------------------------------------------------------+
+// MACRO CONSTANT TYPEDEF
+//--------------------------------------------------------------------+
+
+//--------------------------------------------------------------------+
+// HID Interface common functions
+//--------------------------------------------------------------------+
+static inline tusb_error_t hidh_interface_open(uint8_t dev_addr, uint8_t interface_number, tusb_descriptor_endpoint_t const *p_endpoint_desc, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE;
+static inline tusb_error_t hidh_interface_open(uint8_t dev_addr, uint8_t interface_number, tusb_descriptor_endpoint_t const *p_endpoint_desc, hidh_interface_info_t *p_hid)
+{
+ p_hid->pipe_hdl = hcd_pipe_open(dev_addr, p_endpoint_desc, TUSB_CLASS_HID);
+ p_hid->report_size = p_endpoint_desc->wMaxPacketSize.size; // TODO get size from report descriptor
+ p_hid->interface_number = interface_number;
+
+ ASSERT (pipehandle_is_valid(p_hid->pipe_hdl), TUSB_ERROR_HCD_FAILED);
+
+ return TUSB_ERROR_NONE;
+}
+
+static inline void hidh_interface_close(uint8_t dev_addr, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE;
+static inline void hidh_interface_close(uint8_t dev_addr, hidh_interface_info_t *p_hid)
+{
+ (void) hcd_pipe_close(p_hid->pipe_hdl);
+ memclr_(p_hid, sizeof(hidh_interface_info_t));
+}
+
+// called from public API need to validate parameters
+tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE;
+tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_interface_info_t *p_hid)
+{
+ //------------- parameters validation -------------//
+ // TODO change to use is configured function
+ ASSERT_INT (TUSB_DEVICE_STATE_CONFIGURED, tusbh_device_get_state(dev_addr), TUSB_ERROR_DEVICE_NOT_READY);
+ ASSERT_PTR (report, TUSB_ERROR_INVALID_PARA);
+ ASSERT_FALSE(hcd_pipe_is_busy(p_hid->pipe_hdl), TUSB_ERROR_INTERFACE_IS_BUSY);
+
+ ASSERT_STATUS( hcd_pipe_xfer(p_hid->pipe_hdl, report, p_hid->report_size, true) ) ;
+
+ return TUSB_ERROR_NONE;
+}
+
+//--------------------------------------------------------------------+
+// KEYBOARD
+//--------------------------------------------------------------------+
+#if TUSB_CFG_HOST_HID_KEYBOARD
+
+#define EXPAND_KEYCODE_TO_ASCII(keycode, ascii, shift_modified) \
+ [0][keycode] = ascii,\
+ [1][keycode] = shift_modified,\
+
+// TODO size of table should be a macro for application to check boundary
+uint8_t const hid_keycode_to_ascii_tbl[2][128] =
+{
+ HID_KEYCODE_TABLE(EXPAND_KEYCODE_TO_ASCII)
+};
+
+STATIC_VAR hidh_interface_info_t keyboardh_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
+
+//------------- KEYBOARD PUBLIC API (parameter validation required) -------------//
+bool tusbh_hid_keyboard_is_mounted(uint8_t dev_addr)
+{
+ return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(keyboardh_data[dev_addr-1].pipe_hdl);
+}
+
+tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, void* p_report)
+{
+ return hidh_interface_get_report(dev_addr, p_report, &keyboardh_data[dev_addr-1]);
+}
+
+bool tusbh_hid_keyboard_is_busy(uint8_t dev_addr)
+{
+ return tusbh_hid_keyboard_is_mounted(dev_addr) &&
+ hcd_pipe_is_busy( keyboardh_data[dev_addr-1].pipe_hdl );
+}
+
+#endif
+
+//--------------------------------------------------------------------+
+// MOUSE
+//--------------------------------------------------------------------+
+#if TUSB_CFG_HOST_HID_MOUSE
+
+STATIC_VAR hidh_interface_info_t mouseh_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
+
+//------------- Public API -------------//
+bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr)
+{
+ return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(mouseh_data[dev_addr-1].pipe_hdl);
+}
+
+bool tusbh_hid_mouse_is_busy(uint8_t dev_addr)
+{
+ return tusbh_hid_mouse_is_mounted(dev_addr) &&
+ hcd_pipe_is_busy( mouseh_data[dev_addr-1].pipe_hdl );
+}
+
+tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, void * report)
+{
+ return hidh_interface_get_report(dev_addr, report, &mouseh_data[dev_addr-1]);
+}
+
+#endif
+
+//--------------------------------------------------------------------+
+// GENERIC
+//--------------------------------------------------------------------+
+#if TUSB_CFG_HOST_HID_GENERIC
+
+//STATIC_ struct {
+// hidh_interface_info_t
+//} generic_data[TUSB_CFG_HOST_DEVICE_MAX];
+
+#endif
+
+//--------------------------------------------------------------------+
+// CLASS-USBH API (don't require to verify parameters)
+//--------------------------------------------------------------------+
+void hidh_init(void)
+{
+#if TUSB_CFG_HOST_HID_KEYBOARD
+ memclr_(&keyboardh_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
+#endif
+
+#if TUSB_CFG_HOST_HID_MOUSE
+ memclr_(&mouseh_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
+#endif
+
+#if TUSB_CFG_HOST_HID_GENERIC
+ hidh_generic_init();
+#endif
+}
+
+#if 0
+uint8_t report_descriptor[256] TUSB_CFG_ATTR_USBRAM;
+#endif
+
+tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length)
+{
+ tusb_error_t error;
+ uint8_t const *p_desc = (uint8_t const *) p_interface_desc;
+
+ //------------- HID descriptor -------------//
+ p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
+ tusb_hid_descriptor_hid_t const *p_desc_hid = (tusb_hid_descriptor_hid_t const *) p_desc;
+ ASSERT_INT(HID_DESC_TYPE_HID, p_desc_hid->bDescriptorType, TUSB_ERROR_INVALID_PARA);
+
+ //------------- Endpoint Descriptor -------------//
+ p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
+ tusb_descriptor_endpoint_t const * p_endpoint_desc = (tusb_descriptor_endpoint_t const *) p_desc;
+ ASSERT_INT(TUSB_DESC_TYPE_ENDPOINT, p_endpoint_desc->bDescriptorType, TUSB_ERROR_INVALID_PARA);
+
+ OSAL_SUBTASK_BEGIN
+
+ //------------- SET IDLE (0) request -------------//
+ OSAL_SUBTASK_INVOKED_AND_WAIT(
+ usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_HOST_TO_DEV, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_INTERFACE),
+ HID_REQUEST_CONTROL_SET_IDLE, 0, p_interface_desc->bInterfaceNumber,
+ 0, NULL ),
+ error
+ );
+
+#if 0
+ //------------- Get Report Descriptor TODO HID parser -------------//
+ if ( p_desc_hid->bNumDescriptors )
+ {
+ OSAL_SUBTASK_INVOKED_AND_WAIT(
+ usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_STANDARD, TUSB_REQUEST_RECIPIENT_INTERFACE),
+ TUSB_REQUEST_GET_DESCRIPTOR, (p_desc_hid->bReportType << 8), 0,
+ p_desc_hid->wReportLength, report_descriptor ),
+ error
+ );
+ // if error in getting report descriptor --> treating like there is none
+ }
+#endif
+
+ if ( HID_SUBCLASS_BOOT == p_interface_desc->bInterfaceSubClass )
+ {
+ #if TUSB_CFG_HOST_HID_KEYBOARD
+ if ( HID_PROTOCOL_KEYBOARD == p_interface_desc->bInterfaceProtocol)
+ {
+ SUBTASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &keyboardh_data[dev_addr-1]) );
+ tusbh_hid_keyboard_mounted_cb(dev_addr);
+ } else
+ #endif
+
+ #if TUSB_CFG_HOST_HID_MOUSE
+ if ( HID_PROTOCOL_MOUSE == p_interface_desc->bInterfaceProtocol)
+ {
+ SUBTASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &mouseh_data[dev_addr-1]) );
+ tusbh_hid_mouse_mounted_cb(dev_addr);
+ } else
+ #endif
+
+ {
+ SUBTASK_EXIT(TUSB_ERROR_HIDH_NOT_SUPPORTED_PROTOCOL); // exit & restart task
+ }
+ }else
+ {
+ SUBTASK_EXIT(TUSB_ERROR_HIDH_NOT_SUPPORTED_SUBCLASS); // exit & restart task
+ }
+
+ *p_length = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t);
+
+ OSAL_SUBTASK_END
+}
+
+void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes)
+{
+#if TUSB_CFG_HOST_HID_KEYBOARD
+ if ( pipehandle_is_equal(pipe_hdl, keyboardh_data[pipe_hdl.dev_addr-1].pipe_hdl) )
+ {
+ tusbh_hid_keyboard_isr(pipe_hdl.dev_addr, event);
+ return;
+ }
+#endif
+
+#if TUSB_CFG_HOST_HID_MOUSE
+ if ( pipehandle_is_equal(pipe_hdl, mouseh_data[pipe_hdl.dev_addr-1].pipe_hdl) )
+ {
+ tusbh_hid_mouse_isr(pipe_hdl.dev_addr, event);
+ return;
+ }
+#endif
+
+#if TUSB_CFG_HOST_HID_GENERIC
+
+#endif
+}
+
+void hidh_close(uint8_t dev_addr)
+{
+#if TUSB_CFG_HOST_HID_KEYBOARD
+ if ( pipehandle_is_valid( keyboardh_data[dev_addr-1].pipe_hdl ) )
+ {
+ hidh_interface_close(dev_addr, &keyboardh_data[dev_addr-1]);
+ tusbh_hid_keyboard_unmounted_cb(dev_addr);
+ }
+#endif
+
+#if TUSB_CFG_HOST_HID_MOUSE
+ if( pipehandle_is_valid( mouseh_data[dev_addr-1].pipe_hdl ) )
+ {
+ hidh_interface_close(dev_addr, &mouseh_data[dev_addr-1]);
+ tusbh_hid_mouse_unmounted_cb( dev_addr );
+ }
+#endif
+
+#if TUSB_CFG_HOST_HID_GENERIC
+ hidh_generic_close(dev_addr);
+#endif
+}
+
+
+
+#endif
diff --git a/tinyusb/class/hid_host.h b/tinyusb/class/hid_host.h
index 0c84bfbc3..f282621e9 100644
--- a/tinyusb/class/hid_host.h
+++ b/tinyusb/class/hid_host.h
@@ -1,119 +1,213 @@
-/**************************************************************************/
-/*!
- @file hid_host.h
- @author hathach (tinyusb.org)
-
- @section LICENSE
-
- Software License Agreement (BSD License)
-
- Copyright (c) 2013, hathach (tinyusb.org)
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. Neither the name of the copyright holders nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This file is part of the tinyusb stack.
-*/
-/**************************************************************************/
-
-/** \ingroup TBD
- * \defgroup TBD
- * \brief TBD
- *
- * @{
- */
-
-#ifndef _TUSB_HID_HOST_H_
-#define _TUSB_HID_HOST_H_
-
-#include "common/common.h"
-#include "host/usbh.h"
-#include "hid.h"
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-//--------------------------------------------------------------------+
-// KEYBOARD Application API
-//--------------------------------------------------------------------+
-extern uint8_t const hid_keycode_to_ascii_tbl[2][128]; // TODO used weak attr if build failed without KEYBOARD enabled
-
-bool tusbh_hid_keyboard_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
-bool tusbh_hid_keyboard_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
-tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, void * report) /*ATTR_WARN_UNUSED_RESULT*/;
-
-//------------- Application Callback -------------//
-void tusbh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event);
-void tusbh_hid_keyboard_mounted_cb(uint8_t dev_addr);
-void tusbh_hid_keyboard_unmounted_cb(uint8_t dev_addr);
-
-//--------------------------------------------------------------------+
-// MOUSE Application API
-//--------------------------------------------------------------------+
-bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
-bool tusbh_hid_mouse_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
-tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, void* report) /*ATTR_WARN_UNUSED_RESULT*/;
-
-//------------- Application Callback -------------//
-void tusbh_hid_mouse_isr(uint8_t dev_addr, tusb_event_t event);
-void tusbh_hid_mouse_mounted_cb(uint8_t dev_addr);
-void tusbh_hid_mouse_unmounted_cb(uint8_t dev_addr);
-
-//--------------------------------------------------------------------+
-// GENERIC Application API
-//--------------------------------------------------------------------+
-bool tusbh_hid_generic_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
-tusb_error_t tusbh_hid_generic_get_report(uint8_t dev_addr, void* report, bool int_on_complete) ATTR_WARN_UNUSED_RESULT;
-tusb_error_t tusbh_hid_generic_set_report(uint8_t dev_addr, void* report, bool int_on_complete) ATTR_WARN_UNUSED_RESULT;
-tusb_interface_status_t tusbh_hid_generic_get_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
-tusb_interface_status_t tusbh_hid_generic_set_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
-
-//------------- Application Callback -------------//
-void tusbh_hid_generic_isr(uint8_t dev_addr, tusb_event_t event);
-
-//--------------------------------------------------------------------+
-// USBH-CLASS DRIVER API
-//--------------------------------------------------------------------+
-#ifdef _TINY_USB_SOURCE_FILE_
-
-typedef struct {
- pipe_handle_t pipe_hdl;
- uint16_t report_size;
- uint8_t interface_number;
-}hidh_interface_info_t;
-
-void hidh_init(void);
-tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT;
-void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes);
-void hidh_close(uint8_t dev_addr);
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _TUSB_HID_HOST_H_ */
-
-/** @} */
+/**************************************************************************/
+/*!
+ @file hid_host.h
+ @author hathach (tinyusb.org)
+
+ @section LICENSE
+
+ Software License Agreement (BSD License)
+
+ Copyright (c) 2013, hathach (tinyusb.org)
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holders nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This file is part of the tinyusb stack.
+*/
+/**************************************************************************/
+
+/** \addtogroup ClassDriver_HID
+ * @{ */
+
+#ifndef _TUSB_HID_HOST_H_
+#define _TUSB_HID_HOST_H_
+
+#include "common/common.h"
+#include "host/usbh.h"
+#include "hid.h"
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/** \defgroup hid_keyboard Keyboard
+ * The interface API includes status checking function, data transferring function and callback functions
+ * @{ */
+//--------------------------------------------------------------------+
+// KEYBOARD Application API
+//--------------------------------------------------------------------+
+extern uint8_t const hid_keycode_to_ascii_tbl[2][128]; // TODO used weak attr if build failed without KEYBOARD enabled
+
+/** \brief Check if device supports Keyboard interface or not
+ * \param[in] dev_addr device address
+ * \retval true if device supports Keyboard interface
+ * \retval false if device does not support Keyboard interface or is not mounted
+ */
+bool tusbh_hid_keyboard_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
+
+/** \brief Check if the interface is currently busy or not
+ * \param[in] dev_addr device address
+ * \retval true if the interface is busy meaning the stack is still transferring/waiting data from/to device
+ * \retval false if the interface is not busy meaning the stack successfully transferred data from/to device
+ * \note This function is primarily used for polling/waiting result after \ref tusbh_hid_keyboard_get_report.
+ * Alternatively, asynchronous event API can be used
+ */
+bool tusbh_hid_keyboard_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
+
+/** \brief Perform a get report from Keyboard interface
+ * \param[in] dev_addr device address
+ * \param[in,out] p_report address that is used to store data from device. Must be accessible by usb controller (see \ref TUSB_CFG_ATTR_USBRAM)
+ * \returns \ref tusb_error_t type to indicate success or error condition.
+ * \retval TUSB_ERROR_NONE on success
+ * \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device
+ * \retval TUSB_ERROR_DEVICE_NOT_READY if device is not yet configured (by SET CONFIGURED request)
+ * \retval TUSB_ERROR_INVALID_PARA if inputs parameter are not correct
+ * \note This function is non-blocking and returns immediately. The result of usb transfer will be reported by the interface's callback function
+ */
+tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, void * p_report) /*ATTR_WARN_UNUSED_RESULT*/;
+
+//------------- Application Callback -------------//
+/** \brief Callback function that is invoked when an transferring event occurred
+ * \param[in] dev_addr Address of device
+ * \param[in] event an value from \ref tusb_event_t
+ * \note event can be one of following
+ * - TUSB_EVENT_XFER_COMPLETE : previously scheduled transfer completes successfully.
+ * - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error.
+ * - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device.
+ * \note Application should schedule the next report by calling \ref tusbh_hid_keyboard_get_report within this callback
+ */
+void tusbh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event);
+
+/** \brief Callback function that will be invoked when a device with Keyboard interface is mounted
+ * \param[in] dev_addr Address of newly mounted device
+ * \note This callback should be used by Application to set-up interface-related data
+ */
+void tusbh_hid_keyboard_mounted_cb(uint8_t dev_addr);
+
+/** \brief Callback function that will be invoked when a device with Keyboard interface is unmounted
+ * \param[in] dev_addr Address of newly unmounted device
+ * \note This callback should be used by Application to tear-down interface-related data
+ */
+void tusbh_hid_keyboard_unmounted_cb(uint8_t dev_addr);
+/** @} */
+
+/** \defgroup hid_mouse Mouse
+ * The interface API includes status checking function, data transferring function and callback functions
+ * @{ */
+//--------------------------------------------------------------------+
+// MOUSE Application API
+//--------------------------------------------------------------------+
+/** \brief Check if device supports Mouse interface or not
+ * \param[in] dev_addr device address
+ * \retval true if device supports Mouse interface
+ * \retval false if device does not support Mouse interface or is not mounted
+ */
+bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
+
+/** \brief Check if the interface is currently busy or not
+ * \param[in] dev_addr device address
+ * \retval true if the interface is busy meaning the stack is still transferring/waiting data from/to device
+ * \retval false if the interface is not busy meaning the stack successfully transferred data from/to device
+ * \note This function is primarily used for polling/waiting result after \ref tusbh_hid_mouse_get_report.
+ * Alternatively, asynchronous event API can be used
+ */
+bool tusbh_hid_mouse_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
+
+/** \brief Perform a get report from Mouse interface
+ * \param[in] dev_addr device address
+ * \param[in,out] p_report address that is used to store data from device. Must be accessible by usb controller (see \ref TUSB_CFG_ATTR_USBRAM)
+ * \returns \ref tusb_error_t type to indicate success or error condition.
+ * \retval TUSB_ERROR_NONE on success
+ * \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device
+ * \retval TUSB_ERROR_DEVICE_NOT_READY if device is not yet configured (by SET CONFIGURED request)
+ * \retval TUSB_ERROR_INVALID_PARA if inputs parameter are not correct
+ * \note This function is non-blocking and returns immediately. The result of usb transfer will be reported by the interface's callback function
+ */
+tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, void* p_report) /*ATTR_WARN_UNUSED_RESULT*/;
+
+//------------- Application Callback -------------//
+/** \brief Callback function that is invoked when an transferring event occurred
+ * \param[in] dev_addr Address of device
+ * \param[in] event an value from \ref tusb_event_t
+ * \note event can be one of following
+ * - TUSB_EVENT_XFER_COMPLETE : previously scheduled transfer completes successfully.
+ * - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error.
+ * - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device.
+ * \note Application should schedule the next report by calling \ref tusbh_hid_mouse_get_report within this callback
+ */
+void tusbh_hid_mouse_isr(uint8_t dev_addr, tusb_event_t event);
+
+/** \brief Callback function that will be invoked when a device with Mouse interface is mounted
+ * \param[in] dev_addr Address of newly mounted device
+ * \note This callback should be used by Application to set-up interface-related data
+ */
+void tusbh_hid_mouse_mounted_cb(uint8_t dev_addr);
+
+/** \brief Callback function that will be invoked when a device with Mouse interface is unmounted
+ * \param[in] dev_addr Address of newly unmounted device
+ * \note This callback should be used by Application to tear-down interface-related data
+ */
+void tusbh_hid_mouse_unmounted_cb(uint8_t dev_addr);
+/** @} */
+
+/** \defgroup hid_generic Generic (not supported yet)
+ * The interface API includes status checking function, data transferring function and callback functions
+ * @{ */
+//--------------------------------------------------------------------+
+// GENERIC Application API
+//--------------------------------------------------------------------+
+bool tusbh_hid_generic_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
+tusb_error_t tusbh_hid_generic_get_report(uint8_t dev_addr, void* p_report, bool int_on_complete) ATTR_WARN_UNUSED_RESULT;
+tusb_error_t tusbh_hid_generic_set_report(uint8_t dev_addr, void* p_report, bool int_on_complete) ATTR_WARN_UNUSED_RESULT;
+tusb_interface_status_t tusbh_hid_generic_get_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
+tusb_interface_status_t tusbh_hid_generic_set_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
+
+//------------- Application Callback -------------//
+void tusbh_hid_generic_isr(uint8_t dev_addr, tusb_event_t event);
+/** @} */
+
+//--------------------------------------------------------------------+
+// USBH-CLASS DRIVER API
+//--------------------------------------------------------------------+
+#ifdef _TINY_USB_SOURCE_FILE_
+
+typedef struct {
+ pipe_handle_t pipe_hdl;
+ uint16_t report_size;
+ uint8_t interface_number;
+}hidh_interface_info_t;
+
+void hidh_init(void);
+tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT;
+void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes);
+void hidh_close(uint8_t dev_addr);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _TUSB_HID_HOST_H_ */
+
+/** @} */