/*! * @file apm32f0xx_rcm.h * * @brief This file contains all the functions prototypes for the RCM firmware library * * @version V1.0.2 * * @date 2022-02-21 * * @attention * * Copyright (C) 2020-2022 Geehy Semiconductor * * You may not use this file except in compliance with the * GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE). * * The program is only for reference, which is distributed in the hope * that it will be useful and instructional for customers to develop * their software. Unless required by applicable law or agreed to in * writing, the program is distributed on an "AS IS" BASIS, WITHOUT * ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied. * See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions * and limitations under the License. */ #ifndef __APM32F0XX_RCM_H #define __APM32F0XX_RCM_H #ifdef __cplusplus extern "C" { #endif #include "apm32f0xx.h" /** @addtogroup APM32F0xx_StdPeriphDriver @{ */ /** @addtogroup RCM_Driver RCM Driver @{ */ /** @defgroup RCM_Macros Macros @{ */ /**@} end of group RCM_Macros*/ /** @defgroup RCM_Enumerations Enumerations @{ */ /** * @brief HSE enum */ typedef enum { RCM_HSE_CLOSE = 0x00, /*!< turn OFF the HSE oscillator */ RCM_HSE_OPEN = 0x01, /*!< turn ON the HSE oscillator */ RCM_HSE_BYPASS = 0x05, /*!< HSE oscillator bypassed with external clock */ } RCM_HSE_T; /** * @brief LSE enum */ typedef enum { RCM_LSE_CLOSE = 0x00, /*!< turn OFF the LSE oscillator */ RCM_LSE_OPEN = 0x01, /*!< turn ON the LSE oscillator */ RCM_LSE_BYPASS = 0x05, /*!< LSE oscillator bypassed with external clock */ } RCM_LSE_T; /** * @brief LSE_Drive enum */ typedef enum { RCM_LSE_DRIVE_Low = 0x00, /*!< LSE oscillator low drive capability */ RCM_LSE_DRIVE_MediumLow, /*!< LSE oscillator medium low drive capability */ RCM_LSE_DRIVE_MediumHigh, /*!< LSE oscillator medium high drive capability */ RCM_LSE_DRIVE_High, /*!< LSE oscillator high drive capability */ } RCM_LSE_DRIVE_T; /** * @brief System clock select */ typedef enum { RCM_PLL_SEL_HSI_DIV2, /*!< HSI clock divided by 2 selected as PLL clock source */ RCM_PLL_SEL_HSI, /*!< HSI clock selected as PLL clock entry, only for APM32F072 and APM32F091 devices */ RCM_PLL_SEL_HSE, /*!< HSE/CLKDIV1 selected as PLL clock entry */ RCM_PLL_SEL_HSI48 /*!< HSI48 oscillator clock selected as PLL clock source, only for APM32F072 and APM32F091 devices */ } RCM_PLL_SEL_T; /** * @brief PLL multiplication factor */ typedef enum { RCM_PLLMF_2, /*!< specifies the PLLMULCFG clock multiple factor as 2 */ RCM_PLLMF_3, /*!< specifies the PLLMULCFG clock multiple factor as 3 */ RCM_PLLMF_4, /*!< specifies the PLLMULCFG clock multiple factor as 4 */ RCM_PLLMF_5, /*!< specifies the PLLMULCFG clock multiple factor as 5 */ RCM_PLLMF_6, /*!< specifies the PLLMULCFG clock multiple factor as 6 */ RCM_PLLMF_7, /*!< specifies the PLLMULCFG clock multiple factor as 7 */ RCM_PLLMF_8, /*!< specifies the PLLMULCFG clock multiple factor as 8 */ RCM_PLLMF_9, /*!< specifies the PLLMULCFG clock multiple factor as 9 */ RCM_PLLMF_10, /*!< specifies the PLLMULCFG clock multiple factor as 10 */ RCM_PLLMF_11, /*!< specifies the PLLMULCFG clock multiple factor as 11 */ RCM_PLLMF_12, /*!< specifies the PLLMULCFG clock multiple factor as 12 */ RCM_PLLMF_13, /*!< specifies the PLLMULCFG clock multiple factor as 13 */ RCM_PLLMF_14, /*!< specifies the PLLMULCFG clock multiple factor as 14 */ RCM_PLLMF_15, /*!< specifies the PLLMULCFG clock multiple factor as 15 */ RCM_PLLMF_16, /*!< specifies the PLLMULCFG clock multiple factor as 16 */ } RCM_PLLMF_T; /** * @brief RCM clock division */ typedef enum { RCM_CLK_DIV_1, /*!< specifies the PLLDIVCFG clock division factor as 1 */ RCM_CLK_DIV_2, /*!< specifies the PLLDIVCFG clock division factor as 2 */ RCM_CLK_DIV_3, /*!< specifies the PLLDIVCFG clock division factor as 3 */ RCM_CLK_DIV_4, /*!< specifies the PLLDIVCFG clock division factor as 4 */ RCM_CLK_DIV_5, /*!< specifies the PLLDIVCFG clock division factor as 5 */ RCM_CLK_DIV_6, /*!< specifies the PLLDIVCFG clock division factor as 6 */ RCM_CLK_DIV_7, /*!< specifies the PLLDIVCFG clock division factor as 7 */ RCM_CLK_DIV_8, /*!< specifies the PLLDIVCFG clock division factor as 8 */ RCM_CLK_DIV_9, /*!< specifies the PLLDIVCFG clock division factor as 9 */ RCM_CLK_DIV_10, /*!< specifies the PLLDIVCFG clock division factor as 10 */ RCM_CLK_DIV_11, /*!< specifies the PLLDIVCFG clock division factor as 11 */ RCM_CLK_DIV_12, /*!< specifies the PLLDIVCFG clock division factor as 12 */ RCM_CLK_DIV_13, /*!< specifies the PLLDIVCFG clock division factor as 13 */ RCM_CLK_DIV_14, /*!< specifies the PLLDIVCFG clock division factor as 14 */ RCM_CLK_DIV_15, /*!< specifies the PLLDIVCFG clock division factor as 15 */ RCM_CLK_DIV_16, /*!< specifies the PLLDIVCFG clock division factor as 16 */ } RCM_CLK_DIV_T; /** * @brief Clock output control */ typedef enum { RCM_COC_NO_CLOCK, /*!< No clock selected */ RCM_COC_HSI14, /*!< HSI14 oscillator clock selected */ RCM_COC_LSI, /*!< LSI oscillator clock selected */ RCM_COC_LSE, /*!< LSE oscillator clock selected */ RCM_COC_SYSCLK, /*!< System clock selected */ RCM_COC_HSI, /*!< HSI oscillator clock selected */ RCM_COC_HSE, /*!< HSE oscillator clock selected */ RCM_COC_PLLCLK_DIV_2, /*!< PLL clock divided by 2 selected */ RCM_COC_HSI48, /*!< HSI48 oscillator clock selected, only for APM32F072 and APM32F091 devices */ RCM_COC_PLLCLK /*!< PLL clock selected */ } RCM_COCCLK_T; /** * @brief Clock output division */ typedef enum { RCM_COC_DIV_1, /*!< MCOSEL clock is divided by 1 */ RCM_COC_DIV_2, /*!< MCOSEL clock is divided by 2 */ RCM_COC_DIV_4, /*!< MCOSEL clock is divided by 4 */ RCM_COC_DIV_8, /*!< MCOSEL clock is divided by 8 */ RCM_COC_DIV_16, /*!< MCOSEL clock is divided by 16 */ RCM_COC_DIV_32, /*!< MCOSEL clock is divided by 32 */ RCM_COC_DIV_64, /*!< MCOSEL clock is divided by 64 */ RCM_COC_DIV_128, /*!< MCOSEL clock is divided by 128 */ } RCM_COCPRE_T; /** * @brief System clock select */ typedef enum { RCM_SYSCLK_SEL_HSI, /*!< HSI selected as system clock source */ RCM_SYSCLK_SEL_HSE, /*!< HSE selected as system clock source */ RCM_SYSCLK_SEL_PLL, /*!< PLL selected as system clock source */ RCM_SYSCLK_SEL_HSI48, /*!< HSI48 selected as system clock source, only for APM32F072 and APM32F091 devices */ } RCM_SYSCLK_SEL_T; /** * @brief AHB divider Number */ typedef enum { RCM_SYSCLK_DIV_1 = 7, /*!< AHB clock = SYSCLK */ RCM_SYSCLK_DIV_2, /*!< AHB clock = SYSCLK/2 */ RCM_SYSCLK_DIV_4, /*!< AHB clock = SYSCLK/4 */ RCM_SYSCLK_DIV_8, /*!< AHB clock = SYSCLK/8 */ RCM_SYSCLK_DIV_16, /*!< AHB clock = SYSCLK/16 */ RCM_SYSCLK_DIV_64, /*!< AHB clock = SYSCLK/64 */ RCM_SYSCLK_DIV_128, /*!< AHB clock = SYSCLK/128 */ RCM_SYSCLK_DIV_256, /*!< AHB clock = SYSCLK/256 */ RCM_SYSCLK_DIV_512, /*!< AHB clock = SYSCLK/512 */ } RCM_AHBDIV_T; /** * @brief APB divider Number */ typedef enum { RCM_HCLK_DIV_1 = 3, /*!< APB clock = HCLK */ RCM_HCLK_DIV_2, /*!< APB clock = HCLK/2 */ RCM_HCLK_DIV_4, /*!< APB clock = HCLK/4 */ RCM_HCLK_DIV_8, /*!< APB clock = HCLK/8 */ RCM_HCLK_DIV_16 /*!< APB clock = HCLK/16 */ } RCM_APBDIV_T; /** * @brief CEC divider Number */ typedef enum { RCM_CECCLK_HSI_DIV_224, /*!< CEC clock = HSI/244 (32768Hz) */ RCM_CECCLK_LSI_DIV, /*!< CEC clock = LSI */ } RCM_CECCLK_T; /** * @brief I2C clock source selectio */ typedef enum { RCM_I2C1CLK_HSI, /*!< I2C1 clock = HSI */ RCM_I2C1CLK_SYSCLK, /*!< I2C1 clock = System Clock */ } RCM_I2CCLK_T; /** * @brief USART clock source selectio */ typedef enum { RCM_USART1CLK_PCLK = ((uint32_t)0x00010000), /*!< USART1 clock = APB Clock (PCLK) */ RCM_USART1CLK_SYSCLK = ((uint32_t)0x00010001), /*!< USART1 clock = System Clock */ RCM_USART1CLK_LSE = ((uint32_t)0x00010002), /*!< USART1 clock = LSE Clock */ RCM_USART1CLK_HSI = ((uint32_t)0x00010003), /*!< USART1 clock = HSI Clock */ RCM_USART2CLK_PCLK = ((uint32_t)0x00020000), /*!< USART2 clock = APB Clock (PCLK), only for APM32F072 and APM32F091 devices */ RCM_USART2CLK_SYSCLK = ((uint32_t)0x00020001), /*!< USART2 clock = System Clock, only for APM32F072 and APM32F091 devices */ RCM_USART2CLK_LSE = ((uint32_t)0x00020002), /*!< USART2 clock = LSE Clock, only for APM32F072 and APM32F091 devices */ RCM_USART2CLK_HSI = ((uint32_t)0x00020003), /*!< USART2 clock = HSI Clock, only for APM32F072 and APM32F091 devices */ RCM_USART3CLK_PCLK = ((uint32_t)0x00040000), /*!< USART3 clock = APB Clock (PCLK), only for APM32F091 devices */ RCM_USART3CLK_SYSCLK = ((uint32_t)0x00040001), /*!< USART3 clock = System Clock, only for APM32F091 devices */ RCM_USART3CLK_LSE = ((uint32_t)0x00040002), /*!< USART3 clock = LSE Clock, only for APM32F091 devices */ RCM_USART3CLK_HSI = ((uint32_t)0x00040003), /*!< USART3 clock = HSI Clock, only for APM32F091 devices */ } RCM_USARTCLK_T; /** * @brief USB clock source selection */ typedef enum { RCM_USBCLK_HSI48, /*!