Przeglądaj źródła

Power Management: move lp_timer_hal.c to upper hal layer for esp32h2 and esp32c6

Lou Tianhao 2 lat temu
rodzic
commit
01fb28b65b

+ 1 - 5
components/hal/CMakeLists.txt

@@ -30,10 +30,6 @@ if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
     endif()
 endif()
 
-if(${target} STREQUAL "esp32c6")
-    list(APPEND srcs "esp32c6/lp_timer_hal.c")
-endif()
-
 if(NOT BOOTLOADER_BUILD)
     list(APPEND srcs
         "rtc_io_hal.c"
@@ -143,7 +139,7 @@ if(NOT BOOTLOADER_BUILD)
     endif()
 
     if(CONFIG_SOC_LP_TIMER_SUPPORTED)
-        list(APPEND srcs "${target}/lp_timer_hal.c")
+        list(APPEND srcs "lp_timer_hal.c")
     endif()
 
     if(CONFIG_SOC_PAU_SUPPORTED)

+ 0 - 45
components/hal/esp32h2/include/hal/lp_timer_hal.h

@@ -1,45 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-#pragma once
-
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include "soc/soc.h"
-#include "hal/lp_timer_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * @brief set alarm target value
- *
- * @param timer_id timer num of lp_timer, 0 or 1 for esp32h2
- *
- * @param value when counter reaches alarm value, alarm event will be triggered
- */
-void lp_timer_hal_set_alarm_target(uint8_t timer_id, uint64_t value);
-
-/**
- * @brief get current counter value
- */
-uint64_t lp_timer_hal_get_cycle_count(void);
-
-/**
- * @brief clear alarm interrupt status
- */
-void lp_timer_hal_clear_alarm_intr_status(void);
-
-/**
- * @brief clear overflow interrupt status
- */
-void lp_timer_hal_clear_overflow_intr_status(void);
-
-#ifdef __cplusplus
-}
-#endif

+ 0 - 46
components/hal/esp32h2/lp_timer_hal.c

@@ -1,46 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <esp_types.h>
-#include "sdkconfig.h"
-#include "esp_attr.h"
-#include "soc/soc.h"
-#include "hal/lp_timer_ll.h"
-
-static DRAM_ATTR struct {
-    lp_timer_dev_t *dev;
-} lp_timer_context = { .dev = &LP_TIMER };
-
-void IRAM_ATTR lp_timer_hal_set_alarm_target(uint8_t timer_id, uint64_t value)
-{
-    lp_timer_ll_clear_alarm_intr_status(lp_timer_context.dev);
-    lp_timer_ll_set_alarm_target(lp_timer_context.dev, timer_id, value);
-    lp_timer_ll_set_target_enable(lp_timer_context.dev, timer_id, true);
-}
-
-uint64_t IRAM_ATTR lp_timer_hal_get_cycle_count(void)
-{
-    lp_timer_ll_counter_snapshot(lp_timer_context.dev);
-    uint32_t lo = lp_timer_ll_get_counter_value_low(lp_timer_context.dev, 0);
-    uint32_t hi = lp_timer_ll_get_counter_value_high(lp_timer_context.dev, 0);
-    lp_timer_counter_value_t result = {
-        .lo = lo,
-        .hi = hi
-    };
-    return result.val;
-}
-
-void IRAM_ATTR lp_timer_hal_clear_alarm_intr_status(void)
-{
-    lp_timer_ll_clear_alarm_intr_status(lp_timer_context.dev);
-}
-
-void IRAM_ATTR lp_timer_hal_clear_overflow_intr_status(void)
-{
-    lp_timer_ll_clear_overflow_intr_status(lp_timer_context.dev);
-}

+ 1 - 2
components/hal/esp32c6/include/hal/lp_timer_hal.h → components/hal/include/hal/lp_timer_hal.h

@@ -19,7 +19,7 @@ extern "C" {
 /*
  * @brief set alarm target value
  *
- * @param timer_id timer num of lp_timer, 0 or 1 for esp32c6
+ * @param timer_id timer num of lp_timer, 0 or 1 for esp32c6 and esp32h2
  *
  * @param value when counter reaches alarm value, alarm event will be triggered
  */
@@ -27,7 +27,6 @@ void lp_timer_hal_set_alarm_target(uint8_t timer_id, uint64_t value);
 
 /**
  * @brief get current counter value
- *
  */
 uint64_t lp_timer_hal_get_cycle_count(void);
 

+ 0 - 0
components/hal/esp32c6/lp_timer_hal.c → components/hal/lp_timer_hal.c