mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
refactor(ledc): add compatibility for group and speed_mode
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include "hal/assert.h"
|
||||
#include "hal/ledc_types.h"
|
||||
#include "soc/ledc_struct.h"
|
||||
@@ -18,7 +19,7 @@
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_etm_source.h"
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
#define LEDC_LL_GET_HW(group_id) ((group_id == 0) ? &LEDC : NULL)
|
||||
|
||||
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1
|
||||
|
||||
@@ -128,10 +129,12 @@ extern "C" {
|
||||
/**
|
||||
* @brief Enable peripheral register clock
|
||||
*
|
||||
* @param group_id LEDC group ID
|
||||
* @param enable Enable/Disable
|
||||
*/
|
||||
static inline void ledc_ll_enable_bus_clock(bool enable)
|
||||
static inline void ledc_ll_enable_bus_clock(int group_id, bool enable)
|
||||
{
|
||||
(void)group_id;
|
||||
HP_SYS_CLKRST.soc_clk_ctrl3.reg_ledc_apb_clk_en = enable;
|
||||
}
|
||||
|
||||
@@ -144,17 +147,21 @@ static inline void ledc_ll_enable_bus_clock(bool enable)
|
||||
|
||||
/**
|
||||
* @brief Reset whole peripheral register to init value defined by HW design
|
||||
*
|
||||
* @param group_id LEDC group ID
|
||||
*/
|
||||
static inline void ledc_ll_enable_reset_reg(bool enable)
|
||||
static inline void ledc_ll_reset_register(int group_id)
|
||||
{
|
||||
HP_SYS_CLKRST.hp_rst_en1.reg_rst_en_ledc = enable;
|
||||
(void)group_id;
|
||||
HP_SYS_CLKRST.hp_rst_en1.reg_rst_en_ledc = 1;
|
||||
HP_SYS_CLKRST.hp_rst_en1.reg_rst_en_ledc = 0;
|
||||
}
|
||||
|
||||
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||
#define ledc_ll_enable_reset_reg(...) do { \
|
||||
#define ledc_ll_reset_register(...) do { \
|
||||
(void)__DECLARE_RCC_ATOMIC_ENV; \
|
||||
ledc_ll_enable_reset_reg(__VA_ARGS__); \
|
||||
ledc_ll_reset_register(__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
@@ -168,14 +175,14 @@ static inline void ledc_ll_enable_mem_power(bool enable)
|
||||
/**
|
||||
* @brief Enable LEDC function clock
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers
|
||||
* @param group_id LEDC group ID
|
||||
* @param en True to enable, false to disable
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
static inline void ledc_ll_enable_clock(ledc_dev_t *hw, bool en)
|
||||
static inline void ledc_ll_enable_clock(int group_id, bool en)
|
||||
{
|
||||
(void)hw;
|
||||
(void)group_id;
|
||||
HP_SYS_CLKRST.peri_clk_ctrl22.reg_ledc_clk_en = en;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user