/* set the configuration value to the connected device  */
usbh_status usbh_setcfg(usbh_host *puhost, uint16_t config_index)
/* set the configuration value to the connected device  */
usbh_status usbh_setcfg(usbh_host *puhost, uint16_t config_index)
{
    usbh_status status = USBH_BUSY;
    usbh_control *usb_ctl = &puhost->control;
    if (CTL_IDLE == usb_ctl->ctl_state) {
        usb_ctl->setup.req = (usb_req) {
            .bmRequestType = USB_TRX_OUT | USB_RECPTYPE_DEV | USB_REQTYPE_STRD,
            .bRequest      = USB_SET_CONFIGURATION,
            .wValue        = config_index,
            .wIndex        = 0U,
            .wLength       = 0U
        };
        usbh_ctlstate_config (puhost, NULL, 0U);
    }
    status = usbh_ctl_handler (puhost);
    return status;
}