2 ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 http://www.apache.org/licenses/LICENSE-2.0
7 Unless required by applicable law or agreed to in writing, software
8 distributed under the License is distributed on an "AS IS" BASIS,
9 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 See the License for the specific language governing permissions and
11 limitations under the License.
15 * @file templates/chconf.h
16 * @brief Configuration file template.
17 * @details A copy of this file must be placed in each project directory, it
18 * contains the application specific kernel settings.
21 * @details Kernel related settings and hooks.
28 #define _CHIBIOS_RT_CONF_
30 /*===========================================================================*/
32 * @name System timers settings
35 /*===========================================================================*/
38 * @brief System time counter resolution.
39 * @note Allowed values are 16 or 32 bits.
41 #define CH_CFG_ST_RESOLUTION 32
44 * @brief System tick frequency.
45 * @details Frequency of the system timer that drives the system ticks. This
46 * setting also defines the system tick time unit.
48 #define CH_CFG_ST_FREQUENCY 10000
51 * @brief Time delta constant for the tick-less mode.
52 * @note If this value is zero then the system uses the classic
53 * periodic tick. This value represents the minimum number
54 * of ticks that is safe to specify in a timeout directive.
55 * The value one is not valid, timeouts are rounded up to
58 #define CH_CFG_ST_TIMEDELTA 2
62 /*===========================================================================*/
64 * @name Kernel parameters and options
67 /*===========================================================================*/
70 * @brief Round robin interval.
71 * @details This constant is the number of system ticks allowed for the
72 * threads before preemption occurs. Setting this value to zero
73 * disables the preemption for threads with equal priority and the
74 * round robin becomes cooperative. Note that higher priority
75 * threads can still preempt, the kernel is always preemptive.
76 * @note Disabling the round robin preemption makes the kernel more compact
77 * and generally faster.
78 * @note The round robin preemption is not supported in tickless mode and
79 * must be set to zero in that case.
81 #define CH_CFG_TIME_QUANTUM 0
84 * @brief Managed RAM size.
85 * @details Size of the RAM area to be managed by the OS. If set to zero
86 * then the whole available RAM is used. The core memory is made
87 * available to the heap allocator and/or can be used directly through
88 * the simplified core memory allocator.
90 * @note In order to let the OS manage the whole RAM the linker script must
91 * provide the @p __heap_base__ and @p __heap_end__ symbols.
92 * @note Requires @p CH_CFG_USE_MEMCORE.
94 #define CH_CFG_MEMCORE_SIZE 0
97 * @brief Idle thread automatic spawn suppression.
98 * @details When this option is activated the function @p chSysInit()
99 * does not spawn the idle thread. The application @p main()
100 * function becomes the idle thread and must implement an
103 #define CH_CFG_NO_IDLE_THREAD FALSE
105 /* Use __WFI in the idle thread for waiting. Does lower the power
107 #define CORTEX_ENABLE_WFI_IDLE TRUE
111 /*===========================================================================*/
113 * @name Performance options
116 /*===========================================================================*/
119 * @brief OS optimization.
120 * @details If enabled then time efficient rather than space efficient code
121 * is used when two possible implementations exist.
123 * @note This is not related to the compiler optimization options.
124 * @note The default is @p TRUE.
126 #define CH_CFG_OPTIMIZE_SPEED TRUE
130 /*===========================================================================*/
132 * @name Subsystem options
135 /*===========================================================================*/
138 * @brief Time Measurement APIs.
139 * @details If enabled then the time measurement APIs are included in
142 * @note The default is @p TRUE.
144 #define CH_CFG_USE_TM FALSE
147 * @brief Threads registry APIs.
148 * @details If enabled then the registry APIs are included in the kernel.
150 * @note The default is @p TRUE.
152 #define CH_CFG_USE_REGISTRY TRUE
155 * @brief Threads synchronization APIs.
156 * @details If enabled then the @p chThdWait() function is included in
159 * @note The default is @p TRUE.
161 #define CH_CFG_USE_WAITEXIT TRUE
164 * @brief Semaphores APIs.
165 * @details If enabled then the Semaphores APIs are included in the kernel.
167 * @note The default is @p TRUE.
169 #define CH_CFG_USE_SEMAPHORES TRUE
172 * @brief Semaphores queuing mode.
173 * @details If enabled then the threads are enqueued on semaphores by
174 * priority rather than in FIFO order.
176 * @note The default is @p FALSE. Enable this if you have special
178 * @note Requires @p CH_CFG_USE_SEMAPHORES.
180 #define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
183 * @brief Mutexes APIs.
184 * @details If enabled then the mutexes APIs are included in the kernel.
186 * @note The default is @p TRUE.
188 #define CH_CFG_USE_MUTEXES TRUE
191 * @brief Enables recursive behavior on mutexes.
192 * @note Recursive mutexes are heavier and have an increased
195 * @note The default is @p FALSE.
196 * @note Requires @p CH_CFG_USE_MUTEXES.
198 #define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
201 * @brief Conditional Variables APIs.
202 * @details If enabled then the conditional variables APIs are included
205 * @note The default is @p TRUE.
206 * @note Requires @p CH_CFG_USE_MUTEXES.
208 #define CH_CFG_USE_CONDVARS TRUE
211 * @brief Conditional Variables APIs with timeout.
212 * @details If enabled then the conditional variables APIs with timeout
213 * specification are included in the kernel.
215 * @note The default is @p TRUE.
216 * @note Requires @p CH_CFG_USE_CONDVARS.
218 #define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
221 * @brief Events Flags APIs.
222 * @details If enabled then the event flags APIs are included in the kernel.
224 * @note The default is @p TRUE.
226 #define CH_CFG_USE_EVENTS TRUE
229 * @brief Events Flags APIs with timeout.
230 * @details If enabled then the events APIs with timeout specification
231 * are included in the kernel.
233 * @note The default is @p TRUE.
234 * @note Requires @p CH_CFG_USE_EVENTS.
236 #define CH_CFG_USE_EVENTS_TIMEOUT TRUE
239 * @brief Synchronous Messages APIs.
240 * @details If enabled then the synchronous messages APIs are included
243 * @note The default is @p TRUE.
245 #define CH_CFG_USE_MESSAGES TRUE
248 * @brief Synchronous Messages queuing mode.
249 * @details If enabled then messages are served by priority rather than in
252 * @note The default is @p FALSE. Enable this if you have special
254 * @note Requires @p CH_CFG_USE_MESSAGES.
256 #define CH_CFG_USE_MESSAGES_PRIORITY FALSE
259 * @brief Mailboxes APIs.
260 * @details If enabled then the asynchronous messages (mailboxes) APIs are
261 * included in the kernel.
263 * @note The default is @p TRUE.
264 * @note Requires @p CH_CFG_USE_SEMAPHORES.
266 #define CH_CFG_USE_MAILBOXES TRUE
269 * @brief Core Memory Manager APIs.
270 * @details If enabled then the core memory manager APIs are included
273 * @note The default is @p TRUE.
275 #define CH_CFG_USE_MEMCORE TRUE
278 * @brief Heap Allocator APIs.
279 * @details If enabled then the memory heap allocator APIs are included
282 * @note The default is @p TRUE.
283 * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
284 * @p CH_CFG_USE_SEMAPHORES.
285 * @note Mutexes are recommended.
287 #define CH_CFG_USE_HEAP TRUE
290 * @brief Memory Pools Allocator APIs.
291 * @details If enabled then the memory pools allocator APIs are included
294 * @note The default is @p TRUE.
296 #define CH_CFG_USE_MEMPOOLS TRUE
299 * @brief Dynamic Threads APIs.
300 * @details If enabled then the dynamic threads creation APIs are included
303 * @note The default is @p TRUE.
304 * @note Requires @p CH_CFG_USE_WAITEXIT.
305 * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
307 #define CH_CFG_USE_DYNAMIC TRUE
311 /*===========================================================================*/
313 * @name Debug options
316 /*===========================================================================*/
319 * @brief Debug option, kernel statistics.
321 * @note The default is @p FALSE.
323 #define CH_DBG_STATISTICS FALSE
326 * @brief Debug option, system state check.
327 * @details If enabled the correct call protocol for system APIs is checked
330 * @note The default is @p FALSE.
332 #define CH_DBG_SYSTEM_STATE_CHECK FALSE
335 * @brief Debug option, parameters checks.
336 * @details If enabled then the checks on the API functions input
337 * parameters are activated.
339 * @note The default is @p FALSE.
341 #define CH_DBG_ENABLE_CHECKS FALSE
344 * @brief Debug option, consistency checks.
345 * @details If enabled then all the assertions in the kernel code are
346 * activated. This includes consistency checks inside the kernel,
347 * runtime anomalies and port-defined checks.
349 * @note The default is @p FALSE.
351 #define CH_DBG_ENABLE_ASSERTS FALSE
354 * @brief Debug option, trace buffer.
355 * @details If enabled then the trace buffer is activated.
357 * @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
359 #define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
362 * @brief Trace buffer entries.
363 * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
364 * different from @p CH_DBG_TRACE_MASK_DISABLED.
366 #define CH_DBG_TRACE_BUFFER_SIZE 128
369 * @brief Debug option, stack checks.
370 * @details If enabled then a runtime stack check is performed.
372 * @note The default is @p FALSE.
373 * @note The stack check is performed in a architecture/port dependent way.
374 * It may not be implemented or some ports.
375 * @note The default failure mode is to halt the system with the global
376 * @p panic_msg variable set to @p NULL.
378 #define CH_DBG_ENABLE_STACK_CHECK FALSE
381 * @brief Debug option, stacks initialization.
382 * @details If enabled then the threads working area is filled with a byte
383 * value when a thread is created. This can be useful for the
384 * runtime measurement of the used stack.
386 * @note The default is @p FALSE.
388 #define CH_DBG_FILL_THREADS FALSE
391 * @brief Debug option, threads profiling.
392 * @details If enabled then a field is added to the @p thread_t structure that
393 * counts the system ticks occurred while executing the thread.
395 * @note The default is @p FALSE.
396 * @note This debug option is not currently compatible with the
399 #define CH_DBG_THREADS_PROFILING FALSE
403 /*===========================================================================*/
408 /*===========================================================================*/
411 * @brief Threads descriptor structure extension.
412 * @details User fields added to the end of the @p thread_t structure.
414 #define CH_CFG_THREAD_EXTRA_FIELDS \
415 /* Add threads custom fields here.*/
418 * @brief Threads initialization hook.
419 * @details User initialization code added to the @p chThdInit() API.
421 * @note It is invoked from within @p chThdInit() and implicitly from all
422 * the threads creation APIs.
424 #define CH_CFG_THREAD_INIT_HOOK(tp) { \
425 /* Add threads initialization code here.*/ \
429 * @brief Threads finalization hook.
430 * @details User finalization code added to the @p chThdExit() API.
432 #define CH_CFG_THREAD_EXIT_HOOK(tp) { \
433 /* Add threads finalization code here.*/ \
437 * @brief Context switch hook.
438 * @details This hook is invoked just before switching between threads.
440 #define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
441 /* Context switch code here.*/ \
445 * @brief ISR enter hook.
447 #define CH_CFG_IRQ_PROLOGUE_HOOK() { \
448 /* IRQ prologue code here.*/ \
452 * @brief ISR exit hook.
454 #define CH_CFG_IRQ_EPILOGUE_HOOK() { \
455 /* IRQ epilogue code here.*/ \
459 * @brief Idle thread enter hook.
460 * @note This hook is invoked within a critical zone, no OS functions
461 * should be invoked from here.
462 * @note This macro can be used to activate a power saving mode.
464 #define CH_CFG_IDLE_ENTER_HOOK() { \
465 /* Idle-enter code here.*/ \
469 * @brief Idle thread leave hook.
470 * @note This hook is invoked within a critical zone, no OS functions
471 * should be invoked from here.
472 * @note This macro can be used to deactivate a power saving mode.
474 #define CH_CFG_IDLE_LEAVE_HOOK() { \
475 /* Idle-leave code here.*/ \
479 * @brief Idle Loop hook.
480 * @details This hook is continuously invoked by the idle thread loop.
482 #define CH_CFG_IDLE_LOOP_HOOK() { \
483 /* Idle loop code here.*/ \
487 * @brief System tick event hook.
488 * @details This hook is invoked in the system tick handler immediately
489 * after processing the virtual timers queue.
491 #define CH_CFG_SYSTEM_TICK_HOOK() { \
492 /* System tick event code here.*/ \
496 * @brief System halt hook.
497 * @details This hook is invoked in case to a system halting error before
498 * the system is halted.
500 #define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
501 /* System halt code here.*/ \
506 * @details This hook is invoked each time a new record is written in the
509 #define CH_CFG_TRACE_HOOK(tep) { \
510 /* Trace code here.*/ \
515 /*===========================================================================*/
516 /* Port-specific settings (override port settings defaulted in chcore.h). */
517 /*===========================================================================*/
519 #endif /* CHCONF_H */