drivers/usbdev: support config pid/vid by soft interface
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
ff4c6c33e8
commit
e7fd416f9f
@ -4736,6 +4736,12 @@ config BOARD_USBDEV_SERIALSTR
|
|||||||
---help---
|
---help---
|
||||||
Use board unique serial number to iSerialNumber in the device descriptor.
|
Use board unique serial number to iSerialNumber in the device descriptor.
|
||||||
|
|
||||||
|
config BOARD_USBDEV_PIDVID
|
||||||
|
bool "Board-specific usbdev pid/vid"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Use board unique pid/vid.
|
||||||
|
|
||||||
config BOARD_MEMORY_RANGE
|
config BOARD_MEMORY_RANGE
|
||||||
string "Board memory range"
|
string "Board memory range"
|
||||||
default ""
|
default ""
|
||||||
|
@ -644,6 +644,20 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
|
|||||||
{
|
{
|
||||||
ret = USB_SIZEOF_DEVDESC;
|
ret = USB_SIZEOF_DEVDESC;
|
||||||
memcpy(ctrlreq->buf, priv->descs->devdesc, ret);
|
memcpy(ctrlreq->buf, priv->descs->devdesc, ret);
|
||||||
|
#ifdef CONFIG_BOARD_USBDEV_PIDVID
|
||||||
|
{
|
||||||
|
uint16_t pid = board_usbdev_pid();
|
||||||
|
uint16_t vid = board_usbdev_vid();
|
||||||
|
FAR struct usb_devdesc_s *p_desc =
|
||||||
|
(FAR struct usb_devdesc_s *)ctrlreq->buf;
|
||||||
|
|
||||||
|
p_desc->vendor[0] = LSBYTE(vid);
|
||||||
|
p_desc->vendor[1] = MSBYTE(vid);
|
||||||
|
|
||||||
|
p_desc->product[0] = LSBYTE(pid);
|
||||||
|
p_desc->product[1] = MSBYTE(pid);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -450,6 +450,23 @@ FAR void *board_composite_connect(int port, int configid);
|
|||||||
FAR const char *board_usbdev_serialstr(void);
|
FAR const char *board_usbdev_serialstr(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_usbdev_pid,board_usbdev_vid
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Use board unique pid/vid in the device descriptor. This is for that
|
||||||
|
* usb can be dynamically configured while the board is running
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* The board unique pid/vid.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_BOARD_USBDEV_PIDVID)
|
||||||
|
uint16_t board_usbdev_pid(void);
|
||||||
|
uint16_t board_usbdev_vid(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: board_graphics_setup
|
* Name: board_graphics_setup
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user