瀏覽代碼

Support AT32F403A MCU on F1 board

Keir Fraser 2 年之前
父節點
當前提交
141872c13a
共有 1 個文件被更改,包括 17 次插入0 次删除
  1. 17 0
      src/usb/hw_usbd.c

+ 17 - 0
src/usb/hw_usbd.c

@@ -214,6 +214,21 @@ static void usbd_configure_ep(uint8_t ep, uint8_t type, uint32_t size)
     old_epr = usb->epr[ep];
     new_epr = 0;
 
+#if defined(BOOTLOADER)
+
+    ASSERT(type != EPT_DBLBUF);
+    dbl_buf = FALSE;
+
+#else /* !defined(BOOTLOADER) */
+
+    if (type == EPT_DBLBUF) {
+        /* We detect an Artery MCU by presence of Cortex-M4 CPUID. Cortex-M4:
+         * 41xfc24x ; Cortex-M3: 41xfc23x */
+        bool_t is_artery_mcu = ((scb->cpuid >> 4) & 0xf) == 4;
+        if (is_artery_mcu)
+            type = EPT_BULK;
+    }
+
     dbl_buf = (type == EPT_DBLBUF);
     if (dbl_buf) {
         ASSERT(ep != 0);
@@ -224,6 +239,8 @@ static void usbd_configure_ep(uint8_t ep, uint8_t type, uint32_t size)
         buf_end += 2*size;
     }
 
+#endif
+
     type = types[type];
 
     /* Sets: Type and Endpoint Address.