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 // When enabled this adds a StaticEventGroup_t & EventGroupHandle_t to
22 // every pw::thread::Thread's context.
23 #ifndef PW_THREAD_FREERTOS_CONFIG_JOINING_ENABLED
24 #define PW_THREAD_FREERTOS_CONFIG_JOINING_ENABLED 0
25 #endif  // PW_THREAD_FREERTOS_CONFIG_JOINING_ENABLED
26 #define PW_THREAD_JOINING_ENABLED PW_THREAD_FREERTOS_CONFIG_JOINING_ENABLED
27 
28 // Whether dynamic allocation for thread contexts is enabled. By default this
29 // matches the FreeRTOS configuration on whether dynamic allocations are
30 // enabled. Note that static contexts _must_ be provided if dynamic allocations
31 // are disabled.
32 #ifndef PW_THREAD_FREERTOS_CONFIG_DYNAMIC_ALLOCATION_ENABLED
33 #if configSUPPORT_DYNAMIC_ALLOCATION == 1
34 #define PW_THREAD_FREERTOS_CONFIG_DYNAMIC_ALLOCATION_ENABLED 1
35 #else
36 #define PW_THREAD_FREERTOS_CONFIG_DYNAMIC_ALLOCATION_ENABLED 0
37 #endif  // configSUPPORT_DYNAMIC_ALLOCATION
38 #endif  // PW_THREAD_FREERTOS_CONFIG_DYNAMIC_ALLOCATION_ENABLED
39 
40 // The default stack size in words. By default this uses the minimal FreeRTOS
41 // stack size.
42 #ifndef PW_THREAD_FREERTOS_CONFIG_DEFAULT_STACK_SIZE_WORDS
43 #define PW_THREAD_FREERTOS_CONFIG_DEFAULT_STACK_SIZE_WORDS \
44   configMINIMAL_STACK_SIZE
45 #endif  // PW_THREAD_FREERTOS_CONFIG_DEFAULT_STACK_SIZE_WORDS
46 
47 // The default stack size in words. By default this uses the minimal FreeRTOS
48 // priority level above the idle priority.
49 #ifndef PW_THREAD_FREERTOS_CONFIG_DEFAULT_PRIORITY
50 #define PW_THREAD_FREERTOS_CONFIG_DEFAULT_PRIORITY tskIDLE_PRIORITY + 1
51 #endif  // PW_THREAD_FREERTOS_CONFIG_DEFAULT_PRIORITY
52 
53 namespace pw::thread::freertos::config {
54 
55 inline constexpr size_t kMinimumStackSizeWords = configMINIMAL_STACK_SIZE;
56 inline constexpr size_t kDefaultStackSizeWords =
57     PW_THREAD_FREERTOS_CONFIG_DEFAULT_STACK_SIZE_WORDS;
58 inline constexpr UBaseType_t kDefaultPriority =
59     PW_THREAD_FREERTOS_CONFIG_DEFAULT_PRIORITY;
60 
61 }  // namespace pw::thread::freertos::config
62