From 3a51ec0bf3fa07a8e83d5baf232685322ebd24d7 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Tue, 23 Mar 2021 11:25:49 +0100 Subject: [PATCH] Rename OTG1 -> USBFS --- os/hal/ports/GD/GD32VF103/OTG/gd32_otg.h | 8 +-- os/hal/ports/GD/GD32VF103/OTG/hal_usb_lld.c | 26 +++---- os/hal/ports/GD/GD32VF103/OTG/hal_usb_lld.h | 68 +++++++++---------- os/hal/ports/GD/GD32VF103/gd32_isr.h | 6 +- os/hal/ports/GD/GD32VF103/gd32_registry.h | 6 +- os/hal/ports/GD/GD32VF103/hal_lld.c | 2 +- os/hal/ports/GD/GD32VF103/hal_lld_f103.h | 8 +-- os/hal/ports/GD/GD32VF103/hal_lld_f105_f107.h | 24 +++---- os/hal/ports/GD/GD32VF103/stm32_registry.h | 16 ++--- 9 files changed, 82 insertions(+), 82 deletions(-) diff --git a/os/hal/ports/GD/GD32VF103/OTG/gd32_otg.h b/os/hal/ports/GD/GD32VF103/OTG/gd32_otg.h index c4726ad2..0b9caaf9 100644 --- a/os/hal/ports/GD/GD32VF103/OTG/gd32_otg.h +++ b/os/hal/ports/GD/GD32VF103/OTG/gd32_otg.h @@ -22,13 +22,13 @@ * @{ */ -#ifndef GD32_OTG_H -#define GD32_OTG_H +#ifndef GD32_USBFS_H +#define GD32_USBFS_H /** * @brief OTG_FS FIFO memory size in words. */ -#define GD32_OTG1_FIFO_MEM_SIZE 320 +#define GD32_USBFS_FIFO_MEM_SIZE 320 /** * @brief Host channel registers group. @@ -899,6 +899,6 @@ typedef struct { */ #define OTG_FS ((gd32_otg_t *)OTG_FS_ADDR) -#endif /* GD32_OTG_H */ +#endif /* GD32_USBFS_H */ /** @} */ diff --git a/os/hal/ports/GD/GD32VF103/OTG/hal_usb_lld.c b/os/hal/ports/GD/GD32VF103/OTG/hal_usb_lld.c index 6de2510f..fcf2f347 100644 --- a/os/hal/ports/GD/GD32VF103/OTG/hal_usb_lld.c +++ b/os/hal/ports/GD/GD32VF103/OTG/hal_usb_lld.c @@ -38,7 +38,7 @@ #define EP0_MAX_INSIZE 64 #define EP0_MAX_OUTSIZE 64 -#if GD32_OTG_STEPPING == 1 +#if GD32_USBFS_STEPPING == 1 #if defined(BOARD_OTG_NOVBUSSENS) #define GCCFG_INIT_VALUE (GCCFG_NOVBUSSENS | GCCFG_VBUSASEN | \ GCCFG_VBUSBSEN | GCCFG_PWRDWN) @@ -47,7 +47,7 @@ GCCFG_PWRDWN) #endif -#elif GD32_OTG_STEPPING == 2 +#elif GD32_USBFS_STEPPING == 2 #if defined(BOARD_OTG_NOVBUSSENS) #define GCCFG_INIT_VALUE GCCFG_PWRDWN #else @@ -61,7 +61,7 @@ /*===========================================================================*/ /** @brief OTG_FS driver identifier.*/ -#if GD32_USB_USE_OTG1 || defined(__DOXYGEN__) +#if GD32_USB_USE_USBFS || defined(__DOXYGEN__) USBDriver USBD1; #endif @@ -106,11 +106,11 @@ static const USBEndpointConfig ep0config = { ep0setup_buffer }; -#if GD32_USB_USE_OTG1 +#if GD32_USB_USE_USBFS static const gd32_otg_params_t fsparams = { - GD32_USB_OTG1_RX_FIFO_SIZE / 4, - GD32_OTG1_FIFO_MEM_SIZE, - GD32_OTG1_ENDPOINTS + GD32_USB_USBFS_RX_FIFO_SIZE / 4, + GD32_USBFS_FIFO_MEM_SIZE, + GD32_USBFS_ENDPOINTS }; #endif @@ -427,7 +427,7 @@ static void otg_epout_handler(USBDriver *usbp, usbep_t ep) { /* EP0 requires special handling.*/ if (ep == 0) { -#if defined(GD32_OTG_SEQUENCE_WORKAROUND) +#if defined(GD32_USBFS_SEQUENCE_WORKAROUND) /* If an OUT transaction end interrupt is processed while the state machine is not in an OUT state then it is ignored, this is caused on some devices (L4) apparently injecting spurious data complete @@ -623,13 +623,13 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) { /* Driver interrupt handlers. */ /*===========================================================================*/ -#if GD32_USB_USE_OTG1 || defined(__DOXYGEN__) +#if GD32_USB_USE_USBFS || defined(__DOXYGEN__) /** - * @brief OTG1 interrupt handler. + * @brief USBFS interrupt handler. * * @isr */ -OSAL_IRQ_HANDLER(GD32_OTG1_HANDLER) { +OSAL_IRQ_HANDLER(GD32_USBFS_HANDLER) { OSAL_IRQ_PROLOGUE(); @@ -678,7 +678,7 @@ void usb_lld_start(USBDriver *usbp) { rccResetOTG_FS(); /* Enables IRQ vector.*/ - eclicEnableVector(GD32_OTG1_NUMBER, GD32_USB_OTG1_IRQ_PRIORITY, GD32_USB_OTG1_IRQ_TRIGGER); + eclicEnableVector(GD32_USBFS_NUMBER, GD32_USB_USBFS_IRQ_PRIORITY, GD32_USB_USBFS_IRQ_TRIGGER); /* - Forced device mode. - USB turn-around time = TRDT_VALUE_FS. @@ -751,7 +751,7 @@ void usb_lld_stop(USBDriver *usbp) { otgp->GCCFG = 0; if (&USBD1 == usbp) { - eclicDisableVector(GD32_OTG1_NUMBER); + eclicDisableVector(GD32_USBFS_NUMBER); rccDisableOTG_FS(); } } diff --git a/os/hal/ports/GD/GD32VF103/OTG/hal_usb_lld.h b/os/hal/ports/GD/GD32VF103/OTG/hal_usb_lld.h index bd4ed2d3..e3ad3ca5 100644 --- a/os/hal/ports/GD/GD32VF103/OTG/hal_usb_lld.h +++ b/os/hal/ports/GD/GD32VF103/OTG/hal_usb_lld.h @@ -53,27 +53,27 @@ /*===========================================================================*/ /** - * @brief OTG1 driver enable switch. + * @brief USBFS driver enable switch. * @details If set to @p TRUE the support for OTG_FS is included. * @note The default is @p FALSE */ -#if !defined(GD32_USB_USE_OTG1) || defined(__DOXYGEN__) -#define GD32_USB_USE_OTG1 FALSE +#if !defined(GD32_USB_USE_USBFS) || defined(__DOXYGEN__) +#define GD32_USB_USE_USBFS FALSE #endif /** - * @brief OTG1 interrupt priority level setting. + * @brief USBFS interrupt priority level setting. */ -#if !defined(GD32_USB_OTG1_IRQ_PRIORITY) || defined(__DOXYGEN__) -#define GD32_USB_OTG1_IRQ_PRIORITY 1 +#if !defined(GD32_USB_USBFS_IRQ_PRIORITY) || defined(__DOXYGEN__) +#define GD32_USB_USBFS_IRQ_PRIORITY 1 #endif /** - * @brief OTG1 RX shared FIFO size. + * @brief USBFS RX shared FIFO size. * @note Must be a multiple of 4. */ -#if !defined(GD32_USB_OTG1_RX_FIFO_SIZE) || defined(__DOXYGEN__) -#define GD32_USB_OTG1_RX_FIFO_SIZE 128 +#if !defined(GD32_USB_USBFS_RX_FIFO_SIZE) || defined(__DOXYGEN__) +#define GD32_USB_USBFS_RX_FIFO_SIZE 128 #endif /** @@ -107,53 +107,53 @@ /*===========================================================================*/ /* Registry checks.*/ -#if !defined(GD32_OTG_STEPPING) -#error "GD32_OTG_STEPPING not defined in registry" +#if !defined(GD32_USBFS_STEPPING) +#error "GD32_USBFS_STEPPING not defined in registry" #endif -#if (GD32_OTG_STEPPING < 1) || (GD32_OTG_STEPPING > 2) -#error "unsupported GD32_OTG_STEPPING" +#if (GD32_USBFS_STEPPING < 1) || (GD32_USBFS_STEPPING > 2) +#error "unsupported GD32_USBFS_STEPPING" #endif -#if GD32_HAS_OTG1 && !defined(GD32_OTG1_ENDPOINTS) -#error "GD32_OTG1_ENDPOINTS not defined in registry" +#if GD32_HAS_USBFS && !defined(GD32_USBFS_ENDPOINTS) +#error "GD32_USBFS_ENDPOINTS not defined in registry" #endif -#if GD32_HAS_OTG1 && !defined(GD32_OTG1_FIFO_MEM_SIZE) -#error "GD32_OTG1_FIFO_MEM_SIZE not defined in registry" +#if GD32_HAS_USBFS && !defined(GD32_USBFS_FIFO_MEM_SIZE) +#error "GD32_USBFS_FIFO_MEM_SIZE not defined in registry" #endif -#if (GD32_USB_USE_OTG1 && !defined(GD32_OTG1_HANDLER)) -#error "GD32_OTGx_HANDLER not defined in registry" +#if (GD32_USB_USE_USBFS && !defined(GD32_USBFS_HANDLER)) +#error "GD32_USBFS_HANDLER not defined in registry" #endif -#if (GD32_USB_USE_OTG1 && !defined(GD32_OTG1_NUMBER)) -#error "GD32_OTGx_NUMBER not defined in registry" +#if (GD32_USB_USE_USBFS && !defined(GD32_USBFS_NUMBER)) +#error "GD32_USBFS_NUMBER not defined in registry" #endif /** * @brief Maximum endpoint address. */ -#define USB_MAX_ENDPOINTS GD32_OTG1_ENDPOINTS +#define USB_MAX_ENDPOINTS GD32_USBFS_ENDPOINTS -#if GD32_USB_USE_OTG1 && !GD32_HAS_OTG1 -#error "OTG1 not present in the selected device" +#if GD32_USB_USE_USBFS && !GD32_HAS_USBFS +#error "USBFS not present in the selected device" #endif -#if !GD32_USB_USE_OTG1 +#if !GD32_USB_USE_USBFS #error "USB driver activated but no USB peripheral assigned" #endif -#if GD32_USB_USE_OTG1 && \ - !OSAL_IRQ_IS_VALID_PRIORITY(GD32_USB_OTG1_IRQ_PRIORITY) -#error "Invalid IRQ priority assigned to OTG1" +#if GD32_USB_USE_USBFS && \ + !OSAL_IRQ_IS_VALID_PRIORITY(GD32_USB_USBFS_IRQ_PRIORITY) +#error "Invalid IRQ priority assigned to USBFS" #endif -#if (GD32_USB_OTG1_RX_FIFO_SIZE & 3) != 0 -#error "OTG1 RX FIFO size must be a multiple of 4" +#if (GD32_USB_USBFS_RX_FIFO_SIZE & 3) != 0 +#error "USBFS RX FIFO size must be a multiple of 4" #endif -#define GD32_USBCLK GD32_OTGFSCLK +#define GD32_USBCLK GD32_USBFSCLK /* Allowing for a small tolerance.*/ #if GD32_USBCLK < 47880000 || GD32_USBCLK > 48120000 @@ -447,7 +447,7 @@ struct USBDriver { * * @notapi */ -#if (GD32_OTG_STEPPING == 1) || defined(__DOXYGEN__) +#if (GD32_USBFS_STEPPING == 1) || defined(__DOXYGEN__) #define usb_lld_connect_bus(usbp) ((usbp)->otg->GCCFG |= GCCFG_VBUSBSEN) #else #define usb_lld_connect_bus(usbp) ((usbp)->otg->DCTL &= ~DCTL_SDIS) @@ -458,7 +458,7 @@ struct USBDriver { * * @notapi */ -#if (GD32_OTG_STEPPING == 1) || defined(__DOXYGEN__) +#if (GD32_USBFS_STEPPING == 1) || defined(__DOXYGEN__) #define usb_lld_disconnect_bus(usbp) ((usbp)->otg->GCCFG &= ~GCCFG_VBUSBSEN) #else #define usb_lld_disconnect_bus(usbp) ((usbp)->otg->DCTL |= DCTL_SDIS) @@ -480,7 +480,7 @@ struct USBDriver { /* External declarations. */ /*===========================================================================*/ -#if GD32_USB_USE_OTG1 && !defined(__DOXYGEN__) +#if GD32_USB_USE_USBFS && !defined(__DOXYGEN__) extern USBDriver USBD1; #endif diff --git a/os/hal/ports/GD/GD32VF103/gd32_isr.h b/os/hal/ports/GD/GD32VF103/gd32_isr.h index 03343d42..e817f0b8 100644 --- a/os/hal/ports/GD/GD32VF103/gd32_isr.h +++ b/os/hal/ports/GD/GD32VF103/gd32_isr.h @@ -106,8 +106,8 @@ /* * OTG units. */ -#define GD32_OTG1_HANDLER vector86 -#define GD32_OTG1_NUMBER 86 +#define GD32_USBFS_HANDLER vector86 +#define GD32_USBFS_NUMBER 86 /* * RTC unit @@ -287,7 +287,7 @@ #define GD32_UART_USART2_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT #define GD32_UART_USART3_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT #define GD32_UART_USART6_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT -#define GD32_USB_OTG1_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT +#define GD32_USB_USBFS_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT /*===========================================================================*/ /* Derived constants and error checks. */ diff --git a/os/hal/ports/GD/GD32VF103/gd32_registry.h b/os/hal/ports/GD/GD32VF103/gd32_registry.h index 2da58904..3bc18370 100644 --- a/os/hal/ports/GD/GD32VF103/gd32_registry.h +++ b/os/hal/ports/GD/GD32VF103/gd32_registry.h @@ -303,9 +303,9 @@ #endif /* USB attributes.*/ -#define GD32_OTG_STEPPING 1 -#define GD32_HAS_OTG1 TRUE -#define GD32_OTG1_ENDPOINTS 3 +#define GD32_USBFS_STEPPING 1 +#define GD32_HAS_USBFS TRUE +#define GD32_USBFS_ENDPOINTS 3 #define GD32_HAS_USB TRUE diff --git a/os/hal/ports/GD/GD32VF103/hal_lld.c b/os/hal/ports/GD/GD32VF103/hal_lld.c index e03d282f..ad867db7 100644 --- a/os/hal/ports/GD/GD32VF103/hal_lld.c +++ b/os/hal/ports/GD/GD32VF103/hal_lld.c @@ -234,7 +234,7 @@ void gd32_clock_init(void) { #endif /* Clock settings.*/ -#if GD32_HAS_OTG1 +#if GD32_HAS_USBFS RCC->CFGR = GD32_MCOSEL | GD32_USBPRE | GD32_PLLMUL | GD32_PLLSRC | GD32_ADCPRE | GD32_PPRE2 | GD32_PPRE1 | GD32_HPRE; #else diff --git a/os/hal/ports/GD/GD32VF103/hal_lld_f103.h b/os/hal/ports/GD/GD32VF103/hal_lld_f103.h index c7e89bb5..a3390a69 100644 --- a/os/hal/ports/GD/GD32VF103/hal_lld_f103.h +++ b/os/hal/ports/GD/GD32VF103/hal_lld_f103.h @@ -571,13 +571,13 @@ * @brief USB frequency. */ #if (GD32_USBPRE == GD32_USBPRE_DIV1P5) || defined(__DOXYGEN__) -#define GD32_OTGFSCLK ((GD32_PLLCLKOUT * 2) / 3) +#define GD32_USBFSCLK ((GD32_PLLCLKOUT * 2) / 3) #elif (GD32_USBPRE == GD32_USBPRE_DIV1) -#define GD32_OTGFSCLK GD32_PLLCLKOUT +#define GD32_USBFSCLK GD32_PLLCLKOUT #elif (GD32_USBPRE == GD32_USBPRE_DIV2) -#define GD32_OTGFSCLK GD32_PLLCLKOUT / 2 +#define GD32_USBFSCLK GD32_PLLCLKOUT / 2 #elif (GD32_USBPRE == GD32_USBPRE_DIV2P5) -#define GD32_OTGFSCLK ((GD32_PLLCLKOUT * 2) / 5) +#define GD32_USBFSCLK ((GD32_PLLCLKOUT * 2) / 5) #else #error "invalid GD32_USBPRE value specified" #endif diff --git a/os/hal/ports/GD/GD32VF103/hal_lld_f105_f107.h b/os/hal/ports/GD/GD32VF103/hal_lld_f105_f107.h index 4e65a68a..1fe3022a 100644 --- a/os/hal/ports/GD/GD32VF103/hal_lld_f105_f107.h +++ b/os/hal/ports/GD/GD32VF103/hal_lld_f105_f107.h @@ -165,8 +165,8 @@ #define GD32_PLLSRC_PREDIV1 (1 << 16) /**< PLL clock source is PREDIV1. */ -#define GD32_OTGFSPRE_DIV2 (1 << 22) /**< HCLK*2 divided by 2. */ -#define GD32_OTGFSPRE_DIV3 (0 << 22) /**< HCLK*2 divided by 3. */ +#define GD32_USBFSPRE_DIV2 (1 << 22) /**< HCLK*2 divided by 2. */ +#define GD32_USBFSPRE_DIV3 (0 << 22) /**< HCLK*2 divided by 3. */ #define GD32_MCOSEL_NOCLOCK (0 << 24) /**< No clock on MCO pin. */ #define GD32_MCOSEL_SYSCLK (4 << 24) /**< SYSCLK on MCO pin. */ @@ -315,15 +315,15 @@ /** * @brief USB clock setting. */ -#if !defined(GD32_OTG_CLOCK_REQUIRED) || defined(__DOXYGEN__) -#define GD32_OTG_CLOCK_REQUIRED TRUE +#if !defined(GD32_USBFS_CLOCK_REQUIRED) || defined(__DOXYGEN__) +#define GD32_USBFS_CLOCK_REQUIRED TRUE #endif /** * @brief OTG prescaler initialization. */ -#if !defined(GD32_OTGFSPRE) || defined(__DOXYGEN__) -#define GD32_OTGFSPRE GD32_OTGFSPRE_DIV3 +#if !defined(GD32_USBFSPRE) || defined(__DOXYGEN__) +#define GD32_USBFSPRE GD32_USBFSPRE_DIV3 #endif /** @@ -452,7 +452,7 @@ #endif /* !GD32_LSE_ENABLED */ /* PLL1 activation conditions.*/ -#if GD32_OTG_CLOCK_REQUIRED || \ +#if GD32_USBFS_CLOCK_REQUIRED || \ (GD32_SW == GD32_SW_PLL) || \ (GD32_MCOSEL == GD32_MCOSEL_PLLDIV2) || \ defined(__DOXYGEN__) @@ -772,12 +772,12 @@ /** * @brief OTG frequency. */ -#if (GD32_OTGFSPRE == GD32_OTGFSPRE_DIV3) || defined(__DOXYGEN__) -#define GD32_OTGFSCLK (GD32_PLLVCO / 3) -#elif (GD32_OTGFSPRE == GD32_OTGFSPRE_DIV2) -#define GD32_OTGFSCLK (GD32_PLLVCO / 2) +#if (GD32_USBFSPRE == GD32_USBFSPRE_DIV3) || defined(__DOXYGEN__) +#define GD32_USBFSCLK (GD32_PLLVCO / 3) +#elif (GD32_USBFSPRE == GD32_USBFSPRE_DIV2) +#define GD32_USBFSCLK (GD32_PLLVCO / 2) #else -#error "invalid GD32_OTGFSPRE value specified" +#error "invalid GD32_USBFSPRE value specified" #endif /** diff --git a/os/hal/ports/GD/GD32VF103/stm32_registry.h b/os/hal/ports/GD/GD32VF103/stm32_registry.h index 6cb9e53d..469a4460 100644 --- a/os/hal/ports/GD/GD32VF103/stm32_registry.h +++ b/os/hal/ports/GD/GD32VF103/stm32_registry.h @@ -249,7 +249,7 @@ /* USB attributes.*/ #define GD32_HAS_USB FALSE -#define GD32_HAS_OTG1 FALSE +#define GD32_HAS_USBFS FALSE #define GD32_HAS_OTG2 FALSE /* IWDG attributes.*/ @@ -434,7 +434,7 @@ /* USB attributes.*/ #define GD32_HAS_USB FALSE -#define GD32_HAS_OTG1 FALSE +#define GD32_HAS_USBFS FALSE #define GD32_HAS_OTG2 FALSE /* IWDG attributes.*/ @@ -635,7 +635,7 @@ #define GD32_USB_ACCESS_SCHEME_2x16 FALSE #define GD32_USB_PMA_SIZE 512 #define GD32_USB_HAS_BCDR FALSE -#define GD32_HAS_OTG1 FALSE +#define GD32_HAS_USBFS FALSE #define GD32_HAS_OTG2 FALSE /* IWDG attributes.*/ @@ -875,7 +875,7 @@ #define GD32_USB_ACCESS_SCHEME_2x16 FALSE #define GD32_USB_PMA_SIZE 512 #define GD32_USB_HAS_BCDR FALSE -#define GD32_HAS_OTG1 FALSE +#define GD32_HAS_USBFS FALSE #define GD32_HAS_OTG2 FALSE /* IWDG attributes.*/ @@ -1133,7 +1133,7 @@ #define GD32_USB_ACCESS_SCHEME_2x16 FALSE #define GD32_USB_PMA_SIZE 512 #define GD32_USB_HAS_BCDR FALSE -#define GD32_HAS_OTG1 FALSE +#define GD32_HAS_USBFS FALSE #define GD32_HAS_OTG2 FALSE /* IWDG attributes.*/ @@ -1368,9 +1368,9 @@ #define GD32_HAS_LPUART1 FALSE /* USB attributes.*/ -#define GD32_OTG_STEPPING 1 -#define GD32_HAS_OTG1 TRUE -#define GD32_OTG1_ENDPOINTS 3 +#define GD32_USBFS_STEPPING 1 +#define GD32_HAS_USBFS TRUE +#define GD32_USBFS_ENDPOINTS 3 #define GD32_HAS_OTG2 FALSE #define GD32_HAS_USB FALSE