Skip to content
Snippets Groups Projects
Commit 71312d0b authored by Damien George's avatar Damien George
Browse files

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.
parent e708e871
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment