1 /* 2 * SPDX-FileCopyrightText: 2022 Amazon.com, Inc. or its affiliates 3 * 4 * SPDX-License-Identifier: MIT 5 * 6 * SPDX-FileContributor: 2016-2022 Espressif Systems (Shanghai) CO LTD 7 */ 8 9 /* 10 * FreeRTOS Kernel V11.1.0 11 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 12 * 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: 19 * 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. 23 * 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. 30 * 31 * https://www.FreeRTOS.org 32 * https://github.com/FreeRTOS 33 * 34 * 1 tab == 4 spaces! 35 */ 36 37 #ifndef FREERTOS_CONFIG_XTENSA_H 38 #define FREERTOS_CONFIG_XTENSA_H 39 40 #include "sdkconfig.h" 41 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 45 #endif 46 47 #define XT_USE_THREAD_SAFE_CLIB 0 48 #undef XT_USE_SWPRI 49 50 #if CONFIG_FREERTOS_CORETIMER_0 51 #define XT_TIMER_INDEX 0 52 #elif CONFIG_FREERTOS_CORETIMER_1 53 #define XT_TIMER_INDEX 1 54 #endif 55 56 #ifndef __ASSEMBLER__ 57 58 /** 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 63 */ 64 int xt_clock_freq( void ) __attribute__( ( deprecated ) ); 65 66 #define XT_CLOCK_FREQ ( xt_clock_freq() ) 67 68 #endif // __ASSEMBLER__ 69 70 /* Required for configuration-dependent settings */ 71 #include <xtensa_config.h> 72 73 /* configASSERT behaviour */ 74 #ifndef __ASSEMBLER__ 75 #include <assert.h> 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" 83 #endif 84 #endif // __ASSEMBLER__ 85 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) */ 88 #ifdef configASSERT 89 #undef configASSERT 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__, \ 94 __FUNCTION__ ); \ 95 } 96 #elif defined( CONFIG_FREERTOS_ASSERT_FAIL_ABORT ) 97 #define configASSERT( a ) assert( a ) 98 #endif 99 #endif /* ifdef configASSERT */ 100 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 ); } \ 104 while( 0 ) 105 #else 106 #define UNTESTED_FUNCTION() 107 #endif 108 109 #define configXT_BOARD 1 /* Board mode */ 110 #define configXT_SIMULATOR 0 111 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 114 * interrupts. */ 115 #define configMAX_SYSCALL_INTERRUPT_PRIORITY XCHAL_EXCM_LEVEL 116 117 /* Stack alignment, architecture specifc. Must be a power of two. */ 118 #define configSTACK_ALIGNMENT 16 119 120 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. 125 */ 126 #ifndef configISR_STACK_SIZE 127 #define configISR_STACK_SIZE ( ( CONFIG_FREERTOS_ISR_STACKSIZE + configSTACK_ALIGNMENT - 1 ) & ( ~( configSTACK_ALIGNMENT - 1 ) ) ) 128 #endif 129 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_ ] ) 134 #else 135 #define os_task_switch_is_pended( _cpu_ ) ( false ) 136 #endif 137 #endif 138 139 #endif // FREERTOS_CONFIG_XTENSA_H 140