2022-03-25 18:41:25 +08:00
/*
2025-03-04 16:53:52 +08:00
* SPDX - FileCopyrightText : 2022 - 2025 Espressif Systems ( Shanghai ) CO LTD
2022-03-25 18:41:25 +08:00
*
* SPDX - License - Identifier : Apache - 2.0
*/
# pragma once
# ifdef __cplusplus
extern " C " {
# endif
2022-04-24 15:12:14 +08:00
/*
2022-03-25 18:41:25 +08:00
* * * * * * * * * * * * * * * * * * * * * * * * * ESP32 Root Clock Source * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 1 ) Internal 8 MHz RC Oscillator : RC_FAST ( usually referred as FOSC or CK8M / CLK8M in TRM and reg . description )
*
* This RC oscillator generates a ~ 8.5 MHz clock signal output as the RC_FAST_CLK .
* The ~ 8.5 MHz signal output is also passed into a configurable divider , which by default divides the input clock
* frequency by 256 , to generate a RC_FAST_D256_CLK ( usually referred as 8 md256 or simply d256 in reg . description ) .
*
* The exact frequency of RC_FAST_CLK can be computed in runtime through calibration on the RC_FAST_D256_CLK .
*
* 2 ) External 2 ~ 40 MHz Crystal Clock : XTAL
*
2024-08-06 21:55:21 +08:00
* 3 ) Internal 150 kHz RC Oscillator : RC_SLOW ( usually referred as RTC in TRM or reg . description )
2022-03-25 18:41:25 +08:00
*
* This RC oscillator generates a ~ 150 kHz clock signal output as the RC_SLOW_CLK . The exact frequency of this clock
* can be computed in runtime through calibration .
*
* 4 ) External 32 kHz Crystal Clock ( optional ) : XTAL32K
*
* The clock source for this XTAL32K_CLK can be either a 32 kHz crystal connecting to the 32 K_XP and 32 K_XN pins
* or a 32 kHz clock signal generated by an external circuit . The external signal must be connected to the 32 K_XN pin .
* Additionally , a 1 nF capacitor must be placed between the 32 K_XP pin and ground . In this case , the 32 K_XP pin
* cannot be used as a GPIO pin .
*
* XTAL32K_CLK can also be calibrated to get its exact frequency .
*/
/* With the default value of CK8M_DFREQ = 172, RC_FAST clock frequency is 8.5 MHz +/- 7% */
2022-05-13 11:43:42 +08:00
# define SOC_CLK_RC_FAST_FREQ_APPROX 8500000 /*!< Approximate RC_FAST_CLK frequency in Hz */
2022-04-21 18:24:03 +08:00
/* With the default value of DCAP, range is +/- 5% */
2022-05-13 11:43:42 +08:00
# define SOC_CLK_RC_SLOW_FREQ_APPROX 150000 /*!< Approximate RC_SLOW_CLK frequency in Hz */
# define SOC_CLK_RC_FAST_D256_FREQ_APPROX (SOC_CLK_RC_FAST_FREQ_APPROX / 256) /*!< Approximate RC_FAST_D256_CLK frequency in Hz */
# define SOC_CLK_XTAL32K_FREQ_APPROX 32768 /*!< Approximate XTAL32K_CLK frequency in Hz */
2022-03-25 18:41:25 +08:00
2022-05-13 11:43:42 +08:00
// Naming convention: SOC_ROOT_CLK_{loc}_{type}_[attr]
// {loc}: EXT, INT
// {type}: XTAL, RC
// [attr] - optional: [frequency], FAST, SLOW
2022-03-25 18:41:25 +08:00
/**
* @ brief Root clock
*/
typedef enum {
SOC_ROOT_CLK_INT_RC_FAST , /*!< Internal 8MHz RC oscillator */
SOC_ROOT_CLK_INT_RC_SLOW , /*!< Internal 150kHz RC oscillator */
SOC_ROOT_CLK_EXT_XTAL , /*!< External 2~40MHz crystal */
SOC_ROOT_CLK_EXT_XTAL32K , /*!< External 32kHz crystal/clock signal */
} soc_root_clk_t ;
2025-03-04 16:53:52 +08:00
/**
* @ brief ROOT clock circuit , which requires explicitly enabling the targeting circuit to use
*/
typedef enum {
SOC_ROOT_CIRCUIT_CLK_BBPLL , /*!< BBPLL_CLK is the output of the BBPLL generator circuit */
SOC_ROOT_CIRCUIT_CLK_APLL , /*!< APLL_CLK is the output of the APLL generator circuit */
} soc_root_clk_circuit_t ;
2022-03-25 18:41:25 +08:00
/**
* @ brief CPU_CLK mux inputs , which are the supported clock sources for the CPU_CLK
2022-04-21 18:24:03 +08:00
* @ note Enum values are matched with the register field values on purpose
2022-03-25 18:41:25 +08:00
*/
typedef enum {
2022-04-21 18:24:03 +08:00
SOC_CPU_CLK_SRC_XTAL = 0 , /*!< Select XTAL_CLK as CPU_CLK source */
SOC_CPU_CLK_SRC_PLL = 1 , /*!< Select PLL_CLK as CPU_CLK source (PLL_CLK is the output of 40MHz crystal oscillator frequency multiplier, can be 480MHz or 320MHz) */
SOC_CPU_CLK_SRC_RC_FAST = 2 , /*!< Select RC_FAST_CLK as CPU_CLK source */
SOC_CPU_CLK_SRC_APLL = 3 , /*!< Select APLL_CLK as CPU_CLK source */
2022-05-27 02:23:17 +08:00
SOC_CPU_CLK_SRC_INVALID , /*!< Invalid CPU_CLK source */
2022-03-25 18:41:25 +08:00
} soc_cpu_clk_src_t ;
/**
* @ brief RTC_SLOW_CLK mux inputs , which are the supported clock sources for the RTC_SLOW_CLK
2022-04-21 18:24:03 +08:00
* @ note Enum values are matched with the register field values on purpose
2022-03-25 18:41:25 +08:00
*/
typedef enum {
2022-04-21 18:24:03 +08:00
SOC_RTC_SLOW_CLK_SRC_RC_SLOW = 0 , /*!< Select RC_SLOW_CLK as RTC_SLOW_CLK source */
SOC_RTC_SLOW_CLK_SRC_XTAL32K = 1 , /*!< Select XTAL32K_CLK as RTC_SLOW_CLK source */
SOC_RTC_SLOW_CLK_SRC_RC_FAST_D256 = 2 , /*!< Select RC_FAST_D256_CLK (referred as FOSC_DIV or 8m_d256/8md256 in TRM and reg. description) as RTC_SLOW_CLK source */
2022-05-27 02:23:17 +08:00
SOC_RTC_SLOW_CLK_SRC_INVALID , /*!< Invalid RTC_SLOW_CLK source */
2025-06-25 17:30:46 +08:00
SOC_RTC_SLOW_CLK_SRC_DEFAULT = SOC_RTC_SLOW_CLK_SRC_RC_SLOW , /*!< RC_SLOW_CLK is the default clock source for RTC_SLOW_CLK */
2022-03-25 18:41:25 +08:00
} soc_rtc_slow_clk_src_t ;
/**
* @ brief RTC_FAST_CLK mux inputs , which are the supported clock sources for the RTC_FAST_CLK
2022-04-21 18:24:03 +08:00
* @ note Enum values are matched with the register field values on purpose
2022-03-25 18:41:25 +08:00
*/
typedef enum {
2022-04-21 18:24:03 +08:00
SOC_RTC_FAST_CLK_SRC_XTAL_D4 = 0 , /*!< Select XTAL_D4_CLK (may referred as XTAL_CLK_DIV_4) as RTC_FAST_CLK source */
SOC_RTC_FAST_CLK_SRC_RC_FAST = 1 , /*!< Select RC_FAST_CLK as RTC_FAST_CLK source */
2022-05-27 02:23:17 +08:00
SOC_RTC_FAST_CLK_SRC_INVALID , /*!< Invalid RTC_FAST_CLK source */
2024-08-06 21:55:21 +08:00
SOC_RTC_FAST_CLK_SRC_DEFAULT = SOC_RTC_FAST_CLK_SRC_XTAL_D4 , /*!< XTAL_D4_CLK is the default clock source for RTC_FAST_CLK */
SOC_RTC_FAST_CLK_SRC_XTAL_DIV __attribute__ ( ( deprecated ) ) = SOC_RTC_FAST_CLK_SRC_XTAL_D4 , /*!< Alias name for `SOC_RTC_FAST_CLK_SRC_XTAL_D4` */
2022-03-25 18:41:25 +08:00
} soc_rtc_fast_clk_src_t ;
2024-01-03 15:28:29 +08:00
/**
* @ brief Possible main XTAL frequency options on the target
* @ note Enum values equal to the frequency value in MHz
* @ note Not all frequency values listed here are supported in IDF . Please check SOC_XTAL_SUPPORT_XXX in soc_caps . h for
* the supported ones .
*/
typedef enum {
SOC_XTAL_FREQ_AUTO = 0 , /*!< Automatic XTAL frequency detention */
SOC_XTAL_FREQ_24M = 24 , /*!< 24MHz XTAL */
SOC_XTAL_FREQ_26M = 26 , /*!< 26MHz XTAL */
SOC_XTAL_FREQ_40M = 40 , /*!< 40MHz XTAL */
} soc_xtal_freq_t ;
2022-05-13 11:43:42 +08:00
// Naming convention: SOC_MOD_CLK_{[upstream]clock_name}_[attr]
// {[upstream]clock_name}: APB, APLL, (BB)PLL, etc.
// [attr] - optional: FAST, SLOW, D<divider>, F<freq>
2022-03-25 18:41:25 +08:00
/**
2022-04-21 18:24:03 +08:00
* @ brief Supported clock sources for modules ( CPU , peripherals , RTC , etc . )
2022-05-13 11:43:42 +08:00
*
2022-04-13 13:12:30 +08:00
* @ note enum starts from 1 , to save 0 for special purpose
2022-03-25 18:41:25 +08:00
*/
typedef enum {
// For CPU domain
2022-05-13 11:43:42 +08:00
SOC_MOD_CLK_CPU = 1 , /*!< CPU_CLK can be sourced from XTAL, PLL, RC_FAST, or APLL by configuring soc_cpu_clk_src_t */
2022-03-25 18:41:25 +08:00
// For RTC domain
2022-05-13 11:43:42 +08:00
SOC_MOD_CLK_RTC_FAST , /*!< RTC_FAST_CLK can be sourced from XTAL_D4 or RC_FAST by configuring soc_rtc_fast_clk_src_t */
SOC_MOD_CLK_RTC_SLOW , /*!< RTC_SLOW_CLK can be sourced from RC_SLOW, XTAL32K, or RC_FAST_D256 by configuring soc_rtc_slow_clk_src_t */
2022-03-25 18:41:25 +08:00
// For digital domain: peripherals, WIFI, BLE
2022-05-13 11:43:42 +08:00
SOC_MOD_CLK_APB , /*!< APB_CLK is highly dependent on the CPU_CLK source */
SOC_MOD_CLK_PLL_D2 , /*!< PLL_D2_CLK is derived from PLL, it has a fixed divider of 2 */
2022-10-09 11:17:45 +08:00
SOC_MOD_CLK_PLL_F160M , /*!< PLL_F160M_CLK is derived from PLL, and has a fixed frequency of 160MHz */
2022-05-13 11:43:42 +08:00
SOC_MOD_CLK_XTAL32K , /*!< XTAL32K_CLK comes from the external 32kHz crystal, passing a clock gating to the peripherals */
SOC_MOD_CLK_RC_FAST , /*!< RC_FAST_CLK comes from the internal 8MHz rc oscillator, passing a clock gating to the peripherals */
SOC_MOD_CLK_RC_FAST_D256 , /*!< RC_FAST_D256_CLK comes from the internal 8MHz rc oscillator, divided by 256, and passing a clock gating to the peripherals */
SOC_MOD_CLK_XTAL , /*!< XTAL_CLK comes from the external crystal (2~40MHz) */
SOC_MOD_CLK_REF_TICK , /*!< REF_TICK is derived from APB, it has a fixed frequency of 1MHz even when APB frequency changes */
SOC_MOD_CLK_APLL , /*!< APLL is sourced from PLL, and its frequency is configurable through APLL configuration registers */
2022-12-28 15:04:51 +08:00
SOC_MOD_CLK_INVALID , /*!< Indication of the end of the available module clock sources */
2022-03-25 18:41:25 +08:00
} soc_module_clk_t ;
2022-11-17 21:29:16 +08:00
//////////////////////////////////////////////////SYSTIMER///////////////////////////////////////////////////////////////
/**
* @ brief Type of SYSTIMER clock source
*/
typedef enum {
SYSTIMER_CLK_SRC_XTAL = SOC_MOD_CLK_XTAL , /*!< SYSTIMER source clock is XTAL */
SYSTIMER_CLK_SRC_DEFAULT = SOC_MOD_CLK_XTAL , /*!< SYSTIMER source clock default choice is XTAL */
} soc_periph_systimer_clk_src_t ;
2022-03-25 18:41:25 +08:00
2022-04-13 13:12:30 +08:00
//////////////////////////////////////////////////GPTimer///////////////////////////////////////////////////////////////
2022-03-25 18:41:25 +08:00
2022-04-13 13:12:30 +08:00
/**
* @ brief Array initializer for all supported clock sources of GPTimer
2022-05-13 11:43:42 +08:00
*
2022-04-13 13:12:30 +08:00
* The following code can be used to iterate all possible clocks :
* @ code { c }
* soc_periph_gptimer_clk_src_t gptimer_clks [ ] = ( soc_periph_gptimer_clk_src_t ) SOC_GPTIMER_CLKS ;
* for ( size_t i = 0 ; i < sizeof ( gptimer_clks ) / sizeof ( gptimer_clks [ 0 ] ) ; i + + ) {
* soc_periph_gptimer_clk_src_t clk = gptimer_clks [ i ] ;
* // Test GPTimer with the clock `clk`
* }
* @ endcode
*/
# define SOC_GPTIMER_CLKS {SOC_MOD_CLK_APB}
/**
* @ brief Type of GPTimer clock source
*/
2022-03-25 18:41:25 +08:00
typedef enum {
2022-04-13 13:12:30 +08:00
GPTIMER_CLK_SRC_APB = SOC_MOD_CLK_APB , /*!< Select APB as the source clock */
GPTIMER_CLK_SRC_DEFAULT = SOC_MOD_CLK_APB , /*!< Select APB as the default choice */
2022-03-25 18:41:25 +08:00
} soc_periph_gptimer_clk_src_t ;
2022-04-13 13:12:30 +08:00
/**
* @ brief Type of Timer Group clock source , reserved for the legacy timer group driver
*/
typedef enum {
TIMER_SRC_CLK_APB = SOC_MOD_CLK_APB , /*!< Timer group source clock is APB */
TIMER_SRC_CLK_DEFAULT = SOC_MOD_CLK_APB , /*!< Timer group source clock default choice is APB */
} soc_periph_tg_clk_src_legacy_t ;
//////////////////////////////////////////////////LCD///////////////////////////////////////////////////////////////////
/**
* @ brief Array initializer for all supported clock sources of LCD
*/
2023-02-09 12:03:39 +08:00
# define SOC_LCD_CLKS {SOC_MOD_CLK_PLL_F160M}
2022-04-13 13:12:30 +08:00
/**
* @ brief Type of LCD clock source
*/
2022-03-25 18:41:25 +08:00
typedef enum {
2023-02-09 12:03:39 +08:00
LCD_CLK_SRC_PLL160M = SOC_MOD_CLK_PLL_F160M , /*!< Select PLL_160M as the source clock */
LCD_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_F160M , /*!< Select PLL_160M as the default choice */
2022-03-25 18:41:25 +08:00
} soc_periph_lcd_clk_src_t ;
2022-04-13 13:12:30 +08:00
//////////////////////////////////////////////////RMT///////////////////////////////////////////////////////////////////
/**
* @ brief Array initializer for all supported clock sources of RMT
*/
2022-04-21 18:24:03 +08:00
# define SOC_RMT_CLKS {SOC_MOD_CLK_APB, SOC_MOD_CLK_REF_TICK}
2022-04-13 13:12:30 +08:00
/**
* @ brief Type of RMT clock source
*/
2022-03-25 18:41:25 +08:00
typedef enum {
2022-04-21 18:24:03 +08:00
RMT_CLK_SRC_APB = SOC_MOD_CLK_APB , /*!< Select APB as the source clock */
RMT_CLK_SRC_REF_TICK = SOC_MOD_CLK_REF_TICK , /*!< Select REF_TICK as the source clock */
RMT_CLK_SRC_DEFAULT = SOC_MOD_CLK_APB , /*!< Select APB as the default choice */
2022-03-25 18:41:25 +08:00
} soc_periph_rmt_clk_src_t ;
2022-04-13 13:12:30 +08:00
/**
* @ brief Type of RMT clock source , reserved for the legacy RMT driver
*/
typedef enum {
2022-04-21 18:24:03 +08:00
RMT_BASECLK_APB = SOC_MOD_CLK_APB , /*!< RMT source clock is APB CLK */
RMT_BASECLK_REF = SOC_MOD_CLK_REF_TICK , /*!< RMT source clock is REF_TICK */
RMT_BASECLK_DEFAULT = SOC_MOD_CLK_APB , /*!< RMT source clock default choice is APB */
2022-04-13 13:12:30 +08:00
} soc_periph_rmt_clk_src_legacy_t ;
2022-04-29 12:10:05 +08:00
///////////////////////////////////////////////////UART/////////////////////////////////////////////////////////////////
2024-01-24 22:29:13 +08:00
/**
* @ brief Array initializer for all supported clock sources of UART
*/
# define SOC_UART_CLKS {SOC_MOD_CLK_APB, SOC_MOD_CLK_REF_TICK}
2022-04-29 12:10:05 +08:00
/**
* @ brief Type of UART clock source , reserved for the legacy UART driver
*/
typedef enum {
2022-04-21 18:24:03 +08:00
UART_SCLK_APB = SOC_MOD_CLK_APB , /*!< UART source clock is APB CLK */
UART_SCLK_REF_TICK = SOC_MOD_CLK_REF_TICK , /*!< UART source clock is REF_TICK */
UART_SCLK_DEFAULT = SOC_MOD_CLK_APB , /*!< UART source clock default choice is APB */
2022-04-29 12:10:05 +08:00
} soc_periph_uart_clk_src_legacy_t ;
2022-05-28 16:59:59 +08:00
//////////////////////////////////////////////////MCPWM/////////////////////////////////////////////////////////////////
/**
* @ brief Array initializer for all supported clock sources of MCPWM Timer
*/
2022-10-09 11:17:45 +08:00
# define SOC_MCPWM_TIMER_CLKS {SOC_MOD_CLK_PLL_F160M}
2022-05-28 16:59:59 +08:00
/**
* @ brief Type of MCPWM timer clock source
*/
typedef enum {
2022-10-09 11:17:45 +08:00
MCPWM_TIMER_CLK_SRC_PLL160M = SOC_MOD_CLK_PLL_F160M , /*!< Select PLL_F160M as the source clock */
MCPWM_TIMER_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_F160M , /*!< Select PLL_F160M as the default clock choice */
2022-05-28 16:59:59 +08:00
} soc_periph_mcpwm_timer_clk_src_t ;
/**
* @ brief Array initializer for all supported clock sources of MCPWM Capture Timer
*/
# define SOC_MCPWM_CAPTURE_CLKS {SOC_MOD_CLK_APB}
/**
* @ brief Type of MCPWM capture clock source
*/
typedef enum {
MCPWM_CAPTURE_CLK_SRC_APB = SOC_MOD_CLK_APB , /*!< Select APB as the source clock */
2022-09-05 14:40:58 +08:00
MCPWM_CAPTURE_CLK_SRC_DEFAULT = SOC_MOD_CLK_APB , /*!< Select APB as the default clock choice */
2022-05-28 16:59:59 +08:00
} soc_periph_mcpwm_capture_clk_src_t ;
2023-08-14 14:10:50 +08:00
/**
* @ brief Array initializer for all supported clock sources of MCPWM Carrier
*/
# define SOC_MCPWM_CARRIER_CLKS {SOC_MOD_CLK_PLL_F160M}
/**
* @ brief Type of MCPWM carrier clock source
*/
typedef enum {
MCPWM_CARRIER_CLK_SRC_PLL160M = SOC_MOD_CLK_PLL_F160M , /*!< Select PLL_F160M as the source clock */
MCPWM_CARRIER_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_F160M , /*!< Select PLL_F160M as the default clock choice */
} soc_periph_mcpwm_carrier_clk_src_t ;
2022-04-07 15:32:46 +08:00
///////////////////////////////////////////////////I2S//////////////////////////////////////////////////////////////////
/**
2022-05-17 13:47:14 +08:00
* @ brief Array initializer for all supported clock sources of I2S
2022-04-07 15:32:46 +08:00
*/
2022-12-01 12:56:36 +08:00
# define SOC_I2S_CLKS {SOC_MOD_CLK_PLL_F160M, SOC_MOD_CLK_APLL}
2022-04-07 15:32:46 +08:00
/**
* @ brief I2S clock source enum
*
*/
typedef enum {
2022-12-01 12:56:36 +08:00
I2S_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_F160M , /*!< Select PLL_F160M as the default source clock */
I2S_CLK_SRC_PLL_160M = SOC_MOD_CLK_PLL_F160M , /*!< Select PLL_F160M as the source clock */
2022-04-07 15:32:46 +08:00
I2S_CLK_SRC_APLL = SOC_MOD_CLK_APLL , /*!< Select APLL as the source clock */
} soc_periph_i2s_clk_src_t ;
2022-07-14 19:22:07 +08:00
/////////////////////////////////////////////////I2C////////////////////////////////////////////////////////////////////
/**
* @ brief Array initializer for all supported clock sources of I2C
*/
# define SOC_I2C_CLKS {SOC_MOD_CLK_APB}
/**
* @ brief Type of I2C clock source .
*/
typedef enum {
I2C_CLK_SRC_APB = SOC_MOD_CLK_APB ,
I2C_CLK_SRC_DEFAULT = SOC_MOD_CLK_APB ,
} soc_periph_i2c_clk_src_t ;
2023-01-18 10:56:25 +08:00
/////////////////////////////////////////////////SPI////////////////////////////////////////////////////////////////////
/**
* @ brief Array initializer for all supported clock sources of SPI
*/
# define SOC_SPI_CLKS {SOC_MOD_CLK_APB}
/**
* @ brief Type of SPI clock source .
*/
typedef enum {
SPI_CLK_SRC_DEFAULT = SOC_MOD_CLK_APB , /*!< Select APB as SPI source clock */
SPI_CLK_SRC_APB = SOC_MOD_CLK_APB , /*!< Select APB as SPI source clock */
} soc_periph_spi_clk_src_t ;
2022-05-17 13:47:14 +08:00
//////////////////////////////////////////////////SDM//////////////////////////////////////////////////////////////
/**
* @ brief Array initializer for all supported clock sources of SDM
*/
# define SOC_SDM_CLKS {SOC_MOD_CLK_APB}
/**
* @ brief Sigma Delta Modulator clock source
*/
typedef enum {
SDM_CLK_SRC_APB = SOC_MOD_CLK_APB , /*!< Select APB as the source clock */
SDM_CLK_SRC_DEFAULT = SOC_MOD_CLK_APB , /*!< Select APB as the default clock choice */
} soc_periph_sdm_clk_src_t ;
2022-05-24 17:26:36 +08:00
////////////////////////////////////////////////////DAC/////////////////////////////////////////////////////////////////
/**
* @ brief Array initializer for all supported clock sources of DAC digital controller
*/
# define SOC_DAC_DIGI_CLKS {SOC_MOD_CLK_PLL_D2, SOC_MOD_CLK_APLL}
/**
* @ brief DAC digital controller clock source
*
*/
typedef enum {
2022-10-10 19:17:22 +08:00
DAC_DIGI_CLK_SRC_PLLD2 = SOC_MOD_CLK_PLL_D2 , /*!< Select PLL_D2 as the source clock */
DAC_DIGI_CLK_SRC_APLL = SOC_MOD_CLK_APLL , /*!< Select APLL as the source clock */
DAC_DIGI_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_D2 , /*!< Select PLL_D2 as the default source clock */
2022-05-24 17:26:36 +08:00
} soc_periph_dac_digi_clk_src_t ;
/**
* @ brief Array initializer for all supported clock sources of DAC cosine wave generator
*/
2022-10-10 19:17:22 +08:00
# define SOC_DAC_COSINE_CLKS {SOC_MOD_CLK_RTC_FAST}
2022-05-24 17:26:36 +08:00
/**
* @ brief DAC cosine wave generator clock source
*
*/
typedef enum {
2022-10-10 19:17:22 +08:00
DAC_COSINE_CLK_SRC_RTC_FAST = SOC_MOD_CLK_RTC_FAST , /*!< Select RTC FAST as the source clock */
DAC_COSINE_CLK_SRC_DEFAULT = SOC_MOD_CLK_RTC_FAST , /*!< Select RTC FAST as the default source clock */
2022-05-24 17:26:36 +08:00
} soc_periph_dac_cosine_clk_src_t ;
2022-10-27 18:26:02 +08:00
//////////////////////////////////////////////////TWAI/////////////////////////////////////////////////////////////////
/**
* @ brief Array initializer for all supported clock sources of TWAI
*/
# define SOC_TWAI_CLKS {SOC_MOD_CLK_APB}
/**
* @ brief TWAI clock source
*/
typedef enum {
TWAI_CLK_SRC_APB = SOC_MOD_CLK_APB , /*!< Select APB as the source clock */
TWAI_CLK_SRC_DEFAULT = SOC_MOD_CLK_APB , /*!< Select APB as the default clock choice */
} soc_periph_twai_clk_src_t ;
2022-12-01 17:07:14 +08:00
//////////////////////////////////////////////////ADC///////////////////////////////////////////////////////////////////
/**
* @ brief Array initializer for all supported clock sources of ADC digital controller
*/
2022-12-05 16:01:34 +08:00
# define SOC_ADC_DIGI_CLKS {SOC_MOD_CLK_APLL, SOC_MOD_CLK_PLL_F160M}
2022-12-01 17:07:14 +08:00
/**
* @ brief ADC digital controller clock source
2022-12-05 16:01:34 +08:00
* @ note ADC DMA mode is clocked from I2S on ESP32 , using ` ADC_DIGI_ ` here for compatibility
2022-12-01 17:07:14 +08:00
* Its clock source is same as I2S
*/
typedef enum {
2022-12-05 16:01:34 +08:00
ADC_DIGI_CLK_SRC_PLL_F160M = SOC_MOD_CLK_PLL_F160M , /*!< Select F160M as the source clock */
ADC_DIGI_CLK_SRC_APLL = SOC_MOD_CLK_APLL , /*!< Select APLL as the source clock */
ADC_DIGI_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_F160M , /*!< Select F160M as the default clock choice */
2022-12-01 17:07:14 +08:00
} soc_periph_adc_digi_clk_src_t ;
2022-12-05 16:01:34 +08:00
/**
* @ brief Array initializer for all supported clock sources of ADC RTC controller
*/
# define SOC_ADC_RTC_CLKS {SOC_MOD_CLK_RC_FAST}
/**
* @ brief ADC RTC controller clock source
*/
typedef enum {
ADC_RTC_CLK_SRC_RC_FAST = SOC_MOD_CLK_RC_FAST , /*!< Select RC_FAST as the source clock */
ADC_RTC_CLK_SRC_DEFAULT = SOC_MOD_CLK_RC_FAST , /*!< Select RC_FAST as the default clock choice */
} soc_periph_adc_rtc_clk_src_t ;
2023-01-13 11:36:19 +08:00
//////////////////////////////////////////////////MWDT/////////////////////////////////////////////////////////////////
/**
* @ brief Array initializer for all supported clock sources of MWDT
*/
# define SOC_MWDT_CLKS {SOC_MOD_CLK_APB}
/**
* @ brief MWDT clock source
*/
typedef enum {
MWDT_CLK_SRC_APB = SOC_MOD_CLK_APB , /*!< Select APB as the source clock */
MWDT_CLK_SRC_DEFAULT = SOC_MOD_CLK_APB , /*!< Select APB as the default clock choice */
} soc_periph_mwdt_clk_src_t ;
2023-01-24 01:54:34 +08:00
//////////////////////////////////////////////////LEDC/////////////////////////////////////////////////////////////////
2023-01-13 11:36:19 +08:00
2023-01-24 01:54:34 +08:00
/**
* @ brief Array initializer for all supported clock sources of LEDC
*/
# define SOC_LEDC_CLKS {SOC_MOD_CLK_APB, SOC_MOD_CLK_RC_FAST, SOC_MOD_CLK_REF_TICK}
/**
* @ brief Type of LEDC clock source , reserved for the legacy LEDC driver
*/
typedef enum {
LEDC_AUTO_CLK = 0 , /*!< LEDC source clock will be automatically selected based on the giving resolution and duty parameter when init the timer*/
LEDC_USE_APB_CLK = SOC_MOD_CLK_APB , /*!< Select APB as the source clock */
LEDC_USE_RC_FAST_CLK = SOC_MOD_CLK_RC_FAST , /*!< Select RC_FAST as the source clock */
LEDC_USE_REF_TICK = SOC_MOD_CLK_REF_TICK , /*!< Select REF_TICK as the source clock */
} soc_periph_ledc_clk_src_legacy_t ;
2023-01-13 11:36:19 +08:00
2023-04-18 19:45:27 +08:00
//////////////////////////////////////////////////SDMMC///////////////////////////////////////////////////////////////
/**
* @ brief Array initializer for all supported clock sources of SDMMC
*/
# define SOC_SDMMC_CLKS {SOC_MOD_CLK_PLL_F160M}
/**
* @ brief Type of SDMMC clock source
*/
typedef enum {
SDMMC_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_F160M , /*!< Select PLL_160M as the default choice */
SDMMC_CLK_SRC_PLL160M = SOC_MOD_CLK_PLL_F160M , /*!< Select PLL_160M as the source clock */
} soc_periph_sdmmc_clk_src_t ;
2023-09-04 17:20:36 +08:00
//////////////////////////////////////////////CLOCK OUTPUT///////////////////////////////////////////////////////////
typedef enum {
CLKOUT_SIG_I2S0 = 0 , /*!< I2S0 clock, depends on the i2s driver configuration */
CLKOUT_SIG_PLL = 1 , /*!< PLL_CLK is the output of crystal oscillator frequency multiplier */
CLKOUT_SIG_RC_SLOW = 4 , /*!< RC slow clock, depends on the RTC_CLK_SRC configuration */
CLKOUT_SIG_XTAL = 5 , /*!< Main crystal oscillator clock */
CLKOUT_SIG_APLL = 6 , /*!< Divided by PLL, frequency is configurable */
CLKOUT_SIG_REF_TICK = 12 , /*!< Divided by APB clock, usually be 1MHz */
CLKOUT_SIG_PLL_F80M = 13 , /*!< From PLL, usually be 80MHz */
CLKOUT_SIG_RC_FAST = 14 , /*!< RC fast clock, about 8MHz */
CLKOUT_SIG_I2S1 = 15 , /*!< I2S1 clock, depends on the i2s driver configuration */
CLKOUT_SIG_INVALID = 0xFF ,
} soc_clkout_sig_id_t ;
2025-07-29 21:43:42 +08:00
//////////////////////////////////////CLOCK FREQUENCY CALCULATION////////////////////////////////////////////////////
2025-07-21 22:00:00 +08:00
/**
2025-07-29 21:43:42 +08:00
* @ brief Clock frequency calculation source selection
2025-07-21 22:00:00 +08:00
*/
typedef enum {
2025-07-29 21:43:42 +08:00
CLK_CAL_RTC_SLOW , /*!< Select to calculate frequency of RTC_SLOW_CLK */
CLK_CAL_RC_FAST_D256 , /*!< Select to calculate frequency of RC_FAST_D256_CLK */
CLK_CAL_32K_XTAL , /*!< Select to calculate frequency of XTAL32K_CLK */
} soc_clk_freq_calculation_src_t ;
2025-07-21 22:00:00 +08:00
2022-03-25 18:41:25 +08:00
# ifdef __cplusplus
}
# endif