• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 //
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::Thread as it adds
25 // a TX_EVENT_FLAGS_GROUP to every thread's pw::thread::threadx::Context. In
26 // addition, there is a minute ROM cost to construct and destroy this added
27 // object.
28 //
29 // PW_THREAD_JOINING_ENABLED gets set to this value.
30 #ifndef PW_THREAD_THREADX_CONFIG_JOINING_ENABLED
31 #define PW_THREAD_THREADX_CONFIG_JOINING_ENABLED 0
32 #endif  // PW_THREAD_THREADX_CONFIG_JOINING_ENABLED
33 #define PW_THREAD_JOINING_ENABLED PW_THREAD_THREADX_CONFIG_JOINING_ENABLED
34 
35 // The default stack size in words. By default this uses the minimal ThreadX
36 // stack size.
37 #ifndef PW_THREAD_THREADX_CONFIG_DEFAULT_STACK_SIZE_WORDS
38 #define PW_THREAD_THREADX_CONFIG_DEFAULT_STACK_SIZE_WORDS \
39   (TX_MINIMUM_STACK / sizeof(ULONG))
40 #endif  // PW_THREAD_THREADX_CONFIG_DEFAULT_STACK_SIZE_WORDS
41 
42 // The maximum length of a thread's name, not including null termination. By
43 // default this is arbitrarily set to 15. This results in an array of characters
44 // which is this length + 1 bytes in every pw::thread::Thread's context.
45 #ifndef PW_THREAD_THREADX_CONFIG_MAX_THREAD_NAME_LEN
46 #define PW_THREAD_THREADX_CONFIG_MAX_THREAD_NAME_LEN 15
47 #endif  // PW_THREAD_THREADX_CONFIG_MAX_THREAD_NAME_LEN
48 
49 // The round robin time slice tick interval for threads at the same priority.
50 // By default this is disabled as not all ports support this, using a value of 0
51 // ticks.
52 #ifndef PW_THREAD_THREADX_CONFIG_DEFAULT_TIME_SLICE_INTERVAL
53 #define PW_THREAD_THREADX_CONFIG_DEFAULT_TIME_SLICE_INTERVAL TX_NO_TIME_SLICE
54 #endif  // PW_THREAD_THREADX_CONFIG_DEFAULT_TIME_SLICE_INTERVAL
55 
56 // The minimum priority level, this is normally based on the number of priority
57 // levels.
58 #ifndef PW_THREAD_THREADX_CONFIG_MIN_PRIORITY
59 #define PW_THREAD_THREADX_CONFIG_MIN_PRIORITY (TX_MAX_PRIORITIES - 1)
60 #endif  // PW_THREAD_THREADX_CONFIG_MIN_PRIORITY
61 
62 // The default priority level. By default this uses the minimal ThreadX
63 // priority level, given that 0 is the highest priority.
64 #ifndef PW_THREAD_THREADX_CONFIG_DEFAULT_PRIORITY
65 #define PW_THREAD_THREADX_CONFIG_DEFAULT_PRIORITY \
66   PW_THREAD_THREADX_CONFIG_MIN_PRIORITY
67 #endif  // PW_THREAD_THREADX_CONFIG_DEFAULT_PRIORITY
68 
69 // The log level to use for this module. Logs below this level are omitted.
70 #ifndef PW_THREAD_THREADX_CONFIG_LOG_LEVEL
71 #define PW_THREAD_THREADX_CONFIG_LOG_LEVEL PW_LOG_LEVEL_DEBUG
72 #endif  // PW_THREAD_THREADX_CONFIG_LOG_LEVEL
73 
74 namespace pw::thread::threadx::config {
75 
76 inline constexpr size_t kMaximumNameLength =
77     PW_THREAD_THREADX_CONFIG_MAX_THREAD_NAME_LEN;
78 inline constexpr size_t kMinimumStackSizeWords =
79     TX_MINIMUM_STACK / sizeof(ULONG);
80 inline constexpr size_t kDefaultStackSizeWords =
81     PW_THREAD_THREADX_CONFIG_DEFAULT_STACK_SIZE_WORDS;
82 inline constexpr UINT kMinimumPriority = PW_THREAD_THREADX_CONFIG_MIN_PRIORITY;
83 inline constexpr UINT kDefaultPriority =
84     PW_THREAD_THREADX_CONFIG_DEFAULT_PRIORITY;
85 inline constexpr ULONG kDefaultTimeSliceInterval =
86     PW_THREAD_THREADX_CONFIG_DEFAULT_TIME_SLICE_INTERVAL;
87 
88 }  // namespace pw::thread::threadx::config
89