summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-04-07 15:48:01 +0700
committerhathach <[email protected]>2013-04-07 15:48:01 +0700
commit10c08ab40453b60077c6880b50ace59f6f548ace (patch)
treec1e8210c3bf41cf73ae164bb45606cec10646ecc /tinyusb
parent3d8a4ef8c8b8d6778e2bea47e709822bb6a358b5 (diff)
add test for mouse_open
add hid descriptor for mouse & mouse interface to descriptor_test refractor extract function hidh_interface_status fix error with MACRO HID_REPORT_ITEM with zero data size --> redundant semicolon
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/class/hid.h8
-rw-r--r--tinyusb/class/hid_host.c25
2 files changed, 20 insertions, 13 deletions
diff --git a/tinyusb/class/hid.h b/tinyusb/class/hid.h
index cfc203034..1d423a53e 100644
--- a/tinyusb/class/hid.h
+++ b/tinyusb/class/hid.h
@@ -192,12 +192,12 @@ enum USB_HID_LOCAL_CODE
//--------------------------------------------------------------------+
//------------- 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_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)
+ ((tag << 4) | (type << 2) | size) HID_REPORT_DATA_##size(data)
#define RI_TYPE_MAIN 0
#define RI_TYPE_GLOBAL 1
diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c
index e9e12c71b..c0e507215 100644
--- a/tinyusb/class/hid_host.c
+++ b/tinyusb/class/hid_host.c
@@ -53,6 +53,19 @@
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
+tusb_interface_status_t hidh_interface_status(uint8_t dev_addr, hidh_interface_info_t *p_hid) ATTR_PURE ATTR_ALWAYS_INLINE;
+tusb_interface_status_t hidh_interface_status(uint8_t dev_addr, hidh_interface_info_t *p_hid)
+{
+ switch( tusbh_device_get_state(dev_addr) )
+ {
+ case TUSB_DEVICE_STATE_UNPLUG:
+ case TUSB_DEVICE_STATE_INVALID_PARAMETER:
+ return TUSB_INTERFACE_STATUS_INVALID_PARA;
+
+ default:
+ return p_hid->status;
+ }
+}
//--------------------------------------------------------------------+
// KEYBOARD
@@ -94,15 +107,7 @@ tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, uint8_t instance_nu
tusb_interface_status_t tusbh_hid_keyboard_status(uint8_t dev_addr, uint8_t instance_num)
{
- switch( tusbh_device_get_state(dev_addr) )
- {
- case TUSB_DEVICE_STATE_UNPLUG:
- case TUSB_DEVICE_STATE_INVALID_PARAMETER:
- return TUSB_INTERFACE_STATUS_INVALID_PARA;
-
- default:
- return keyboard_data[dev_addr-1].status;
- }
+ return hidh_interface_status(dev_addr, &keyboard_data[dev_addr-1]);
}
//------------- Internal API -------------//
static inline tusb_error_t hidh_keyboard_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const *p_endpoint_desc) ATTR_ALWAYS_INLINE;
@@ -160,6 +165,8 @@ tusb_interface_status_t tusbh_hid_mouse_status(uint8_t dev_addr, uint8_t instanc
default:
return mouse_data[dev_addr-1].status;
}*/
+
+ return TUSB_INTERFACE_STATUS_INVALID_PARA;
}
//------------- Internal API -------------//