/* * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once #include "esp_err.h" #include "esp_attr.h" #include "soc/soc.h" #include "soc/soc_caps.h" #include "soc/timer_periph.h" #include "esp_intr_alloc.h" #include "hal/timer_types.h" #ifdef __cplusplus extern "C" { #endif /** * @brief Frequency of the clock on the input of the timer groups * @note This macro is not correct for Timer Groups with multiple clock sources (e.g. APB, XTAL) * So please don't use it in your application, we keep it here only for backward compatible */ #define TIMER_BASE_CLK (APB_CLK_FREQ) /** * @brief Selects a Timer-Group out of 2 available groups */ typedef enum { TIMER_GROUP_0 = 0, /*!< Hw timer group 0 */ #if SOC_TIMER_GROUPS > 1 TIMER_GROUP_1 = 1, /*!< Hw timer group 1 */ #endif TIMER_GROUP_MAX /*!< Maximum number of Hw timer groups */ } timer_group_t; /** * @brief Select a hardware timer from timer groups */ typedef enum { TIMER_0 = 0, /*! 1 TIMER_INTR_T1 = 1 << 1, /*!< interrupt of timer 1 */ TIMER_INTR_WDT = 1 << 2, /*!< interrupt of watchdog */ #else TIMER_INTR_WDT = 1 << 1, /*!< interrupt of watchdog */ #endif TIMER_INTR_NONE = 0 } timer_intr_t; FLAG_ATTR(timer_intr_t) /** * @brief Decides the direction of counter */ typedef enum { TIMER_COUNT_DOWN = GPTIMER_COUNT_DOWN, /*!< Descending Count from cnt.high|cnt.low*/ TIMER_COUNT_UP = GPTIMER_COUNT_UP, /*!< Ascending Count from Zero*/ TIMER_COUNT_MAX /*!< Maximum number of timer count directions */ } timer_count_dir_t; /** * @brief Decides whether timer is on or paused */ typedef enum { TIMER_PAUSE, /*!