/*! \file gd32e50x_rcu.h \brief definitions for the RCU \version 2020-03-10, V1.0.0, firmware for GD32E50X \version 2020-08-26, V1.1.0, firmware for GD32E50x \version 2020-09-20, V1.1.1, firmware for GD32E50x \version 2021-03-23, V1.2.0, firmware for GD32E50x */ /* Copyright (c) 2021, GigaDevice Semiconductor Inc. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef GD32E50X_RCU_H #define GD32E50X_RCU_H #include "gd32e50x.h" /* RCU definitions */ #define RCU RCU_BASE /* registers definitions */ #if (defined(GD32E50X_HD) || defined(GD32E50X_XD)) #define RCU_CTL REG32(RCU + 0x00000000U) /*!< control register */ #define RCU_CFG0 REG32(RCU + 0x00000004U) /*!< clock configuration register 0 */ #define RCU_INT REG32(RCU + 0x00000008U) /*!< clock interrupt register */ #define RCU_APB2RST REG32(RCU + 0x0000000CU) /*!< APB2 reset register */ #define RCU_APB1RST REG32(RCU + 0x00000010U) /*!< APB1 reset register */ #define RCU_AHBEN REG32(RCU + 0x00000014U) /*!< AHB enable register */ #define RCU_APB2EN REG32(RCU + 0x00000018U) /*!< APB2 enable register */ #define RCU_APB1EN REG32(RCU + 0x0000001CU) /*!< APB1 enable register */ #define RCU_BDCTL REG32(RCU + 0x00000020U) /*!< backup domain control register */ #define RCU_RSTSCK REG32(RCU + 0x00000024U) /*!< reset source / clock register */ #define RCU_CFG1 REG32(RCU + 0x0000002CU) /*!< clock configuration register 1 */ #define RCU_DSV REG32(RCU + 0x00000034U) /*!< deep-sleep mode voltage register */ #define RCU_ADDCTL REG32(RCU + 0x000000C0U) /*!< Additional clock control register */ #define RCU_ADDINT REG32(RCU + 0x000000CCU) /*!< Additional clock interrupt register */ #define RCU_ADDAPB1RST REG32(RCU + 0x000000E0U) /*!< APB1 additional reset register */ #define RCU_ADDAPB1EN REG32(RCU + 0x000000E4U) /*!< APB1 additional enable register */ #define RCU_CFG2 REG32(RCU + 0x000000D4U) /*!< clock configuration register 2 */ #define RCU_ADDAPB1RST REG32(RCU + 0x000000E0U) /*!< APB1 additional reset register */ #define RCU_ADDAPB1EN REG32(RCU + 0x000000E4U) /*!< APB1 additional enable register */ #elif defined(GD32E50X_CL) || defined(GD32E508) #define RCU_CTL REG32(RCU + 0x00000000U) /*!< control register */ #define RCU_CFG0 REG32(RCU + 0x00000004U) /*!< clock configuration register 0 */ #define RCU_INT REG32(RCU + 0x00000008U) /*!< clock interrupt register */ #define RCU_APB2RST REG32(RCU + 0x0000000CU) /*!< APB2 reset register */ #define RCU_APB1RST REG32(RCU + 0x00000010U) /*!< APB1 reset register */ #define RCU_AHBEN REG32(RCU + 0x00000014U) /*!< AHB1 enable register */ #define RCU_APB2EN REG32(RCU + 0x00000018U) /*!< APB2 enable register */ #define RCU_APB1EN REG32(RCU + 0x0000001CU) /*!< APB1 enable register */ #define RCU_BDCTL REG32(RCU + 0x00000020U) /*!< backup domain control register */ #define RCU_RSTSCK REG32(RCU + 0x00000024U) /*!< reset source / clock register */ #define RCU_AHBRST REG32(RCU + 0x00000028U) /*!< AHB reset register */ #define RCU_CFG1 REG32(RCU + 0x0000002CU) /*!< clock configuration register 1 */ #define RCU_DSV REG32(RCU + 0x00000034U) /*!< deep-sleep mode voltage register */ #define RCU_ADDCTL REG32(RCU + 0x000000C0U) /*!< Additional clock control register */ #define RCU_ADDCFG REG32(RCU + 0x000000C4U) /*!< Additional clock configuration register */ #define RCU_ADDINT REG32(RCU + 0x000000CCU) /*!< Additional clock interrupt register */ #define RCU_PLLSSCTL REG32(RCU + 0x000000D0U) /*!< PLL clock spread spectrum control register */ #define RCU_CFG2 REG32(RCU + 0x000000D4U) /*!< clock configuration register 2 */ #define RCU_ADDAPB1RST REG32(RCU + 0x000000E0U) /*!< APB1 additional reset register */ #define RCU_ADDAPB1EN REG32(RCU + 0x000000E4U) /*!< APB1 additional enable register */ #elif defined(GD32EPRT) #define RCU_CTL REG32(RCU + 0x00000000U) /*!< control register */ #define RCU_CFG0 REG32(RCU + 0x00000004U) /*!< clock configuration register 0 */ #define RCU_INT REG32(RCU + 0x00000008U) /*!< clock interrupt register */ #define RCU_APB2RST REG32(RCU + 0x0000000CU) /*!< APB2 reset register */ #define RCU_APB1RST REG32(RCU + 0x00000010U) /*!< APB1 reset register */ #define RCU_AHBEN REG32(RCU + 0x00000014U) /*!< AHB1 enable register */ #define RCU_APB2EN REG32(RCU + 0x00000018U) /*!< APB2 enable register */ #define RCU_APB1EN REG32(RCU + 0x0000001CU) /*!< APB1 enable register */ #define RCU_BDCTL REG32(RCU + 0x00000020U) /*!< backup domain control register */ #define RCU_RSTSCK REG32(RCU + 0x00000024U) /*!< reset source / clock register */ #define RCU_AHBRST REG32(RCU + 0x00000028U) /*!< AHB reset register */ #define RCU_CFG1 REG32(RCU + 0x0000002CU) /*!< clock configuration register 1 */ #define RCU_DSV REG32(RCU + 0x00000034U) /*!< deep-sleep mode voltage register */ #define RCU_ADDCTL REG32(RCU + 0x000000C0U) /*!< Additional clock control register */ #define RCU_ADDINT REG32(RCU + 0x000000CCU) /*!< Additional clock interrupt register */ #define RCU_PLLSSCTL REG32(RCU + 0x000000D0U) /*!< PLL clock spread spectrum control register */ #define RCU_CFG2 REG32(RCU + 0x000000D4U) /*!< clock configuration register 2 */ #define RCU_ADDAPB1RST REG32(RCU + 0x000000E0U) /*!< APB1 additional reset register */ #define RCU_ADDAPB1EN REG32(RCU + 0x000000E4U) /*!< APB1 additional enable register */ #endif /* GD32E50X_HD and GD32E50X_XD */ /* bits definitions */ /* RCU_CTL */ #if defined(GD32E50X_HD) || defined(GD32E50X_XD) #define RCU_CTL_IRC8MEN BIT(0) /*!< internal high speed oscillator enable */ #define RCU_CTL_IRC8MSTB BIT(1) /*!< IRC8M high speed internal oscillator stabilization flag */ #define RCU_CTL_IRC8MADJ BITS(3,7) /*!< high speed internal oscillator clock trim adjust value */ #define RCU_CTL_IRC8MCALIB BITS(8,15) /*!< high speed internal oscillator calibration value register */ #define RCU_CTL_HXTALEN BIT(16) /*!< external high speed oscillator enable */ #define RCU_CTL_HXTALSTB BIT(17) /*!< external crystal oscillator clock stabilization flag */ #define RCU_CTL_HXTALBPS BIT(18) /*!< external crystal oscillator clock bypass mode enable */ #define RCU_CTL_CKMEN BIT(19) /*!< HXTAL clock monitor enable */ #define RCU_CTL_PLLEN BIT(24) /*!< PLL enable */ #define RCU_CTL_PLLSTB BIT(25) /*!< PLL clock stabilization flag */ #elif defined(GD32E50X_CL) || defined(GD32EPRT) || defined(GD32E508) #define RCU_CTL_IRC8MEN BIT(0) /*!< internal high speed oscillator enable */ #define RCU_CTL_IRC8MSTB BIT(1) /*!< IRC8M high speed internal oscillator stabilization flag */ #define RCU_CTL_IRC8MADJ BITS(3,7) /*!< high speed internal oscillator clock trim adjust value */ #define RCU_CTL_IRC8MCALIB BITS(8,15) /*!< high speed internal oscillator calibration value register */ #define RCU_CTL_HXTALEN BIT(16) /*!< external high speed oscillator enable */ #define RCU_CTL_HXTALSTB BIT(17) /*!< external crystal oscillator clock stabilization flag */ #define RCU_CTL_HXTALBPS BIT(18) /*!< external crystal oscillator clock bypass mode enable */ #define RCU_CTL_CKMEN BIT(19) /*!< HXTAL clock monitor enable */ #define RCU_CTL_PLLEN BIT(24) /*!< PLL enable */ #define RCU_CTL_PLLSTB BIT(25) /*!< PLL clock stabilization flag */ #define RCU_CTL_PLL1EN BIT(26) /*!< PLL1 enable */ #define RCU_CTL_PLL1STB BIT(27) /*!< PLL1 clock stabilization flag */ #define RCU_CTL_PLL2EN BIT(28) /*!< PLL2 enable */ #define RCU_CTL_PLL2STB BIT(29) /*!< PLL2 clock stabilization flag */ #endif /* GD32E50X_HD and GD32E50X_XD*/ /* RCU_CFG0 */ #if defined(GD32E50X_HD) || defined(GD32E50X_XD) #define RCU_CFG0_SCS BITS(0,1) /*!< system clock switch */ #define RCU_CFG0_SCSS BITS(2,3) /*!< system clock switch status */ #define RCU_CFG0_AHBPSC BITS(4,7) /*!< AHB prescaler selection */ #define RCU_CFG0_APB1PSC BITS(8,10) /*!< APB1 prescaler selection */ #define RCU_CFG0_APB2PSC BITS(11,13) /*!< APB2 prescaler selection */ #define RCU_CFG0_ADCPSC BITS(14,15) /*!< ADC prescaler selection */ #define RCU_CFG0_PLLSEL BIT(16) /*!< PLL clock source selection */ #define RCU_CFG0_PREDV0 BIT(17) /*!< PREDV0 division factor */ #define RCU_CFG0_PLLMF BITS(18,21) /*!< PLL clock multiplication factor */ #define RCU_CFG0_USBDPSC BITS(22,23) /*!< USBD clock prescaler selection */ #define RCU_CFG0_CKOUT0SEL BITS(24,26) /*!< CKOUT0 clock source selection */ #define RCU_CFG0_PLLMF_4 BIT(27) /*!< bit 4 of PLLMF */ #define RCU_CFG0_ADCPSC_2 BIT(28) /*!< bit 2 of ADCPSC */ #define RCU_CFG0_PLLMF_5 BIT(30) /*!< bit 5 of PLLMF */ #define RCU_CFG0_USBDPSC_2 BIT(31) /*!< bit 2 of USBDPSC */ #elif defined(GD32E50X_CL) || defined(GD32E508) #define RCU_CFG0_SCS BITS(0,1) /*!< system clock switch */ #define RCU_CFG0_SCSS BITS(2,3) /*!< system clock switch status */ #define RCU_CFG0_AHBPSC BITS(4,7) /*!< AHB prescaler selection */ #define RCU_CFG0_APB1PSC BITS(8,10) /*!< APB1 prescaler selection */ #define RCU_CFG0_APB2PSC BITS(11,13) /*!< APB2 prescaler selection */ #define RCU_CFG0_ADCPSC BITS(14,15) /*!< ADC prescaler selection */ #define RCU_CFG0_PLLSEL BIT(16) /*!< PLL clock source selection */ #define RCU_CFG0_PREDV0_LSB BIT(17) /*!< the LSB of PREDV0 division factor */ #define RCU_CFG0_PLLMF BITS(18,21) /*!< PLL clock multiplication factor */ #define RCU_CFG0_USBHSPSC BITS(22,23) /*!< USBHS clock prescaler selection */ #define RCU_CFG0_CKOUT0SEL BITS(24,27) /*!< CKOUT0 clock source selection */ #define RCU_CFG0_ADCPSC_2 BIT(28) /*!< bit 2 of ADCPSC */ #define RCU_CFG0_PLLMF_4 BIT(29) /*!< bit 4 of PLLMF */ #define RCU_CFG0_PLLMF_5 BIT(30) /*!< bit 5 of PLLMF */ #define RCU_CFG0_USBHSPSC_2 BIT(31) /*!< bit 2 of USBHSPSC */ #elif defined(GD32EPRT) #define RCU_CFG0_SCS BITS(0,1) /*!< system clock switch */ #define RCU_CFG0_SCSS BITS(2,3) /*!< system clock switch status */ #define RCU_CFG0_AHBPSC BITS(4,7) /*!< AHB prescaler selection */ #define RCU_CFG0_APB1PSC BITS(8,10) /*!< APB1 prescaler selection */ #define RCU_CFG0_APB2PSC BITS(11,13) /*!< APB2 prescaler selection */ #define RCU_CFG0_ADCPSC BITS(14,15) /*!< ADC prescaler selection */ #define RCU_CFG0_PLLSEL BIT(16) /*!< PLL clock source selection */ #define RCU_CFG0_PREDV0_LSB BIT(17) /*!< the LSB of PREDV0 division factor */ #define RCU_CFG0_PLLMF BITS(18,21) /*!< PLL clock multiplication factor */ #define RCU_CFG0_USBDPSC BITS(22,23) /*!< USBD clock prescaler selection */ #define RCU_CFG0_CKOUT0SEL BITS(24,27) /*!< CKOUT0 clock source selection */ #define RCU_CFG0_ADCPSC_2 BIT(28) /*!< bit 2 of ADCPSC */ #define RCU_CFG0_PLLMF_4 BIT(29) /*!< bit 4 of PLLMF */ #define RCU_CFG0_PLLMF_5 BIT(30) /*!< bit 5 of PLLMF */ #define RCU_CFG0_USBDPSC_2 BIT(31) /*!< bit 2 of USBDPSC */ #endif /* GD32E50X_HD and GD32E50X_XD */ /* RCU_INT */ #if defined(GD32E50X_HD) || defined(GD32E50X_XD) #define RCU_INT_IRC40KSTBIF BIT(0) /*!< IRC40K stabilization interrupt flag */ #define RCU_INT_LXTALSTBIF BIT(1) /*!< LXTAL stabilization interrupt flag */ #define RCU_INT_IRC8MSTBIF BIT(2) /*!< IRC8M stabilization interrupt flag */ #define RCU_INT_HXTALSTBIF BIT(3) /*!< HXTAL stabilization interrupt flag */ #define RCU_INT_PLLSTBIF BIT(4) /*!< PLL stabilization interrupt flag */ #define RCU_INT_CKMIF BIT(7) /*!< HXTAL clock stuck interrupt flag */ #define RCU_INT_IRC40KSTBIE BIT(8) /*!< IRC40K stabilization interrupt enable */ #define RCU_INT_LXTALSTBIE BIT(9) /*!< LXTAL stabilization interrupt enable */ #define RCU_INT_IRC8MSTBIE BIT(10) /*!< IRC8M stabilization interrupt enable */ #define RCU_INT_HXTALSTBIE BIT(11) /*!< HXTAL stabilization interrupt enable */ #define RCU_INT_PLLSTBIE BIT(12) /*!< PLL stabilization interrupt enable */ #define RCU_INT_IRC40KSTBIC BIT(16) /*!< IRC40K Stabilization interrupt clear */ #define RCU_INT_LXTALSTBIC BIT(17) /*!< LXTAL Stabilization interrupt clear */ #define RCU_INT_IRC8MSTBIC BIT(18) /*!< IRC8M Stabilization interrupt clear */ #define RCU_INT_HXTALSTBIC BIT(19) /*!< HXTAL Stabilization interrupt clear */ #define RCU_INT_PLLSTBIC BIT(20) /*!< PLL stabilization interrupt clear */ #define RCU_INT_CKMIC BIT(23) /*!< HXTAL clock stuck interrupt clear */ #elif defined(GD32E50X_CL) || defined(GD32EPRT) || defined(GD32E508) #define RCU_INT_IRC40KSTBIF BIT(0) /*!< IRC40K stabilization interrupt flag */ #define RCU_INT_LXTALSTBIF BIT(1) /*!< LXTAL stabilization interrupt flag */ #define RCU_INT_IRC8MSTBIF BIT(2) /*!< IRC8M stabilization interrupt flag */ #define RCU_INT_HXTALSTBIF BIT(3) /*!< HXTAL stabilization interrupt flag */ #define RCU_INT_PLLSTBIF BIT(4) /*!< PLL stabilization interrupt flag */ #define RCU_INT_PLL1STBIF BIT(5) /*!< PLL1 stabilization interrupt flag */ #define RCU_INT_PLL2STBIF BIT(6) /*!< PLL2 stabilization interrupt flag */ #define RCU_INT_CKMIF BIT(7) /*!< HXTAL clock stuck interrupt flag */ #define RCU_INT_IRC40KSTBIE BIT(8) /*!< IRC40K stabilization interrupt enable */ #define RCU_INT_LXTALSTBIE BIT(9) /*!< LXTAL stabilization interrupt enable */ #define RCU_INT_IRC8MSTBIE BIT(10) /*!< IRC8M stabilization interrupt enable */ #define RCU_INT_HXTALSTBIE BIT(11) /*!< HXTAL stabilization interrupt enable */ #define RCU_INT_PLLSTBIE BIT(12) /*!< PLL stabilization interrupt enable */ #define RCU_INT_PLL1STBIE BIT(13) /*!< PLL1 stabilization interrupt enable */ #define RCU_INT_PLL2STBIE BIT(14) /*!< PLL2 stabilization interrupt enable */ #define RCU_INT_IRC40KSTBIC BIT(16) /*!< IRC40K stabilization interrupt clear */ #define RCU_INT_LXTALSTBIC BIT(17) /*!< LXTAL stabilization interrupt clear */ #define RCU_INT_IRC8MSTBIC BIT(18) /*!< IRC8M stabilization interrupt clear */ #define RCU_INT_HXTALSTBIC BIT(19) /*!< HXTAL stabilization interrupt clear */ #define RCU_INT_PLLSTBIC BIT(20) /*!< PLL stabilization interrupt clear */ #define RCU_INT_PLL1STBIC BIT(21) /*!< PLL1 stabilization interrupt clear */ #define RCU_INT_PLL2STBIC BIT(22) /*!< PLL2 stabilization interrupt clear */ #define RCU_INT_CKMIC BIT(23) /*!< HXTAL clock stuck interrupt clear */ #endif /* GD32E50X_HD and GD32E50X_XD */ /* RCU_APB2RST */ #define RCU_APB2RST_AFRST BIT(0) /*!< alternate function I/O reset */ #define RCU_APB2RST_PARST BIT(2) /*!< GPIO port A reset */ #define RCU_APB2RST_PBRST BIT(3) /*!< GPIO port B reset */ #define RCU_APB2RST_PCRST BIT(4) /*!< GPIO port C reset */ #define RCU_APB2RST_PDRST BIT(5) /*!< GPIO port D reset */ #define RCU_APB2RST_PERST BIT(6) /*!< GPIO port E reset */ #define RCU_APB2RST_PFRST BIT(7) /*!< GPIO port F reset */ #define RCU_APB2RST_PGRST BIT(8) /*!< GPIO port G reset */ #define RCU_APB2RST_ADC0RST BIT(9) /*!< ADC0 reset */ #define RCU_APB2RST_ADC1RST BIT(10) /*!< ADC1 reset */ #define RCU_APB2RST_TIMER0RST BIT(11) /*!< TIMER0 reset */ #define RCU_APB2RST_SPI0RST BIT(12) /*!< SPI0 reset */ #define RCU_APB2RST_TIMER7RST BIT(13) /*!< TIMER7 reset */ #define RCU_APB2RST_USART0RST BIT(14) /*!< USART0 reset */ #if defined(GD32E50X_XD) || defined(GD32E50X_HD) || defined(GD32EPRT) #define RCU_APB2RST_ADC2RST BIT(15) /*!< ADC2 reset */ #endif /* GD32E50X_XD and GD32E50X_HDand GD32EPRT */ #ifndef GD32EPRT #define RCU_APB2RST_TIMER8RST BIT(19) /*!< TIMER8 reset */ #define RCU_APB2RST_TIMER9RST BIT(20) /*!< TIMER9 reset */ #define RCU_APB2RST_TIMER10RST BIT(21) /*!< TIMER10 reset */ #endif /* GD32EPRT*/ #define RCU_APB2RST_USART5RST BIT(28) /*!< USART5 reset */ #ifndef GD32EPRT #define RCU_APB2RST_SHRTIMERRST BIT(29) /*!< HPTIME reset */ #endif /* GD32EPRT */ #if defined(GD32E50X_CL) || defined(GD32E508) #define RCU_APB2RST_CMPRST BIT(31) /*!< CMP reset */ #endif /* GD32E50X_CL and GD32E508 */ /* RCU_APB1RST */ #define RCU_APB1RST_TIMER1RST BIT(0) /*!< TIMER1 reset */ #define RCU_APB1RST_TIMER2RST BIT(1) /*!< TIMER2 reset */ #define RCU_APB1RST_TIMER3RST BIT(2) /*!< TIMER3 reset */ #define RCU_APB1RST_TIMER4RST BIT(3) /*!< TIMER4 reset */ #define RCU_APB1RST_TIMER5RST BIT(4) /*!< TIMER5 reset */ #define RCU_APB1RST_TIMER6RST BIT(5) /*!< TIMER6 reset */ #ifndef GD32EPRT #define RCU_APB1RST_TIMER11RST BIT(6) /*!< TIMER11 reset */ #define RCU_APB1RST_TIMER12RST BIT(7) /*!< TIMER12 reset */ #define RCU_APB1RST_TIMER13RST BIT(8) /*!< TIMER13 reset */ #endif /* GD32EPRT */ #define RCU_APB1RST_WWDGTRST BIT(11) /*!< WWDGT reset */ #define RCU_APB1RST_SPI1RST BIT(14) /*!< SPI1 reset */ #define RCU_APB1RST_SPI2RST BIT(15) /*!< SPI2 reset */ #define RCU_APB1RST_USART1RST BIT(17) /*!< USART1 reset */ #define RCU_APB1RST_USART2RST BIT(18) /*!< USART2 reset */ #define RCU_APB1RST_UART3RST BIT(19) /*!< UART3 reset */ #define RCU_APB1RST_UART4RST BIT(20) /*!< UART4 reset */ #define RCU_APB1RST_I2C0RST BIT(21) /*!< I2C0 reset */ #define RCU_APB1RST_I2C1RST BIT(22) /*!< I2C1 reset */ #if (defined(GD32E50X_HD) || defined(GD32E50X_XD) || defined(GD32EPRT)) #define RCU_APB1RST_USBDRST BIT(23) /*!< USBD reset */ #endif /* GD32E50X_HD and GD32E50X_XD and GD32EPRT */ #define RCU_APB1RST_I2C2RST BIT(24) /*!< I2C2 reset */ #ifndef GD32EPRT #define RCU_APB1RST_CAN0RST BIT(25) /*!< CAN0 reset */ #define RCU_APB1RST_CAN1RST BIT(26) /*!< CAN1 reset */ #endif /* GD32EPRT */ #define RCU_APB1RST_BKPIRST BIT(27) /*!< backup interface reset */ #define RCU_APB1RST_PMURST BIT(28) /*!< PMU reset */ #define RCU_APB1RST_DACRST BIT(29) /*!< DAC reset */ /* RCU_AHBEN */ #define RCU_AHBEN_DMA0EN BIT(0) /*!< DMA0 clock enable */ #define RCU_AHBEN_DMA1EN BIT(1) /*!< DMA1 clock enable */ #define RCU_AHBEN_SRAMSPEN BIT(2) /*!< SRAM clock enable when sleep mode */ #define RCU_AHBEN_FMCSPEN BIT(4) /*!< FMC clock enable when sleep mode */ #define RCU_AHBEN_CRCEN BIT(6) /*!< CRC clock enable */ #define RCU_AHBEN_EXMCEN BIT(8) /*!< EXMC clock enable */ #if (defined(GD32E50X_HD) || defined(GD32E50X_XD)) #define RCU_AHBEN_SDIOEN BIT(10) /*!< SDIO clock enable */ #elif defined(GD32E50X_CL) || defined(GD32E508) #define RCU_AHBEN_USBHSEN BIT(12) /*!< USBHS clock enable */ #define RCU_AHBEN_ULPIEN BIT(13) /*!< ULPI clock enable */ #define RCU_AHBEN_TMUEN BIT(30) /*!< TMU clock enable */ #endif /* GD32E50X_HD and GD32E50X_XD */ #if (defined(GD32E50X_CL) || defined(GD32EPRT) || defined(GD32E508)) #define RCU_AHBEN_ENETEN BIT(14) /*!< ENET clock enable */ #define RCU_AHBEN_ENETTXEN BIT(15) /*!< Ethernet TX clock enable */ #define RCU_AHBEN_ENETRXEN BIT(16) /*!< Ethernet RX clock enable */ #endif /* GD32E50X_CL and GD32EPRT and GD32E508 */ #define RCU_AHBEN_SQPIEN BIT(31) /*!< SQPI clock enable */ /* RCU_APB2EN */ #define RCU_APB2EN_AFEN BIT(0) /*!< alternate function IO clock enable */ #define RCU_APB2EN_PAEN BIT(2) /*!< GPIO port A clock enable */ #define RCU_APB2EN_PBEN BIT(3) /*!< GPIO port B clock enable */ #define RCU_APB2EN_PCEN BIT(4) /*!< GPIO port C clock enable */ #define RCU_APB2EN_PDEN BIT(5) /*!< GPIO port D clock enable */ #define RCU_APB2EN_PEEN BIT(6) /*!< GPIO port E clock enable */ #define RCU_APB2EN_PFEN BIT(7) /*!< GPIO port F clock enable */ #define RCU_APB2EN_PGEN BIT(8) /*!< GPIO port G clock enable */ #define RCU_APB2EN_ADC0EN BIT(9) /*!< ADC0 clock enable */ #define RCU_APB2EN_ADC1EN BIT(10) /*!< ADC1 clock enable */ #define RCU_APB2EN_TIMER0EN BIT(11) /*!< TIMER0 clock enable */ #define RCU_APB2EN_SPI0EN BIT(12) /*!< SPI0 clock enable */ #define RCU_APB2EN_TIMER7EN BIT(13) /*!< TIMER7 clock enable */ #define RCU_APB2EN_USART0EN BIT(14) /*!< USART0 clock enable */ #if defined(GD32E50X_XD) || defined(GD32E50X_HD) || defined(GD32EPRT) #define RCU_APB2EN_ADC2EN BIT(15) /*!< ADC2 clock enable */ #endif /* GD32E50X_XD and GD32E50X_HDand GD32EPRT */ #ifndef GD32EPRT #define RCU_APB2EN_TIMER8EN BIT(19) /*!< TIMER8 clock enable */ #define RCU_APB2EN_TIMER9EN BIT(20) /*!< TIMER9 clock enable */ #define RCU_APB2EN_TIMER10EN BIT(21) /*!< TIMER10 clock enable */ #endif /* GD32EPRT */ #define RCU_APB2EN_USART5EN BIT(28) /*!< USART5 clock enable */ #ifndef GD32EPRT #define RCU_APB2EN_SHRTIMEREN BIT(29) /*!< SHRTIMER clock enable */ #endif /* GD32EPRT */ #if defined(GD32E50X_CL) || defined(GD32E508) #define RCU_APB2EN_CMPEN BIT(31) /*!< CMP clock enable */ #endif /* GD32E50X_CL and GD32E508 */ /* RCU_APB1EN */ #define RCU_APB1EN_TIMER1EN BIT(0) /*!< TIMER1 clock enable */ #define RCU_APB1EN_TIMER2EN BIT(1) /*!< TIMER2 clock enable */ #define RCU_APB1EN_TIMER3EN BIT(2) /*!< TIMER3 clock enable */ #define RCU_APB1EN_TIMER4EN BIT(3) /*!< TIMER4 clock enable */ #define RCU_APB1EN_TIMER5EN BIT(4) /*!< TIMER5 clock enable */ #define RCU_APB1EN_TIMER6EN BIT(5) /*!< TIMER6 clock enable */ #ifndef GD32EPRT #define RCU_APB1EN_TIMER11EN BIT(6) /*!< TIMER11 clock enable */ #define RCU_APB1EN_TIMER12EN BIT(7) /*!< TIMER12 clock enable */ #define RCU_APB1EN_TIMER13EN BIT(8) /*!< TIMER13 clock enable */ #endif /* GD32EPRT */ #define RCU_APB1EN_WWDGTEN BIT(11) /*!< WWDGT clock enable */ #define RCU_APB1EN_SPI1EN BIT(14) /*!< SPI1 clock enable */ #define RCU_APB1EN_SPI2EN BIT(15) /*!< SPI2 clock enable */ #define RCU_APB1EN_USART1EN BIT(17) /*!< USART1 clock enable */ #define RCU_APB1EN_USART2EN BIT(18) /*!< USART2 clock enable */ #define RCU_APB1EN_UART3EN BIT(19) /*!< UART3 clock enable */ #define RCU_APB1EN_UART4EN BIT(20) /*!< UART4 clock enable */ #define RCU_APB1EN_I2C0EN BIT(21) /*!< I2C0 clock enable */ #define RCU_APB1EN_I2C1EN BIT(22) /*!< I2C1 clock enable */ #if (defined(GD32E50X_HD) || defined(GD32E50X_XD) || defined(GD32EPRT)) #define RCU_APB1EN_USBDEN BIT(23) /*!< USBD clock enable */ #endif /* GD32E50X_HD and GD32E50X_XD and GD32EPRT */ #define RCU_APB1EN_I2C2EN BIT(24) /*!< I2C2 clock enable */ #ifndef GD32EPRT #define RCU_APB1EN_CAN0EN BIT(25) /*!< CAN0 clock enable */ #define RCU_APB1EN_CAN1EN BIT(26) /*!< CAN1 clock enable */ #endif /* GD32EPRT */ #define RCU_APB1EN_BKPIEN BIT(27) /*!< backup interface clock enable */ #define RCU_APB1EN_PMUEN BIT(28) /*!< PMU clock enable */ #define RCU_APB1EN_DACEN BIT(29) /*!< DAC clock enable */ /* RCU_BDCTL */ #define RCU_BDCTL_LXTALEN BIT(0) /*!< LXTAL enable */ #define RCU_BDCTL_LXTALSTB BIT(1) /*!< low speed crystal oscillator stabilization flag */ #define RCU_BDCTL_LXTALBPS BIT(2) /*!< LXTAL bypass mode enable */ #define RCU_BDCTL_LXTALDRI BITS(3,4) /*!< LXTAL drive capability */ #define RCU_BDCTL_RTCSRC BITS(8,9) /*!< RTC clock entry selection */ #define RCU_BDCTL_RTCEN BIT(15) /*!< RTC clock enable */ #define RCU_BDCTL_BKPRST BIT(16) /*!< backup domain reset */ /* RCU_RSTSCK */ #define RCU_RSTSCK_IRC40KEN BIT(0) /*!< IRC40K enable */ #define RCU_RSTSCK_IRC40KSTB BIT(1) /*!< IRC40K stabilization flag */ #define RCU_RSTSCK_RSTFC BIT(24) /*!< reset flag clear */ #define RCU_RSTSCK_BORRSTF BIT(25) /*!< BOR reset flag */ #define RCU_RSTSCK_EPRSTF BIT(26) /*!< external pin reset flag */ #define RCU_RSTSCK_PORRSTF BIT(27) /*!< power reset flag */ #define RCU_RSTSCK_SWRSTF BIT(28) /*!< software reset flag */ #define RCU_RSTSCK_FWDGTRSTF BIT(29) /*!< free watchdog timer reset flag */ #define RCU_RSTSCK_WWDGTRSTF BIT(30) /*!< window watchdog timer reset flag */ #define RCU_RSTSCK_LPRSTF BIT(31) /*!< low-power reset flag */ #if defined(GD32E50X_CL) || defined(GD32E508) /* RCU_AHBRST */ #define RCU_AHBRST_USBHSRST BIT(12) /*!< USBHS reset */ #define RCU_AHBRST_TMURST BIT(30) /*!< TMU reset */ #endif /* GD32E50X_CL and GD32E508 */ #if (defined(GD32E50X_CL) || defined(GD32EPRT) || defined(GD32E508)) #define RCU_AHBRST_ENETRST BIT(14) /*!< ENET reset */ #endif /* GD32E50X_CL and GD32EPRT and GD32E508 */ #define RCU_AHBRST_SQPIRST BIT(31) /*!< SQPI reset */ /* RCU_CFG1 */ #define RCU_CFG1_PREDV0 BITS(0,3) /*!< PREDV0 division factor */ #define RCU_CFG1_PREDV1 BITS(4,7) /*!< PREDV1 division factor */ #define RCU_CFG1_PLL1MF BITS(8,11) /*!< PLL1 clock multiplication factor */ #define RCU_CFG1_PLL2MF BITS(12,15) /*!< PLL2 clock multiplication factor */ #define RCU_CFG1_PREDV0SEL BIT(16) /*!< PREDV0 input clock source selection */ #if defined(GD32E50X_CL) || defined(GD32EPRT) || defined(GD32E508) #define RCU_CFG1_I2S1SEL BIT(17) /*!< I2S1 clock source selection */ #define RCU_CFG1_I2S2SEL BIT(18) /*!< I2S2 clock source selection */ #define RCU_CFG1_PLL2MF_5 BIT(28) /*!< bit 6 of PLL2MF */ #define RCU_CFG1_PLL2MF_4 BIT(31) /*!< bit 5 of PLL2MF */ #endif /* GD32E50X_CL and GD32EPRT and GD32E508 */ #ifndef GD32EPRT #define RCU_CFG1_SHRTIMERSEL BIT(19) /*!< SHRTIMER clock source selection */ #endif /* GD32EPRT */ #define RCU_CFG1_ADCPSC_3 BIT(29) /*!< bit 4 of ADCPSC */ #define RCU_CFG1_PLLPRESEL BIT(30) /*!< PLL clock source selection */ /* RCU_DSV */ #define RCU_DSV_DSLPVS BITS(0,2) /*!< deep-sleep mode voltage select */ /* RCU_ADDCTL */ #define RCU_ADDCTL_CK48MSEL BITS(0,1) /*!< 48MHz clock selection */ #if defined(GD32E50X_CL) || defined(GD32E508) #define RCU_ADDCTL_USBHSSEL BIT(2) /*!< USBHS clock selection */ #define RCU_ADDCTL_USBHSDV BITS(3,5) /*!< USBHS clock divider factor */ #define RCU_ADDCTL_USBSWEN BIT(6) /*!< USB clock source selection enable */ #define RCU_ADDCTL_PLLUSBEN BIT(14) /*!< PLLUSB enable */ #define RCU_ADDCTL_PLLUSBSTB BIT(15) /*!< PLLUSB clock stabilization flag */ #endif /* GD32E50X_CL and GD32E508 */ #define RCU_ADDCTL_IRC48MEN BIT(16) /*!< internal 48MHz RC oscillator enable */ #define RCU_ADDCTL_IRC48MSTB BIT(17) /*!< internal 48MHz RC oscillator clock stabilization flag */ #define RCU_ADDCTL_IRC48MCAL BITS(24,31) /*!< internal 48MHz RC oscillator calibration value register */ /* RCU_ADDCFG */ #if defined(GD32E50X_CL) || defined(GD32E508) #define RCU_ADDCFG_PLLUSBPREDV BITS(0,3) /*!< PLLUSBPREDV division factor */ #define RCU_ADDCFG_PLLUSBPRESEL BIT(16) /*!< PLLUSB clock source preselection */ #define RCU_ADDCFG_PLLUSBPREDVSEL BIT(17) /*!< PLLUSBPREDV input Clock Source Selection */ #define RCU_ADDCFG_PLLUSBMF BITS(18,24) /*!< The PLLUSB clock multiplication factor */ #endif /* GD32E50X_CL and GD32E508 */ /* RCU_ADDINT */ #define RCU_ADDINT_IRC48MSTBIF BIT(6) /*!< IRC48M stabilization interrupt flag */ #define RCU_ADDINT_IRC48MSTBIE BIT(14) /*!< internal 48 MHz RC oscillator stabilization interrupt enable */ #define RCU_ADDINT_IRC48MSTBIC BIT(22) /*!< internal 48 MHz RC oscillator stabilization interrupt clear */ #if defined(GD32E50X_CL) || defined(GD32E508) #define RCU_ADDINT_PLLUSBSTBIF BIT(7) /*!< PLLUSB stabilization interrupt flag */ #define RCU_ADDINT_PLLUSBSTBIE BIT(15) /*!< PLLUSB stabilization interrupt enable */ #define RCU_ADDINT_PLLUSBSTBIC BIT(23) /*!< PLLUSB stabilization interrupt clear */ #endif /* GD32E50X_CL and GD32E508 */ /* RCU_PLLSSCTL */ #define RCU_PLLSSCTL_MODCNT BITS(0,12) /*!< these bits configure PLL spread spectrum modulation profile amplitude and frequency. the following criteria must be met: MODSTEP*MODCNT=215-1 */ #define RCU_PLLSSCTL_MODSTEP BITS(13,27) /*!< these bits configure PLL spread spectrum modulation profile amplitude and frequency. the following criteria must be met: MODSTEP*MODCNT=215-1 */ #define RCU_PLLSSCTL_SS_TYPE BIT(30) /*!< PLL spread spectrum modulation type select */ #define RCU_PLLSSCTL_SSCGON BIT(31) /*!< PLL spread spectrum modulation enable */ /* RCU_CFG2 */ #define RCU_CFG2_USART5SEL BITS(0,1) /*!< USART5 Clock Source Selection */ #define RCU_CFG2_I2C2SEL BITS(4,5) /*!< I2C2 Clock Source Selection */ /* RCU_ADDAPB1RST */ #define RCU_ADDAPB1RST_CTCRST BIT(27) /*!< CTC reset */ #if defined(GD32E50X_CL) || defined(GD32E508) #define RCU_ADDAPB1RST_CAN2RST BIT(31) /*!< CAN2 reset */ #endif /* GD32E50X_CL and GD32E508 */ /* RCU_ADDAPB1EN */ #define RCU_ADDAPB1EN_CTCEN BIT(27) /*!< CTC clock enable */ #if defined(GD32E50X_CL) || defined(GD32E508) #define RCU_ADDAPB1EN_CAN2EN BIT(31) /*!< CAN2 clock enable */ #endif /* GD32E50X_CL and GD32E508 */ /* constants definitions */ /* define the peripheral clock enable bit position and its register index offset */ #define RCU_REGIDX_BIT(regidx, bitpos) (((uint32_t)(regidx) << 6) | (uint32_t)(bitpos)) #define RCU_REG_VAL(periph) (REG32(RCU + ((uint32_t)(periph) >> 6))) #define RCU_BIT_POS(val) ((uint32_t)(val) & 0x1FU) /* register offset */ /* peripherals enable */ #define AHBEN_REG_OFFSET 0x14U /*!< AHB enable register offset */ #define APB1EN_REG_OFFSET 0x1CU /*!< APB1 enable register offset */ #define APB2EN_REG_OFFSET 0x18U /*!< APB2 enable register offset */ #define ADD_APB1EN_REG_OFFSET 0xE4U /*!< APB1 additional enable register offset */ /* peripherals reset */ #define AHBRST_REG_OFFSET 0x28U /*!< AHB reset register offset */ #define APB1RST_REG_OFFSET 0x10U /*!< APB1 reset register offset */ #define APB2RST_REG_OFFSET 0x0CU /*!< APB2 reset register offset */ #define ADD_APB1RST_REG_OFFSET 0xE0U /*!< APB1 additional reset register offset */ #define RSTSCK_REG_OFFSET 0x24U /*!< reset source/clock register offset */ /* clock control */ #define CTL_REG_OFFSET 0x00U /*!< control register offset */ #define BDCTL_REG_OFFSET 0x20U /*!< backup domain control register offset */ #define ADDCTL_REG_OFFSET 0xC0U /*!< additional clock control register offset */ #define PLLSSCTL_REG_OFFSET 0xD0U /*!