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 32
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 10000
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
108 /*===========================================================================*/
110 * @name Performance options
113 /*===========================================================================*/
116 * @brief OS optimization.
117 * @details If enabled then time efficient rather than space efficient code
118 * is used when two possible implementations exist.
120 * @note This is not related to the compiler optimization options.
121 * @note The default is @p TRUE.
123 #define CH_CFG_OPTIMIZE_SPEED FALSE
127 /*===========================================================================*/
129 * @name Subsystem options
132 /*===========================================================================*/
135 * @brief Time Measurement APIs.
136 * @details If enabled then the time measurement APIs are included in
139 * @note The default is @p TRUE.
141 #define CH_CFG_USE_TM FALSE
144 * @brief Threads registry APIs.
145 * @details If enabled then the registry APIs are included in the kernel.
147 * @note The default is @p TRUE.
149 #define CH_CFG_USE_REGISTRY TRUE
152 * @brief Threads synchronization APIs.
153 * @details If enabled then the @p chThdWait() function is included in
156 * @note The default is @p TRUE.
158 #define CH_CFG_USE_WAITEXIT TRUE
161 * @brief Semaphores APIs.
162 * @details If enabled then the Semaphores APIs are included in the kernel.
164 * @note The default is @p TRUE.
166 #define CH_CFG_USE_SEMAPHORES TRUE
169 * @brief Semaphores queuing mode.
170 * @details If enabled then the threads are enqueued on semaphores by
171 * priority rather than in FIFO order.
173 * @note The default is @p FALSE. Enable this if you have special
175 * @note Requires @p CH_CFG_USE_SEMAPHORES.
177 #define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
180 * @brief Mutexes APIs.
181 * @details If enabled then the mutexes APIs are included in the kernel.
183 * @note The default is @p TRUE.
185 #define CH_CFG_USE_MUTEXES TRUE
188 * @brief Enables recursive behavior on mutexes.
189 * @note Recursive mutexes are heavier and have an increased
192 * @note The default is @p FALSE.
193 * @note Requires @p CH_CFG_USE_MUTEXES.
195 #define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
198 * @brief Conditional Variables APIs.
199 * @details If enabled then the conditional variables APIs are included
202 * @note The default is @p TRUE.
203 * @note Requires @p CH_CFG_USE_MUTEXES.
205 #define CH_CFG_USE_CONDVARS TRUE
208 * @brief Conditional Variables APIs with timeout.
209 * @details If enabled then the conditional variables APIs with timeout
210 * specification are included in the kernel.
212 * @note The default is @p TRUE.
213 * @note Requires @p CH_CFG_USE_CONDVARS.
215 #define CH_CFG_USE_CONDVARS_TIMEOUT FALSE
218 * @brief Events Flags APIs.
219 * @details If enabled then the event flags APIs are included in the kernel.
221 * @note The default is @p TRUE.
223 #define CH_CFG_USE_EVENTS TRUE
226 * @brief Events Flags APIs with timeout.
227 * @details If enabled then the events APIs with timeout specification
228 * are included in the kernel.
230 * @note The default is @p TRUE.
231 * @note Requires @p CH_CFG_USE_EVENTS.
233 #define CH_CFG_USE_EVENTS_TIMEOUT TRUE
236 * @brief Synchronous Messages APIs.
237 * @details If enabled then the synchronous messages APIs are included
240 * @note The default is @p TRUE.
242 #define CH_CFG_USE_MESSAGES TRUE
245 * @brief Synchronous Messages queuing mode.
246 * @details If enabled then messages are served by priority rather than in
249 * @note The default is @p FALSE. Enable this if you have special
251 * @note Requires @p CH_CFG_USE_MESSAGES.
253 #define CH_CFG_USE_MESSAGES_PRIORITY FALSE
256 * @brief Mailboxes APIs.
257 * @details If enabled then the asynchronous messages (mailboxes) APIs are
258 * included in the kernel.
260 * @note The default is @p TRUE.
261 * @note Requires @p CH_CFG_USE_SEMAPHORES.
263 #define CH_CFG_USE_MAILBOXES TRUE
266 * @brief I/O Queues APIs.
267 * @details If enabled then the I/O queues APIs are included in the kernel.
269 * @note The default is @p TRUE.
271 #define CH_CFG_USE_QUEUES TRUE
274 * @brief Core Memory Manager APIs.
275 * @details If enabled then the core memory manager APIs are included
278 * @note The default is @p TRUE.
280 #define CH_CFG_USE_MEMCORE FALSE
283 * @brief Heap Allocator APIs.
284 * @details If enabled then the memory heap allocator APIs are included
287 * @note The default is @p TRUE.
288 * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
289 * @p CH_CFG_USE_SEMAPHORES.
290 * @note Mutexes are recommended.
292 #define CH_CFG_USE_HEAP FALSE
295 * @brief Memory Pools Allocator APIs.
296 * @details If enabled then the memory pools allocator APIs are included
299 * @note The default is @p TRUE.
301 #define CH_CFG_USE_MEMPOOLS FALSE
304 * @brief Dynamic Threads APIs.
305 * @details If enabled then the dynamic threads creation APIs are included
308 * @note The default is @p TRUE.
309 * @note Requires @p CH_CFG_USE_WAITEXIT.
310 * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
312 #define CH_CFG_USE_DYNAMIC FALSE
316 /*===========================================================================*/
318 * @name Debug options
321 /*===========================================================================*/
324 * @brief Debug option, kernel statistics.
326 * @note The default is @p FALSE.
328 #define CH_DBG_STATISTICS FALSE
331 * @brief Debug option, system state check.
332 * @details If enabled the correct call protocol for system APIs is checked
335 * @note The default is @p FALSE.
337 #define CH_DBG_SYSTEM_STATE_CHECK FALSE
340 * @brief Debug option, parameters checks.
341 * @details If enabled then the checks on the API functions input
342 * parameters are activated.
344 * @note The default is @p FALSE.
346 #define CH_DBG_ENABLE_CHECKS FALSE
349 * @brief Debug option, consistency checks.
350 * @details If enabled then all the assertions in the kernel code are
351 * activated. This includes consistency checks inside the kernel,
352 * runtime anomalies and port-defined checks.
354 * @note The default is @p FALSE.
356 #define CH_DBG_ENABLE_ASSERTS FALSE
359 * @brief Debug option, trace buffer.
360 * @details If enabled then the context switch circular trace buffer is
363 * @note The default is @p FALSE.
365 #define CH_DBG_ENABLE_TRACE FALSE
368 * @brief Debug option, stack checks.
369 * @details If enabled then a runtime stack check is performed.
371 * @note The default is @p FALSE.
372 * @note The stack check is performed in a architecture/port dependent way.
373 * It may not be implemented or some ports.
374 * @note The default failure mode is to halt the system with the global
375 * @p panic_msg variable set to @p NULL.
377 #define CH_DBG_ENABLE_STACK_CHECK FALSE
380 * @brief Debug option, stacks initialization.
381 * @details If enabled then the threads working area is filled with a byte
382 * value when a thread is created. This can be useful for the
383 * runtime measurement of the used stack.
385 * @note The default is @p FALSE.
387 #define CH_DBG_FILL_THREADS FALSE
390 * @brief Debug option, threads profiling.
391 * @details If enabled then a field is added to the @p thread_t structure that
392 * counts the system ticks occurred while executing the thread.
394 * @note The default is @p FALSE.
395 * @note This debug option is not currently compatible with the
398 #define CH_DBG_THREADS_PROFILING FALSE
402 /*===========================================================================*/
407 /*===========================================================================*/
410 * @brief Threads descriptor structure extension.
411 * @details User fields added to the end of the @p thread_t structure.
413 #define CH_CFG_THREAD_EXTRA_FIELDS \
414 /* Add threads custom fields here.*/
417 * @brief Threads initialization hook.
418 * @details User initialization code added to the @p chThdInit() API.
420 * @note It is invoked from within @p chThdInit() and implicitly from all
421 * the threads creation APIs.
423 #define CH_CFG_THREAD_INIT_HOOK(tp) { \
424 /* Add threads initialization code here.*/ \
428 * @brief Threads finalization hook.
429 * @details User finalization code added to the @p chThdExit() API.
431 * @note It is inserted into lock zone.
432 * @note It is also invoked when the threads simply return in order to
435 #define CH_CFG_THREAD_EXIT_HOOK(tp) { \
436 /* Add threads finalization code here.*/ \
440 * @brief Context switch hook.
441 * @details This hook is invoked just before switching between threads.
443 #define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
444 /* Context switch code here.*/ \
448 * @brief Idle thread enter hook.
449 * @note This hook is invoked within a critical zone, no OS functions
450 * should be invoked from here.
451 * @note This macro can be used to activate a power saving mode.
453 #define CH_CFG_IDLE_ENTER_HOOK() { \
457 * @brief Idle thread leave hook.
458 * @note This hook is invoked within a critical zone, no OS functions
459 * should be invoked from here.
460 * @note This macro can be used to deactivate a power saving mode.
462 #define CH_CFG_IDLE_LEAVE_HOOK() { \
466 * @brief Idle Loop hook.
467 * @details This hook is continuously invoked by the idle thread loop.
469 #define CH_CFG_IDLE_LOOP_HOOK() { \
470 /* Idle loop code here.*/ \
474 * @brief System tick event hook.
475 * @details This hook is invoked in the system tick handler immediately
476 * after processing the virtual timers queue.
478 #define CH_CFG_SYSTEM_TICK_HOOK() { \
479 /* System tick event code here.*/ \
483 * @brief System halt hook.
484 * @details This hook is invoked in case to a system halting error before
485 * the system is halted.
487 #define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
488 /* System halt code here.*/ \
493 /*===========================================================================*/
494 /* Port-specific settings (override port settings defaulted in chcore.h). */
495 /*===========================================================================*/
497 #endif /* _CHCONF_H_ */