summaryrefslogtreecommitdiff
path: root/ucoo/hal/usb
diff options
context:
space:
mode:
authorNicolas Schodet2015-04-28 11:58:32 +0200
committerNicolas Schodet2019-10-07 00:44:50 +0200
commita91aa1aad65c5f5da38511175c79a72c019b271b (patch)
tree571d28127341c62f5b58a95f317bfce7d9104f75 /ucoo/hal/usb
parent0ad5dc5b09f749e8d3b1db737d7283ab58412c96 (diff)
ucoo/hal/usb: add configuration item to select OTG HS driver
Diffstat (limited to 'ucoo/hal/usb')
-rw-r--r--ucoo/hal/usb/Config2
-rw-r--r--ucoo/hal/usb/usb.stm32.cc24
2 files changed, 24 insertions, 2 deletions
diff --git a/ucoo/hal/usb/Config b/ucoo/hal/usb/Config
index 9adaece..80341e8 100644
--- a/ucoo/hal/usb/Config
+++ b/ucoo/hal/usb/Config
@@ -10,3 +10,5 @@ self_powered = 0
max_power = 100
# End point size, you should use 64.
ep_size = 64
+# Use HS driver instead of FS
+driver_hs = false
diff --git a/ucoo/hal/usb/usb.stm32.cc b/ucoo/hal/usb/usb.stm32.cc
index 04f0b70..79f73d2 100644
--- a/ucoo/hal/usb/usb.stm32.cc
+++ b/ucoo/hal/usb/usb.stm32.cc
@@ -30,6 +30,14 @@
#include "usb_desc.stm32.h"
+#if UCOO_CONFIG_HAL_USB_DRIVER_HS
+# define usb_isr otg_hs_isr
+# define usb_driver otghs_usb_driver
+#else
+# define usb_isr otg_fs_isr
+# define usb_driver otgfs_usb_driver
+#endif
+
static usbd_device *usbdev;
// Buffer for control requests.
@@ -38,7 +46,7 @@ static uint8_t usb_control_buffer[128];
extern "C" {
void
-otg_fs_isr ()
+usb_isr ()
{
usbd_poll (usbdev);
}
@@ -66,16 +74,28 @@ UsbStreamControl::UsbStreamControl (const char *vendor, const char *product)
instance_ = this;
strings[0] = vendor;
strings[1] = product;
+#if UCOO_CONFIG_HAL_USB_DRIVER_HS
+ rcc_periph_clock_enable (RCC_OTGHS);
+ rcc_periph_clock_enable (RCC_GPIOB);
+ gpio_mode_setup (GPIOB, GPIO_MODE_AF, GPIO_PUPD_NONE,
+ GPIO13 | GPIO14 | GPIO15);
+ gpio_set_af (GPIOB, GPIO_AF12, GPIO13 | GPIO14 | GPIO15);
+#else
rcc_periph_clock_enable (RCC_OTGFS);
rcc_periph_clock_enable (RCC_GPIOA);
gpio_mode_setup (GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE,
GPIO9 | GPIO11 | GPIO12);
gpio_set_af (GPIOA, GPIO_AF10, GPIO9 | GPIO11 | GPIO12);
- usbdev = usbd_init (&otgfs_usb_driver, &usb_desc_dev, &usb_desc_config,
+#endif
+ usbdev = usbd_init (&usb_driver, &usb_desc_dev, &usb_desc_config,
strings, lengthof (strings),
usb_control_buffer, sizeof (usb_control_buffer));
usbd_register_set_config_callback (usbdev, set_config);
+#if UCOO_CONFIG_HAL_USB_DRIVER_HS
+ nvic_enable_irq (NVIC_OTG_HS_IRQ);
+#else
nvic_enable_irq (NVIC_OTG_FS_IRQ);
+#endif
}
void