diff options
| author | hathach <[email protected]> | 2022-03-17 12:53:52 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2022-03-17 12:53:52 +0700 |
| commit | 68bfd048a54d1ff2def4cb1ee5285eacdb55f143 (patch) | |
| tree | 61b1f278ed2b5e5d60588fdb8b3344671d8764cc /src/class | |
| parent | 98d4ed05845e3a2efb32b0817d635457698b8cc9 (diff) | |
change tuh_control_xfer_t struct
Diffstat (limited to 'src/class')
| -rw-r--r-- | src/class/cdc/cdc_host.c | 26 | ||||
| -rw-r--r-- | src/class/hid/hid_host.c | 103 | ||||
| -rw-r--r-- | src/class/msc/msc_host.c | 26 |
3 files changed, 84 insertions, 71 deletions
diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c index 8ca3dfbcb..9838df818 100644 --- a/src/class/cdc/cdc_host.c +++ b/src/class/cdc/cdc_host.c @@ -124,22 +124,24 @@ bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_co { cdch_data_t const * p_cdc = get_itf(dev_addr); - tuh_control_xfer_t const xfer = + tusb_control_request_t const request = { - .request = + .bmRequestType_bit = { - .bmRequestType_bit = - { - .recipient = TUSB_REQ_RCPT_INTERFACE, - .type = TUSB_REQ_TYPE_CLASS, - .direction = TUSB_DIR_OUT - }, - .bRequest = CDC_REQUEST_SET_CONTROL_LINE_STATE, - .wValue = (rts ? 2 : 0) | (dtr ? 1 : 0), - .wIndex = p_cdc->itf_num, - .wLength = 0 + .recipient = TUSB_REQ_RCPT_INTERFACE, + .type = TUSB_REQ_TYPE_CLASS, + .direction = TUSB_DIR_OUT }, + .bRequest = CDC_REQUEST_SET_CONTROL_LINE_STATE, + .wValue = (rts ? 2 : 0) | (dtr ? 1 : 0), + .wIndex = p_cdc->itf_num, + .wLength = 0 + }; + tuh_control_xfer_t const xfer = + { + .ep_addr = 0, + .setup = &request, .buffer = NULL, .complete_cb = complete_cb, .user_arg = 0 diff --git a/src/class/hid/hid_host.c b/src/class/hid/hid_host.c index 6bcd2f5d3..8c1a5ebc9 100644 --- a/src/class/hid/hid_host.c +++ b/src/class/hid/hid_host.c @@ -105,11 +105,11 @@ uint8_t tuh_hid_get_protocol(uint8_t dev_addr, uint8_t instance) static bool set_protocol_complete(uint8_t dev_addr, tuh_control_xfer_t const * xfer, xfer_result_t result) { - uint8_t const itf_num = (uint8_t) xfer->request.wIndex; + uint8_t const itf_num = (uint8_t) xfer->setup->wIndex; uint8_t const instance = get_instance_id_by_itfnum(dev_addr, itf_num); hidh_interface_t* hid_itf = get_instance(dev_addr, instance); - if (XFER_RESULT_SUCCESS == result) hid_itf->protocol_mode = (uint8_t) xfer->request.wValue; + if (XFER_RESULT_SUCCESS == result) hid_itf->protocol_mode = (uint8_t) xfer->setup->wValue; if (tuh_hid_set_protocol_complete_cb) { @@ -124,22 +124,24 @@ static bool _hidh_set_protocol(uint8_t dev_addr, uint8_t itf_num, uint8_t protoc { TU_LOG2("HID Set Protocol = %d\r\n", protocol); - tuh_control_xfer_t const xfer = + tusb_control_request_t const request = { - .request = + .bmRequestType_bit = { - .bmRequestType_bit = - { - .recipient = TUSB_REQ_RCPT_INTERFACE, - .type = TUSB_REQ_TYPE_CLASS, - .direction = TUSB_DIR_OUT - }, - .bRequest = HID_REQ_CONTROL_SET_PROTOCOL, - .wValue = protocol, - .wIndex = itf_num, - .wLength = 0 + .recipient = TUSB_REQ_RCPT_INTERFACE, + .type = TUSB_REQ_TYPE_CLASS, + .direction = TUSB_DIR_OUT }, + .bRequest = HID_REQ_CONTROL_SET_PROTOCOL, + .wValue = protocol, + .wIndex = itf_num, + .wLength = 0 + }; + tuh_control_xfer_t const xfer = + { + .ep_addr = 0, + .setup = &request, .buffer = NULL, .complete_cb = complete_cb, .user_arg = user_arg @@ -163,13 +165,13 @@ static bool set_report_complete(uint8_t dev_addr, tuh_control_xfer_t const * xfe if (tuh_hid_set_report_complete_cb) { - uint8_t const itf_num = (uint8_t) xfer->request.wIndex; + uint8_t const itf_num = (uint8_t) xfer->setup->wIndex; uint8_t const instance = get_instance_id_by_itfnum(dev_addr, itf_num); - uint8_t const report_type = tu_u16_high(xfer->request.wValue); - uint8_t const report_id = tu_u16_low(xfer->request.wValue); + uint8_t const report_type = tu_u16_high(xfer->setup->wValue); + uint8_t const report_id = tu_u16_low(xfer->setup->wValue); - tuh_hid_set_report_complete_cb(dev_addr, instance, report_id, report_type, (result == XFER_RESULT_SUCCESS) ? xfer->request.wLength : 0); + tuh_hid_set_report_complete_cb(dev_addr, instance, report_id, report_type, (result == XFER_RESULT_SUCCESS) ? xfer->setup->wLength : 0); } return true; @@ -180,22 +182,24 @@ bool tuh_hid_set_report(uint8_t dev_addr, uint8_t instance, uint8_t report_id, u hidh_interface_t* hid_itf = get_instance(dev_addr, instance); TU_LOG2("HID Set Report: id = %u, type = %u, len = %u\r\n", report_id, report_type, len); - tuh_control_xfer_t const xfer = + tusb_control_request_t const request = { - .request = + .bmRequestType_bit = { - .bmRequestType_bit = - { - .recipient = TUSB_REQ_RCPT_INTERFACE, - .type = TUSB_REQ_TYPE_CLASS, - .direction = TUSB_DIR_OUT - }, - .bRequest = HID_REQ_CONTROL_SET_REPORT, - .wValue = tu_u16(report_type, report_id), - .wIndex = hid_itf->itf_num, - .wLength = len + .recipient = TUSB_REQ_RCPT_INTERFACE, + .type = TUSB_REQ_TYPE_CLASS, + .direction = TUSB_DIR_OUT }, + .bRequest = HID_REQ_CONTROL_SET_REPORT, + .wValue = tu_u16(report_type, report_id), + .wIndex = hid_itf->itf_num, + .wLength = len + }; + tuh_control_xfer_t const xfer = + { + .ep_addr = 0, + .setup = &request, .buffer = report, .complete_cb = set_report_complete, .user_arg = 0 @@ -209,22 +213,24 @@ static bool _hidh_set_idle(uint8_t dev_addr, uint8_t itf_num, uint16_t idle_rate { // SET IDLE request, device can stall if not support this request TU_LOG2("HID Set Idle \r\n"); - tuh_control_xfer_t const xfer = + tusb_control_request_t const request = { - .request = + .bmRequestType_bit = { - .bmRequestType_bit = - { - .recipient = TUSB_REQ_RCPT_INTERFACE, - .type = TUSB_REQ_TYPE_CLASS, - .direction = TUSB_DIR_OUT - }, - .bRequest = HID_REQ_CONTROL_SET_IDLE, - .wValue = idle_rate, - .wIndex = itf_num, - .wLength = 0 + .recipient = TUSB_REQ_RCPT_INTERFACE, + .type = TUSB_REQ_TYPE_CLASS, + .direction = TUSB_DIR_OUT }, + .bRequest = HID_REQ_CONTROL_SET_IDLE, + .wValue = idle_rate, + .wIndex = itf_num, + .wLength = 0 + }; + tuh_control_xfer_t const xfer = + { + .ep_addr = 0, + .setup = &request, .buffer = NULL, .complete_cb = complete_cb, .user_arg = user_arg @@ -387,24 +393,27 @@ static bool process_set_config(uint8_t dev_addr, tuh_control_xfer_t const * xfer bool hidh_set_config(uint8_t dev_addr, uint8_t itf_num) { + tusb_control_request_t request; + request.wIndex = tu_htole16((uint16_t) itf_num); + tuh_control_xfer_t xfer; - xfer.request.wIndex = tu_htole16((uint16_t) itf_num); + xfer.setup = &request; xfer.user_arg = CONFG_SET_IDLE; - // start the set config process + // fake request to start the set config process return process_set_config(dev_addr, &xfer, XFER_RESULT_SUCCESS); } static bool process_set_config(uint8_t dev_addr, tuh_control_xfer_t const * xfer, xfer_result_t result) { // Stall is a valid response for SET_IDLE, therefore we could ignore its result - if ( xfer->request.bRequest != HID_REQ_CONTROL_SET_IDLE ) + if ( xfer->setup->bRequest != HID_REQ_CONTROL_SET_IDLE ) { TU_ASSERT(result == XFER_RESULT_SUCCESS); } uintptr_t const state = xfer->user_arg; - uint8_t const itf_num = (uint8_t) tu_le16toh(xfer->request.wIndex); + uint8_t const itf_num = (uint8_t) tu_le16toh(xfer->setup->wIndex); uint8_t const instance = get_instance_id_by_itfnum(dev_addr, itf_num); hidh_interface_t* hid_itf = get_instance(dev_addr, instance); @@ -441,7 +450,7 @@ static bool process_set_config(uint8_t dev_addr, tuh_control_xfer_t const * xfer case CONFIG_COMPLETE: { uint8_t const* desc_report = usbh_get_enum_buf(); - uint16_t const desc_len = xfer->request.wLength; + uint16_t const desc_len = xfer->setup->wLength; config_driver_mount_complete(dev_addr, instance, desc_report, desc_len); } diff --git a/src/class/msc/msc_host.c b/src/class/msc/msc_host.c index b3af65942..d8910db0f 100644 --- a/src/class/msc/msc_host.c +++ b/src/class/msc/msc_host.c @@ -405,22 +405,24 @@ bool msch_set_config(uint8_t dev_addr, uint8_t itf_num) //------------- Get Max Lun -------------// TU_LOG2("MSC Get Max Lun\r\n"); - tuh_control_xfer_t const xfer = + tusb_control_request_t const request = { - .request = + .bmRequestType_bit = { - .bmRequestType_bit = - { - .recipient = TUSB_REQ_RCPT_INTERFACE, - .type = TUSB_REQ_TYPE_CLASS, - .direction = TUSB_DIR_IN - }, - .bRequest = MSC_REQ_GET_MAX_LUN, - .wValue = 0, - .wIndex = itf_num, - .wLength = 1 + .recipient = TUSB_REQ_RCPT_INTERFACE, + .type = TUSB_REQ_TYPE_CLASS, + .direction = TUSB_DIR_IN }, + .bRequest = MSC_REQ_GET_MAX_LUN, + .wValue = 0, + .wIndex = itf_num, + .wLength = 1 + }; + tuh_control_xfer_t const xfer = + { + .ep_addr = 0, + .setup = &request, .buffer = &p_msc->max_lun, .complete_cb = config_get_maxlun_complete, .user_arg = 0 |
