1 // Copyright 2021 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 "RTOS.h" 18 19 // Whether thread joining is enabled. By default this is disabled. 20 // 21 // We suggest only enabling this when thread joining is required to minimize 22 // the RAM and ROM cost of threads. 23 // 24 // Enabling this grows the RAM footprint of every pw::Thread as it adds 25 // an OS_EVENT to every thread's pw::thread::embos::Context. In addition, there 26 // is a minute ROM cost to construct and destroy this added object. 27 // 28 // PW_THREAD_JOINING_ENABLED gets set to this value. 29 #ifndef PW_THREAD_EMBOS_CONFIG_JOINING_ENABLED 30 #define PW_THREAD_EMBOS_CONFIG_JOINING_ENABLED 0 31 #endif // PW_THREAD_EMBOS_CONFIG_JOINING_ENABLED 32 #define PW_THREAD_JOINING_ENABLED PW_THREAD_EMBOS_CONFIG_JOINING_ENABLED 33 34 // The minimum stack size in words. By default this uses Segger's recommendation 35 // of 68 bytes. 36 #ifndef PW_THREAD_EMBOS_CONFIG_MINIMUM_STACK_SIZE_WORDS 37 #define PW_THREAD_EMBOS_CONFIG_MINIMUM_STACK_SIZE_WORDS (68 / sizeof(OS_UINT)) 38 #endif // PW_THREAD_EMBOS_CONFIG_MINIMUM_STACK_SIZE_WORDS 39 40 // The default stack size in words. By default this uses Segger's recommendation 41 // of 256 bytes to start. 42 #ifndef PW_THREAD_EMBOS_CONFIG_DEFAULT_STACK_SIZE_WORDS 43 #define PW_THREAD_EMBOS_CONFIG_DEFAULT_STACK_SIZE_WORDS (256 / sizeof(OS_UINT)) 44 #endif // PW_THREAD_EMBOS_CONFIG_DEFAULT_STACK_SIZE_WORDS 45 46 // The maximum length of a thread's name, not including null termination. By 47 // default this is arbitrarily set to 15. This results in an array of characters 48 // which is this length + 1 bytes in every pw::Thread's context. 49 #ifndef PW_THREAD_EMBOS_CONFIG_MAX_THREAD_NAME_LEN 50 #define PW_THREAD_EMBOS_CONFIG_MAX_THREAD_NAME_LEN 15 51 #endif // PW_THREAD_EMBOS_CONFIG_MAX_THREAD_NAME_LEN 52 53 // The minimum priority level, this is normally 1, since 0 is not a valid 54 // priority level. 55 #ifndef PW_THREAD_EMBOS_CONFIG_MIN_PRIORITY 56 #define PW_THREAD_EMBOS_CONFIG_MIN_PRIORITY 1 57 #endif // PW_THREAD_EMBOS_CONFIG_MIN_PRIORITY 58 59 // The default priority level. By default this uses the minimal embOS priority. 60 #ifndef PW_THREAD_EMBOS_CONFIG_DEFAULT_PRIORITY 61 #define PW_THREAD_EMBOS_CONFIG_DEFAULT_PRIORITY \ 62 PW_THREAD_EMBOS_CONFIG_MIN_PRIORITY 63 #endif // PW_THREAD_EMBOS_CONFIG_DEFAULT_PRIORITY 64 65 // The round robin time slice tick interval for threads at the same priority. 66 // By default this is set to 2 ticks based on the embOS default. 67 #ifndef PW_THREAD_EMBOS_CONFIG_DEFAULT_TIME_SLICE_INTERVAL 68 #define PW_THREAD_EMBOS_CONFIG_DEFAULT_TIME_SLICE_INTERVAL 2 69 #endif // PW_THREAD_EMBOS_CONFIG_DEFAULT_TIME_SLICE_INTERVAL 70 71 // The log level to use for this module. Logs below this level are omitted. 72 #ifndef PW_THREAD_EMBOS_CONFIG_LOG_LEVEL 73 #define PW_THREAD_EMBOS_CONFIG_LOG_LEVEL PW_LOG_LEVEL_DEBUG 74 #endif // PW_THREAD_EMBOS_CONFIG_LOG_LEVEL 75 76 namespace pw::thread::embos::config { 77 78 inline constexpr size_t kMaximumNameLength = 79 PW_THREAD_EMBOS_CONFIG_MAX_THREAD_NAME_LEN; 80 inline constexpr size_t kMinimumStackSizeWords = 81 PW_THREAD_EMBOS_CONFIG_MINIMUM_STACK_SIZE_WORDS; 82 inline constexpr size_t kDefaultStackSizeWords = 83 PW_THREAD_EMBOS_CONFIG_DEFAULT_STACK_SIZE_WORDS; 84 inline constexpr OS_PRIO kMinimumPriority = PW_THREAD_EMBOS_CONFIG_MIN_PRIORITY; 85 inline constexpr OS_PRIO kDefaultPriority = 86 PW_THREAD_EMBOS_CONFIG_DEFAULT_PRIORITY; 87 inline constexpr OS_UINT kDefaultTimeSliceInterval = 88 PW_THREAD_EMBOS_CONFIG_DEFAULT_TIME_SLICE_INTERVAL; 89 90 } // namespace pw::thread::embos::config 91