Explorar el Código

Tweak F1 and AT32F4 specific aspects of the USBD peripheral.

Keir Fraser hace 3 años
padre
commit
5bd5d19718
Se han modificado 3 ficheros con 13 adiciones y 4 borrados
  1. 8 0
      src/usb/hw_at32f4.c
  2. 5 0
      src/usb/hw_f1.c
  3. 0 4
      src/usb/hw_usbd.c

+ 8 - 0
src/usb/hw_at32f4.c

@@ -87,6 +87,14 @@ void usb_stall(uint8_t epnr)
 
 void usb_configure_ep(uint8_t epnr, uint8_t type, uint32_t size)
 {
+    switch (at32f4_series) {
+    case AT32F403:
+        /* Double-buffer hardware implementation is incompatible. */
+        if (type == EPT_DBLBUF)
+            type = EPT_BULK;
+        break;
+    }
+
     drv->configure_ep(epnr, type, size);
 }
 

+ 5 - 0
src/usb/hw_f1.c

@@ -12,10 +12,15 @@
 void hw_usb_init(void)
 {
     usbd.init();
+
+    /* Indicate we are connected by pulling up D+. */
+    gpio_configure_pin(gpioa, 0, GPO_pushpull(_2MHz, HIGH));
 }
 
 void hw_usb_deinit(void)
 {
+    gpio_configure_pin(gpioa, 0, GPI_floating);
+
     usbd.deinit();
 }
 

+ 0 - 4
src/usb/hw_usbd.c

@@ -47,14 +47,10 @@ static void usbd_init(void)
 
     /* Clear IRQ state. */
     usb->istr = 0;
-
-    /* Indicate we are connected by pulling up D+. */
-    gpio_configure_pin(gpioa, 0, GPO_pushpull(_2MHz, HIGH));
 }
 
 static void usbd_deinit(void)
 {
-    gpio_configure_pin(gpioa, 0, GPI_floating);
     rcc->apb1enr &= ~RCC_APB1ENR_USBEN;
 }