change return type of callback to void
This commit is contained in:
parent
deab8c276a
commit
66942b814b
|
@ -103,20 +103,21 @@ uint8_t tuh_hid_get_protocol(uint8_t dev_addr, uint8_t instance)
|
|||
return hid_itf->protocol_mode;
|
||||
}
|
||||
|
||||
static bool set_protocol_complete(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void set_protocol_complete(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
{
|
||||
uint8_t const itf_num = (uint8_t) xfer->setup->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);
|
||||
|
||||
if (XFER_RESULT_SUCCESS == xfer->result) hid_itf->protocol_mode = (uint8_t) xfer->setup->wValue;
|
||||
if (XFER_RESULT_SUCCESS == xfer->result)
|
||||
{
|
||||
hid_itf->protocol_mode = (uint8_t) tu_le16toh(xfer->setup->wValue);
|
||||
}
|
||||
|
||||
if (tuh_hid_set_protocol_complete_cb)
|
||||
{
|
||||
tuh_hid_set_protocol_complete_cb(dev_addr, instance, hid_itf->protocol_mode);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -159,13 +160,13 @@ 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 bool set_report_complete(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void set_report_complete(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
{
|
||||
TU_LOG2("HID Set Report complete\r\n");
|
||||
|
||||
if (tuh_hid_set_report_complete_cb)
|
||||
{
|
||||
uint8_t const itf_num = (uint8_t) xfer->setup->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);
|
||||
|
||||
uint8_t const report_type = tu_u16_high(xfer->setup->wValue);
|
||||
|
@ -174,8 +175,6 @@ static bool set_report_complete(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
tuh_hid_set_report_complete_cb(dev_addr, instance, report_id, report_type,
|
||||
(xfer->result == XFER_RESULT_SUCCESS) ? xfer->setup->wLength : 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tuh_hid_set_report(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t report_type, void* report, uint16_t len)
|
||||
|
@ -390,7 +389,7 @@ enum {
|
|||
};
|
||||
|
||||
static void config_driver_mount_complete(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_report, uint16_t desc_len);
|
||||
static bool process_set_config(uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
static void process_set_config(uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
|
||||
bool hidh_set_config(uint8_t dev_addr, uint8_t itf_num)
|
||||
{
|
||||
|
@ -403,15 +402,17 @@ bool hidh_set_config(uint8_t dev_addr, uint8_t itf_num)
|
|||
xfer.user_arg = CONFG_SET_IDLE;
|
||||
|
||||
// fake request to kick-off the set config process
|
||||
return process_set_config(dev_addr, &xfer);
|
||||
process_set_config(dev_addr, &xfer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool process_set_config(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void process_set_config(uint8_t dev_addr, tuh_control_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 )
|
||||
{
|
||||
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS);
|
||||
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS, );
|
||||
}
|
||||
|
||||
uintptr_t const state = xfer->user_arg;
|
||||
|
@ -426,12 +427,12 @@ static bool process_set_config(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
// Idle rate = 0 mean only report when there is changes
|
||||
const uint16_t idle_rate = 0;
|
||||
const uintptr_t next_state = (hid_itf->itf_protocol != HID_ITF_PROTOCOL_NONE) ? CONFIG_SET_PROTOCOL : CONFIG_GET_REPORT_DESC;
|
||||
TU_VERIFY( _hidh_set_idle(dev_addr, itf_num, idle_rate, process_set_config, next_state) );
|
||||
_hidh_set_idle(dev_addr, itf_num, idle_rate, process_set_config, next_state);
|
||||
}
|
||||
break;
|
||||
|
||||
case CONFIG_SET_PROTOCOL:
|
||||
TU_VERIFY(_hidh_set_protocol(dev_addr, hid_itf->itf_num, HID_PROTOCOL_BOOT, process_set_config, CONFIG_GET_REPORT_DESC));
|
||||
_hidh_set_protocol(dev_addr, hid_itf->itf_num, HID_PROTOCOL_BOOT, process_set_config, CONFIG_GET_REPORT_DESC);
|
||||
break;
|
||||
|
||||
case CONFIG_GET_REPORT_DESC:
|
||||
|
@ -445,7 +446,7 @@ static bool process_set_config(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
config_driver_mount_complete(dev_addr, instance, NULL, 0);
|
||||
}else
|
||||
{
|
||||
TU_ASSERT(tuh_descriptor_get_hid_report(dev_addr, itf_num, hid_itf->report_desc_type, 0, usbh_get_enum_buf(), hid_itf->report_desc_len, process_set_config, CONFIG_COMPLETE));
|
||||
tuh_descriptor_get_hid_report(dev_addr, itf_num, hid_itf->report_desc_type, 0, usbh_get_enum_buf(), hid_itf->report_desc_len, process_set_config, CONFIG_COMPLETE);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -460,8 +461,6 @@ static bool process_set_config(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
|
||||
default: break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void config_driver_mount_complete(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_report, uint16_t desc_len)
|
||||
|
|
|
@ -358,7 +358,7 @@ bool msch_xfer_cb(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32
|
|||
// MSC Enumeration
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
static bool config_get_maxlun_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
static void config_get_maxlun_complete (uint8_t dev_addr, tuh_control_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);
|
||||
|
@ -432,7 +432,7 @@ bool msch_set_config(uint8_t dev_addr, uint8_t itf_num)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool config_get_maxlun_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void config_get_maxlun_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
{
|
||||
msch_interface_t* p_msc = get_itf(dev_addr);
|
||||
|
||||
|
@ -444,8 +444,6 @@ static bool config_get_maxlun_complete (uint8_t dev_addr, tuh_control_xfer_t* xf
|
|||
TU_LOG2("SCSI Test Unit Ready\r\n");
|
||||
uint8_t const lun = 0;
|
||||
tuh_msc_test_unit_ready(dev_addr, lun, config_test_unit_ready_complete);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool config_test_unit_ready_complete(uint8_t dev_addr, msc_cbw_t const* cbw, msc_csw_t const* csw)
|
||||
|
|
|
@ -225,8 +225,8 @@ bool hub_edpt_status_xfer(uint8_t dev_addr)
|
|||
// Set Configure
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
static bool config_set_port_power (uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
static bool config_port_power_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
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);
|
||||
|
||||
bool hub_set_config(uint8_t dev_addr, uint8_t itf_num)
|
||||
{
|
||||
|
@ -262,9 +262,9 @@ bool hub_set_config(uint8_t dev_addr, uint8_t itf_num)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool config_set_port_power (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void config_set_port_power (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
{
|
||||
TU_ASSERT(XFER_RESULT_SUCCESS == xfer->result);
|
||||
TU_ASSERT(XFER_RESULT_SUCCESS == xfer->result, );
|
||||
|
||||
hub_interface_t* p_hub = get_itf(dev_addr);
|
||||
|
||||
|
@ -276,38 +276,36 @@ static bool config_set_port_power (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
|
||||
// Set Port Power to be able to detect connection, starting with port 1
|
||||
uint8_t const hub_port = 1;
|
||||
return hub_port_set_feature(dev_addr, hub_port, HUB_FEATURE_PORT_POWER, config_port_power_complete, 0);
|
||||
hub_port_set_feature(dev_addr, hub_port, HUB_FEATURE_PORT_POWER, config_port_power_complete, 0);
|
||||
}
|
||||
|
||||
static bool config_port_power_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void config_port_power_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
{
|
||||
TU_ASSERT(XFER_RESULT_SUCCESS == xfer->result);
|
||||
TU_ASSERT(XFER_RESULT_SUCCESS == xfer->result, );
|
||||
hub_interface_t* p_hub = get_itf(dev_addr);
|
||||
|
||||
if (xfer->setup->wIndex == p_hub->port_count)
|
||||
{
|
||||
// All ports are power -> queue notification status endpoint and
|
||||
// complete the SET CONFIGURATION
|
||||
TU_ASSERT( usbh_edpt_xfer(dev_addr, p_hub->ep_in, &p_hub->status_change, 1) );
|
||||
TU_ASSERT( usbh_edpt_xfer(dev_addr, p_hub->ep_in, &p_hub->status_change, 1), );
|
||||
|
||||
usbh_driver_set_config_complete(dev_addr, p_hub->itf_num);
|
||||
}else
|
||||
{
|
||||
// power next port
|
||||
uint8_t const hub_port = (uint8_t) (xfer->setup->wIndex + 1);
|
||||
return hub_port_set_feature(dev_addr, hub_port, HUB_FEATURE_PORT_POWER, config_port_power_complete, 0);
|
||||
hub_port_set_feature(dev_addr, hub_port, HUB_FEATURE_PORT_POWER, config_port_power_complete, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Connection Changes
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
static bool connection_get_status_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
static bool connection_clear_conn_change_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
static bool connection_port_reset_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer);
|
||||
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);
|
||||
|
||||
// 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)
|
||||
|
@ -335,12 +333,12 @@ bool hub_xfer_cb(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t result, uint32
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool connection_get_status_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void connection_get_status_complete (uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
{
|
||||
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS);
|
||||
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS, );
|
||||
|
||||
hub_interface_t* p_hub = get_itf(dev_addr);
|
||||
uint8_t const port_num = (uint8_t) xfer->setup->wIndex;
|
||||
uint8_t const port_num = (uint8_t) tu_le16toh(xfer->setup->wIndex);
|
||||
|
||||
// Connection change
|
||||
if (p_hub->port_status.change.connection)
|
||||
|
@ -359,16 +357,14 @@ static bool connection_get_status_complete (uint8_t dev_addr, tuh_control_xfer_t
|
|||
// TODO continue with status_change, or maybe we can do it again with status
|
||||
hub_edpt_status_xfer(dev_addr);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool 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_control_xfer_t* xfer)
|
||||
{
|
||||
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS);
|
||||
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS, );
|
||||
|
||||
hub_interface_t* p_hub = get_itf(dev_addr);
|
||||
uint8_t const port_num = (uint8_t) xfer->setup->wIndex;
|
||||
uint8_t const port_num = (uint8_t) tu_le16toh(xfer->setup->wIndex);
|
||||
|
||||
if ( p_hub->port_status.status.connection )
|
||||
{
|
||||
|
@ -390,16 +386,14 @@ static bool connection_clear_conn_change_complete (uint8_t dev_addr, tuh_control
|
|||
|
||||
hcd_event_handler(&event, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool connection_port_reset_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)
|
||||
{
|
||||
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS);
|
||||
TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS, );
|
||||
|
||||
// hub_interface_t* p_hub = get_itf(dev_addr);
|
||||
uint8_t const port_num = (uint8_t) xfer->setup->wIndex;
|
||||
uint8_t const port_num = (uint8_t) tu_le16toh(xfer->setup->wIndex);
|
||||
|
||||
// submit attach event
|
||||
hcd_event_t event =
|
||||
|
@ -414,8 +408,6 @@ static bool connection_port_reset_complete (uint8_t dev_addr, tuh_control_xfer_t
|
|||
};
|
||||
|
||||
hcd_event_handler(&event, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -882,14 +882,11 @@ bool usbh_edpt_busy(uint8_t dev_addr, uint8_t ep_addr)
|
|||
// Control transfer
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
static bool _control_blocking_complete_cb(uint8_t daddr, tuh_control_xfer_t* xfer)
|
||||
static void _control_blocking_complete_cb(uint8_t daddr, tuh_control_xfer_t* xfer)
|
||||
{
|
||||
(void) daddr;
|
||||
|
||||
// update result
|
||||
*((xfer_result_t*) xfer->user_arg) = xfer->result;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tuh_control_xfer (uint8_t daddr, tuh_control_xfer_t const* xfer)
|
||||
|
@ -1122,13 +1119,13 @@ static bool parse_configuration_descriptor (uint8_t dev_addr, tusb_desc_configur
|
|||
static void enum_full_complete(void);
|
||||
|
||||
// process device enumeration
|
||||
static bool process_enumeration(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
static void process_enumeration(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
||||
{
|
||||
if (XFER_RESULT_SUCCESS != xfer->result)
|
||||
{
|
||||
// stop enumeration, maybe we could retry this
|
||||
enum_full_complete();
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
uintptr_t const state = xfer->user_arg;
|
||||
|
@ -1146,7 +1143,7 @@ static bool process_enumeration(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
{
|
||||
// device unplugged while delaying, nothing else to do
|
||||
enum_full_complete();
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
_dev0.speed = (port_status.status.high_speed) ? TUSB_SPEED_HIGH :
|
||||
|
@ -1162,7 +1159,7 @@ static bool process_enumeration(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
|
||||
case ENUM_HUB_GET_STATUS_2:
|
||||
osal_task_delay(RESET_DELAY);
|
||||
TU_ASSERT( hub_port_get_status(_dev0.hub_addr, _dev0.hub_port, _usbh_ctrl_buf, process_enumeration, ENUM_HUB_CLEAR_RESET_2) );
|
||||
TU_ASSERT( hub_port_get_status(_dev0.hub_addr, _dev0.hub_port, _usbh_ctrl_buf, process_enumeration, ENUM_HUB_CLEAR_RESET_2), );
|
||||
break;
|
||||
|
||||
case ENUM_HUB_CLEAR_RESET_2:
|
||||
|
@ -1173,7 +1170,7 @@ static bool process_enumeration(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
// Acknowledge Port Reset Change if Reset Successful
|
||||
if (port_status.change.reset)
|
||||
{
|
||||
TU_ASSERT( hub_port_clear_reset_change(_dev0.hub_addr, _dev0.hub_port, process_enumeration, ENUM_SET_ADDR) );
|
||||
TU_ASSERT( hub_port_clear_reset_change(_dev0.hub_addr, _dev0.hub_port, process_enumeration, ENUM_SET_ADDR), );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1183,11 +1180,11 @@ static bool process_enumeration(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
{
|
||||
// TODO probably doesn't need to open/close each enumeration
|
||||
uint8_t const addr0 = 0;
|
||||
TU_ASSERT( usbh_edpt_control_open(addr0, 8) );
|
||||
TU_ASSERT( usbh_edpt_control_open(addr0, 8), );
|
||||
|
||||
// Get first 8 bytes of device descriptor for Control Endpoint size
|
||||
TU_LOG2("Get 8 byte of Device Descriptor\r\n");
|
||||
TU_ASSERT(tuh_descriptor_get_device(addr0, _usbh_ctrl_buf, 8, process_enumeration, ENUM_SET_ADDR));
|
||||
TU_ASSERT(tuh_descriptor_get_device(addr0, _usbh_ctrl_buf, 8, process_enumeration, ENUM_SET_ADDR), );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1206,7 +1203,7 @@ static bool process_enumeration(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
else
|
||||
{
|
||||
// after RESET_DELAY the hub_port_reset() already complete
|
||||
TU_ASSERT( hub_port_reset(_dev0.hub_addr, _dev0.hub_port, process_enumeration, ENUM_HUB_GET_STATUS_2) );
|
||||
TU_ASSERT( hub_port_reset(_dev0.hub_addr, _dev0.hub_port, process_enumeration, ENUM_HUB_GET_STATUS_2), );
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
@ -1221,18 +1218,18 @@ static bool process_enumeration(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
uint8_t const new_addr = (uint8_t) tu_le16toh(xfer->setup->wValue);
|
||||
|
||||
usbh_device_t* new_dev = get_device(new_addr);
|
||||
TU_ASSERT(new_dev);
|
||||
TU_ASSERT(new_dev, );
|
||||
new_dev->addressed = 1;
|
||||
|
||||
// TODO close device 0, may not be needed
|
||||
hcd_device_close(_dev0.rhport, 0);
|
||||
|
||||
// open control pipe for new address
|
||||
TU_ASSERT( usbh_edpt_control_open(new_addr, new_dev->ep0_size) );
|
||||
TU_ASSERT( usbh_edpt_control_open(new_addr, new_dev->ep0_size), );
|
||||
|
||||
// Get full device descriptor
|
||||
TU_LOG2("Get Device Descriptor\r\n");
|
||||
TU_ASSERT(tuh_descriptor_get_device(new_addr, _usbh_ctrl_buf, sizeof(tusb_desc_device_t), process_enumeration, ENUM_GET_9BYTE_CONFIG_DESC));
|
||||
TU_ASSERT(tuh_descriptor_get_device(new_addr, _usbh_ctrl_buf, sizeof(tusb_desc_device_t), process_enumeration, ENUM_GET_9BYTE_CONFIG_DESC), );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1240,7 +1237,7 @@ static bool process_enumeration(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
{
|
||||
tusb_desc_device_t const * desc_device = (tusb_desc_device_t const*) _usbh_ctrl_buf;
|
||||
usbh_device_t* dev = get_device(dev_addr);
|
||||
TU_ASSERT(dev);
|
||||
TU_ASSERT(dev, );
|
||||
|
||||
dev->vid = desc_device->idVendor;
|
||||
dev->pid = desc_device->idProduct;
|
||||
|
@ -1253,7 +1250,7 @@ static bool process_enumeration(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
// Get 9-byte for total length
|
||||
uint8_t const config_idx = CONFIG_NUM - 1;
|
||||
TU_LOG2("Get Configuration[0] Descriptor (9 bytes)\r\n");
|
||||
TU_ASSERT( tuh_descriptor_get_configuration(dev_addr, config_idx, _usbh_ctrl_buf, 9, process_enumeration, ENUM_GET_FULL_CONFIG_DESC) );
|
||||
TU_ASSERT( tuh_descriptor_get_configuration(dev_addr, config_idx, _usbh_ctrl_buf, 9, process_enumeration, ENUM_GET_FULL_CONFIG_DESC), );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1265,28 +1262,28 @@ static bool process_enumeration(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
uint16_t const total_len = tu_le16toh( tu_unaligned_read16(desc_config + offsetof(tusb_desc_configuration_t, wTotalLength)) );
|
||||
|
||||
// TODO not enough buffer to hold configuration descriptor
|
||||
TU_ASSERT(total_len <= CFG_TUH_ENUMERATION_BUFSIZE);
|
||||
TU_ASSERT(total_len <= CFG_TUH_ENUMERATION_BUFSIZE, );
|
||||
|
||||
// Get full configuration descriptor
|
||||
uint8_t const config_idx = CONFIG_NUM - 1;
|
||||
TU_LOG2("Get Configuration[0] Descriptor\r\n");
|
||||
TU_ASSERT( tuh_descriptor_get_configuration(dev_addr, config_idx, _usbh_ctrl_buf, total_len, process_enumeration, ENUM_SET_CONFIG) );
|
||||
TU_ASSERT( tuh_descriptor_get_configuration(dev_addr, config_idx, _usbh_ctrl_buf, total_len, process_enumeration, ENUM_SET_CONFIG), );
|
||||
}
|
||||
break;
|
||||
|
||||
case ENUM_SET_CONFIG:
|
||||
// Parse configuration & set up drivers
|
||||
// Driver open aren't allowed to make any usb transfer yet
|
||||
TU_ASSERT( parse_configuration_descriptor(dev_addr, (tusb_desc_configuration_t*) _usbh_ctrl_buf) );
|
||||
TU_ASSERT( parse_configuration_descriptor(dev_addr, (tusb_desc_configuration_t*) _usbh_ctrl_buf), );
|
||||
|
||||
TU_ASSERT( tuh_configuration_set(dev_addr, CONFIG_NUM, process_enumeration, ENUM_CONFIG_DRIVER) );
|
||||
TU_ASSERT( tuh_configuration_set(dev_addr, CONFIG_NUM, process_enumeration, ENUM_CONFIG_DRIVER), );
|
||||
break;
|
||||
|
||||
case ENUM_CONFIG_DRIVER:
|
||||
{
|
||||
TU_LOG2("Device configured\r\n");
|
||||
usbh_device_t* dev = get_device(dev_addr);
|
||||
TU_ASSERT(dev);
|
||||
TU_ASSERT(dev, );
|
||||
|
||||
dev->configured = 1;
|
||||
|
||||
|
@ -1303,8 +1300,6 @@ static bool process_enumeration(uint8_t dev_addr, tuh_control_xfer_t* xfer)
|
|||
enum_full_complete();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool enum_new_device(hcd_event_t* event)
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
struct tuh_control_xfer_s;
|
||||
typedef struct tuh_control_xfer_s tuh_control_xfer_t;
|
||||
|
||||
typedef bool (*tuh_control_xfer_cb_t)(uint8_t daddr, tuh_control_xfer_t* xfer);
|
||||
typedef void (*tuh_control_xfer_cb_t)(uint8_t daddr, tuh_control_xfer_t* xfer);
|
||||
|
||||
struct tuh_control_xfer_s
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue