refine hid host driver
This commit is contained in:
+3
-2
@@ -104,8 +104,9 @@ typedef ATTR_PREPACKED struct ATTR_PACKED {
|
||||
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 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;
|
||||
|
||||
/**
|
||||
|
||||
+23
-32
@@ -197,7 +197,10 @@ void hidh_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
//uint8_t report_descriptor[256] TUSB_CFG_ATTR_USBRAM;
|
||||
#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;
|
||||
@@ -215,41 +218,29 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
|
||||
|
||||
OSAL_SUBTASK_BEGIN
|
||||
|
||||
#if 0
|
||||
//------------- SET IDLE request -------------//
|
||||
// TODO this request can be stalled by device (indicate not supported),
|
||||
// until we have clear stall handler, temporarily disable it.
|
||||
// OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||
// usbh_control_xfer_subtask(
|
||||
// dev_addr,
|
||||
// &(tusb_control_request_t)
|
||||
// {
|
||||
// .bmRequestType = { .direction = TUSB_DIR_HOST_TO_DEV, .type = TUSB_REQUEST_TYPE_CLASS, .recipient = TUSB_REQUEST_RECIPIENT_INTERFACE },
|
||||
// .bRequest = HID_REQUEST_CONTROL_SET_IDLE,
|
||||
// .wValue = 0,
|
||||
// .wIndex = p_interface_desc->bInterfaceNumber
|
||||
// },
|
||||
// NULL ),
|
||||
// error
|
||||
// );
|
||||
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
|
||||
);
|
||||
|
||||
//------------- TODO skip Get Report Descriptor -------------//
|
||||
// memclr_(report_descriptor, 256);
|
||||
|
||||
// OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||
// usbh_control_xfer_subtask(
|
||||
// dev_addr,
|
||||
// &(tusb_control_request_t)
|
||||
// {
|
||||
// .bmRequestType = { .direction = TUSB_DIR_DEV_TO_HOST, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_INTERFACE },
|
||||
// .bRequest = TUSB_REQUEST_GET_DESCRIPTOR,
|
||||
// .wValue = HID_DESC_TYPE_REPORT,
|
||||
// .wIndex = p_interface_desc->bInterfaceNumber,
|
||||
// .wLength = p_desc_hid->wReportLength,
|
||||
// },
|
||||
// report_descriptor ),
|
||||
// error
|
||||
// );
|
||||
// uint8_t *p_report_desc = NULL; // report descriptor has to be global & in USB RAM
|
||||
//------------- 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 )
|
||||
{
|
||||
|
||||
+2
-2
@@ -418,14 +418,14 @@ tusb_error_t enumeration_body_subtask(void)
|
||||
error
|
||||
);
|
||||
SUBTASK_ASSERT_STATUS(error);
|
||||
SUBTASK_ASSERT_WITH_HANDLER( TUSB_CFG_HOST_ENUM_BUFFER_SIZE > ((tusb_descriptor_configuration_t*)enum_data_buffer)->wTotalLength,
|
||||
SUBTASK_ASSERT_WITH_HANDLER( TUSB_CFG_HOST_ENUM_BUFFER_SIZE >= ((tusb_descriptor_configuration_t*)enum_data_buffer)->wTotalLength,
|
||||
tusbh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_CONFIG_DESC_TOO_LONG, NULL) );
|
||||
|
||||
//------------- Get full configuration descriptor -------------//
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||
usbh_control_xfer_subtask( new_addr, bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_STANDARD, TUSB_REQUEST_RECIPIENT_DEVICE),
|
||||
TUSB_REQUEST_GET_DESCRIPTOR, (TUSB_DESC_TYPE_CONFIGURATION << 8) | (configure_selected - 1), 0,
|
||||
((tusb_descriptor_configuration_t*) enum_data_buffer)->wTotalLength, enum_data_buffer ),
|
||||
TUSB_CFG_HOST_ENUM_BUFFER_SIZE, enum_data_buffer ),
|
||||
error
|
||||
);
|
||||
SUBTASK_ASSERT_STATUS(error);
|
||||
|
||||
Reference in New Issue
Block a user