Files
esp-idf/components/esp_hal_systimer/rom_patch.c
T
morris 43bc8c2fe5 feat(etm): add ETM LL and GPIO ETM support on esp32s31
Enable ETM caps and add S31 ETM/GPIO LL and retention support for
GPTimer ETM builds.
2026-04-07 14:47:36 +08:00

39 lines
1.1 KiB
C

/*
* SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief ROM patch for systimer HAL
*
* Some chips have systimer HAL implementations in ROM that require patches.
* This file provides the necessary patches when ROM implementation is used.
*/
#include <stddef.h>
#include "esp_rom_caps.h"
#include "hal/systimer_hal.h"
#include "hal/systimer_ll.h"
#if !CONFIG_IDF_TARGET_ESP32C2 // esp32c2 has dedicated ROM patch
extern void rom_systimer_hal_init(systimer_hal_context_t *hal);
extern void rom_systimer_hal_deinit(systimer_hal_context_t *hal);
void systimer_hal_init(systimer_hal_context_t *hal)
{
// For chips with ROM systimer that does not enable ETM, the ROM functions are
// exposed with "rom_" prefix in rom.systimer.ld. We wrap them here to add
// the missing systimer_ll_enable_etm() call.
rom_systimer_hal_init(hal);
systimer_ll_enable_etm(&SYSTIMER, true);
}
void systimer_hal_deinit(systimer_hal_context_t *hal)
{
systimer_ll_enable_etm(&SYSTIMER, false);
rom_systimer_hal_deinit(hal);
}
#endif // !CONFIG_IDF_TARGET_ESP32C2