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
3 changed files with 37 additions and 0 deletions
|
@ -4736,6 +4736,12 @@ config BOARD_USBDEV_SERIALSTR
|
|||
---help---
|
||||
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
|
||||
string "Board memory range"
|
||||
default ""
|
||||
|
|
|
@ -644,6 +644,20 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
|
|||
{
|
||||
ret = USB_SIZEOF_DEVDESC;
|
||||
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;
|
||||
|
||||
|
|
|
@ -450,6 +450,23 @@ FAR void *board_composite_connect(int port, int configid);
|
|||
FAR const char *board_usbdev_serialstr(void);
|
||||
#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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue