1 /* 2 * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include "stubs.h" 8 #include "esp_private/systimer.h" 9 10 /** 11 * @brief systimer's clock source is fixed to XTAL (40MHz/26MHz), and has a fixed fractional divider (2.5). 12 * So the resolution of the systimer is 40MHz/2.5 = 16MHz, or 26MHz/2.5 = 10.4MHz. 13 */ 14 15 #if CONFIG_XTAL_FREQ == 40 systimer_ticks_to_us(uint64_t ticks)16uint64_t systimer_ticks_to_us(uint64_t ticks) 17 { 18 return ticks / 16; 19 } 20 systimer_us_to_ticks(uint64_t us)21uint64_t systimer_us_to_ticks(uint64_t us) 22 { 23 return us * 16; 24 } 25 #elif CONFIG_XTAL_FREQ == 26 systimer_ticks_to_us(uint64_t ticks)26uint64_t systimer_ticks_to_us(uint64_t ticks) 27 { 28 return ticks * 5 / 52; 29 } 30 systimer_us_to_ticks(uint64_t us)31uint64_t systimer_us_to_ticks(uint64_t us) 32 { 33 return us * 52 / 5; 34 } 35 #else 36 #error "Unsupported XTAL frequency by systimer" 37 #endif 38