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 #define _CHIBIOS_RT_CONF_
33 /*===========================================================================*/
35 * @name System timers settings
38 /*===========================================================================*/
41 * @brief System time counter resolution.
42 * @note Allowed values are 16 or 32 bits.
44 #define CH_CFG_ST_RESOLUTION 32
47 * @brief System tick frequency.
48 * @details Frequency of the system timer that drives the system ticks. This
49 * setting also defines the system tick time unit.
51 #define CH_CFG_ST_FREQUENCY 100000
54 * @brief Time delta constant for the tick-less mode.
55 * @note If this value is zero then the system uses the classic
56 * periodic tick. This value represents the minimum number
57 * of ticks that is safe to specify in a timeout directive.
58 * The value one is not valid, timeouts are rounded up to
61 #define CH_CFG_ST_TIMEDELTA 0
65 /*===========================================================================*/
67 * @name Kernel parameters and options
70 /*===========================================================================*/
73 * @brief Round robin interval.
74 * @details This constant is the number of system ticks allowed for the
75 * threads before preemption occurs. Setting this value to zero
76 * disables the preemption for threads with equal priority and the
77 * round robin becomes cooperative. Note that higher priority
78 * threads can still preempt, the kernel is always preemptive.
79 * @note Disabling the round robin preemption makes the kernel more compact
80 * and generally faster.
81 * @note The round robin preemption is not supported in tickless mode and
82 * must be set to zero in that case.
84 #define CH_CFG_TIME_QUANTUM 20
87 * @brief Managed RAM size.
88 * @details Size of the RAM area to be managed by the OS. If set to zero
89 * then the whole available RAM is used. The core memory is made
90 * available to the heap allocator and/or can be used directly through
91 * the simplified core memory allocator.
93 * @note In order to let the OS manage the whole RAM the linker script must
94 * provide the @p __heap_base__ and @p __heap_end__ symbols.
95 * @note Requires @p CH_CFG_USE_MEMCORE.
97 #define CH_CFG_MEMCORE_SIZE 0
100 * @brief Idle thread automatic spawn suppression.
101 * @details When this option is activated the function @p chSysInit()
102 * does not spawn the idle thread. The application @p main()
103 * function becomes the idle thread and must implement an
106 #define CH_CFG_NO_IDLE_THREAD FALSE
110 /*===========================================================================*/
112 * @name Performance options
115 /*===========================================================================*/
118 * @brief OS optimization.
119 * @details If enabled then time efficient rather than space efficient code
120 * is used when two possible implementations exist.
122 * @note This is not related to the compiler optimization options.
123 * @note The default is @p TRUE.
125 #define CH_CFG_OPTIMIZE_SPEED TRUE
129 /*===========================================================================*/
131 * @name Subsystem options
134 /*===========================================================================*/
137 * @brief Time Measurement APIs.
138 * @details If enabled then the time measurement APIs are included in
141 * @note The default is @p TRUE.
143 #define CH_CFG_USE_TM FALSE
146 * @brief Threads registry APIs.
147 * @details If enabled then the registry APIs are included in the kernel.
149 * @note The default is @p TRUE.
151 #define CH_CFG_USE_REGISTRY TRUE
154 * @brief Threads synchronization APIs.
155 * @details If enabled then the @p chThdWait() function is included in
158 * @note The default is @p TRUE.
160 #define CH_CFG_USE_WAITEXIT TRUE
163 * @brief Semaphores APIs.
164 * @details If enabled then the Semaphores APIs are included in the kernel.
166 * @note The default is @p TRUE.
168 #define CH_CFG_USE_SEMAPHORES TRUE
171 * @brief Semaphores queuing mode.
172 * @details If enabled then the threads are enqueued on semaphores by
173 * priority rather than in FIFO order.
175 * @note The default is @p FALSE. Enable this if you have special
177 * @note Requires @p CH_CFG_USE_SEMAPHORES.
179 #define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
182 * @brief Mutexes APIs.
183 * @details If enabled then the mutexes APIs are included in the kernel.
185 * @note The default is @p TRUE.
187 #define CH_CFG_USE_MUTEXES TRUE
190 * @brief Enables recursive behavior on mutexes.
191 * @note Recursive mutexes are heavier and have an increased
194 * @note The default is @p FALSE.
195 * @note Requires @p CH_CFG_USE_MUTEXES.
197 #define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
200 * @brief Conditional Variables APIs.
201 * @details If enabled then the conditional variables APIs are included
204 * @note The default is @p TRUE.
205 * @note Requires @p CH_CFG_USE_MUTEXES.
207 #define CH_CFG_USE_CONDVARS TRUE
210 * @brief Conditional Variables APIs with timeout.
211 * @details If enabled then the conditional variables APIs with timeout
212 * specification are included in the kernel.
214 * @note The default is @p TRUE.
215 * @note Requires @p CH_CFG_USE_CONDVARS.
217 #define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
220 * @brief Events Flags APIs.
221 * @details If enabled then the event flags APIs are included in the kernel.
223 * @note The default is @p TRUE.
225 #define CH_CFG_USE_EVENTS TRUE
228 * @brief Events Flags APIs with timeout.
229 * @details If enabled then the events APIs with timeout specification
230 * are included in the kernel.
232 * @note The default is @p TRUE.
233 * @note Requires @p CH_CFG_USE_EVENTS.
235 #define CH_CFG_USE_EVENTS_TIMEOUT TRUE
238 * @brief Synchronous Messages APIs.
239 * @details If enabled then the synchronous messages APIs are included
242 * @note The default is @p TRUE.
244 #define CH_CFG_USE_MESSAGES TRUE
247 * @brief Synchronous Messages queuing mode.
248 * @details If enabled then messages are served by priority rather than in
251 * @note The default is @p FALSE. Enable this if you have special
253 * @note Requires @p CH_CFG_USE_MESSAGES.
255 #define CH_CFG_USE_MESSAGES_PRIORITY FALSE
258 * @brief Mailboxes APIs.
259 * @details If enabled then the asynchronous messages (mailboxes) APIs are
260 * included in the kernel.
262 * @note The default is @p TRUE.
263 * @note Requires @p CH_CFG_USE_SEMAPHORES.
265 #define CH_CFG_USE_MAILBOXES TRUE
268 * @brief I/O Queues APIs.
269 * @details If enabled then the I/O queues APIs are included in the kernel.
271 * @note The default is @p TRUE.
273 #define CH_CFG_USE_QUEUES TRUE
276 * @brief Core Memory Manager APIs.
277 * @details If enabled then the core memory manager APIs are included
280 * @note The default is @p TRUE.
282 #define CH_CFG_USE_MEMCORE TRUE
285 * @brief Heap Allocator APIs.
286 * @details If enabled then the memory heap allocator APIs are included
289 * @note The default is @p TRUE.
290 * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
291 * @p CH_CFG_USE_SEMAPHORES.
292 * @note Mutexes are recommended.
294 #define CH_CFG_USE_HEAP TRUE
297 * @brief Memory Pools Allocator APIs.
298 * @details If enabled then the memory pools allocator APIs are included
301 * @note The default is @p TRUE.
303 #define CH_CFG_USE_MEMPOOLS TRUE
306 * @brief Dynamic Threads APIs.
307 * @details If enabled then the dynamic threads creation APIs are included
310 * @note The default is @p TRUE.
311 * @note Requires @p CH_CFG_USE_WAITEXIT.
312 * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
314 #define CH_CFG_USE_DYNAMIC TRUE
318 /*===========================================================================*/
320 * @name Debug options
323 /*===========================================================================*/
326 * @brief Debug option, kernel statistics.
328 * @note The default is @p FALSE.
330 #define CH_DBG_STATISTICS FALSE
333 * @brief Debug option, system state check.
334 * @details If enabled the correct call protocol for system APIs is checked
337 * @note The default is @p FALSE.
339 #define CH_DBG_SYSTEM_STATE_CHECK FALSE
342 * @brief Debug option, parameters checks.
343 * @details If enabled then the checks on the API functions input
344 * parameters are activated.
346 * @note The default is @p FALSE.
348 #define CH_DBG_ENABLE_CHECKS FALSE
351 * @brief Debug option, consistency checks.
352 * @details If enabled then all the assertions in the kernel code are
353 * activated. This includes consistency checks inside the kernel,
354 * runtime anomalies and port-defined checks.
356 * @note The default is @p FALSE.
358 #define CH_DBG_ENABLE_ASSERTS FALSE
361 * @brief Debug option, trace buffer.
362 * @details If enabled then the context switch circular trace buffer is
365 * @note The default is @p FALSE.
367 #define CH_DBG_ENABLE_TRACE FALSE
370 * @brief Debug option, stack checks.
371 * @details If enabled then a runtime stack check is performed.
373 * @note The default is @p FALSE.
374 * @note The stack check is performed in a architecture/port dependent way.
375 * It may not be implemented or some ports.
376 * @note The default failure mode is to halt the system with the global
377 * @p panic_msg variable set to @p NULL.
379 #define CH_DBG_ENABLE_STACK_CHECK FALSE
382 * @brief Debug option, stacks initialization.
383 * @details If enabled then the threads working area is filled with a byte
384 * value when a thread is created. This can be useful for the
385 * runtime measurement of the used stack.
387 * @note The default is @p FALSE.
389 #define CH_DBG_FILL_THREADS FALSE
392 * @brief Debug option, threads profiling.
393 * @details If enabled then a field is added to the @p thread_t structure that
394 * counts the system ticks occurred while executing the thread.
396 * @note The default is @p FALSE.
397 * @note This debug option is not currently compatible with the
400 #define CH_DBG_THREADS_PROFILING FALSE
404 /*===========================================================================*/
409 /*===========================================================================*/
412 * @brief Threads descriptor structure extension.
413 * @details User fields added to the end of the @p thread_t structure.
415 #define CH_CFG_THREAD_EXTRA_FIELDS \
416 /* Add threads custom fields here.*/
419 * @brief Threads initialization hook.
420 * @details User initialization code added to the @p chThdInit() API.
422 * @note It is invoked from within @p chThdInit() and implicitly from all
423 * the threads creation APIs.
425 #define CH_CFG_THREAD_INIT_HOOK(tp) { \
426 /* Add threads initialization code here.*/ \
430 * @brief Threads finalization hook.
431 * @details User finalization code added to the @p chThdExit() API.
433 * @note It is inserted into lock zone.
434 * @note It is also invoked when the threads simply return in order to
437 #define CH_CFG_THREAD_EXIT_HOOK(tp) { \
438 /* Add threads finalization code here.*/ \
442 * @brief Context switch hook.
443 * @details This hook is invoked just before switching between threads.
445 #define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
446 /* Context switch code here.*/ \
450 * @brief ISR enter hook.
452 #define CH_CFG_IRQ_PROLOGUE_HOOK() { \
453 /* IRQ prologue code here.*/ \
457 * @brief ISR exit hook.
459 #define CH_CFG_IRQ_EPILOGUE_HOOK() { \
460 /* IRQ epilogue code here.*/ \
464 * @brief Idle thread enter hook.
465 * @note This hook is invoked within a critical zone, no OS functions
466 * should be invoked from here.
467 * @note This macro can be used to activate a power saving mode.
469 #define CH_CFG_IDLE_ENTER_HOOK() { \
473 * @brief Idle thread leave hook.
474 * @note This hook is invoked within a critical zone, no OS functions
475 * should be invoked from here.
476 * @note This macro can be used to deactivate a power saving mode.
478 #define CH_CFG_IDLE_LEAVE_HOOK() { \
482 * @brief Idle Loop hook.
483 * @details This hook is continuously invoked by the idle thread loop.
485 #define CH_CFG_IDLE_LOOP_HOOK() { \
486 /* Idle loop code here.*/ \
490 * @brief System tick event hook.
491 * @details This hook is invoked in the system tick handler immediately
492 * after processing the virtual timers queue.
494 #define CH_CFG_SYSTEM_TICK_HOOK() { \
495 /* System tick event code here.*/ \
499 * @brief System halt hook.
500 * @details This hook is invoked in case to a system halting error before
501 * the system is halted.
503 #define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
504 /* System halt code here.*/ \
509 * @details This hook is invoked each time a new record is written in the
512 #define CH_CFG_TRACE_HOOK(tep) { \
513 /* Trace code here.*/ \
518 /*===========================================================================*/
519 /* Port-specific settings (override port settings defaulted in chcore.h). */
520 /*===========================================================================*/
522 #endif /* _CHCONF_H_ */