mirror of
https://github.com/sakumisu/CherryUSB.git
synced 2025-05-08 16:18:44 +08:00
133 lines
3.6 KiB
C
133 lines
3.6 KiB
C
/*
|
|
* Copyright (c) 2025, sakumisu
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
#include "usbh_core.h"
|
|
#include "usbh_hub.h"
|
|
|
|
int usb_hc_init(struct usbh_bus *bus)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int usb_hc_deinit(struct usbh_bus *bus)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
uint16_t usbh_get_frame_number(struct usbh_bus *bus)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int usbh_roothub_control(struct usbh_bus *bus, struct usb_setup_packet *setup, uint8_t *buf)
|
|
{
|
|
uint8_t nports;
|
|
uint8_t port;
|
|
uint32_t status;
|
|
|
|
nports = CONFIG_USBHOST_MAX_RHPORTS;
|
|
port = setup->wIndex;
|
|
if (setup->bmRequestType & USB_REQUEST_RECIPIENT_DEVICE) {
|
|
switch (setup->bRequest) {
|
|
case HUB_REQUEST_CLEAR_FEATURE:
|
|
switch (setup->wValue) {
|
|
case HUB_FEATURE_HUB_C_LOCALPOWER:
|
|
break;
|
|
case HUB_FEATURE_HUB_C_OVERCURRENT:
|
|
break;
|
|
default:
|
|
return -USB_ERR_NOTSUPP;
|
|
}
|
|
break;
|
|
case HUB_REQUEST_SET_FEATURE:
|
|
switch (setup->wValue) {
|
|
case HUB_FEATURE_HUB_C_LOCALPOWER:
|
|
break;
|
|
case HUB_FEATURE_HUB_C_OVERCURRENT:
|
|
break;
|
|
default:
|
|
return -USB_ERR_NOTSUPP;
|
|
}
|
|
break;
|
|
case HUB_REQUEST_GET_DESCRIPTOR:
|
|
break;
|
|
case HUB_REQUEST_GET_STATUS:
|
|
memset(buf, 0, 4);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
} else if (setup->bmRequestType & USB_REQUEST_RECIPIENT_OTHER) {
|
|
switch (setup->bRequest) {
|
|
case HUB_REQUEST_CLEAR_FEATURE:
|
|
if (!port || port > nports) {
|
|
return -USB_ERR_INVAL;
|
|
}
|
|
|
|
switch (setup->wValue) {
|
|
case HUB_PORT_FEATURE_ENABLE:
|
|
break;
|
|
case HUB_PORT_FEATURE_SUSPEND:
|
|
break;
|
|
case HUB_PORT_FEATURE_C_SUSPEND:
|
|
break;
|
|
case HUB_PORT_FEATURE_POWER:
|
|
break;
|
|
case HUB_PORT_FEATURE_C_CONNECTION:
|
|
break;
|
|
case HUB_PORT_FEATURE_C_ENABLE:
|
|
break;
|
|
case HUB_PORT_FEATURE_C_OVER_CURREN:
|
|
break;
|
|
case HUB_PORT_FEATURE_C_RESET:
|
|
break;
|
|
default:
|
|
return -USB_ERR_NOTSUPP;
|
|
}
|
|
break;
|
|
case HUB_REQUEST_SET_FEATURE:
|
|
if (!port || port > nports) {
|
|
return -USB_ERR_INVAL;
|
|
}
|
|
|
|
switch (setup->wValue) {
|
|
case HUB_PORT_FEATURE_SUSPEND:
|
|
break;
|
|
case HUB_PORT_FEATURE_POWER:
|
|
break;
|
|
case HUB_PORT_FEATURE_RESET:
|
|
break;
|
|
|
|
default:
|
|
return -USB_ERR_NOTSUPP;
|
|
}
|
|
break;
|
|
case HUB_REQUEST_GET_STATUS:
|
|
if (!port || port > nports) {
|
|
return -USB_ERR_INVAL;
|
|
}
|
|
|
|
memcpy(buf, &status, 4);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int usbh_submit_urb(struct usbh_urb *urb)
|
|
{
|
|
return -USB_ERR_NOTSUPP;
|
|
}
|
|
|
|
int usbh_kill_urb(struct usbh_urb *urb)
|
|
{
|
|
return -USB_ERR_NOTSUPP;
|
|
}
|
|
|
|
void USBH_IRQHandler(uint8_t busid)
|
|
{
|
|
} |