/* * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */#pragmaonce#include<stdint.h>#include<stdatomic.h>#include"sdkconfig.h"#include"soc/soc_caps.h"#include"freertos/FreeRTOS.h"#include"esp_err.h"#include"esp_intr_alloc.h"#include"esp_heap_caps.h"#include"clk_ctrl_os.h"#include"esp_pm.h"#include"soc/timer_periph.h"#include"hal/timer_types.h"#include"hal/timer_hal.h"#include"hal/timer_ll.h"#include"esp_private/sleep_retention.h"#include"esp_private/periph_ctrl.h"16 includes#ifdef__cplusplusextern"C"{#endif// If ISR handler is allowed to run whilst cache is disabled,// Make sure all the code and related variables used by the handler are in the SRAM#ifCONFIG_GPTIMER_ISR_IRAM_SAFE||CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM#defineGPTIMER_MEM_ALLOC_CAPS(MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT)#else#defineGPTIMER_MEM_ALLOC_CAPSMALLOC_CAP_DEFAULT#endif#ifCONFIG_GPTIMER_ISR_IRAM_SAFE#defineGPTIMER_INTR_ALLOC_FLAGS(ESP_INTR_FLAG_IRAM|ESP_INTR_FLAG_INTRDISABLED)#else#defineGPTIMER_INTR_ALLOC_FLAGSESP_INTR_FLAG_INTRDISABLED#endif#defineGPTIMER_ALLOW_INTR_PRIORITY_MASKESP_INTR_FLAG_LOWMED#defineGPTIMER_PM_LOCK_NAME_LEN_MAX16#defineGPTIMER_USE_RETENTION_LINK(SOC_TIMER_SUPPORT_SLEEP_RETENTION&&CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP)#ifSOC_PERIPH_CLK_CTRL_SHARED#defineGPTIMER_CLOCK_SRC_ATOMIC()PERIPH_RCC_ATOMIC()#else#defineGPTIMER_CLOCK_SRC_ATOMIC()#endiftypedefstructgptimer_tgptimer_t;typedefstructgptimer_group_t{intgroup_id;portMUX_TYPEspinlock;// to protect per-group register level concurrent accessgptimer_t*timers[SOC_TIMER_GROUP_TIMERS_PER_GROUP];}{ ... }gptimer_group_t;typedefenum{GPTIMER_FSM_INIT,// Timer is initialized, but not enabledGPTIMER_FSM_ENABLE,// Timer is enabled, but is not runningGPTIMER_FSM_ENABLE_WAIT,// Timer is in the middle of the enable process (Intermediate state)GPTIMER_FSM_RUN,// Timer is in runningGPTIMER_FSM_RUN_WAIT,// Timer is in the middle of the run process (Intermediate state)}{ ... }gptimer_fsm_t;structgptimer_t{gptimer_group_t*group;inttimer_id;uint32_tresolution_hz;uint64_treload_count;uint64_talarm_count;gptimer_count_direction_tdirection;timer_hal_context_thal;_Atomicgptimer_fsm_tfsm;intintr_priority;intr_handle_tintr;portMUX_TYPEspinlock;// to protect per-timer resources concurrent accessed by task and ISR handlergptimer_alarm_cb_ton_alarm;void*user_ctx;gptimer_clock_source_tclk_src;esp_pm_lock_handle_tpm_lock;// power management lock#ifCONFIG_PM_ENABLEcharpm_lock_name[GPTIMER_PM_LOCK_NAME_LEN_MAX];// pm lock name#endifstruct{uint32_tintr_shared:1;uint32_tauto_reload_on_alarm:1;uint32_talarm_en:1;}{ ... }flags;}{ ... };gptimer_group_t*gptimer_acquire_group_handle(intgroup_id);voidgptimer_release_group_handle(gptimer_group_t*group);esp_err_tgptimer_select_periph_clock(gptimer_t*timer,gptimer_clock_source_tsrc_clk,uint32_tresolution_hz);#ifdef__cplusplus}{...}#endif
Details
Show: from
Types: Columns:
All items filtered out
All items filtered out
This file uses the notable symbols shown below. Click anywhere in the file to view more details.