summaryrefslogtreecommitdiff
path: root/ucoo/hal/usb
diff options
context:
space:
mode:
authorNicolas Schodet2015-05-04 11:57:31 +0200
committerNicolas Schodet2019-10-07 00:44:50 +0200
commitc5171a64652771c5c835754ef65f9cef7d78aa76 (patch)
tree7b114961d3dcd95cc23dd76c9aec4385f745d93d /ucoo/hal/usb
parent9fe68a0e7b216f8142d6b0423d5cf8fc08ec7091 (diff)
Add STM32F1 support
Diffstat (limited to 'ucoo/hal/usb')
-rw-r--r--ucoo/hal/usb/test/Makefile2
-rw-r--r--ucoo/hal/usb/usb.stm32.cc26
2 files changed, 20 insertions, 8 deletions
diff --git a/ucoo/hal/usb/test/Makefile b/ucoo/hal/usb/test/Makefile
index cec9ded..9ef0eab 100644
--- a/ucoo/hal/usb/test/Makefile
+++ b/ucoo/hal/usb/test/Makefile
@@ -1,7 +1,7 @@
BASE = ../../../..
TARGETS = stm32f4
-stm32f4_PROGS = test_usb
+PROGS = test_usb
test_usb_SOURCES = test_usb.cc
MODULES = hal/usb
diff --git a/ucoo/hal/usb/usb.stm32.cc b/ucoo/hal/usb/usb.stm32.cc
index 79f73d2..37595e8 100644
--- a/ucoo/hal/usb/usb.stm32.cc
+++ b/ucoo/hal/usb/usb.stm32.cc
@@ -30,12 +30,19 @@
#include "usb_desc.stm32.h"
-#if UCOO_CONFIG_HAL_USB_DRIVER_HS
-# define usb_isr otg_hs_isr
-# define usb_driver otghs_usb_driver
+#if defined (TARGET_stm32f4)
+# 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
+#elif defined (TARGET_stm32f1)
+# define usb_isr otg_fs_isr
+# define usb_driver otgfs_usb_driver
#else
-# define usb_isr otg_fs_isr
-# define usb_driver otgfs_usb_driver
+# error "not implemented for this target"
#endif
static usbd_device *usbdev;
@@ -74,18 +81,23 @@ UsbStreamControl::UsbStreamControl (const char *vendor, const char *product)
instance_ = this;
strings[0] = vendor;
strings[1] = product;
-#if UCOO_CONFIG_HAL_USB_DRIVER_HS
+#if defined (TARGET_stm32f4)
+# 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
+# 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);
+# endif
+#elif defined (TARGET_stm32f1)
+ rcc_periph_clock_enable (RCC_OTGFS);
+ rcc_periph_clock_enable (RCC_GPIOA);
#endif
usbdev = usbd_init (&usb_driver, &usb_desc_dev, &usb_desc_config,
strings, lengthof (strings),