mirror of
https://gitee.com/Vancouver2017/luban-lite-t3e-pro.git
synced 2025-12-15 02:48:54 +00:00
v1.1.2
This commit is contained in:
11
packages/third-party/cherryusb/class/vender/usb_vender.h
vendored
Normal file
11
packages/third-party/cherryusb/class/vender/usb_vender.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _USB_VENDER_H
|
||||
#define _USB_VENDER_H
|
||||
|
||||
#endif
|
||||
61
packages/third-party/cherryusb/class/vender/usbd_vender.c
vendored
Normal file
61
packages/third-party/cherryusb/class/vender/usbd_vender.c
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_vender.h"
|
||||
|
||||
static int vender_class_interface_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
||||
{
|
||||
USB_LOG_WRN("VENDER Class request: "
|
||||
"bRequest 0x%02x\r\n",
|
||||
setup->bRequest);
|
||||
|
||||
switch (setup->bRequest) {
|
||||
default:
|
||||
USB_LOG_WRN("Unhandled VENDER Class bRequest 0x%02x\r\n", setup->bRequest);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vender_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
||||
{
|
||||
USB_LOG_WRN("VENDER request: "
|
||||
"bRequest 0x%02x\r\n",
|
||||
setup->bRequest);
|
||||
|
||||
switch (setup->bRequest) {
|
||||
default:
|
||||
USB_LOG_WRN("Unhandled VENDER Class bRequest 0x%02x\r\n", setup->bRequest);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void vender_notify_handler(uint8_t event, void *arg)
|
||||
{
|
||||
switch (event) {
|
||||
case USBD_EVENT_RESET:
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
struct usbd_interface *usbd_vender_init_intf(struct usbd_interface *intf)
|
||||
{
|
||||
intf->class_interface_handler = vender_class_interface_request_handler;
|
||||
intf->class_endpoint_handler = NULL;
|
||||
intf->vendor_handler = vender_request_handler;
|
||||
intf->notify_handler = vender_notify_handler;
|
||||
|
||||
return intf;
|
||||
}
|
||||
23
packages/third-party/cherryusb/class/vender/usbd_vender.h
vendored
Normal file
23
packages/third-party/cherryusb/class/vender/usbd_vender.h
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _USBD_VENDER_H_
|
||||
#define _USBD_VENDER_H_
|
||||
|
||||
#include "usb_vender.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct usbd_interface *usbd_vender_init_intf(struct usbd_interface *intf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _USBD_VENDER_H_ */
|
||||
105
packages/third-party/cherryusb/class/vender/usbh_vender.c
vendored
Normal file
105
packages/third-party/cherryusb/class/vender/usbh_vender.c
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
#include "usbh_core.h"
|
||||
#include "usbh_vender.h"
|
||||
|
||||
#define DEV_FORMAT "/dev/vender"
|
||||
|
||||
#define CONFIG_USBHOST_MAX_CUSTOM_CLASS 1
|
||||
static struct usbh_vender g_vender_class[CONFIG_USBHOST_MAX_CUSTOM_CLASS];
|
||||
static uint32_t g_devinuse = 0;
|
||||
|
||||
static struct usbh_vender *usbh_vender_class_alloc(void)
|
||||
{
|
||||
int devno;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_CUSTOM_CLASS; devno++) {
|
||||
if ((g_devinuse & (1 << devno)) == 0) {
|
||||
g_devinuse |= (1 << devno);
|
||||
memset(&g_vender_class[devno], 0, sizeof(struct usbh_vender));
|
||||
g_vender_class[devno].minor = devno;
|
||||
return &g_vender_class[devno];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void usbh_vender_class_free(struct usbh_vender *vender_class)
|
||||
{
|
||||
int devno = vender_class->minor;
|
||||
|
||||
if (devno >= 0 && devno < 32) {
|
||||
g_devinuse &= ~(1 << devno);
|
||||
}
|
||||
memset(vender_class, 0, sizeof(struct usbh_vender));
|
||||
}
|
||||
|
||||
static int usbh_vender_connect(struct usbh_hubport *hport, uint8_t intf)
|
||||
{
|
||||
struct usb_endpoint_descriptor *ep_desc;
|
||||
int ret = 0;
|
||||
|
||||
struct usbh_vender *vender_class = usbh_vender_class_alloc();
|
||||
if (vender_class == NULL) {
|
||||
USB_LOG_ERR("Fail to alloc vender_class\r\n");
|
||||
return -USB_ERR_NOMEM;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int usbh_vender_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
struct usbh_vender *vender_class = (struct usbh_vender *)hport->config.intf[intf].priv;
|
||||
|
||||
if (vender_class) {
|
||||
if (vender_class->venderin) {
|
||||
usbh_kill_urb(&vender_class->venderin_urb);
|
||||
}
|
||||
|
||||
if (vender_class->venderout) {
|
||||
usbh_kill_urb(&vender_class->venderout_urb);
|
||||
}
|
||||
|
||||
if (hport->config.intf[intf].devname[0] != '\0') {
|
||||
USB_LOG_INFO("Unregister vender Class:%s\r\n", hport->config.intf[intf].devname);
|
||||
usbh_vender_stop(vender_class);
|
||||
}
|
||||
|
||||
usbh_vender_class_free(vender_class);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
__WEAK void usbh_vender_run(struct usbh_vender *vender_class)
|
||||
{
|
||||
}
|
||||
|
||||
__WEAK void usbh_vender_stop(struct usbh_vender *vender_class)
|
||||
{
|
||||
}
|
||||
|
||||
static const struct usbh_class_driver vender_class_driver = {
|
||||
.driver_name = "vender",
|
||||
.connect = usbh_vender_connect,
|
||||
.disconnect = usbh_vender_disconnect
|
||||
};
|
||||
|
||||
CLASS_INFO_DEFINE const struct usbh_class_info vender_class_info = {
|
||||
.match_flags = USB_CLASS_MATCH_INTF_CLASS | USB_CLASS_MATCH_INTF_SUBCLASS | USB_CLASS_MATCH_INTF_PROTOCOL,
|
||||
.class = 0,
|
||||
.subclass = 0,
|
||||
.protocol = 0,
|
||||
.vid = 0x00,
|
||||
.pid = 0x00,
|
||||
.class_driver = &vender_class_driver
|
||||
};
|
||||
27
packages/third-party/cherryusb/class/vender/usbh_vender.h
vendored
Normal file
27
packages/third-party/cherryusb/class/vender/usbh_vender.h
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _USBH_VENDER_H
|
||||
#define _USBH_VENDER_H
|
||||
|
||||
#include "usb_vender.h"
|
||||
|
||||
struct usbh_vender {
|
||||
struct usbh_hubport *hport;
|
||||
struct usb_endpoint_descriptor *vender_in;
|
||||
struct usb_endpoint_descriptor *vender_out;
|
||||
struct usbh_urb vender_in_urb;
|
||||
struct usbh_urb vender_out_urb;
|
||||
|
||||
uint8_t intf; /* interface number */
|
||||
uint8_t minor;
|
||||
};
|
||||
|
||||
void usbh_vender_run(struct usbh_vender *vender_class);
|
||||
void usbh_vender_stop(struct usbh_vender *vender_class);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user