2 * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 * Copyright (C) 2003-2015 Cadence Design Systems, Inc.
4 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
6 * SPDX-License-Identifier: MIT
8 * Permission is hereby granted, free of charge, to any person obtaining a copy of
9 * this software and associated documentation files (the "Software"), to deal in
10 * the Software without restriction, including without limitation the rights to
11 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12 * the Software, and to permit persons to whom the Software is furnished to do so,
13 * subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in all
16 * copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * https://www.FreeRTOS.org
26 * https://github.com/FreeRTOS
30 /*******************************************************************************
32 * XTENSA INITIALIZATION ROUTINES CODED IN C
34 * This file contains miscellaneous Xtensa RTOS-generic initialization functions
35 * that are implemented in C.
37 *******************************************************************************/
41 #include <xtensa/xtbsp.h>
44 #include "xtensa_rtos.h"
45 #include "esp_idf_version.h"
46 #if (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 2, 0))
49 #if CONFIG_IDF_TARGET_ESP32S2
50 #include "esp32s2/clk.h"
51 #elif CONFIG_IDF_TARGET_ESP32
52 #include "esp32/clk.h"
54 #endif /* ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 2, 0) */
56 #ifdef XT_RTOS_TIMER_INT
58 unsigned _xt_tick_divisor = 0; /* cached number of cycles per tick */
60 void _xt_tick_divisor_init( void )
62 _xt_tick_divisor = esp_clk_cpu_freq() / XT_TICK_PER_SEC;
65 /* Deprecated, to be removed */
66 int xt_clock_freq( void )
68 return esp_clk_cpu_freq();
71 #endif /* XT_RTOS_TIMER_INT */