kopia lustrzana https://github.com/espressif/esp-idf
73 wiersze
2.2 KiB
C
73 wiersze
2.2 KiB
C
/*
|
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "hal/assert.h"
|
|
#include "soc/periph_defs.h"
|
|
#include "soc/pcr_reg.h"
|
|
#include "soc/soc.h"
|
|
#include "soc/soc_caps.h"
|
|
#include "esp_attr.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
static inline uint32_t periph_ll_get_clk_en_mask(periph_module_t periph)
|
|
{
|
|
// Only add peripherals that haven't implemented clock enable by their own ll function
|
|
return 0;
|
|
}
|
|
|
|
static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool enable)
|
|
{
|
|
// Only add peripherals that haven't implemented reset by their own ll function
|
|
return 0;
|
|
}
|
|
|
|
static inline uint32_t periph_ll_get_clk_en_reg(periph_module_t periph)
|
|
{
|
|
// Only add peripherals that haven't implemented clock enable by their own ll function
|
|
return 0;
|
|
}
|
|
|
|
static inline uint32_t periph_ll_get_rst_en_reg(periph_module_t periph)
|
|
{
|
|
// Only add peripherals that haven't implemented reset by their own ll function
|
|
return 0;
|
|
}
|
|
|
|
static inline void periph_ll_enable_clk_clear_rst(periph_module_t periph)
|
|
{
|
|
SET_PERI_REG_MASK(periph_ll_get_clk_en_reg(periph), periph_ll_get_clk_en_mask(periph));
|
|
CLEAR_PERI_REG_MASK(periph_ll_get_rst_en_reg(periph), periph_ll_get_rst_en_mask(periph, true));
|
|
}
|
|
|
|
static inline void periph_ll_disable_clk_set_rst(periph_module_t periph)
|
|
{
|
|
CLEAR_PERI_REG_MASK(periph_ll_get_clk_en_reg(periph), periph_ll_get_clk_en_mask(periph));
|
|
SET_PERI_REG_MASK(periph_ll_get_rst_en_reg(periph), periph_ll_get_rst_en_mask(periph, false));
|
|
}
|
|
|
|
static inline void periph_ll_reset(periph_module_t periph)
|
|
{
|
|
SET_PERI_REG_MASK(periph_ll_get_rst_en_reg(periph), periph_ll_get_rst_en_mask(periph, false));
|
|
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 REG_GET_BIT(periph_ll_get_rst_en_reg(periph), periph_ll_get_rst_en_mask(periph, false)) == 0 &&
|
|
REG_GET_BIT(periph_ll_get_clk_en_reg(periph), periph_ll_get_clk_en_mask(periph)) != 0;
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|