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 "tx_api.h" 18 19 // Whether thread joining is enabled. By default this is disabled. 20 // When enabled this adds a TX_EVENT_FLAGS_GROUP to every pw::thread::Thread's 21 // context. 22 #ifndef PW_THREAD_THREADX_CONFIG_JOINING_ENABLED 23 #define PW_THREAD_THREADX_CONFIG_JOINING_ENABLED 0 24 #endif // PW_THREAD_THREADX_CONFIG_JOINING_ENABLED 25 #define PW_THREAD_JOINING_ENABLED PW_THREAD_THREADX_CONFIG_JOINING_ENABLED 26 27 // The default stack size in words. By default this uses the minimal ThreadX 28 // stack size. 29 #ifndef PW_THREAD_THREADX_CONFIG_DEFAULT_STACK_SIZE_WORDS 30 #define PW_THREAD_THREADX_CONFIG_DEFAULT_STACK_SIZE_WORDS \ 31 TX_MINIMUM_STACK / sizeof(ULONG) 32 #endif // PW_THREAD_THREADX_CONFIG_DEFAULT_STACK_SIZE_WORDS 33 34 // The maximum length of a thread's name, not including null termination. By 35 // default this is arbitrarily set to 15. This results in an array of characters 36 // which is this length + 1 bytes in every pw::thread::Thread's context. 37 #ifndef PW_THREAD_THREADX_CONFIG_MAX_THREAD_NAME_LEN 38 #define PW_THREAD_THREADX_CONFIG_MAX_THREAD_NAME_LEN 15 39 #endif // PW_THREAD_THREADX_CONFIG_MAX_THREAD_NAME_LEN 40 41 // The round robin time slice tick interval for threads at the same priority. 42 // By default this is disabled as not all ports support this, using a value of 0 43 // ticks. 44 #ifndef PW_THREAD_THREADX_CONFIG_DEFAULT_TIME_SLICE_INTERVAL 45 #define PW_THREAD_THREADX_CONFIG_DEFAULT_TIME_SLICE_INTERVAL TX_NO_TIME_SLICE 46 #endif // PW_THREAD_THREADX_CONFIG_DEFAULT_TIME_SLICE_INTERVAL 47 48 // The minimum priority level, this is normally based on the number of priority 49 // levels. 50 #ifndef PW_THREAD_THREADX_CONFIG_MIN_PRIORITY 51 #define PW_THREAD_THREADX_CONFIG_MIN_PRIORITY TX_MAX_PRIORITIES - 1 52 #endif // PW_THREAD_THREADX_CONFIG_MIN_PRIORITY 53 54 // The default stack size in words. By default this uses the minimal ThreadX 55 // priority level, given that 0 is the highest priority. 56 #ifndef PW_THREAD_THREADX_CONFIG_DEFAULT_PRIORITY 57 #define PW_THREAD_THREADX_CONFIG_DEFAULT_PRIORITY \ 58 PW_THREAD_THREADX_CONFIG_MIN_PRIORITY 59 #endif // PW_THREAD_THREADX_CONFIG_DEFAULT_PRIORITY 60 61 namespace pw::thread::threadx::config { 62 63 inline constexpr size_t kMaximumNameLength = 64 PW_THREAD_THREADX_CONFIG_MAX_THREAD_NAME_LEN + 1; 65 inline constexpr size_t kMinimumStackSizeWords = 66 TX_MINIMUM_STACK / sizeof(ULONG); 67 inline constexpr size_t kDefaultStackSizeWords = 68 PW_THREAD_THREADX_CONFIG_DEFAULT_STACK_SIZE_WORDS; 69 inline constexpr UINT kMinimumPriority = PW_THREAD_THREADX_CONFIG_MIN_PRIORITY; 70 inline constexpr UINT kDefaultPriority = 71 PW_THREAD_THREADX_CONFIG_DEFAULT_PRIORITY; 72 inline constexpr ULONG kDefaultTimeSliceInterval = 73 PW_THREAD_THREADX_CONFIG_DEFAULT_TIME_SLICE_INTERVAL; 74 75 } // namespace pw::thread::threadx::config 76