1 /** 2 ****************************************************************************** 3 * @file bl702_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 __BL702_CLOCK_H__ 37 #define __BL702_CLOCK_H__ 38 39 #include "glb_reg.h" 40 #include "bl702_hbn.h" 41 #include "bl702_common.h" 42 43 /** @addtogroup BL702_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_I2S, /*!< I2S clock */ 74 BL_PERIPHERAL_CLOCK_GPADC, /*!< GPADC clock */ 75 BL_PERIPHERAL_CLOCK_GPDAC, /*!< GPDAC clock */ 76 BL_PERIPHERAL_CLOCK_PWM, /*!< PWM clock */ 77 BL_PERIPHERAL_CLOCK_IR, /*!< IR clock */ 78 BL_PERIPHERAL_CLOCK_FLASH, /*!< FLASH clock */ 79 BL_PERIPHERAL_CLOCK_CAM, /*!< CAM clock */ 80 BL_PERIPHERAL_CLOCK_QDEC, /*!< QDEC clock */ 81 BL_PERIPHERAL_CLOCK_TIMER0, /*!< TIMER0 clock */ 82 BL_PERIPHERAL_CLOCK_TIMER1, /*!< TIMER1 clock */ 83 BL_PERIPHERAL_CLOCK_WDT, /*!< WDT clock */ 84 BL_PERIPHERAL_CLOCK_MAX, 85 } BL_Peripheral_Type; 86 87 /** 88 * @brief SOC clock config type 89 */ 90 typedef struct 91 { 92 uint16_t systemClock[BL_SYSTEM_CLOCK_MAX]; /*!< System lock value */ 93 uint16_t peripheralClock[BL_AHB_SLAVE1_MAX]; /*!< Pewripherals clock value */ 94 uint32_t i2sClock; /*!< I2S clock */ 95 } Clock_Cfg_Type; 96 97 /*@} end of group CLOCK_Public_Types */ 98 99 /** @defgroup CLOCK_Public_Constants 100 * @{ 101 */ 102 103 /** @defgroup BL_SYSTEM_CLOCK_TYPE 104 * @{ 105 */ 106 #define IS_BL_SYSTEM_CLOCK_TYPE(type) (((type) == BL_SYSTEM_CLOCK_ROOT) || \ 107 ((type) == BL_SYSTEM_CLOCK_FCLK) || \ 108 ((type) == BL_SYSTEM_CLOCK_BCLK) || \ 109 ((type) == BL_SYSTEM_CLOCK_F32K) || \ 110 ((type) == BL_SYSTEM_CLOCK_XCLK) || \ 111 ((type) == BL_SYSTEM_CLOCK_XTAL) || \ 112 ((type) == BL_SYSTEM_CLOCK_MAX)) 113 114 /*@} end of group CLOCK_Public_Constants */ 115 116 /** @defgroup CLOCK_Public_Macros 117 * @{ 118 */ 119 120 /*@} end of group CLOCK_Public_Macros */ 121 122 /** @defgroup CLOCK_Public_Functions 123 * @{ 124 */ 125 uint32_t Clock_System_Clock_Get(BL_System_Clock_Type type); 126 uint32_t Clock_Peripheral_Clock_Get(BL_Peripheral_Type type); 127 128 /*@} end of group CLOCK_Public_Functions */ 129 130 /*@} end of group CLOCK */ 131 132 /*@} end of group BL702_Peripheral_Driver */ 133 134 #endif /* __BL702_CLOCK_H__ */ 135