2 * SPDX-FileCopyrightText: 2022 Amazon.com, Inc. or its affiliates
4 * SPDX-License-Identifier: MIT
6 * SPDX-FileContributor: 2016-2022 Espressif Systems (Shanghai) CO LTD
10 * FreeRTOS Kernel <DEVELOPMENT BRANCH>
11 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
13 * Permission is hereby granted, free of charge, to any person obtaining a copy of
14 * this software and associated documentation files (the "Software"), to deal in
15 * the Software without restriction, including without limitation the rights to
16 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
17 * the Software, and to permit persons to whom the Software is furnished to do so,
18 * subject to the following conditions:
20 * The above copyright notice and this permission notice shall be included in all
21 * copies or substantial portions of the Software. If you wish to use our Amazon
22 * FreeRTOS name, please do so in a fair use way that does not cause confusion.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
26 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
27 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
28 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 * https://www.FreeRTOS.org
32 * https://github.com/FreeRTOS
37 #ifndef FREERTOS_CONFIG_XTENSA_H
38 #define FREERTOS_CONFIG_XTENSA_H
40 #include "sdkconfig.h"
42 /* enable use of optimized task selection by the scheduler */
43 #if defined( CONFIG_FREERTOS_OPTIMIZED_SCHEDULER ) && !defined( configUSE_PORT_OPTIMISED_TASK_SELECTION )
44 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
47 #define XT_USE_THREAD_SAFE_CLIB 0
50 #if CONFIG_FREERTOS_CORETIMER_0
51 #define XT_TIMER_INDEX 0
52 #elif CONFIG_FREERTOS_CORETIMER_1
53 #define XT_TIMER_INDEX 1
59 * This function is defined to provide a deprecation warning whenever
60 * XT_CLOCK_FREQ macro is used.
61 * Update the code to use esp_clk_cpu_freq function instead.
62 * @return current CPU clock frequency, in Hz
64 int xt_clock_freq( void ) __attribute__( ( deprecated ) );
66 #define XT_CLOCK_FREQ ( xt_clock_freq() )
68 #endif // __ASSEMBLER__
70 /* Required for configuration-dependent settings */
71 #include <xtensa_config.h>
73 /* configASSERT behaviour */
76 #include "esp_rom_sys.h"
77 #if CONFIG_IDF_TARGET_ESP32
78 #include "esp32/rom/ets_sys.h" /* will be removed in idf v5.0 */
79 #elif CONFIG_IDF_TARGET_ESP32S2
80 #include "esp32s2/rom/ets_sys.h"
81 #elif CONFIG_IDF_TARGET_ESP32S3
82 #include "esp32s3/rom/ets_sys.h"
84 #endif // __ASSEMBLER__
86 /* If CONFIG_FREERTOS_ASSERT_DISABLE is set then configASSERT is defined empty later in FreeRTOS.h and the macro */
87 /* configASSERT_DEFINED remains unset (meaning some warnings are avoided) */
90 #if defined( CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE )
91 #define configASSERT( a ) \
92 if( unlikely( !( a ) ) ) { \
93 esp_rom_printf( "%s:%d (%s)- assert failed!\n", __FILE__, __LINE__, \
96 #elif defined( CONFIG_FREERTOS_ASSERT_FAIL_ABORT )
97 #define configASSERT( a ) assert( a )
99 #endif /* ifdef configASSERT */
101 #if CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION
102 #define UNTESTED_FUNCTION() \
103 { esp_rom_printf( "Untested FreeRTOS function %s\r\n", __FUNCTION__ ); configASSERT( false ); } \
106 #define UNTESTED_FUNCTION()
109 #define configXT_BOARD 1 /* Board mode */
110 #define configXT_SIMULATOR 0
112 /* The maximum interrupt priority from which FreeRTOS.org API functions can
113 * be called. Only API functions that end in ...FromISR() can be used within
115 #define configMAX_SYSCALL_INTERRUPT_PRIORITY XCHAL_EXCM_LEVEL
117 /* Stack alignment, architecture specific. Must be a power of two. */
118 #define configSTACK_ALIGNMENT 16
121 /* The Xtensa port uses a separate interrupt stack. Adjust the stack size
122 * to suit the needs of your specific application.
123 * Size needs to be aligned to the stack increment, since the location of
124 * the stack for the 2nd CPU will be calculated using configISR_STACK_SIZE.
126 #ifndef configISR_STACK_SIZE
127 #define configISR_STACK_SIZE ( ( CONFIG_FREERTOS_ISR_STACKSIZE + configSTACK_ALIGNMENT - 1 ) & ( ~( configSTACK_ALIGNMENT - 1 ) ) )
130 #ifndef __ASSEMBLER__
131 #if CONFIG_APPTRACE_SV_ENABLE
132 extern uint32_t port_switch_flag[];
133 #define os_task_switch_is_pended( _cpu_ ) ( port_switch_flag[ _cpu_ ] )
135 #define os_task_switch_is_pended( _cpu_ ) ( false )
139 #endif // FREERTOS_CONFIG_XTENSA_H