refactor(ledc): split ledc hal into a separate component

This commit is contained in:
Song Ruo Jing
2025-12-25 17:23:27 +08:00
parent 847840150b
commit 6ca90bd14a
41 changed files with 152 additions and 118 deletions
@@ -20,6 +20,7 @@ endif()
idf_component_register( idf_component_register(
SRCS ${srcs} SRCS ${srcs}
INCLUDE_DIRS ${public_include} INCLUDE_DIRS ${public_include}
REQUIRES esp_hal_ledc
PRIV_REQUIRES "${priv_requires}" PRIV_REQUIRES "${priv_requires}"
LDFRAGMENTS "linker.lf" LDFRAGMENTS "linker.lf"
) )
+1 -1
View File
@@ -7,7 +7,7 @@ entries:
ledc: _ledc_update_duty (noflash) ledc: _ledc_update_duty (noflash)
[mapping:ledc_hal] [mapping:ledc_hal]
archive: libhal.a archive: libesp_hal_ledc.a
entries: entries:
if SOC_LEDC_SUPPORTED = y: if SOC_LEDC_SUPPORTED = y:
ledc_hal_iram (noflash) ledc_hal_iram (noflash)
+1 -1
View File
@@ -12,7 +12,7 @@
#include "freertos/idf_additions.h" #include "freertos/idf_additions.h"
#include "esp_log.h" #include "esp_log.h"
#include "esp_check.h" #include "esp_check.h"
#include "soc/ledc_periph.h" #include "hal/ledc_periph.h"
#include "esp_clk_tree.h" #include "esp_clk_tree.h"
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
#include "hal/ledc_hal.h" #include "hal/ledc_hal.h"
@@ -9,3 +9,4 @@ components/esp_driver_ledc/test_apps/ledc:
reason: p4 rev3 migration # TODO: IDF-14398 reason: p4 rev3 migration # TODO: IDF-14398
depends_components: depends_components:
- esp_driver_ledc - esp_driver_ledc
- esp_hal_ledc
@@ -9,10 +9,16 @@ project(ledc_test)
idf_build_get_property(elf EXECUTABLE) idf_build_get_property(elf EXECUTABLE)
if(CONFIG_COMPILER_DUMP_RTL_FILES) 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( add_custom_target(
check_test_app_sections ALL check_test_app_sections ALL
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py 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 --elf-file ${CMAKE_BINARY_DIR}/ledc_test.elf
find-refs find-refs
--from-sections=.iram0.text --from-sections=.iram0.text
@@ -14,7 +14,7 @@
#include "esp_private/sleep_cpu.h" #include "esp_private/sleep_cpu.h"
#include "esp_private/esp_sleep_internal.h" #include "esp_private/esp_sleep_internal.h"
#include "esp_private/esp_pmu.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_private/sleep_retention.h"
#include "esp_rom_serial_output.h" #include "esp_rom_serial_output.h"
+17
View File
@@ -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)
+35
View File
@@ -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
@@ -10,14 +10,10 @@
#pragma once #pragma once
#include "hal/ledc_types.h" #include "hal/ledc_types.h"
#include "soc/ledc_periph.h"
#include "soc/ledc_struct.h" #include "soc/ledc_struct.h"
#include "soc/ledc_reg.h"
#include "soc/dport_reg.h" #include "soc/dport_reg.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LEDC_LL_GET_HW() &LEDC #define LEDC_LL_GET_HW() &LEDC
#define LEDC_LL_DUTY_NUM_MAX (LEDC_DUTY_NUM_LSCH0_V) #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) \ ((SPEED) == LEDC_HIGH_SPEED_MODE && (CLK) == LEDC_USE_APB_CLK) \
) )
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Enable peripheral register clock * @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; return &hw->int_st.val;
} }
/** /**
* @brief Clear fade end interrupt status * @brief Clear fade end interrupt status
* *
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "soc/ledc_periph.h" #include "hal/ledc_periph.h"
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
/* /*
@@ -10,14 +10,11 @@
#pragma once #pragma once
#include "hal/ledc_types.h" #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 "soc/system_struct.h"
#include "hal/assert.h" #include "hal/assert.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LEDC_LL_GET_HW() &LEDC #define LEDC_LL_GET_HW() &LEDC
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1 #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_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 #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 * @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; return &hw->int_st.val;
} }
/** /**
* @brief Clear fade end interrupt status * @brief Clear fade end interrupt status
* *
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "soc/ledc_periph.h" #include "hal/ledc_periph.h"
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
/* /*
@@ -10,15 +10,11 @@
#pragma once #pragma once
#include "hal/ledc_types.h" #include "hal/ledc_types.h"
#include "soc/ledc_periph.h"
#include "soc/ledc_struct.h" #include "soc/ledc_struct.h"
#include "soc/ledc_reg.h"
#include "soc/system_struct.h" #include "soc/system_struct.h"
#include "hal/assert.h" #include "hal/assert.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LEDC_LL_GET_HW() &LEDC #define LEDC_LL_GET_HW() &LEDC
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1 #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_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 #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 * @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; return &hw->int_st.val;
} }
/** /**
* @brief Clear fade end interrupt status * @brief Clear fade end interrupt status
* *
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "soc/ledc_periph.h" #include "hal/ledc_periph.h"
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
/* /*
@@ -18,10 +18,6 @@
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
#include "soc/soc_etm_source.h" #include "soc/soc_etm_source.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LEDC_LL_GET_HW() &LEDC #define LEDC_LL_GET_HW() &LEDC
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1 #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), \ [LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
}}[(group)][(event)] << (timer)) }}[(group)][(event)] << (timer))
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Enable peripheral register clock * @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; (void) hw;
uint32_t clk_sel_val = 3; uint32_t clk_sel_val = 3;
switch (slow_clk_sel) switch (slow_clk_sel) {
{
case LEDC_SLOW_CLK_XTAL: case LEDC_SLOW_CLK_XTAL:
clk_sel_val = 0; clk_sel_val = 0;
break; 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) static inline void ledc_ll_get_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t *slow_clk_sel)
{ {
(void) hw; (void) hw;
switch (PCR.ledc_sclk_conf.ledc_sclk_sel) switch (PCR.ledc_sclk_conf.ledc_sclk_sel) {
{
case 0: case 0:
*slow_clk_sel = LEDC_SLOW_CLK_XTAL; *slow_clk_sel = LEDC_SLOW_CLK_XTAL;
break; 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; return &hw->int_st.val;
} }
/** /**
* @brief Clear fade end interrupt status * @brief Clear fade end interrupt status
* *
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "soc/ledc_periph.h" #include "hal/ledc_periph.h"
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
#include "soc/ledc_reg.h"
/* /*
Bunch of constants for every LEDC peripheral: GPIO signals Bunch of constants for every LEDC peripheral: GPIO signals
@@ -19,10 +19,6 @@
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
#include "soc/soc_etm_source.h" #include "soc/soc_etm_source.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LEDC_LL_GET_HW() &LEDC #define LEDC_LL_GET_HW() &LEDC
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1 #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), \ [LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
}}[(group)][(event)] << (timer)) }}[(group)][(event)] << (timer))
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Enable peripheral register clock * @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; return &hw->int_st.val;
} }
/** /**
* @brief Clear fade end interrupt status * @brief Clear fade end interrupt status
* *
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "soc/ledc_periph.h" #include "hal/ledc_periph.h"
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
#include "soc/ledc_reg.h"
/* /*
Bunch of constants for every LEDC peripheral: GPIO signals Bunch of constants for every LEDC peripheral: GPIO signals
@@ -18,10 +18,6 @@
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
#include "soc/soc_etm_source.h" #include "soc/soc_etm_source.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LEDC_LL_GET_HW() &LEDC #define LEDC_LL_GET_HW() &LEDC
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1 #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), \ [LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
}}[(group)][(event)] << (timer)) }}[(group)][(event)] << (timer))
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Enable peripheral register clock * @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; (void) hw;
uint32_t clk_sel_val = 3; uint32_t clk_sel_val = 3;
switch (slow_clk_sel) switch (slow_clk_sel) {
{
case LEDC_SLOW_CLK_XTAL: case LEDC_SLOW_CLK_XTAL:
clk_sel_val = 0; clk_sel_val = 0;
break; 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) static inline void ledc_ll_get_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t *slow_clk_sel)
{ {
(void) hw; (void) hw;
switch (PCR.ledc_sclk_conf.ledc_sclk_sel) switch (PCR.ledc_sclk_conf.ledc_sclk_sel) {
{
case 0: case 0:
*slow_clk_sel = LEDC_SLOW_CLK_XTAL; *slow_clk_sel = LEDC_SLOW_CLK_XTAL;
break; 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; return &hw->int_st.val;
} }
/** /**
* @brief Clear fade end interrupt status * @brief Clear fade end interrupt status
* *
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "soc/ledc_periph.h" #include "hal/ledc_periph.h"
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
#include "soc/ledc_reg.h"
/* /*
Bunch of constants for every LEDC peripheral: GPIO signals Bunch of constants for every LEDC peripheral: GPIO signals
@@ -19,10 +19,6 @@
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
#include "soc/soc_etm_source.h" #include "soc/soc_etm_source.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LEDC_LL_GET_HW() &LEDC #define LEDC_LL_GET_HW() &LEDC
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1 #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), \ [LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
}}[(group)][(event)] << (timer)) }}[(group)][(event)] << (timer))
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Enable peripheral register clock * @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; return &hw->int_st.val;
} }
/** /**
* @brief Clear fade end interrupt status * @brief Clear fade end interrupt status
* *
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "soc/ledc_periph.h" #include "hal/ledc_periph.h"
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
#include "soc/ledc_reg.h"
/* /*
Bunch of constants for every LEDC peripheral: GPIO signals Bunch of constants for every LEDC peripheral: GPIO signals
@@ -19,10 +19,6 @@
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
#include "soc/soc_etm_source.h" #include "soc/soc_etm_source.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LEDC_LL_GET_HW() &LEDC #define LEDC_LL_GET_HW() &LEDC
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1 #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), \ [LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
}}[(group)][(event)] << (timer)) }}[(group)][(event)] << (timer))
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Enable peripheral register clock * @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; return &hw->int_st.val;
} }
/** /**
* @brief Clear fade end interrupt status * @brief Clear fade end interrupt status
* *
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "soc/ledc_periph.h" #include "hal/ledc_periph.h"
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
#include "soc/ledc_reg.h"
/* /*
Bunch of constants for every LEDC peripheral: GPIO signals Bunch of constants for every LEDC peripheral: GPIO signals
@@ -18,10 +18,6 @@
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
#include "soc/soc_etm_source.h" #include "soc/soc_etm_source.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LEDC_LL_GET_HW() &LEDC #define LEDC_LL_GET_HW() &LEDC
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1 #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), \ [LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
}}[(group)][(event)] << (timer)) }}[(group)][(event)] << (timer))
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Enable peripheral register clock * @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; (void) hw;
uint32_t clk_sel_val = 3; uint32_t clk_sel_val = 3;
switch (slow_clk_sel) switch (slow_clk_sel) {
{
case LEDC_SLOW_CLK_XTAL: case LEDC_SLOW_CLK_XTAL:
clk_sel_val = 0; clk_sel_val = 0;
break; 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) static inline void ledc_ll_get_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t *slow_clk_sel)
{ {
(void) hw; (void) hw;
switch (PCR.ledc_sclk_conf.ledc_sclk_sel) switch (PCR.ledc_sclk_conf.ledc_sclk_sel) {
{
case 0: case 0:
*slow_clk_sel = LEDC_SLOW_CLK_XTAL; *slow_clk_sel = LEDC_SLOW_CLK_XTAL;
break; 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; return &hw->int_st.val;
} }
/** /**
* @brief Clear fade end interrupt status * @brief Clear fade end interrupt status
* *
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "soc/ledc_periph.h" #include "hal/ledc_periph.h"
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
#include "soc/ledc_reg.h"
/* /*
Bunch of constants for every LEDC peripheral: GPIO signals Bunch of constants for every LEDC peripheral: GPIO signals
@@ -18,10 +18,6 @@
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
#include "soc/soc_etm_source.h" #include "soc/soc_etm_source.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LEDC_LL_GET_HW() &LEDC #define LEDC_LL_GET_HW() &LEDC
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1 #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), \ [LEDC_TIMER_ETM_EVENT_OVF] = BIT(LEDC_EVT_TIME_OVF_TIMER0_EN_S), \
}}[(group)][(event)] << (timer)) }}[(group)][(event)] << (timer))
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Enable peripheral register clock * @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; (void) hw;
uint32_t clk_sel_val = 3; uint32_t clk_sel_val = 3;
switch (slow_clk_sel) switch (slow_clk_sel) {
{
case LEDC_SLOW_CLK_XTAL: case LEDC_SLOW_CLK_XTAL:
clk_sel_val = 0; clk_sel_val = 0;
break; 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) static inline void ledc_ll_get_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t *slow_clk_sel)
{ {
(void) hw; (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: case 0:
*slow_clk_sel = LEDC_SLOW_CLK_XTAL; *slow_clk_sel = LEDC_SLOW_CLK_XTAL;
break; 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; return &hw->int_st.val;
} }
/** /**
* @brief Clear fade end interrupt status * @brief Clear fade end interrupt status
* *
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "soc/ledc_periph.h" #include "hal/ledc_periph.h"
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
#include "soc/ledc_reg.h"
/* /*
Bunch of constants for every LEDC peripheral: GPIO signals Bunch of constants for every LEDC peripheral: GPIO signals
@@ -10,15 +10,11 @@
#pragma once #pragma once
#include "hal/ledc_types.h" #include "hal/ledc_types.h"
#include "soc/ledc_periph.h"
#include "soc/ledc_struct.h" #include "soc/ledc_struct.h"
#include "soc/ledc_reg.h"
#include "soc/dport_reg.h" #include "soc/dport_reg.h"
#include "hal/assert.h" #include "hal/assert.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LEDC_LL_GET_HW() &LEDC #define LEDC_LL_GET_HW() &LEDC
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1 #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_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 #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 * @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; return &hw->int_st.val;
} }
/** /**
* @brief Clear fade end interrupt status * @brief Clear fade end interrupt status
* *
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "soc/ledc_periph.h" #include "hal/ledc_periph.h"
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
/* /*
@@ -10,15 +10,11 @@
#pragma once #pragma once
#include "hal/ledc_types.h" #include "hal/ledc_types.h"
#include "soc/ledc_periph.h"
#include "soc/ledc_struct.h" #include "soc/ledc_struct.h"
#include "soc/ledc_reg.h"
#include "soc/system_struct.h" #include "soc/system_struct.h"
#include "hal/assert.h" #include "hal/assert.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LEDC_LL_GET_HW() &LEDC #define LEDC_LL_GET_HW() &LEDC
#define LEDC_LL_CHANNEL_SUPPORT_OVF_CNT 1 #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_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 #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 * @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; return &hw->int_st.val;
} }
/** /**
* @brief Clear fade end interrupt status * @brief Clear fade end interrupt status
* *
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "soc/ledc_periph.h" #include "hal/ledc_periph.h"
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
/* /*
@@ -25,7 +25,6 @@
extern "C" { extern "C" {
#endif #endif
#if SOC_LEDC_SUPPORTED #if SOC_LEDC_SUPPORTED
/** /**
* Context that should be maintained by both the driver and the HAL * Context that should be maintained by both the driver and the HAL
@@ -7,8 +7,6 @@
#pragma once #pragma once
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
#include "soc/ledc_reg.h"
#include "soc/ledc_struct.h"
#if SOC_PAU_SUPPORTED #if SOC_PAU_SUPPORTED
#include "soc/regdma.h" #include "soc/regdma.h"
#include "soc/retention_periph_defs.h" #include "soc/retention_periph_defs.h"
@@ -22,7 +20,7 @@ extern "C" {
Stores a bunch of per-ledc-peripheral data. Stores a bunch of per-ledc-peripheral data.
*/ */
typedef struct { typedef struct {
const uint8_t sig_out0_idx; const int sig_out0_idx;
} ledc_signal_conn_t; } ledc_signal_conn_t;
#if SOC_LEDC_SUPPORT_HS_MODE #if SOC_LEDC_SUPPORT_HS_MODE
@@ -6,15 +6,15 @@
#pragma once #pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
#include "soc/clk_tree_defs.h" #include "soc/clk_tree_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { typedef enum {
#if SOC_LEDC_SUPPORT_HS_MODE #if SOC_LEDC_SUPPORT_HS_MODE
LEDC_HIGH_SPEED_MODE = 0, /*!< LEDC high speed speed_mode */ LEDC_HIGH_SPEED_MODE = 0, /*!< LEDC high speed speed_mode */
-4
View File
@@ -84,10 +84,6 @@ elseif(NOT BOOTLOADER_BUILD)
list(APPEND srcs "uart_hal.c" "uart_hal_iram.c") list(APPEND srcs "uart_hal.c" "uart_hal_iram.c")
endif() endif()
if(CONFIG_SOC_LEDC_SUPPORTED)
list(APPEND srcs "ledc_hal.c" "ledc_hal_iram.c")
endif()
if(CONFIG_SOC_I3C_MASTER_SUPPORTED) if(CONFIG_SOC_I3C_MASTER_SUPPORTED)
list(APPEND srcs "i3c_master_hal.c") list(APPEND srcs "i3c_master_hal.c")
endif() endif()
-4
View File
@@ -72,10 +72,6 @@ if(CONFIG_SOC_EMAC_SUPPORTED)
list(APPEND srcs "${target_folder}/emac_periph.c") list(APPEND srcs "${target_folder}/emac_periph.c")
endif() endif()
if(CONFIG_SOC_LEDC_SUPPORTED)
list(APPEND srcs "${target_folder}/ledc_periph.c")
endif()
if(CONFIG_SOC_I3C_MASTER_SUPPORTED) if(CONFIG_SOC_I3C_MASTER_SUPPORTED)
list(APPEND srcs "${target_folder}/i3c_master_periph.c") list(APPEND srcs "${target_folder}/i3c_master_periph.c")
endif() endif()
+1 -1
View File
@@ -173,6 +173,7 @@ INPUT = \
$(PROJECT_PATH)/components/esp_hal_i2c/include/hal/i2c_types.h \ $(PROJECT_PATH)/components/esp_hal_i2c/include/hal/i2c_types.h \
$(PROJECT_PATH)/components/esp_hal_i2s/include/hal/i2s_types.h \ $(PROJECT_PATH)/components/esp_hal_i2s/include/hal/i2s_types.h \
$(PROJECT_PATH)/components/esp_hal_lcd/include/hal/lcd_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_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/esp_flash_err.h \
$(PROJECT_PATH)/components/esp_hal_mspi/include/hal/spi_flash_types.h \ $(PROJECT_PATH)/components/esp_hal_mspi/include/hal/spi_flash_types.h \
@@ -264,7 +265,6 @@ INPUT = \
$(PROJECT_PATH)/components/freertos/FreeRTOS-Kernel/include/freertos/task.h \ $(PROJECT_PATH)/components/freertos/FreeRTOS-Kernel/include/freertos/task.h \
$(PROJECT_PATH)/components/freertos/FreeRTOS-Kernel/include/freertos/timers.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/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/mcpwm_types.h \
$(PROJECT_PATH)/components/hal/include/hal/sdio_slave_types.h \ $(PROJECT_PATH)/components/hal/include/hal/sdio_slave_types.h \
$(PROJECT_PATH)/components/hal/include/hal/temperature_sensor_types.h \ $(PROJECT_PATH)/components/hal/include/hal/temperature_sensor_types.h \
+1 -4
View File
@@ -272,18 +272,15 @@ examples/peripherals/ledc:
- if: SOC_LEDC_SUPPORTED != 1 - if: SOC_LEDC_SUPPORTED != 1
depends_components: depends_components:
- esp_driver_ledc - esp_driver_ledc
- esp_hal_ledc
examples/peripherals/ledc/ledc_dimmer: examples/peripherals/ledc/ledc_dimmer:
disable: disable:
- if: SOC_ETM_SUPPORTED != 1 or SOC_LEDC_SUPPORT_ETM != 1 - if: SOC_ETM_SUPPORTED != 1 or SOC_LEDC_SUPPORT_ETM != 1
depends_components:
- esp_driver_ledc
examples/peripherals/ledc/ledc_gamma_curve_fade: examples/peripherals/ledc/ledc_gamma_curve_fade:
disable: disable:
- if: SOC_LEDC_SUPPORTED != 1 or SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED != 1 - if: SOC_LEDC_SUPPORTED != 1 or SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED != 1
depends_components:
- esp_driver_ledc
examples/peripherals/mcpwm: examples/peripherals/mcpwm:
disable: disable: