2 ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
18 * @file templates/chconf.h
19 * @brief Configuration file template.
20 * @details A copy of this file must be placed in each project directory, it
21 * contains the application specific kernel settings.
24 * @details Kernel related settings and hooks.
31 /*===========================================================================*/
33 * @name System timers settings
36 /*===========================================================================*/
39 * @brief System time counter resolution.
40 * @note Allowed values are 16 or 32 bits.
42 #define CH_CFG_ST_RESOLUTION 16
45 * @brief System tick frequency.
46 * @details Frequency of the system timer that drives the system ticks. This
47 * setting also defines the system tick time unit.
49 #define CH_CFG_ST_FREQUENCY 2000
52 * @brief Time delta constant for the tick-less mode.
53 * @note If this value is zero then the system uses the classic
54 * periodic tick. This value represents the minimum number
55 * of ticks that is safe to specify in a timeout directive.
56 * The value one is not valid, timeouts are rounded up to
59 #define CH_CFG_ST_TIMEDELTA 2
63 /*===========================================================================*/
65 * @name Kernel parameters and options
68 /*===========================================================================*/
71 * @brief Round robin interval.
72 * @details This constant is the number of system ticks allowed for the
73 * threads before preemption occurs. Setting this value to zero
74 * disables the preemption for threads with equal priority and the
75 * round robin becomes cooperative. Note that higher priority
76 * threads can still preempt, the kernel is always preemptive.
77 * @note Disabling the round robin preemption makes the kernel more compact
78 * and generally faster.
79 * @note The round robin preemption is not supported in tickless mode and
80 * must be set to zero in that case.
82 #define CH_CFG_TIME_QUANTUM 0
85 * @brief Managed RAM size.
86 * @details Size of the RAM area to be managed by the OS. If set to zero
87 * then the whole available RAM is used. The core memory is made
88 * available to the heap allocator and/or can be used directly through
89 * the simplified core memory allocator.
91 * @note In order to let the OS manage the whole RAM the linker script must
92 * provide the @p __heap_base__ and @p __heap_end__ symbols.
93 * @note Requires @p CH_CFG_USE_MEMCORE.
95 #define CH_CFG_MEMCORE_SIZE 0
98 * @brief Idle thread automatic spawn suppression.
99 * @details When this option is activated the function @p chSysInit()
100 * does not spawn the idle thread. The application @p main()
101 * function becomes the idle thread and must implement an
104 #define CH_CFG_NO_IDLE_THREAD FALSE
106 /* Use __WFI in the idle thread for waiting. Does lower the power
108 #define CORTEX_ENABLE_WFI_IDLE TRUE
112 /*===========================================================================*/
114 * @name Performance options
117 /*===========================================================================*/
120 * @brief OS optimization.
121 * @details If enabled then time efficient rather than space efficient code
122 * is used when two possible implementations exist.
124 * @note This is not related to the compiler optimization options.
125 * @note The default is @p TRUE.
127 #define CH_CFG_OPTIMIZE_SPEED TRUE
131 /*===========================================================================*/
133 * @name Subsystem options
136 /*===========================================================================*/
139 * @brief Time Measurement APIs.
140 * @details If enabled then the time measurement APIs are included in
143 * @note The default is @p TRUE.
145 #define CH_CFG_USE_TM FALSE
148 * @brief Threads registry APIs.
149 * @details If enabled then the registry APIs are included in the kernel.
151 * @note The default is @p TRUE.
153 #define CH_CFG_USE_REGISTRY TRUE
156 * @brief Threads synchronization APIs.
157 * @details If enabled then the @p chThdWait() function is included in
160 * @note The default is @p TRUE.
162 #define CH_CFG_USE_WAITEXIT TRUE
165 * @brief Semaphores APIs.
166 * @details If enabled then the Semaphores APIs are included in the kernel.
168 * @note The default is @p TRUE.
170 #define CH_CFG_USE_SEMAPHORES TRUE
173 * @brief Semaphores queuing mode.
174 * @details If enabled then the threads are enqueued on semaphores by
175 * priority rather than in FIFO order.
177 * @note The default is @p FALSE. Enable this if you have special
179 * @note Requires @p CH_CFG_USE_SEMAPHORES.
181 #define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
184 * @brief Mutexes APIs.
185 * @details If enabled then the mutexes APIs are included in the kernel.
187 * @note The default is @p TRUE.
189 #define CH_CFG_USE_MUTEXES TRUE
192 * @brief Enables recursive behavior on mutexes.
193 * @note Recursive mutexes are heavier and have an increased
196 * @note The default is @p FALSE.
197 * @note Requires @p CH_CFG_USE_MUTEXES.
199 #define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
202 * @brief Conditional Variables APIs.
203 * @details If enabled then the conditional variables APIs are included
206 * @note The default is @p TRUE.
207 * @note Requires @p CH_CFG_USE_MUTEXES.
209 #define CH_CFG_USE_CONDVARS TRUE
212 * @brief Conditional Variables APIs with timeout.
213 * @details If enabled then the conditional variables APIs with timeout
214 * specification are included in the kernel.
216 * @note The default is @p TRUE.
217 * @note Requires @p CH_CFG_USE_CONDVARS.
219 #define CH_CFG_USE_CONDVARS_TIMEOUT FALSE
222 * @brief Events Flags APIs.
223 * @details If enabled then the event flags APIs are included in the kernel.
225 * @note The default is @p TRUE.
227 #define CH_CFG_USE_EVENTS TRUE
230 * @brief Events Flags APIs with timeout.
231 * @details If enabled then the events APIs with timeout specification
232 * are included in the kernel.
234 * @note The default is @p TRUE.
235 * @note Requires @p CH_CFG_USE_EVENTS.
237 #define CH_CFG_USE_EVENTS_TIMEOUT TRUE
240 * @brief Synchronous Messages APIs.
241 * @details If enabled then the synchronous messages APIs are included
244 * @note The default is @p TRUE.
246 #define CH_CFG_USE_MESSAGES TRUE
249 * @brief Synchronous Messages queuing mode.
250 * @details If enabled then messages are served by priority rather than in
253 * @note The default is @p FALSE. Enable this if you have special
255 * @note Requires @p CH_CFG_USE_MESSAGES.
257 #define CH_CFG_USE_MESSAGES_PRIORITY FALSE
260 * @brief Mailboxes APIs.
261 * @details If enabled then the asynchronous messages (mailboxes) APIs are
262 * included in the kernel.
264 * @note The default is @p TRUE.
265 * @note Requires @p CH_CFG_USE_SEMAPHORES.
267 #define CH_CFG_USE_MAILBOXES TRUE
270 * @brief I/O Queues APIs.
271 * @details If enabled then the I/O queues APIs are included in the kernel.
273 * @note The default is @p TRUE.
275 #define CH_CFG_USE_QUEUES TRUE
278 * @brief Core Memory Manager APIs.
279 * @details If enabled then the core memory manager APIs are included
282 * @note The default is @p TRUE.
284 #define CH_CFG_USE_MEMCORE TRUE
287 * @brief Heap Allocator APIs.
288 * @details If enabled then the memory heap allocator APIs are included
291 * @note The default is @p TRUE.
292 * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
293 * @p CH_CFG_USE_SEMAPHORES.
294 * @note Mutexes are recommended.
296 #define CH_CFG_USE_HEAP TRUE
299 * @brief Memory Pools Allocator APIs.
300 * @details If enabled then the memory pools allocator APIs are included
303 * @note The default is @p TRUE.
305 #define CH_CFG_USE_MEMPOOLS FALSE
308 * @brief Dynamic Threads APIs.
309 * @details If enabled then the dynamic threads creation APIs are included
312 * @note The default is @p TRUE.
313 * @note Requires @p CH_CFG_USE_WAITEXIT.
314 * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
316 #define CH_CFG_USE_DYNAMIC FALSE
320 /*===========================================================================*/
322 * @name Debug options
325 /*===========================================================================*/
328 * @brief Debug option, kernel statistics.
330 * @note The default is @p FALSE.
332 #define CH_DBG_STATISTICS FALSE
335 * @brief Debug option, system state check.
336 * @details If enabled the correct call protocol for system APIs is checked
339 * @note The default is @p FALSE.
341 #define CH_DBG_SYSTEM_STATE_CHECK FALSE
344 * @brief Debug option, parameters checks.
345 * @details If enabled then the checks on the API functions input
346 * parameters are activated.
348 * @note The default is @p FALSE.
350 #define CH_DBG_ENABLE_CHECKS FALSE
353 * @brief Debug option, consistency checks.
354 * @details If enabled then all the assertions in the kernel code are
355 * activated. This includes consistency checks inside the kernel,
356 * runtime anomalies and port-defined checks.
358 * @note The default is @p FALSE.
360 #define CH_DBG_ENABLE_ASSERTS FALSE
363 * @brief Debug option, trace buffer.
364 * @details If enabled then the context switch circular trace buffer is
367 * @note The default is @p FALSE.
369 #define CH_DBG_ENABLE_TRACE FALSE
372 * @brief Debug option, stack checks.
373 * @details If enabled then a runtime stack check is performed.
375 * @note The default is @p FALSE.
376 * @note The stack check is performed in a architecture/port dependent way.
377 * It may not be implemented or some ports.
378 * @note The default failure mode is to halt the system with the global
379 * @p panic_msg variable set to @p NULL.
381 #define CH_DBG_ENABLE_STACK_CHECK FALSE
384 * @brief Debug option, stacks initialization.
385 * @details If enabled then the threads working area is filled with a byte
386 * value when a thread is created. This can be useful for the
387 * runtime measurement of the used stack.
389 * @note The default is @p FALSE.
391 #define CH_DBG_FILL_THREADS FALSE
394 * @brief Debug option, threads profiling.
395 * @details If enabled then a field is added to the @p thread_t structure that
396 * counts the system ticks occurred while executing the thread.
398 * @note The default is @p FALSE.
399 * @note This debug option is not currently compatible with the
402 #define CH_DBG_THREADS_PROFILING FALSE
406 /*===========================================================================*/
411 /*===========================================================================*/
414 * @brief Threads descriptor structure extension.
415 * @details User fields added to the end of the @p thread_t structure.
417 #define CH_CFG_THREAD_EXTRA_FIELDS \
418 /* Add threads custom fields here.*/
421 * @brief Threads initialization hook.
422 * @details User initialization code added to the @p chThdInit() API.
424 * @note It is invoked from within @p chThdInit() and implicitly from all
425 * the threads creation APIs.
427 #define CH_CFG_THREAD_INIT_HOOK(tp) { \
428 /* Add threads initialization code here.*/ \
432 * @brief Threads finalization hook.
433 * @details User finalization code added to the @p chThdExit() API.
435 * @note It is inserted into lock zone.
436 * @note It is also invoked when the threads simply return in order to
439 #define CH_CFG_THREAD_EXIT_HOOK(tp) { \
440 /* Add threads finalization code here.*/ \
444 * @brief Context switch hook.
445 * @details This hook is invoked just before switching between threads.
447 #define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
448 /* Context switch code here.*/ \
452 * @brief Idle thread enter hook.
453 * @note This hook is invoked within a critical zone, no OS functions
454 * should be invoked from here.
455 * @note This macro can be used to activate a power saving mode.
457 #define CH_CFG_IDLE_ENTER_HOOK() { \
461 * @brief Idle thread leave hook.
462 * @note This hook is invoked within a critical zone, no OS functions
463 * should be invoked from here.
464 * @note This macro can be used to deactivate a power saving mode.
466 #define CH_CFG_IDLE_LEAVE_HOOK() { \
470 * @brief Idle Loop hook.
471 * @details This hook is continuously invoked by the idle thread loop.
473 #define CH_CFG_IDLE_LOOP_HOOK() { \
474 /* Idle loop code here.*/ \
478 * @brief System tick event hook.
479 * @details This hook is invoked in the system tick handler immediately
480 * after processing the virtual timers queue.
482 #define CH_CFG_SYSTEM_TICK_HOOK() { \
483 /* System tick event code here.*/ \
487 * @brief System halt hook.
488 * @details This hook is invoked in case to a system halting error before
489 * the system is halted.
491 #define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
492 /* System halt code here.*/ \
497 /*===========================================================================*/
498 /* Port-specific settings (override port settings defaulted in chcore.h). */
499 /*===========================================================================*/
501 #endif /* _CHCONF_H_ */