aboutsummaryrefslogtreecommitdiff
path: root/ports/stm32
diff options
context:
space:
mode:
authorDamien George2018-02-01 17:47:28 +1100
committerDamien George2018-02-01 17:47:28 +1100
commit71312d0bd10d47e958cca71ed6f6ce5bbdc93f88 (patch)
tree96b03465e88ec2801db3933a8842fe51bf102796 /ports/stm32
parente708e87139ec2bd2c94ce33c0f7b873ef89d3827 (diff)
stm32/usb: Allow board to select which USBD is used as the main one.
By defining MICROPY_HW_USB_MAIN_DEV a given board can select to use either USB_PHY_FS_ID or USB_PHY_HS_ID as the main USBD peripheral, on which the REPL will appear. If not defined this will be automatically configured.
Diffstat (limited to 'ports/stm32')
-rw-r--r--ports/stm32/usb.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/ports/stm32/usb.c b/ports/stm32/usb.c
index 1544b1d9c..634c9e6f4 100644
--- a/ports/stm32/usb.c
+++ b/ports/stm32/usb.c
@@ -42,12 +42,15 @@
#include "bufhelper.h"
#include "usb.h"
+// Work out which USB device to use as the main one (the one with the REPL)
+#if !defined(MICROPY_HW_USB_MAIN_DEV)
#if defined(USE_USB_FS)
-#define USB_PHY_ID USB_PHY_FS_ID
+#define MICROPY_HW_USB_MAIN_DEV (USB_PHY_FS_ID)
#elif defined(USE_USB_HS) && defined(USE_USB_HS_IN_FS)
-#define USB_PHY_ID USB_PHY_HS_ID
+#define MICROPY_HW_USB_MAIN_DEV (USB_PHY_HS_ID)
#else
-#error Unable to determine proper USB_PHY_ID to use
+#error Unable to determine proper MICROPY_HW_USB_MAIN_DEV to use
+#endif
#endif
// this will be persistent across a soft-reset
@@ -123,7 +126,7 @@ bool pyb_usb_dev_init(uint16_t vid, uint16_t pid, usb_device_mode_t mode, USBD_H
// set up the USBD state
USBD_HandleTypeDef *usbd = &usb_dev->hUSBDDevice;
- usbd->id = USB_PHY_ID;
+ usbd->id = MICROPY_HW_USB_MAIN_DEV;
usbd->dev_state = USBD_STATE_DEFAULT;
usbd->pDesc = (USBD_DescriptorsTypeDef*)&USBD_Descriptors;
usbd->pClass = &USBD_CDC_MSC_HID;