summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-06-26 00:02:36 +1000
committerDamien George <damien.p.george@gmail.com>2018-06-26 00:02:36 +1000
commit967123d42ee3089ae163dc08c05007075f7e9431 (patch)
treef025264115940369404565053e95057e99086f26
parent37c4fd3b50fa0fc2548331859e4e7df369a1ca73 (diff)
stm32/mboot: Only compile in code for the USB periph that is being used.
Prior to this patch, if both USB FS and HS were enabled via the configuration file then code was included to handle both of their IRQs. But mboot only supports listening on a single USB peripheral, so this patch excludes the code for the USB that is not used.
-rw-r--r--ports/stm32/mboot/main.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/ports/stm32/mboot/main.c b/ports/stm32/mboot/main.c
index f75d9809b..1c762c9e4 100644
--- a/ports/stm32/mboot/main.c
+++ b/ports/stm32/mboot/main.c
@@ -58,9 +58,9 @@
// Work out which USB device to use for the USB DFU interface
#if !defined(MICROPY_HW_USB_MAIN_DEV)
-#if defined(MICROPY_HW_USB_FS)
+#if MICROPY_HW_USB_FS
#define MICROPY_HW_USB_MAIN_DEV (USB_PHY_FS_ID)
-#elif defined(MICROPY_HW_USB_HS) && defined(MICROPY_HW_USB_HS_IN_FS)
+#elif MICROPY_HW_USB_HS && MICROPY_HW_USB_HS_IN_FS
#define MICROPY_HW_USB_MAIN_DEV (USB_PHY_HS_ID)
#else
#error Unable to determine proper MICROPY_HW_USB_MAIN_DEV to use
@@ -846,10 +846,8 @@ static int dfu_handle_tx(int cmd, int arg, int len, uint8_t *buf, int max_len) {
#define USB_XFER_SIZE (DFU_XFER_SIZE)
-enum {
- USB_PHY_FS_ID = 0,
- USB_PHY_HS_ID = 1,
-};
+#define USB_PHY_FS_ID (0)
+#define USB_PHY_HS_ID (1)
typedef struct _pyb_usbdd_obj_t {
bool started;
@@ -1248,12 +1246,11 @@ enter_bootloader:
#endif
for (;;) {
#if USE_USB_POLLING
- #if defined(MICROPY_HW_USB_FS)
+ #if MICROPY_HW_USB_MAIN_DEV == USB_PHY_FS_ID
if (USB_OTG_FS->GINTSTS & USB_OTG_FS->GINTMSK) {
HAL_PCD_IRQHandler(&pcd_fs_handle);
}
- #endif
- #if defined(MICROPY_HW_USB_HS)
+ #else
if (USB_OTG_HS->GINTSTS & USB_OTG_HS->GINTMSK) {
HAL_PCD_IRQHandler(&pcd_hs_handle);
}
@@ -1328,12 +1325,11 @@ void I2Cx_EV_IRQHandler(void) {
#endif
#if !USE_USB_POLLING
-#if defined(MICROPY_HW_USB_FS)
+#if MICROPY_HW_USB_MAIN_DEV == USB_PHY_FS_ID
void OTG_FS_IRQHandler(void) {
HAL_PCD_IRQHandler(&pcd_fs_handle);
}
-#endif
-#if defined(MICROPY_HW_USB_HS)
+#else
void OTG_HS_IRQHandler(void) {
HAL_PCD_IRQHandler(&pcd_hs_handle);
}