You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/05/15 09:32:38 UTC

[nuttx] 01/02: stm32h7/otg: move sanity checks to common header file for use USBDEV and USBHOST

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit eee25ea1ebc864ffe50713f1e122b4a209123c8d
Author: raiden00pl <ra...@railab.me>
AuthorDate: Tue May 9 11:53:17 2023 +0200

    stm32h7/otg: move sanity checks to common header file for use USBDEV and USBHOST
---
 arch/arm/src/stm32h7/stm32_otg.h    | 19 +++++++++++++++++++
 arch/arm/src/stm32h7/stm32_otgdev.c | 16 ----------------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/arch/arm/src/stm32h7/stm32_otg.h b/arch/arm/src/stm32h7/stm32_otg.h
index 2a41456668..c1d546cb9f 100644
--- a/arch/arm/src/stm32h7/stm32_otg.h
+++ b/arch/arm/src/stm32h7/stm32_otg.h
@@ -29,11 +29,30 @@
 
 #include <stdint.h>
 
+#include <arch/board/board.h>
+
 #include "chip.h"
+#include "stm32_rcc.h"
 #include "hardware/stm32_otg.h"
 
 #if defined(CONFIG_STM32H7_OTGFS) || defined(CONFIG_STM32H7_OTGHS)
 
+#if (STM32_RCC_D2CCIP2R_USBSRC == RCC_D2CCIP2R_USBSEL_HSI48) && \
+    !defined(CONFIG_STM32H7_HSI48)
+#  error board.h selected HSI48 as USB clock source, but HSI48 is not \
+         enabled. Enable STM32H7_HSI48
+#endif
+
+#if defined(CONFIG_STM32H7_OTGHS) && !defined(CONFIG_STM32H7_OTGHS_FS) && \
+    defined(CONFIG_STM32H7_OTGHS_NO_ULPI)
+#  error OTG HS selected but no ULPI enabled
+#endif
+
+#if defined(CONFIG_STM32H7_OTGHS_EXTERNAL_ULPI) &&  \
+    !defined(CONFIG_STM32H7_SYSCFG_IOCOMPENSATION)
+#  error External ULPI needs IOCOMPENSATION enabled
+#endif
+
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
diff --git a/arch/arm/src/stm32h7/stm32_otgdev.c b/arch/arm/src/stm32h7/stm32_otgdev.c
index 51604fc827..68abf01fed 100644
--- a/arch/arm/src/stm32h7/stm32_otgdev.c
+++ b/arch/arm/src/stm32h7/stm32_otgdev.c
@@ -54,22 +54,6 @@
 #if defined(CONFIG_USBDEV) && (defined(CONFIG_STM32H7_OTGFS) || \
     defined(CONFIG_STM32H7_OTGHS))
 
-#if (STM32_RCC_D2CCIP2R_USBSRC == RCC_D2CCIP2R_USBSEL_HSI48) && \
-    !defined(CONFIG_STM32H7_HSI48)
-#  error board.h selected HSI48 as USB clock source, but HSI48 is not \
-         enabled. Enable STM32H7_HSI48
-#endif
-
-#if defined(CONFIG_STM32H7_OTGHS) && !defined(CONFIG_STM32H7_OTGHS_FS) && \
-    defined(CONFIG_STM32H7_OTGHS_NO_ULPI)
-#  error OTG HS selected but no ULPI enabled
-#endif
-
-#if defined(CONFIG_STM32H7_OTGHS_EXTERNAL_ULPI) &&  \
-    !defined(CONFIG_STM32H7_SYSCFG_IOCOMPENSATION)
-#  error External ULPI needs IOCOMPENSATION enabled
-#endif
-
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/