From 3a88ac790084961dec55b2f2350f5ff5805c74b6 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Wed, 3 Jun 2020 15:43:25 +0200 Subject: [PATCH] soc: add periph_ll_periph_enabled to clk_gate_ll.h --- components/soc/src/esp32/include/hal/clk_gate_ll.h | 6 ++++++ components/soc/src/esp32s2/include/hal/clk_gate_ll.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/components/soc/src/esp32/include/hal/clk_gate_ll.h b/components/soc/src/esp32/include/hal/clk_gate_ll.h index 7849433bb..23e90cdaa 100644 --- a/components/soc/src/esp32/include/hal/clk_gate_ll.h +++ b/components/soc/src/esp32/include/hal/clk_gate_ll.h @@ -248,6 +248,12 @@ static inline void periph_ll_reset(periph_module_t periph) DPORT_CLEAR_PERI_REG_MASK(periph_ll_get_rst_en_reg(periph), periph_ll_get_rst_en_mask(periph, false)); } +static inline bool IRAM_ATTR periph_ll_periph_enabled(periph_module_t periph) +{ + return DPORT_REG_GET_BIT(periph_ll_get_rst_en_reg(periph), periph_ll_get_rst_en_mask(periph, false)) == 0 && + DPORT_REG_GET_BIT(periph_ll_get_clk_en_reg(periph), periph_ll_get_clk_en_mask(periph)) != 0; +} + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/components/soc/src/esp32s2/include/hal/clk_gate_ll.h b/components/soc/src/esp32s2/include/hal/clk_gate_ll.h index 261398f95..8e93bece8 100644 --- a/components/soc/src/esp32s2/include/hal/clk_gate_ll.h +++ b/components/soc/src/esp32s2/include/hal/clk_gate_ll.h @@ -260,6 +260,12 @@ static inline void periph_ll_reset(periph_module_t periph) DPORT_CLEAR_PERI_REG_MASK(periph_ll_get_rst_en_reg(periph), periph_ll_get_rst_en_mask(periph, false)); } +static inline bool IRAM_ATTR periph_ll_periph_enabled(periph_module_t periph) +{ + return DPORT_REG_GET_BIT(periph_ll_get_rst_en_reg(periph), periph_ll_get_rst_en_mask(periph, false)) != 0 && + DPORT_REG_GET_BIT(periph_ll_get_clk_en_reg(periph), periph_ll_get_clk_en_mask(periph)) != 0; +} + #ifdef __cplusplus } #endif