summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/usb.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-10-25 22:55:07 +0100
committerDamien George <damien.p.george@gmail.com>2014-10-25 22:55:07 +0100
commitd7353fe6fe9c9d421ef045c0eea8d4591710e1ba (patch)
treeab5e7b89f001855e6e55d9e907a29800a16af97a /stmhal/usb.c
parent627852019b915f9d34f7d036c90f6a1d8307df53 (diff)
downloadmicropython-d7353fe6fe9c9d421ef045c0eea8d4591710e1ba.tar.gz
micropython-d7353fe6fe9c9d421ef045c0eea8d4591710e1ba.zip
stmhal: Change USB PID when in CDC+HID mode.
This gets CDC+HID working on Windows, since it needs a different PID for a different USB configuration. Thanks to tmbinc and dhylands.
Diffstat (limited to 'stmhal/usb.c')
-rw-r--r--stmhal/usb.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/stmhal/usb.c b/stmhal/usb.c
index 152dc8f3cd..c522b64432 100644
--- a/stmhal/usb.c
+++ b/stmhal/usb.c
@@ -58,10 +58,14 @@ void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium) {
#ifdef USE_DEVICE_MODE
if (!dev_is_enabled) {
// only init USB once in the device's power-lifetime
+ // Windows needs a different PID to distinguish different device
+ // configurations, so we set it here depending on mode.
if (mode == USB_DEVICE_MODE_CDC_MSC) {
USBD_SelectMode(USBD_MODE_CDC_MSC);
+ USBD_SetPID(0x9800);
} else {
USBD_SelectMode(USBD_MODE_CDC_HID);
+ USBD_SetPID(0x9801);
}
USBD_Init(&hUSBDDevice, (USBD_DescriptorsTypeDef*)&VCP_Desc, 0);
USBD_RegisterClass(&hUSBDDevice, &USBD_CDC_MSC_HID);