mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
Merge branch 'refactor/esp_hal_ledc' into 'master'
refactor(ledc): split ledc hal into a separate component Closes IDF-14085 See merge request espressif/esp-idf!44204
This commit is contained in:
@@ -20,6 +20,7 @@ endif()
|
||||
idf_component_register(
|
||||
SRCS ${srcs}
|
||||
INCLUDE_DIRS ${public_include}
|
||||
REQUIRES esp_hal_ledc
|
||||
PRIV_REQUIRES "${priv_requires}"
|
||||
LDFRAGMENTS "linker.lf"
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ entries:
|
||||
ledc: _ledc_update_duty (noflash)
|
||||
|
||||
[mapping:ledc_hal]
|
||||
archive: libhal.a
|
||||
archive: libesp_hal_ledc.a
|
||||
entries:
|
||||
if SOC_LEDC_SUPPORTED = y:
|
||||
ledc_hal_iram (noflash)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "freertos/idf_additions.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_check.h"
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "esp_clk_tree.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "hal/ledc_hal.h"
|
||||
|
||||
@@ -5,3 +5,4 @@ components/esp_driver_ledc/test_apps/ledc:
|
||||
- if: SOC_LEDC_SUPPORTED != 1
|
||||
depends_components:
|
||||
- esp_driver_ledc
|
||||
- esp_hal_ledc
|
||||
|
||||
@@ -9,10 +9,16 @@ project(ledc_test)
|
||||
|
||||
idf_build_get_property(elf EXECUTABLE)
|
||||
if(CONFIG_COMPILER_DUMP_RTL_FILES)
|
||||
set(LEDC_RTL_DIRS
|
||||
${CMAKE_BINARY_DIR}/esp-idf/esp_driver_ledc
|
||||
${CMAKE_BINARY_DIR}/esp-idf/hal
|
||||
${CMAKE_BINARY_DIR}/esp-idf/esp_hal_ledc
|
||||
)
|
||||
string(JOIN "," LEDC_RTL_DIRS_JOINED ${LEDC_RTL_DIRS})
|
||||
add_custom_target(
|
||||
check_test_app_sections ALL
|
||||
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
|
||||
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/esp_driver_ledc/,${CMAKE_BINARY_DIR}/esp-idf/hal/
|
||||
--rtl-dirs ${LEDC_RTL_DIRS_JOINED}
|
||||
--elf-file ${CMAKE_BINARY_DIR}/ledc_test.elf
|
||||
find-refs
|
||||
--from-sections=.iram0.text
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "esp_private/sleep_cpu.h"
|
||||
#include "esp_private/esp_sleep_internal.h"
|
||||
#include "esp_private/esp_pmu.h"
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "esp_private/sleep_retention.h"
|
||||
#include "esp_rom_serial_output.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
idf_build_get_property(target IDF_TARGET)
|
||||
|
||||
set(srcs)
|
||||
set(includes "include")
|
||||
|
||||
# Add target-specific include directory if it exists
|
||||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}/include")
|
||||
list(APPEND includes "${target}/include")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LEDC_SUPPORTED)
|
||||
list(APPEND srcs "ledc_hal.c" "ledc_hal_iram.c" "${target}/ledc_periph.c")
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS ${includes}
|
||||
REQUIRES soc hal)
|
||||
@@ -0,0 +1,35 @@
|
||||
# ESP Hardware Abstraction Layer for LEDC Peripheral
|
||||
|
||||
> [!NOTE]
|
||||
> This component is currently in beta. Its API, behavior, and compatibility may change at any time and without notice; backward compatibility is not guaranteed. Use caution when integrating into production systems.
|
||||
|
||||
## Overview
|
||||
|
||||
The `esp_hal_ledc` component provides a **Hardware Abstraction Layer** for the LEDC (LED PWM Controller) peripheral across all ESP-IDF supported targets.
|
||||
|
||||
## Architecture
|
||||
|
||||
The LEDC HAL is structured in two main sub-layers:
|
||||
|
||||
1. **HAL Layer (Upper)**: Defines the operational steps and data structures required to control LEDC (e.g., timer/channel configuration, duty updates, fade and low-power helpers).
|
||||
2. **Low-Level Layer (Bottom)**: Serves as a translation layer between the HAL and the register files defined in the `soc` component, handling target-specific register configurations.
|
||||
|
||||
## Features
|
||||
|
||||
- Multi-timer and multi-channel PWM generation
|
||||
- High-speed and low-speed modes (on supported chips)
|
||||
- Duty cycle setting and smooth fading
|
||||
- Timer resolution and frequency configuration
|
||||
- Interrupt-driven operations
|
||||
- Low-power helpers (on supported chips)
|
||||
|
||||
## Usage
|
||||
|
||||
The HAL functions primarily serve ESP-IDF peripheral drivers such as `esp_driver_ledc`.
|
||||
|
||||
Advanced developers can use these interfaces directly when implementing custom drivers, with the understanding that API stability is not guaranteed.
|
||||
|
||||
## Dependencies
|
||||
|
||||
- `soc`: Provides chip-specific register definitions
|
||||
- `hal`: Core hardware abstraction utilities and macros
|
||||
+5
-6
@@ -10,14 +10,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "hal/ledc_types.h"
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "soc/ledc_struct.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
#include "soc/dport_reg.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
|
||||
#define LEDC_LL_DUTY_NUM_MAX (LEDC_DUTY_NUM_LSCH0_V)
|
||||
@@ -43,6 +39,10 @@ extern "C" {
|
||||
((SPEED) == LEDC_HIGH_SPEED_MODE && (CLK) == LEDC_USE_APB_CLK) \
|
||||
)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable peripheral register clock
|
||||
*
|
||||
@@ -580,7 +580,6 @@ static inline volatile void* ledc_ll_get_fade_end_intr_addr(ledc_dev_t *hw)
|
||||
return &hw->int_st.val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clear fade end interrupt status
|
||||
*
|
||||
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
|
||||
/*
|
||||
+6
-6
@@ -10,14 +10,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "hal/ledc_types.h"
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "soc/ledc_struct.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
#include "soc/system_struct.h"
|
||||
#include "hal/assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
|
||||
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1
|
||||
@@ -40,6 +37,10 @@ extern "C" {
|
||||
#define LEDC_LL_GLOBAL_CLK_NC_BY_DEFAULT 1
|
||||
#define LEDC_LL_GLOBAL_CLK_DEFAULT LEDC_SLOW_CLK_RC_FAST // The temporal global clock source to set to at least make the LEDC core clock on
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable peripheral register clock
|
||||
*
|
||||
@@ -557,7 +558,6 @@ static inline volatile void* ledc_ll_get_fade_end_intr_addr(ledc_dev_t *hw)
|
||||
return &hw->int_st.val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clear fade end interrupt status
|
||||
*
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
|
||||
/*
|
||||
+5
-6
@@ -10,15 +10,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "hal/ledc_types.h"
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "soc/ledc_struct.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
#include "soc/system_struct.h"
|
||||
#include "hal/assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
|
||||
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1
|
||||
@@ -42,6 +38,10 @@ extern "C" {
|
||||
#define LEDC_LL_GLOBAL_CLK_NC_BY_DEFAULT 1
|
||||
#define LEDC_LL_GLOBAL_CLK_DEFAULT LEDC_SLOW_CLK_RC_FAST // The temporal global clock source to set to at least make the LEDC core clock on
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable peripheral register clock
|
||||
*
|
||||
@@ -559,7 +559,6 @@ static inline volatile void* ledc_ll_get_fade_end_intr_addr(ledc_dev_t *hw)
|
||||
return &hw->int_st.val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clear fade end interrupt status
|
||||
*
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
|
||||
/*
|
||||
+6
-9
@@ -18,10 +18,6 @@
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_etm_source.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
|
||||
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1
|
||||
@@ -125,6 +121,10 @@ extern "C" {
|
||||
[LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
|
||||
}}[(group)][(event)] << (timer))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable peripheral register clock
|
||||
*
|
||||
@@ -205,8 +205,7 @@ static inline void ledc_ll_set_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t
|
||||
{
|
||||
(void) hw;
|
||||
uint32_t clk_sel_val = 3;
|
||||
switch (slow_clk_sel)
|
||||
{
|
||||
switch (slow_clk_sel) {
|
||||
case LEDC_SLOW_CLK_XTAL:
|
||||
clk_sel_val = 0;
|
||||
break;
|
||||
@@ -234,8 +233,7 @@ static inline void ledc_ll_set_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t
|
||||
static inline void ledc_ll_get_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t *slow_clk_sel)
|
||||
{
|
||||
(void) hw;
|
||||
switch (PCR.ledc_sclk_conf.ledc_sclk_sel)
|
||||
{
|
||||
switch (PCR.ledc_sclk_conf.ledc_sclk_sel) {
|
||||
case 0:
|
||||
*slow_clk_sel = LEDC_SLOW_CLK_XTAL;
|
||||
break;
|
||||
@@ -646,7 +644,6 @@ static inline volatile void* ledc_ll_get_fade_end_intr_addr(ledc_dev_t *hw)
|
||||
return &hw->int_st.val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clear fade end interrupt status
|
||||
*
|
||||
+3
-2
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
|
||||
/*
|
||||
Bunch of constants for every LEDC peripheral: GPIO signals
|
||||
+4
-5
@@ -19,10 +19,6 @@
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_etm_source.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
|
||||
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1
|
||||
@@ -129,6 +125,10 @@ extern "C" {
|
||||
[LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
|
||||
}}[(group)][(event)] << (timer))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable peripheral register clock
|
||||
*
|
||||
@@ -768,7 +768,6 @@ static inline volatile void* ledc_ll_get_fade_end_intr_addr(ledc_dev_t *hw)
|
||||
return &hw->int_st.val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clear fade end interrupt status
|
||||
*
|
||||
+3
-2
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
|
||||
/*
|
||||
Bunch of constants for every LEDC peripheral: GPIO signals
|
||||
+6
-9
@@ -18,10 +18,6 @@
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_etm_source.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
|
||||
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1
|
||||
@@ -125,6 +121,10 @@ extern "C" {
|
||||
[LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
|
||||
}}[(group)][(event)] << (timer))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable peripheral register clock
|
||||
*
|
||||
@@ -205,8 +205,7 @@ static inline void ledc_ll_set_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t
|
||||
{
|
||||
(void) hw;
|
||||
uint32_t clk_sel_val = 3;
|
||||
switch (slow_clk_sel)
|
||||
{
|
||||
switch (slow_clk_sel) {
|
||||
case LEDC_SLOW_CLK_XTAL:
|
||||
clk_sel_val = 0;
|
||||
break;
|
||||
@@ -234,8 +233,7 @@ static inline void ledc_ll_set_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t
|
||||
static inline void ledc_ll_get_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t *slow_clk_sel)
|
||||
{
|
||||
(void) hw;
|
||||
switch (PCR.ledc_sclk_conf.ledc_sclk_sel)
|
||||
{
|
||||
switch (PCR.ledc_sclk_conf.ledc_sclk_sel) {
|
||||
case 0:
|
||||
*slow_clk_sel = LEDC_SLOW_CLK_XTAL;
|
||||
break;
|
||||
@@ -646,7 +644,6 @@ static inline volatile void* ledc_ll_get_fade_end_intr_addr(ledc_dev_t *hw)
|
||||
return &hw->int_st.val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clear fade end interrupt status
|
||||
*
|
||||
+3
-2
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
|
||||
/*
|
||||
Bunch of constants for every LEDC peripheral: GPIO signals
|
||||
+4
-5
@@ -19,10 +19,6 @@
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_etm_source.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
|
||||
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1
|
||||
@@ -126,6 +122,10 @@ extern "C" {
|
||||
[LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
|
||||
}}[(group)][(event)] << (timer))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable peripheral register clock
|
||||
*
|
||||
@@ -765,7 +765,6 @@ static inline volatile void* ledc_ll_get_fade_end_intr_addr(ledc_dev_t *hw)
|
||||
return &hw->int_st.val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clear fade end interrupt status
|
||||
*
|
||||
+3
-2
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
|
||||
/*
|
||||
Bunch of constants for every LEDC peripheral: GPIO signals
|
||||
+4
-5
@@ -19,10 +19,6 @@
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_etm_source.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
|
||||
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1
|
||||
@@ -126,6 +122,10 @@ extern "C" {
|
||||
[LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
|
||||
}}[(group)][(event)] << (timer))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable peripheral register clock
|
||||
*
|
||||
@@ -764,7 +764,6 @@ static inline volatile void* ledc_ll_get_fade_end_intr_addr(ledc_dev_t *hw)
|
||||
return &hw->int_st.val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clear fade end interrupt status
|
||||
*
|
||||
+3
-2
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
|
||||
/*
|
||||
Bunch of constants for every LEDC peripheral: GPIO signals
|
||||
+6
-9
@@ -18,10 +18,6 @@
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_etm_source.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
|
||||
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1
|
||||
@@ -125,6 +121,10 @@ extern "C" {
|
||||
[LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
|
||||
}}[(group)][(event)] << (timer))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable peripheral register clock
|
||||
*
|
||||
@@ -211,8 +211,7 @@ static inline void ledc_ll_set_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t
|
||||
{
|
||||
(void) hw;
|
||||
uint32_t clk_sel_val = 3;
|
||||
switch (slow_clk_sel)
|
||||
{
|
||||
switch (slow_clk_sel) {
|
||||
case LEDC_SLOW_CLK_XTAL:
|
||||
clk_sel_val = 0;
|
||||
break;
|
||||
@@ -240,8 +239,7 @@ static inline void ledc_ll_set_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t
|
||||
static inline void ledc_ll_get_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t *slow_clk_sel)
|
||||
{
|
||||
(void) hw;
|
||||
switch (PCR.ledc_sclk_conf.ledc_sclk_sel)
|
||||
{
|
||||
switch (PCR.ledc_sclk_conf.ledc_sclk_sel) {
|
||||
case 0:
|
||||
*slow_clk_sel = LEDC_SLOW_CLK_XTAL;
|
||||
break;
|
||||
@@ -593,7 +591,6 @@ static inline volatile void* ledc_ll_get_fade_end_intr_addr(ledc_dev_t *hw)
|
||||
return &hw->int_st.val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clear fade end interrupt status
|
||||
*
|
||||
+3
-2
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
|
||||
/*
|
||||
Bunch of constants for every LEDC peripheral: GPIO signals
|
||||
+6
-9
@@ -18,10 +18,6 @@
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_etm_source.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
|
||||
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1
|
||||
@@ -125,6 +121,10 @@ extern "C" {
|
||||
[LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
|
||||
}}[(group)][(event)] << (timer))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable peripheral register clock
|
||||
*
|
||||
@@ -224,8 +224,7 @@ static inline void ledc_ll_set_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t
|
||||
{
|
||||
(void) hw;
|
||||
uint32_t clk_sel_val = 3;
|
||||
switch (slow_clk_sel)
|
||||
{
|
||||
switch (slow_clk_sel) {
|
||||
case LEDC_SLOW_CLK_XTAL:
|
||||
clk_sel_val = 0;
|
||||
break;
|
||||
@@ -260,8 +259,7 @@ static inline void ledc_ll_set_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t
|
||||
static inline void ledc_ll_get_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t *slow_clk_sel)
|
||||
{
|
||||
(void) hw;
|
||||
switch (HP_SYS_CLKRST.peri_clk_ctrl22.reg_ledc_clk_src_sel)
|
||||
{
|
||||
switch (HP_SYS_CLKRST.peri_clk_ctrl22.reg_ledc_clk_src_sel) {
|
||||
case 0:
|
||||
*slow_clk_sel = LEDC_SLOW_CLK_XTAL;
|
||||
break;
|
||||
@@ -671,7 +669,6 @@ static inline volatile void* ledc_ll_get_fade_end_intr_addr(ledc_dev_t *hw)
|
||||
return &hw->int_st.val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clear fade end interrupt status
|
||||
*
|
||||
+3
-2
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
|
||||
/*
|
||||
Bunch of constants for every LEDC peripheral: GPIO signals
|
||||
+5
-6
@@ -10,15 +10,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "hal/ledc_types.h"
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "soc/ledc_struct.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "hal/assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
|
||||
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1
|
||||
@@ -47,6 +43,10 @@ extern "C" {
|
||||
#define LEDC_LL_GLOBAL_CLK_NC_BY_DEFAULT 1
|
||||
#define LEDC_LL_GLOBAL_CLK_DEFAULT LEDC_SLOW_CLK_RC_FAST // The temporal global clock source to set to at least make the LEDC core clock on
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable peripheral register clock
|
||||
*
|
||||
@@ -598,7 +598,6 @@ static inline volatile void* ledc_ll_get_fade_end_intr_addr(ledc_dev_t *hw)
|
||||
return &hw->int_st.val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clear fade end interrupt status
|
||||
*
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
|
||||
/*
|
||||
+5
-6
@@ -10,15 +10,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "hal/ledc_types.h"
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "soc/ledc_struct.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
#include "soc/system_struct.h"
|
||||
#include "hal/assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
|
||||
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1
|
||||
@@ -42,6 +38,10 @@ extern "C" {
|
||||
#define LEDC_LL_GLOBAL_CLK_NC_BY_DEFAULT 1
|
||||
#define LEDC_LL_GLOBAL_CLK_DEFAULT LEDC_SLOW_CLK_RC_FAST // The temporal global clock source to set to at least make the LEDC core clock on
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable peripheral register clock
|
||||
*
|
||||
@@ -559,7 +559,6 @@ static inline volatile void* ledc_ll_get_fade_end_intr_addr(ledc_dev_t *hw)
|
||||
return &hw->int_st.val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clear fade end interrupt status
|
||||
*
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "hal/ledc_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
|
||||
/*
|
||||
@@ -25,7 +25,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if SOC_LEDC_SUPPORTED
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
+2
-4
@@ -1,14 +1,12 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/ledc_reg.h"
|
||||
#include "soc/ledc_struct.h"
|
||||
#if SOC_PAU_SUPPORTED
|
||||
#include "soc/regdma.h"
|
||||
#include "soc/retention_periph_defs.h"
|
||||
@@ -22,7 +20,7 @@ extern "C" {
|
||||
Stores a bunch of per-ledc-peripheral data.
|
||||
*/
|
||||
typedef struct {
|
||||
const uint8_t sig_out0_idx;
|
||||
const int sig_out0_idx;
|
||||
} ledc_signal_conn_t;
|
||||
|
||||
#if SOC_LEDC_SUPPORT_HS_MODE
|
||||
+4
-4
@@ -6,15 +6,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/clk_tree_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
#if SOC_LEDC_SUPPORT_HS_MODE
|
||||
LEDC_HIGH_SPEED_MODE = 0, /*!< LEDC high speed speed_mode */
|
||||
@@ -84,10 +84,6 @@ elseif(NOT BOOTLOADER_BUILD)
|
||||
list(APPEND srcs "uart_hal.c" "uart_hal_iram.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LEDC_SUPPORTED)
|
||||
list(APPEND srcs "ledc_hal.c" "ledc_hal_iram.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_I3C_MASTER_SUPPORTED)
|
||||
list(APPEND srcs "i3c_master_hal.c")
|
||||
endif()
|
||||
|
||||
@@ -68,10 +68,6 @@ if(CONFIG_SOC_DEBUG_PROBE_SUPPORTED)
|
||||
list(APPEND srcs "${target_folder}/debug_probe_periph.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LEDC_SUPPORTED)
|
||||
list(APPEND srcs "${target_folder}/ledc_periph.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_I3C_MASTER_SUPPORTED)
|
||||
list(APPEND srcs "${target_folder}/i3c_master_periph.c")
|
||||
endif()
|
||||
|
||||
@@ -174,6 +174,7 @@ INPUT = \
|
||||
$(PROJECT_PATH)/components/esp_hal_i2s/include/hal/i2s_types.h \
|
||||
$(PROJECT_PATH)/components/esp_hal_jpeg/include/hal/jpeg_types.h \
|
||||
$(PROJECT_PATH)/components/esp_hal_lcd/include/hal/lcd_types.h \
|
||||
$(PROJECT_PATH)/components/esp_hal_ledc/include/hal/ledc_types.h \
|
||||
$(PROJECT_PATH)/components/esp_hal_parlio/include/hal/parlio_types.h \
|
||||
$(PROJECT_PATH)/components/esp_hal_mspi/include/hal/esp_flash_err.h \
|
||||
$(PROJECT_PATH)/components/esp_hal_mspi/include/hal/spi_flash_types.h \
|
||||
@@ -265,7 +266,6 @@ INPUT = \
|
||||
$(PROJECT_PATH)/components/freertos/FreeRTOS-Kernel/include/freertos/task.h \
|
||||
$(PROJECT_PATH)/components/freertos/FreeRTOS-Kernel/include/freertos/timers.h \
|
||||
$(PROJECT_PATH)/components/hal/include/hal/color_types.h \
|
||||
$(PROJECT_PATH)/components/hal/include/hal/ledc_types.h \
|
||||
$(PROJECT_PATH)/components/hal/include/hal/mcpwm_types.h \
|
||||
$(PROJECT_PATH)/components/hal/include/hal/sdio_slave_types.h \
|
||||
$(PROJECT_PATH)/components/hal/include/hal/temperature_sensor_types.h \
|
||||
|
||||
@@ -272,18 +272,15 @@ examples/peripherals/ledc:
|
||||
- if: SOC_LEDC_SUPPORTED != 1
|
||||
depends_components:
|
||||
- esp_driver_ledc
|
||||
- esp_hal_ledc
|
||||
|
||||
examples/peripherals/ledc/ledc_dimmer:
|
||||
disable:
|
||||
- if: SOC_ETM_SUPPORTED != 1 or SOC_LEDC_SUPPORT_ETM != 1
|
||||
depends_components:
|
||||
- esp_driver_ledc
|
||||
|
||||
examples/peripherals/ledc/ledc_gamma_curve_fade:
|
||||
disable:
|
||||
- if: SOC_LEDC_SUPPORTED != 1 or SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED != 1
|
||||
depends_components:
|
||||
- esp_driver_ledc
|
||||
|
||||
examples/peripherals/mcpwm:
|
||||
disable:
|
||||
|
||||
Reference in New Issue
Block a user