1 /** 2 ****************************************************************************** 3 * @file bl602_clock.h 4 * @version V1.0 5 * @date 6 * @brief This file is the standard driver header file 7 ****************************************************************************** 8 * @attention 9 * 10 * <h2><center>© COPYRIGHT(c) 2020 Bouffalo Lab</center></h2> 11 * 12 * Redistribution and use in source and binary forms, with or without modification, 13 * are permitted provided that the following conditions are met: 14 * 1. Redistributions of source code must retain the above copyright notice, 15 * this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright notice, 17 * this list of conditions and the following disclaimer in the documentation 18 * and/or other materials provided with the distribution. 19 * 3. Neither the name of Bouffalo Lab nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 ****************************************************************************** 35 */ 36 #ifndef __BL602_CLOCK_H__ 37 #define __BL602_CLOCK_H__ 38 39 #include "glb_reg.h" 40 #include "bl602_hbn.h" 41 #include "bl602_common.h" 42 43 /** @addtogroup BL602_Peripheral_Driver 44 * @{ 45 */ 46 47 /** @addtogroup CLOCK 48 * @{ 49 */ 50 51 /** @defgroup CLOCK_Public_Types 52 * @{ 53 */ 54 55 /** 56 * @brief System clock type definition 57 */ 58 typedef enum { 59 BL_SYSTEM_CLOCK_ROOT, /*!< ROOT clock */ 60 BL_SYSTEM_CLOCK_FCLK, /*!< Fast clock/CPU clock */ 61 BL_SYSTEM_CLOCK_BCLK, /*!< BUS clock */ 62 BL_SYSTEM_CLOCK_F32K, /*!< F32K clock */ 63 BL_SYSTEM_CLOCK_XCLK, /*!< XCLK:RC32M or XTAL */ 64 BL_SYSTEM_CLOCK_XTAL, /*!< XTAL clock */ 65 BL_SYSTEM_CLOCK_MAX, /*!< MAX type of system clock */ 66 } BL_System_Clock_Type; 67 68 typedef enum { 69 BL_PERIPHERAL_CLOCK_UART0, /*!< UART0 clock */ 70 BL_PERIPHERAL_CLOCK_UART1, /*!< UART1 clock */ 71 BL_PERIPHERAL_CLOCK_SPI0, /*!< SPI0 clock */ 72 BL_PERIPHERAL_CLOCK_I2C0, /*!< I2C0 clock */ 73 BL_PERIPHERAL_CLOCK_GPADC, /*!< GPADC clock */ 74 BL_PERIPHERAL_CLOCK_GPDAC, /*!< GPDAC clock */ 75 BL_PERIPHERAL_CLOCK_PWM, /*!< PWM clock */ 76 BL_PERIPHERAL_CLOCK_IR, /*!< IR clock */ 77 BL_PERIPHERAL_CLOCK_FLASH, /*!< FLASH clock */ 78 BL_PERIPHERAL_CLOCK_MAX, 79 } BL_Peripheral_Type; 80 81 /** 82 * @brief SOC clock config type 83 */ 84 typedef struct 85 { 86 uint16_t systemClock[BL_SYSTEM_CLOCK_MAX]; /*!< System lock value */ 87 uint16_t peripheralClock[BL_AHB_SLAVE1_MAX]; /*!< Pewripherals clock value */ 88 uint32_t i2sClock; /*!< I2S clock */ 89 } Clock_Cfg_Type; 90 91 /*@} end of group CLOCK_Public_Types */ 92 93 /** @defgroup CLOCK_Public_Constants 94 * @{ 95 */ 96 97 /** @defgroup BL_SYSTEM_CLOCK_TYPE 98 * @{ 99 */ 100 #define IS_BL_SYSTEM_CLOCK_TYPE(type) (((type) == BL_SYSTEM_CLOCK_ROOT) || \ 101 ((type) == BL_SYSTEM_CLOCK_FCLK) || \ 102 ((type) == BL_SYSTEM_CLOCK_BCLK) || \ 103 ((type) == BL_SYSTEM_CLOCK_F32K) || \ 104 ((type) == BL_SYSTEM_CLOCK_XCLK) || \ 105 ((type) == BL_SYSTEM_CLOCK_XTAL) || \ 106 ((type) == BL_SYSTEM_CLOCK_MAX)) 107 108 /*@} end of group CLOCK_Public_Constants */ 109 110 /** @defgroup CLOCK_Public_Macros 111 * @{ 112 */ 113 114 /*@} end of group CLOCK_Public_Macros */ 115 116 /** @defgroup CLOCK_Public_Functions 117 * @{ 118 */ 119 uint32_t Clock_System_Clock_Get(BL_System_Clock_Type type); 120 uint32_t Clock_Peripheral_Clock_Get(BL_Peripheral_Type type); 121 122 /*@} end of group CLOCK_Public_Functions */ 123 124 /*@} end of group CLOCK */ 125 126 /*@} end of group BL602_Peripheral_Driver */ 127 128 #endif /* __BL602_CLOCK_H__ */ 129