1 // Copyright 2020 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 // Configuration macros for the tokenizer module. 15 #pragma once 16 17 #include "FreeRTOS.h" 18 #include "task.h" 19 20 // Whether thread joining is enabled. By default this is disabled. 21 // 22 // We suggest only enabling this when thread joining is required to minimize 23 // the RAM and ROM cost of threads. 24 // 25 // Enabling this grows the RAM footprint of every pw::Thread as it adds 26 // a StaticEventGroup_t to every thread's pw::thread::freertos::Context. In 27 // addition, there is a minute ROM cost to construct and destroy this added 28 // object. 29 // 30 // PW_THREAD_JOINING_ENABLED gets set to this value. 31 #ifndef PW_THREAD_FREERTOS_CONFIG_JOINING_ENABLED 32 #define PW_THREAD_FREERTOS_CONFIG_JOINING_ENABLED 0 33 #endif // PW_THREAD_FREERTOS_CONFIG_JOINING_ENABLED 34 #define PW_THREAD_JOINING_ENABLED PW_THREAD_FREERTOS_CONFIG_JOINING_ENABLED 35 36 // Whether dynamic allocation for thread contexts is enabled. By default this 37 // matches the FreeRTOS configuration on whether dynamic allocations are 38 // enabled. Note that static contexts _must_ be provided if dynamic allocations 39 // are disabled. 40 #ifndef PW_THREAD_FREERTOS_CONFIG_DYNAMIC_ALLOCATION_ENABLED 41 #if configSUPPORT_DYNAMIC_ALLOCATION == 1 42 #define PW_THREAD_FREERTOS_CONFIG_DYNAMIC_ALLOCATION_ENABLED 1 43 #else 44 #define PW_THREAD_FREERTOS_CONFIG_DYNAMIC_ALLOCATION_ENABLED 0 45 #endif // configSUPPORT_DYNAMIC_ALLOCATION 46 #endif // PW_THREAD_FREERTOS_CONFIG_DYNAMIC_ALLOCATION_ENABLED 47 48 // The default stack size in words. By default this uses the minimal FreeRTOS 49 // stack size. 50 #ifndef PW_THREAD_FREERTOS_CONFIG_DEFAULT_STACK_SIZE_WORDS 51 #define PW_THREAD_FREERTOS_CONFIG_DEFAULT_STACK_SIZE_WORDS \ 52 configMINIMAL_STACK_SIZE 53 #endif // PW_THREAD_FREERTOS_CONFIG_DEFAULT_STACK_SIZE_WORDS 54 55 // The default thread priority. By default this uses the minimal FreeRTOS 56 // priority level above the idle priority. 57 #ifndef PW_THREAD_FREERTOS_CONFIG_DEFAULT_PRIORITY 58 #define PW_THREAD_FREERTOS_CONFIG_DEFAULT_PRIORITY (tskIDLE_PRIORITY + 1) 59 #endif // PW_THREAD_FREERTOS_CONFIG_DEFAULT_PRIORITY 60 61 // The maximum thread priority defined by the FreeRTOS configuration. 62 #ifndef PW_THREAD_FREERTOS_CONFIG_MAXIMUM_PRIORITY 63 #define PW_THREAD_FREERTOS_CONFIG_MAXIMUM_PRIORITY (configMAX_PRIORITIES - 1) 64 #endif // PW_THREAD_FREERTOS_CONFIG_MAXIMUM_PRIORITY 65 66 // The log level to use for this module. Logs below this level are omitted. 67 #ifndef PW_THREAD_FREERTOS_CONFIG_LOG_LEVEL 68 #define PW_THREAD_FREERTOS_CONFIG_LOG_LEVEL PW_LOG_LEVEL_DEBUG 69 #endif // PW_THREAD_FREERTOS_CONFIG_LOG_LEVEL 70 71 namespace pw::thread::freertos::config { 72 73 inline constexpr size_t kMinimumStackSizeWords = configMINIMAL_STACK_SIZE; 74 inline constexpr size_t kDefaultStackSizeWords = 75 PW_THREAD_FREERTOS_CONFIG_DEFAULT_STACK_SIZE_WORDS; 76 inline constexpr UBaseType_t kDefaultPriority = 77 PW_THREAD_FREERTOS_CONFIG_DEFAULT_PRIORITY; 78 inline constexpr UBaseType_t kMaximumPriority = 79 PW_THREAD_FREERTOS_CONFIG_MAXIMUM_PRIORITY; 80 81 } // namespace pw::thread::freertos::config 82