]> begriffs open source - freertos/blob - portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_init.c
Cleanup license text in Xtensa XCC and Xtensa ESP32 GCC ports.
[freertos] / portable / ThirdParty / GCC / Xtensa_ESP32 / xtensa_init.c
1 /*
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.
5  *
6  * SPDX-License-Identifier: MIT
7  *
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:
14  *
15  * The above copyright notice and this permission notice shall be included in all
16  * copies or substantial portions of the Software.
17  *
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.
24  *
25  * https://www.FreeRTOS.org
26  * https://github.com/FreeRTOS
27  *
28  */
29
30 /*******************************************************************************
31 *
32 *       XTENSA INITIALIZATION ROUTINES CODED IN C
33 *
34 *  This file contains miscellaneous Xtensa RTOS-generic initialization functions
35 *  that are implemented in C.
36 *
37 *******************************************************************************/
38
39
40 #ifdef XT_BOARD
41     #include    <xtensa/xtbsp.h>
42 #endif
43
44 #include    "xtensa_rtos.h"
45 #include "esp_idf_version.h"
46 #if (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 2, 0))
47 #include    "esp_clk.h"
48 #else
49 #if CONFIG_IDF_TARGET_ESP32S2
50 #include    "esp32s2/clk.h"
51 #elif CONFIG_IDF_TARGET_ESP32
52 #include    "esp32/clk.h"
53 #endif
54 #endif /* ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 2, 0) */
55
56 #ifdef XT_RTOS_TIMER_INT
57
58     unsigned _xt_tick_divisor = 0; /* cached number of cycles per tick */
59
60     void _xt_tick_divisor_init( void )
61     {
62         _xt_tick_divisor = esp_clk_cpu_freq() / XT_TICK_PER_SEC;
63     }
64
65 /* Deprecated, to be removed */
66     int xt_clock_freq( void )
67     {
68         return esp_clk_cpu_freq();
69     }
70
71 #endif /* XT_RTOS_TIMER_INT */