mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
rename tuh_control_xfer_t to tuh_xfer_t
This commit is contained in:
parent
102b99a0e8
commit
55428d7dd2
@ -115,7 +115,7 @@ static void utf16_to_utf8(uint16_t *temp_buf, size_t buf_len) {
|
||||
((uint8_t*) temp_buf)[utf8_len] = '\0';
|
||||
}
|
||||
|
||||
void print_device_descriptor(uint8_t daddr, tuh_control_xfer_t* xfer)
|
||||
void print_device_descriptor(uint8_t daddr, tuh_xfer_t* xfer)
|
||||
{
|
||||
if ( XFER_RESULT_SUCCESS != xfer->result )
|
||||
{
|
||||
|
@ -120,7 +120,7 @@ bool tuh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length, bool is
|
||||
return usbh_edpt_xfer(dev_addr, ep_in, p_buffer, length);
|
||||
}
|
||||
|
||||
bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_control_xfer_cb_t complete_cb)
|
||||
bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_xfer_cb_t complete_cb)
|
||||
{
|
||||
cdch_data_t const * p_cdc = get_itf(dev_addr);
|
||||
|
||||
@ -138,7 +138,7 @@ bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_co
|
||||
.wLength = 0
|
||||
};
|
||||
|
||||
tuh_control_xfer_t xfer =
|
||||
tuh_xfer_t xfer =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.setup = &request,
|
||||
|
@ -42,14 +42,14 @@
|
||||
* \defgroup CDC_Serial_Host Host
|
||||
* @{ */
|
||||
|
||||
bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_control_xfer_cb_t complete_cb);
|
||||
bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_xfer_cb_t complete_cb);
|
||||
|
||||
static inline bool tuh_cdc_connect(uint8_t dev_addr, tuh_control_xfer_cb_t complete_cb)
|
||||
static inline bool tuh_cdc_connect(uint8_t dev_addr, tuh_xfer_cb_t complete_cb)
|
||||
{
|
||||
return tuh_cdc_set_control_line_state(dev_addr, true, true, complete_cb);
|
||||
}
|
||||
|
||||
static inline bool tuh_cdc_disconnect(uint8_t dev_addr, tuh_control_xfer_cb_t complete_cb)
|
||||
static inline bool tuh_cdc_disconnect(uint8_t dev_addr, tuh_xfer_cb_t complete_cb)
|
||||
{
|
||||
return tuh_cdc_set_control_line_state(dev_addr, false, false, complete_cb);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ uint8_t tuh_hid_get_protocol(uint8_t dev_addr, uint8_t instance)
|
||||
return hid_itf->protocol_mode;
|
||||
}
|
||||
|
||||
static void set_protocol_complete(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void set_protocol_complete(uint8_t dev_addr, tuh_xfer_t* xfer)
|
||||
{
|
||||
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);
|
||||
@ -121,7 +121,7 @@ static void set_protocol_complete(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
}
|
||||
|
||||
|
||||
static bool _hidh_set_protocol(uint8_t dev_addr, uint8_t itf_num, uint8_t protocol, tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
static bool _hidh_set_protocol(uint8_t dev_addr, uint8_t itf_num, uint8_t protocol, tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
TU_LOG2("HID Set Protocol = %d\r\n", protocol);
|
||||
|
||||
@ -139,7 +139,7 @@ static bool _hidh_set_protocol(uint8_t dev_addr, uint8_t itf_num, uint8_t protoc
|
||||
.wLength = 0
|
||||
};
|
||||
|
||||
tuh_control_xfer_t xfer =
|
||||
tuh_xfer_t xfer =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.setup = &request,
|
||||
@ -160,7 +160,7 @@ bool tuh_hid_set_protocol(uint8_t dev_addr, uint8_t instance, uint8_t protocol)
|
||||
return _hidh_set_protocol(dev_addr, hid_itf->itf_num, protocol, set_protocol_complete, 0);
|
||||
}
|
||||
|
||||
static void set_report_complete(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void set_report_complete(uint8_t dev_addr, tuh_xfer_t* xfer)
|
||||
{
|
||||
TU_LOG2("HID Set Report complete\r\n");
|
||||
|
||||
@ -196,7 +196,7 @@ bool tuh_hid_set_report(uint8_t dev_addr, uint8_t instance, uint8_t report_id, u
|
||||
.wLength = len
|
||||
};
|
||||
|
||||
tuh_control_xfer_t xfer =
|
||||
tuh_xfer_t xfer =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.setup = &request,
|
||||
@ -209,7 +209,7 @@ bool tuh_hid_set_report(uint8_t dev_addr, uint8_t instance, uint8_t report_id, u
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _hidh_set_idle(uint8_t dev_addr, uint8_t itf_num, uint16_t idle_rate, tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
static bool _hidh_set_idle(uint8_t dev_addr, uint8_t itf_num, uint16_t idle_rate, tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
// SET IDLE request, device can stall if not support this request
|
||||
TU_LOG2("HID Set Idle \r\n");
|
||||
@ -227,7 +227,7 @@ static bool _hidh_set_idle(uint8_t dev_addr, uint8_t itf_num, uint16_t idle_rate
|
||||
.wLength = 0
|
||||
};
|
||||
|
||||
tuh_control_xfer_t xfer =
|
||||
tuh_xfer_t xfer =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.setup = &request,
|
||||
@ -389,14 +389,14 @@ enum {
|
||||
};
|
||||
|
||||
static void config_driver_mount_complete(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_report, uint16_t desc_len);
|
||||
static void process_set_config(uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
static void process_set_config(uint8_t dev_addr, tuh_xfer_t* 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;
|
||||
tuh_xfer_t xfer;
|
||||
xfer.result = XFER_RESULT_SUCCESS;
|
||||
xfer.setup = &request;
|
||||
xfer.user_arg = CONFG_SET_IDLE;
|
||||
@ -407,7 +407,7 @@ bool hidh_set_config(uint8_t dev_addr, uint8_t itf_num)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void process_set_config(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void process_set_config(uint8_t dev_addr, tuh_xfer_t* xfer)
|
||||
{
|
||||
// Stall is a valid response for SET_IDLE, therefore we could ignore its result
|
||||
if ( xfer->setup->bRequest != HID_REQ_CONTROL_SET_IDLE )
|
||||
|
@ -358,7 +358,7 @@ bool msch_xfer_cb(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32
|
||||
// MSC Enumeration
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
static void config_get_maxlun_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
static void config_get_maxlun_complete (uint8_t dev_addr, tuh_xfer_t* xfer);
|
||||
static bool config_test_unit_ready_complete(uint8_t dev_addr, msc_cbw_t const* cbw, msc_csw_t const* csw);
|
||||
static bool config_request_sense_complete(uint8_t dev_addr, msc_cbw_t const* cbw, msc_csw_t const* csw);
|
||||
static bool config_read_capacity_complete(uint8_t dev_addr, msc_cbw_t const* cbw, msc_csw_t const* csw);
|
||||
@ -419,7 +419,7 @@ bool msch_set_config(uint8_t dev_addr, uint8_t itf_num)
|
||||
.wLength = 1
|
||||
};
|
||||
|
||||
tuh_control_xfer_t xfer =
|
||||
tuh_xfer_t xfer =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.setup = &request,
|
||||
@ -432,7 +432,7 @@ bool msch_set_config(uint8_t dev_addr, uint8_t itf_num)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void config_get_maxlun_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void config_get_maxlun_complete (uint8_t dev_addr, tuh_xfer_t* xfer)
|
||||
{
|
||||
msch_interface_t* p_msc = get_itf(dev_addr);
|
||||
|
||||
|
@ -78,7 +78,7 @@ static char const* const _hub_feature_str[] =
|
||||
// HUB
|
||||
//--------------------------------------------------------------------+
|
||||
bool hub_port_clear_feature(uint8_t hub_addr, uint8_t hub_port, uint8_t feature,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
tusb_control_request_t const request =
|
||||
{
|
||||
@ -94,7 +94,7 @@ bool hub_port_clear_feature(uint8_t hub_addr, uint8_t hub_port, uint8_t feature,
|
||||
.wLength = 0
|
||||
};
|
||||
|
||||
tuh_control_xfer_t xfer =
|
||||
tuh_xfer_t xfer =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.setup = &request,
|
||||
@ -109,7 +109,7 @@ bool hub_port_clear_feature(uint8_t hub_addr, uint8_t hub_port, uint8_t feature,
|
||||
}
|
||||
|
||||
bool hub_port_set_feature(uint8_t hub_addr, uint8_t hub_port, uint8_t feature,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
tusb_control_request_t const request =
|
||||
{
|
||||
@ -125,7 +125,7 @@ bool hub_port_set_feature(uint8_t hub_addr, uint8_t hub_port, uint8_t feature,
|
||||
.wLength = 0
|
||||
};
|
||||
|
||||
tuh_control_xfer_t xfer =
|
||||
tuh_xfer_t xfer =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.setup = &request,
|
||||
@ -140,7 +140,7 @@ bool hub_port_set_feature(uint8_t hub_addr, uint8_t hub_port, uint8_t feature,
|
||||
}
|
||||
|
||||
bool hub_port_get_status(uint8_t hub_addr, uint8_t hub_port, void* resp,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
tusb_control_request_t const request =
|
||||
{
|
||||
@ -156,7 +156,7 @@ bool hub_port_get_status(uint8_t hub_addr, uint8_t hub_port, void* resp,
|
||||
.wLength = 4
|
||||
};
|
||||
|
||||
tuh_control_xfer_t xfer =
|
||||
tuh_xfer_t xfer =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.setup = &request,
|
||||
@ -225,8 +225,8 @@ bool hub_edpt_status_xfer(uint8_t dev_addr)
|
||||
// Set Configure
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
static void config_set_port_power (uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
static void config_port_power_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
static void config_set_port_power (uint8_t dev_addr, tuh_xfer_t* xfer);
|
||||
static void config_port_power_complete (uint8_t dev_addr, tuh_xfer_t* xfer);
|
||||
|
||||
bool hub_set_config(uint8_t dev_addr, uint8_t itf_num)
|
||||
{
|
||||
@ -248,7 +248,7 @@ bool hub_set_config(uint8_t dev_addr, uint8_t itf_num)
|
||||
.wLength = sizeof(descriptor_hub_desc_t)
|
||||
};
|
||||
|
||||
tuh_control_xfer_t xfer =
|
||||
tuh_xfer_t xfer =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.setup = &request,
|
||||
@ -262,7 +262,7 @@ bool hub_set_config(uint8_t dev_addr, uint8_t itf_num)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void config_set_port_power (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void config_set_port_power (uint8_t dev_addr, tuh_xfer_t* xfer)
|
||||
{
|
||||
TU_ASSERT(XFER_RESULT_SUCCESS == xfer->result, );
|
||||
|
||||
@ -279,7 +279,7 @@ static void config_set_port_power (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
hub_port_set_feature(dev_addr, hub_port, HUB_FEATURE_PORT_POWER, config_port_power_complete, 0);
|
||||
}
|
||||
|
||||
static void config_port_power_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void config_port_power_complete (uint8_t dev_addr, tuh_xfer_t* xfer)
|
||||
{
|
||||
TU_ASSERT(XFER_RESULT_SUCCESS == xfer->result, );
|
||||
hub_interface_t* p_hub = get_itf(dev_addr);
|
||||
@ -303,9 +303,9 @@ static void config_port_power_complete (uint8_t dev_addr, tuh_control_xfer_t* xf
|
||||
// Connection Changes
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
static void connection_get_status_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
static void connection_clear_conn_change_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
static void connection_port_reset_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
static void connection_get_status_complete (uint8_t dev_addr, tuh_xfer_t* xfer);
|
||||
static void connection_clear_conn_change_complete (uint8_t dev_addr, tuh_xfer_t* xfer);
|
||||
static void connection_port_reset_complete (uint8_t dev_addr, tuh_xfer_t* xfer);
|
||||
|
||||
// callback as response of interrupt endpoint polling
|
||||
bool hub_xfer_cb(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
|
||||
@ -333,7 +333,7 @@ bool hub_xfer_cb(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t result, uint32
|
||||
return true;
|
||||
}
|
||||
|
||||
static void connection_get_status_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void connection_get_status_complete (uint8_t dev_addr, tuh_xfer_t* xfer)
|
||||
{
|
||||
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS, );
|
||||
|
||||
@ -359,7 +359,7 @@ static void connection_get_status_complete (uint8_t dev_addr, tuh_control_xfer_t
|
||||
}
|
||||
}
|
||||
|
||||
static void connection_clear_conn_change_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void connection_clear_conn_change_complete (uint8_t dev_addr, tuh_xfer_t* xfer)
|
||||
{
|
||||
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS, );
|
||||
|
||||
@ -388,7 +388,7 @@ static void connection_clear_conn_change_complete (uint8_t dev_addr, tuh_control
|
||||
}
|
||||
}
|
||||
|
||||
static void connection_port_reset_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void connection_port_reset_complete (uint8_t dev_addr, tuh_xfer_t* xfer)
|
||||
{
|
||||
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS, );
|
||||
|
||||
|
@ -173,29 +173,29 @@ TU_VERIFY_STATIC( sizeof(hub_port_status_response_t) == 4, "size is not correct"
|
||||
|
||||
// Clear feature
|
||||
bool hub_port_clear_feature (uint8_t hub_addr, uint8_t hub_port, uint8_t feature,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
|
||||
// Set feature
|
||||
bool hub_port_set_feature (uint8_t hub_addr, uint8_t hub_port, uint8_t feature,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
|
||||
// Get port status
|
||||
bool hub_port_get_status (uint8_t hub_addr, uint8_t hub_port, void* resp,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
|
||||
// Get status from Interrupt endpoint
|
||||
bool hub_edpt_status_xfer(uint8_t dev_addr);
|
||||
|
||||
// Reset a port
|
||||
static inline bool hub_port_reset(uint8_t hub_addr, uint8_t hub_port,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
return hub_port_set_feature(hub_addr, hub_port, HUB_FEATURE_PORT_RESET, complete_cb, user_arg);
|
||||
}
|
||||
|
||||
// Clear Reset Change
|
||||
static inline bool hub_port_clear_reset_change(uint8_t hub_addr, uint8_t hub_port,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
return hub_port_clear_feature(hub_addr, hub_port, HUB_FEATURE_PORT_RESET_CHANGE, complete_cb, user_arg);
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ struct
|
||||
{
|
||||
tusb_control_request_t request TU_ATTR_ALIGNED(4);
|
||||
uint8_t* buffer;
|
||||
tuh_control_xfer_cb_t complete_cb;
|
||||
tuh_xfer_cb_t complete_cb;
|
||||
uintptr_t user_arg;
|
||||
|
||||
volatile uint16_t actual_len;
|
||||
@ -311,7 +311,7 @@ void osal_task_delay(uint32_t msec)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
static bool _get_descriptor(uint8_t daddr, uint8_t type, uint8_t index, uint16_t language_id, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
tusb_control_request_t const request =
|
||||
{
|
||||
@ -327,7 +327,7 @@ static bool _get_descriptor(uint8_t daddr, uint8_t type, uint8_t index, uint16_t
|
||||
.wLength = tu_htole16(len)
|
||||
};
|
||||
|
||||
tuh_control_xfer_t xfer =
|
||||
tuh_xfer_t xfer =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.setup = &request,
|
||||
@ -340,20 +340,20 @@ static bool _get_descriptor(uint8_t daddr, uint8_t type, uint8_t index, uint16_t
|
||||
}
|
||||
|
||||
bool tuh_descriptor_get(uint8_t daddr, uint8_t type, uint8_t index, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
return _get_descriptor(daddr, type, index, 0x0000, buffer, len, complete_cb, user_arg);
|
||||
}
|
||||
|
||||
bool tuh_descriptor_get_device(uint8_t daddr, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
len = tu_min16(len, sizeof(tusb_desc_device_t));
|
||||
return tuh_descriptor_get(daddr, TUSB_DESC_DEVICE, 0, buffer, len, complete_cb, user_arg);
|
||||
}
|
||||
|
||||
bool tuh_descriptor_get_configuration(uint8_t daddr, uint8_t index, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
return tuh_descriptor_get(daddr, TUSB_DESC_CONFIGURATION, index, buffer, len, complete_cb, user_arg);
|
||||
}
|
||||
@ -361,14 +361,14 @@ bool tuh_descriptor_get_configuration(uint8_t daddr, uint8_t index, void* buffer
|
||||
//------------- String Descriptor -------------//
|
||||
|
||||
bool tuh_descriptor_get_string(uint8_t daddr, uint8_t index, uint16_t language_id, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
return _get_descriptor(daddr, TUSB_DESC_STRING, index, language_id, buffer, len, complete_cb, user_arg);
|
||||
}
|
||||
|
||||
// Get manufacturer string descriptor
|
||||
bool tuh_descriptor_get_manufacturer_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
usbh_device_t const* dev = get_device(daddr);
|
||||
TU_VERIFY(dev && dev->i_manufacturer);
|
||||
@ -377,7 +377,7 @@ bool tuh_descriptor_get_manufacturer_string(uint8_t daddr, uint16_t language_id,
|
||||
|
||||
// Get product string descriptor
|
||||
bool tuh_descriptor_get_product_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
usbh_device_t const* dev = get_device(daddr);
|
||||
TU_VERIFY(dev && dev->i_product);
|
||||
@ -386,7 +386,7 @@ bool tuh_descriptor_get_product_string(uint8_t daddr, uint16_t language_id, void
|
||||
|
||||
// Get serial string descriptor
|
||||
bool tuh_descriptor_get_serial_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
usbh_device_t const* dev = get_device(daddr);
|
||||
TU_VERIFY(dev && dev->i_serial);
|
||||
@ -395,7 +395,7 @@ bool tuh_descriptor_get_serial_string(uint8_t daddr, uint16_t language_id, void*
|
||||
|
||||
// Get HID report descriptor
|
||||
bool tuh_descriptor_get_hid_report(uint8_t daddr, uint8_t itf_num, uint8_t desc_type, uint8_t index, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
TU_LOG2("HID Get Report Descriptor\r\n");
|
||||
tusb_control_request_t const request =
|
||||
@ -412,7 +412,7 @@ bool tuh_descriptor_get_hid_report(uint8_t daddr, uint8_t itf_num, uint8_t desc_
|
||||
.wLength = len
|
||||
};
|
||||
|
||||
tuh_control_xfer_t xfer =
|
||||
tuh_xfer_t xfer =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.setup = &request,
|
||||
@ -425,7 +425,7 @@ bool tuh_descriptor_get_hid_report(uint8_t daddr, uint8_t itf_num, uint8_t desc_
|
||||
}
|
||||
|
||||
bool tuh_configuration_set(uint8_t daddr, uint8_t config_num,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg)
|
||||
{
|
||||
TU_LOG2("Set Configuration = %d\r\n", config_num);
|
||||
|
||||
@ -443,7 +443,7 @@ bool tuh_configuration_set(uint8_t daddr, uint8_t config_num,
|
||||
.wLength = 0
|
||||
};
|
||||
|
||||
tuh_control_xfer_t xfer =
|
||||
tuh_xfer_t xfer =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.setup = &request,
|
||||
@ -531,7 +531,7 @@ bool tuh_init(uint8_t rhport)
|
||||
TU_LOG2("USBH init\r\n");
|
||||
TU_LOG2_INT(sizeof(usbh_device_t));
|
||||
TU_LOG2_INT(sizeof(hcd_event_t));
|
||||
TU_LOG2_INT(sizeof(tuh_control_xfer_t));
|
||||
TU_LOG2_INT(sizeof(tuh_xfer_t));
|
||||
|
||||
// Event queue
|
||||
_usbh_q = osal_queue_create( &_usbh_qdef );
|
||||
@ -883,14 +883,14 @@ bool usbh_edpt_busy(uint8_t dev_addr, uint8_t ep_addr)
|
||||
// Control transfer
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
static void _control_blocking_complete_cb(uint8_t daddr, tuh_control_xfer_t* xfer)
|
||||
static void _control_blocking_complete_cb(uint8_t daddr, tuh_xfer_t* xfer)
|
||||
{
|
||||
(void) daddr;
|
||||
// update result
|
||||
*((xfer_result_t*) xfer->user_arg) = xfer->result;
|
||||
}
|
||||
|
||||
bool tuh_control_xfer (uint8_t daddr, tuh_control_xfer_t* xfer)
|
||||
bool tuh_control_xfer (uint8_t daddr, tuh_xfer_t* xfer)
|
||||
{
|
||||
// pre-check to help reducing mutex lock
|
||||
TU_VERIFY(_ctrl_xfer.stage == CONTROL_STAGE_IDLE);
|
||||
@ -956,7 +956,7 @@ bool tuh_control_xfer (uint8_t daddr, tuh_control_xfer_t* xfer)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tuh_control_xfer_sync(uint8_t daddr, tuh_control_xfer_t* xfer, uint32_t timeout_ms)
|
||||
bool tuh_control_xfer_sync(uint8_t daddr, tuh_xfer_t* xfer, uint32_t timeout_ms)
|
||||
{
|
||||
(void) timeout_ms;
|
||||
|
||||
@ -982,7 +982,7 @@ static void _xfer_complete(uint8_t dev_addr, xfer_result_t result)
|
||||
|
||||
// duplicate xfer since user can execute control transfer within callback
|
||||
tusb_control_request_t const request = _ctrl_xfer.request;
|
||||
tuh_control_xfer_t xfer_temp =
|
||||
tuh_xfer_t xfer_temp =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.result = result,
|
||||
@ -1125,7 +1125,7 @@ static bool parse_configuration_descriptor (uint8_t dev_addr, tusb_desc_configur
|
||||
static void enum_full_complete(void);
|
||||
|
||||
// process device enumeration
|
||||
static void process_enumeration(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void process_enumeration(uint8_t dev_addr, tuh_xfer_t* xfer)
|
||||
{
|
||||
if (XFER_RESULT_SUCCESS != xfer->result)
|
||||
{
|
||||
@ -1327,7 +1327,7 @@ static bool enum_new_device(hcd_event_t* event)
|
||||
TU_LOG2("%s Speed\r\n", tu_str_speed[_dev0.speed]);
|
||||
|
||||
// fake transfer to kick-off the enumeration process
|
||||
tuh_control_xfer_t xfer;
|
||||
tuh_xfer_t xfer;
|
||||
xfer.result = XFER_RESULT_SUCCESS;
|
||||
xfer.user_arg = ENUM_ADDR0_DEVICE_DESC;
|
||||
|
||||
@ -1410,7 +1410,7 @@ static bool enum_request_set_addr(void)
|
||||
.wLength = 0
|
||||
};
|
||||
|
||||
tuh_control_xfer_t xfer =
|
||||
tuh_xfer_t xfer =
|
||||
{
|
||||
.ep_addr = 0,
|
||||
.setup = &request,
|
||||
|
@ -39,12 +39,12 @@
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// forward declaration
|
||||
struct tuh_control_xfer_s;
|
||||
typedef struct tuh_control_xfer_s tuh_control_xfer_t;
|
||||
struct tuh_xfer_s;
|
||||
typedef struct tuh_xfer_s tuh_xfer_t;
|
||||
|
||||
typedef void (*tuh_control_xfer_cb_t)(uint8_t daddr, tuh_control_xfer_t* xfer);
|
||||
typedef void (*tuh_xfer_cb_t)(uint8_t daddr, tuh_xfer_t* xfer);
|
||||
|
||||
struct tuh_control_xfer_s
|
||||
struct tuh_xfer_s
|
||||
{
|
||||
uint8_t ep_addr;
|
||||
xfer_result_t result;
|
||||
@ -53,7 +53,7 @@ struct tuh_control_xfer_s
|
||||
uint32_t actual_len; // excluding setup packet
|
||||
|
||||
uint8_t* buffer;
|
||||
tuh_control_xfer_cb_t complete_cb;
|
||||
tuh_xfer_cb_t complete_cb;
|
||||
uintptr_t user_arg;
|
||||
};
|
||||
|
||||
@ -117,7 +117,7 @@ static inline bool tuh_ready(uint8_t daddr)
|
||||
// true on success, false if there is on-going control transfer or incorrect parameters
|
||||
// Note: blocking if complete callback is NULL. In this case 'xfer->result' will be updated
|
||||
// and if 'user_arg' point to a xfer_result_t variable, it will be updated as well.
|
||||
bool tuh_control_xfer(uint8_t daddr, tuh_control_xfer_t* xfer);
|
||||
bool tuh_control_xfer(uint8_t daddr, tuh_xfer_t* xfer);
|
||||
|
||||
//bool tuh_edpt_xfer(uint8_t daddr, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
|
||||
|
||||
@ -125,7 +125,7 @@ bool tuh_control_xfer(uint8_t daddr, tuh_control_xfer_t* xfer);
|
||||
// config_num = 0 will un-configure device. Note: config_num = config_descriptor_index + 1
|
||||
// true on success, false if there is on-going control transfer or incorrect parameters
|
||||
bool tuh_configuration_set(uint8_t daddr, uint8_t config_num,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Endpoint Synchronous (blocking)
|
||||
@ -133,7 +133,7 @@ bool tuh_configuration_set(uint8_t daddr, uint8_t config_num,
|
||||
|
||||
// Sync (blocking) version of tuh_control_xfer()
|
||||
// xfer contents will be updated to reflect the transfer
|
||||
bool tuh_control_xfer_sync(uint8_t daddr, tuh_control_xfer_t * xfer, uint32_t timeout_ms);
|
||||
bool tuh_control_xfer_sync(uint8_t daddr, tuh_xfer_t * xfer, uint32_t timeout_ms);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Descriptors Asynchronous (non-blocking)
|
||||
@ -142,43 +142,43 @@ bool tuh_control_xfer_sync(uint8_t daddr, tuh_control_xfer_t * xfer, uint32_t ti
|
||||
// Get an descriptor (control transfer)
|
||||
// true on success, false if there is on-going control transfer or incorrect parameters
|
||||
bool tuh_descriptor_get(uint8_t daddr, uint8_t type, uint8_t index, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
|
||||
// Get device descriptor (control transfer)
|
||||
// true on success, false if there is on-going control transfer or incorrect parameters
|
||||
bool tuh_descriptor_get_device(uint8_t daddr, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
|
||||
// Get configuration descriptor (control transfer)
|
||||
// true on success, false if there is on-going control transfer or incorrect parameters
|
||||
bool tuh_descriptor_get_configuration(uint8_t daddr, uint8_t index, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
|
||||
// Get HID report descriptor (control transfer)
|
||||
// true on success, false if there is on-going control transfer or incorrect parameters
|
||||
bool tuh_descriptor_get_hid_report(uint8_t daddr, uint8_t itf_num, uint8_t desc_type, uint8_t index, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
|
||||
// Get string descriptor (control transfer)
|
||||
// true on success, false if there is on-going control transfer or incorrect parameters
|
||||
// Blocking if complete callback is NULL, in this case 'user_arg' must contain xfer_result_t variable
|
||||
bool tuh_descriptor_get_string(uint8_t daddr, uint8_t index, uint16_t language_id, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
|
||||
// Get manufacturer string descriptor (control transfer)
|
||||
// true on success, false if there is on-going control transfer or incorrect parameters
|
||||
bool tuh_descriptor_get_manufacturer_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
|
||||
// Get product string descriptor (control transfer)
|
||||
// true on success, false if there is on-going control transfer or incorrect parameters
|
||||
bool tuh_descriptor_get_product_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
|
||||
// Get serial string descriptor (control transfer)
|
||||
// true on success, false if there is on-going control transfer or incorrect parameters
|
||||
bool tuh_descriptor_get_serial_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len,
|
||||
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_arg);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Descriptors Synchronous (blocking)
|
||||
|
Loading…
x
Reference in New Issue
Block a user