[libopenstm32-devel] Move enabling the USB Clock into stm32f10x_usbd_init
Status: Inactive
Brought to you by:
uh1763
|
From: Uwe B. <bo...@el...> - 2011-07-08 10:59:46
|
Hello,
Gareth had no objections, but the original mail is not visible in the
archive, so I resend.
Please apply or let me know any problems
Bye
--
Uwe Bonnes bo...@el...
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
>From 2f27157aa305fed214a6317db82c15b7ed53d9da Mon Sep 17 00:00:00 2001
From: Uwe Bonnes <bo...@el...>
Date: Tue, 5 Jul 2011 18:40:34 +0200
Subject: Move enabling the USB Clock into stm32f10x_usbd_init
---
examples/stm32/lisa-m/usb_dfu/usbdfu.c | 1 -
examples/stm32/lisa-m/usb_hid/usbhid.c | 1 -
examples/stm32/other/usb_cdcacm/cdcacm.c | 1 -
examples/stm32/other/usb_dfu/usbdfu.c | 1 -
examples/stm32/other/usb_hid/usbhid.c | 1 -
examples/stm32/stm32-h103/usb_cdcacm/cdcacm.c | 1 -
examples/stm32/stm32-h103/usb_dfu/usbdfu.c | 1 -
examples/stm32/stm32-h103/usb_hid/usbhid.c | 1 -
examples/stm32/stm32-h103/usb_iap/usbiap.c | 1 -
examples/stm32/stm32-h107/usb_simple/usb_simple.c | 1 -
lib/usb/usb_f103.c | 2 ++
lib/usb/usb_f107.c | 2 ++
12 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/examples/stm32/lisa-m/usb_dfu/usbdfu.c b/examples/stm32/lisa-m/usb_dfu/usbdfu.c
index 4e83ce0..7ffbc74 100644
--- a/examples/stm32/lisa-m/usb_dfu/usbdfu.c
+++ b/examples/stm32/lisa-m/usb_dfu/usbdfu.c
@@ -248,7 +248,6 @@ int main(void)
rcc_clock_setup_in_hsi_out_48mhz();
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USBEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
diff --git a/examples/stm32/lisa-m/usb_hid/usbhid.c b/examples/stm32/lisa-m/usb_hid/usbhid.c
index 241c481..5314241 100644
--- a/examples/stm32/lisa-m/usb_hid/usbhid.c
+++ b/examples/stm32/lisa-m/usb_hid/usbhid.c
@@ -241,7 +241,6 @@ int main(void)
rcc_clock_setup_in_hsi_out_48mhz();
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USBEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
diff --git a/examples/stm32/other/usb_cdcacm/cdcacm.c b/examples/stm32/other/usb_cdcacm/cdcacm.c
index cd701b8..fdc92e2 100644
--- a/examples/stm32/other/usb_cdcacm/cdcacm.c
+++ b/examples/stm32/other/usb_cdcacm/cdcacm.c
@@ -226,7 +226,6 @@ int main(void)
{
rcc_clock_setup_in_hsi_out_48mhz();
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USBEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
diff --git a/examples/stm32/other/usb_dfu/usbdfu.c b/examples/stm32/other/usb_dfu/usbdfu.c
index 4e83ce0..7ffbc74 100644
--- a/examples/stm32/other/usb_dfu/usbdfu.c
+++ b/examples/stm32/other/usb_dfu/usbdfu.c
@@ -248,7 +248,6 @@ int main(void)
rcc_clock_setup_in_hsi_out_48mhz();
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USBEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
diff --git a/examples/stm32/other/usb_hid/usbhid.c b/examples/stm32/other/usb_hid/usbhid.c
index 459ccbe..8f08aac 100644
--- a/examples/stm32/other/usb_hid/usbhid.c
+++ b/examples/stm32/other/usb_hid/usbhid.c
@@ -240,7 +240,6 @@ int main(void)
{
rcc_clock_setup_in_hsi_out_48mhz();
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USBEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
diff --git a/examples/stm32/stm32-h103/usb_cdcacm/cdcacm.c b/examples/stm32/stm32-h103/usb_cdcacm/cdcacm.c
index fe1f542..4b90640 100644
--- a/examples/stm32/stm32-h103/usb_cdcacm/cdcacm.c
+++ b/examples/stm32/stm32-h103/usb_cdcacm/cdcacm.c
@@ -228,7 +228,6 @@ int main(void)
rcc_clock_setup_in_hsi_out_48mhz();
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USBEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
gpio_set(GPIOC, GPIO11);
diff --git a/examples/stm32/stm32-h103/usb_dfu/usbdfu.c b/examples/stm32/stm32-h103/usb_dfu/usbdfu.c
index 4e83ce0..7ffbc74 100644
--- a/examples/stm32/stm32-h103/usb_dfu/usbdfu.c
+++ b/examples/stm32/stm32-h103/usb_dfu/usbdfu.c
@@ -248,7 +248,6 @@ int main(void)
rcc_clock_setup_in_hsi_out_48mhz();
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USBEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
diff --git a/examples/stm32/stm32-h103/usb_hid/usbhid.c b/examples/stm32/stm32-h103/usb_hid/usbhid.c
index 09c49e9..a21fce6 100644
--- a/examples/stm32/stm32-h103/usb_hid/usbhid.c
+++ b/examples/stm32/stm32-h103/usb_hid/usbhid.c
@@ -241,7 +241,6 @@ int main(void)
rcc_clock_setup_in_hsi_out_48mhz();
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USBEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
gpio_set(GPIOC, GPIO11);
diff --git a/examples/stm32/stm32-h103/usb_iap/usbiap.c b/examples/stm32/stm32-h103/usb_iap/usbiap.c
index 4e83ce0..7ffbc74 100644
--- a/examples/stm32/stm32-h103/usb_iap/usbiap.c
+++ b/examples/stm32/stm32-h103/usb_iap/usbiap.c
@@ -248,7 +248,6 @@ int main(void)
rcc_clock_setup_in_hsi_out_48mhz();
- rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USBEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
diff --git a/examples/stm32/stm32-h107/usb_simple/usb_simple.c b/examples/stm32/stm32-h107/usb_simple/usb_simple.c
index 517f37e..85f67df 100644
--- a/examples/stm32/stm32-h107/usb_simple/usb_simple.c
+++ b/examples/stm32/stm32-h107/usb_simple/usb_simple.c
@@ -98,7 +98,6 @@ int main(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
- rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_OTGFSEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
diff --git a/lib/usb/usb_f103.c b/lib/usb/usb_f103.c
index 19f645d..594d3c6 100644
--- a/lib/usb/usb_f103.c
+++ b/lib/usb/usb_f103.c
@@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <libopencm3/stm32/rcc.h>
#include <libopencm3/cm3/common.h>
#include <libopencm3/stm32/tools.h>
#include <libopencm3/stm32/usb.h>
@@ -53,6 +54,7 @@ const struct _usbd_driver stm32f103_usb_driver = {
/** Initialize the USB device controller hardware of the STM32. */
static void stm32f103_usbd_init(void)
{
+ rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USBEN);
SET_REG(USB_CNTR_REG, 0);
SET_REG(USB_BTABLE_REG, 0);
SET_REG(USB_ISTR_REG, 0);
diff --git a/lib/usb/usb_f107.c b/lib/usb/usb_f107.c
index ee83b65..134b728 100644
--- a/lib/usb/usb_f107.c
+++ b/lib/usb/usb_f107.c
@@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <libopencm3/stm32/rcc.h>
#include <libopencm3/cm3/common.h>
#include <libopencm3/stm32/tools.h>
#include <libopencm3/stm32/otg_fs.h>
@@ -63,6 +64,7 @@ const struct _usbd_driver stm32f107_usb_driver = {
/** Initialize the USB device controller hardware of the STM32. */
static void stm32f107_usbd_init(void)
{
+ rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_OTGFSEN);
OTG_FS_GINTSTS = OTG_FS_GINTSTS_MMIS;
/* WARNING: Undocumented! Select internal PHY */
--
1.7.3.4
|