ChibiOS/RT  5.1.0
chconf.h
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
3 
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
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
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.
15 */
16 
17 /**
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.
22  *
23  * @addtogroup config
24  * @details Kernel related settings and hooks.
25  * @{
26  */
27 
28 #ifndef CHCONF_H
29 #define CHCONF_H
30 
31 #define _CHIBIOS_RT_CONF_
32 #define _CHIBIOS_RT_CONF_VER_5_1_
33 
34 /*===========================================================================*/
35 /**
36  * @name System timers settings
37  * @{
38  */
39 /*===========================================================================*/
40 
41 /**
42  * @brief System time counter resolution.
43  * @note Allowed values are 16 or 32 bits.
44  */
45 #if !defined(CH_CFG_ST_RESOLUTION)
46 #define CH_CFG_ST_RESOLUTION 32
47 #endif
48 
49 /**
50  * @brief System tick frequency.
51  * @details Frequency of the system timer that drives the system ticks. This
52  * setting also defines the system tick time unit.
53  */
54 #if !defined(CH_CFG_ST_FREQUENCY)
55 #define CH_CFG_ST_FREQUENCY 10000
56 #endif
57 
58 /**
59  * @brief Time intervals data size.
60  * @note Allowed values are 16, 32 or 64 bits.
61  */
62 #if !defined(CH_CFG_INTERVALS_SIZE)
63 #define CH_CFG_INTERVALS_SIZE 32
64 #endif
65 
66 /**
67  * @brief Time types data size.
68  * @note Allowed values are 16 or 32 bits.
69  */
70 #if !defined(CH_CFG_TIME_TYPES_SIZE)
71 #define CH_CFG_TIME_TYPES_SIZE 32
72 #endif
73 
74 /**
75  * @brief Time delta constant for the tick-less mode.
76  * @note If this value is zero then the system uses the classic
77  * periodic tick. This value represents the minimum number
78  * of ticks that is safe to specify in a timeout directive.
79  * The value one is not valid, timeouts are rounded up to
80  * this value.
81  */
82 #if !defined(CH_CFG_ST_TIMEDELTA)
83 #define CH_CFG_ST_TIMEDELTA 2
84 #endif
85 
86 /** @} */
87 
88 /*===========================================================================*/
89 /**
90  * @name Kernel parameters and options
91  * @{
92  */
93 /*===========================================================================*/
94 
95 /**
96  * @brief Round robin interval.
97  * @details This constant is the number of system ticks allowed for the
98  * threads before preemption occurs. Setting this value to zero
99  * disables the preemption for threads with equal priority and the
100  * round robin becomes cooperative. Note that higher priority
101  * threads can still preempt, the kernel is always preemptive.
102  * @note Disabling the round robin preemption makes the kernel more compact
103  * and generally faster.
104  * @note The round robin preemption is not supported in tickless mode and
105  * must be set to zero in that case.
106  */
107 #if !defined(CH_CFG_TIME_QUANTUM)
108 #define CH_CFG_TIME_QUANTUM 0
109 #endif
110 
111 /**
112  * @brief Managed RAM size.
113  * @details Size of the RAM area to be managed by the OS. If set to zero
114  * then the whole available RAM is used. The core memory is made
115  * available to the heap allocator and/or can be used directly through
116  * the simplified core memory allocator.
117  *
118  * @note In order to let the OS manage the whole RAM the linker script must
119  * provide the @p __heap_base__ and @p __heap_end__ symbols.
120  * @note Requires @p CH_CFG_USE_MEMCORE.
121  */
122 #if !defined(CH_CFG_MEMCORE_SIZE)
123 #define CH_CFG_MEMCORE_SIZE 0
124 #endif
125 
126 /**
127  * @brief Idle thread automatic spawn suppression.
128  * @details When this option is activated the function @p chSysInit()
129  * does not spawn the idle thread. The application @p main()
130  * function becomes the idle thread and must implement an
131  * infinite loop.
132  */
133 #if !defined(CH_CFG_NO_IDLE_THREAD)
134 #define CH_CFG_NO_IDLE_THREAD FALSE
135 #endif
136 
137 /** @} */
138 
139 /*===========================================================================*/
140 /**
141  * @name Performance options
142  * @{
143  */
144 /*===========================================================================*/
145 
146 /**
147  * @brief OS optimization.
148  * @details If enabled then time efficient rather than space efficient code
149  * is used when two possible implementations exist.
150  *
151  * @note This is not related to the compiler optimization options.
152  * @note The default is @p TRUE.
153  */
154 #if !defined(CH_CFG_OPTIMIZE_SPEED)
155 #define CH_CFG_OPTIMIZE_SPEED TRUE
156 #endif
157 
158 /** @} */
159 
160 /*===========================================================================*/
161 /**
162  * @name Subsystem options
163  * @{
164  */
165 /*===========================================================================*/
166 
167 /**
168  * @brief Time Measurement APIs.
169  * @details If enabled then the time measurement APIs are included in
170  * the kernel.
171  *
172  * @note The default is @p TRUE.
173  */
174 #if !defined(CH_CFG_USE_TM)
175 #define CH_CFG_USE_TM TRUE
176 #endif
177 
178 /**
179  * @brief Threads registry APIs.
180  * @details If enabled then the registry APIs are included in the kernel.
181  *
182  * @note The default is @p TRUE.
183  */
184 #if !defined(CH_CFG_USE_REGISTRY)
185 #define CH_CFG_USE_REGISTRY TRUE
186 #endif
187 
188 /**
189  * @brief Threads synchronization APIs.
190  * @details If enabled then the @p chThdWait() function is included in
191  * the kernel.
192  *
193  * @note The default is @p TRUE.
194  */
195 #if !defined(CH_CFG_USE_WAITEXIT)
196 #define CH_CFG_USE_WAITEXIT TRUE
197 #endif
198 
199 /**
200  * @brief Semaphores APIs.
201  * @details If enabled then the Semaphores APIs are included in the kernel.
202  *
203  * @note The default is @p TRUE.
204  */
205 #if !defined(CH_CFG_USE_SEMAPHORES)
206 #define CH_CFG_USE_SEMAPHORES TRUE
207 #endif
208 
209 /**
210  * @brief Semaphores queuing mode.
211  * @details If enabled then the threads are enqueued on semaphores by
212  * priority rather than in FIFO order.
213  *
214  * @note The default is @p FALSE. Enable this if you have special
215  * requirements.
216  * @note Requires @p CH_CFG_USE_SEMAPHORES.
217  */
218 #if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY)
219 #define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
220 #endif
221 
222 /**
223  * @brief Mutexes APIs.
224  * @details If enabled then the mutexes APIs are included in the kernel.
225  *
226  * @note The default is @p TRUE.
227  */
228 #if !defined(CH_CFG_USE_MUTEXES)
229 #define CH_CFG_USE_MUTEXES TRUE
230 #endif
231 
232 /**
233  * @brief Enables recursive behavior on mutexes.
234  * @note Recursive mutexes are heavier and have an increased
235  * memory footprint.
236  *
237  * @note The default is @p FALSE.
238  * @note Requires @p CH_CFG_USE_MUTEXES.
239  */
240 #if !defined(CH_CFG_USE_MUTEXES_RECURSIVE)
241 #define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
242 #endif
243 
244 /**
245  * @brief Conditional Variables APIs.
246  * @details If enabled then the conditional variables APIs are included
247  * in the kernel.
248  *
249  * @note The default is @p TRUE.
250  * @note Requires @p CH_CFG_USE_MUTEXES.
251  */
252 #if !defined(CH_CFG_USE_CONDVARS)
253 #define CH_CFG_USE_CONDVARS TRUE
254 #endif
255 
256 /**
257  * @brief Conditional Variables APIs with timeout.
258  * @details If enabled then the conditional variables APIs with timeout
259  * specification are included in the kernel.
260  *
261  * @note The default is @p TRUE.
262  * @note Requires @p CH_CFG_USE_CONDVARS.
263  */
264 #if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
265 #define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
266 #endif
267 
268 /**
269  * @brief Events Flags APIs.
270  * @details If enabled then the event flags APIs are included in the kernel.
271  *
272  * @note The default is @p TRUE.
273  */
274 #if !defined(CH_CFG_USE_EVENTS)
275 #define CH_CFG_USE_EVENTS TRUE
276 #endif
277 
278 /**
279  * @brief Events Flags APIs with timeout.
280  * @details If enabled then the events APIs with timeout specification
281  * are included in the kernel.
282  *
283  * @note The default is @p TRUE.
284  * @note Requires @p CH_CFG_USE_EVENTS.
285  */
286 #if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
287 #define CH_CFG_USE_EVENTS_TIMEOUT TRUE
288 #endif
289 
290 /**
291  * @brief Synchronous Messages APIs.
292  * @details If enabled then the synchronous messages APIs are included
293  * in the kernel.
294  *
295  * @note The default is @p TRUE.
296  */
297 #if !defined(CH_CFG_USE_MESSAGES)
298 #define CH_CFG_USE_MESSAGES TRUE
299 #endif
300 
301 /**
302  * @brief Synchronous Messages queuing mode.
303  * @details If enabled then messages are served by priority rather than in
304  * FIFO order.
305  *
306  * @note The default is @p FALSE. Enable this if you have special
307  * requirements.
308  * @note Requires @p CH_CFG_USE_MESSAGES.
309  */
310 #if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
311 #define CH_CFG_USE_MESSAGES_PRIORITY FALSE
312 #endif
313 
314 /**
315  * @brief Mailboxes APIs.
316  * @details If enabled then the asynchronous messages (mailboxes) APIs are
317  * included in the kernel.
318  *
319  * @note The default is @p TRUE.
320  * @note Requires @p CH_CFG_USE_SEMAPHORES.
321  */
322 #if !defined(CH_CFG_USE_MAILBOXES)
323 #define CH_CFG_USE_MAILBOXES TRUE
324 #endif
325 
326 /**
327  * @brief Core Memory Manager APIs.
328  * @details If enabled then the core memory manager APIs are included
329  * in the kernel.
330  *
331  * @note The default is @p TRUE.
332  */
333 #if !defined(CH_CFG_USE_MEMCORE)
334 #define CH_CFG_USE_MEMCORE TRUE
335 #endif
336 
337 /**
338  * @brief Heap Allocator APIs.
339  * @details If enabled then the memory heap allocator APIs are included
340  * in the kernel.
341  *
342  * @note The default is @p TRUE.
343  * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
344  * @p CH_CFG_USE_SEMAPHORES.
345  * @note Mutexes are recommended.
346  */
347 #if !defined(CH_CFG_USE_HEAP)
348 #define CH_CFG_USE_HEAP TRUE
349 #endif
350 
351 /**
352  * @brief Memory Pools Allocator APIs.
353  * @details If enabled then the memory pools allocator APIs are included
354  * in the kernel.
355  *
356  * @note The default is @p TRUE.
357  */
358 #if !defined(CH_CFG_USE_MEMPOOLS)
359 #define CH_CFG_USE_MEMPOOLS TRUE
360 #endif
361 
362 /**
363  * @brief Objects FIFOs APIs.
364  * @details If enabled then the objects FIFOs APIs are included
365  * in the kernel.
366  *
367  * @note The default is @p TRUE.
368  */
369 #if !defined(CH_CFG_USE_OBJ_FIFOS)
370 #define CH_CFG_USE_OBJ_FIFOS TRUE
371 #endif
372 
373 /**
374  * @brief Dynamic Threads APIs.
375  * @details If enabled then the dynamic threads creation APIs are included
376  * in the kernel.
377  *
378  * @note The default is @p TRUE.
379  * @note Requires @p CH_CFG_USE_WAITEXIT.
380  * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
381  */
382 #if !defined(CH_CFG_USE_DYNAMIC)
383 #define CH_CFG_USE_DYNAMIC TRUE
384 #endif
385 
386 /** @} */
387 
388 /*===========================================================================*/
389 /**
390  * @name Objects factory options
391  * @{
392  */
393 /*===========================================================================*/
394 
395 /**
396  * @brief Objects Factory APIs.
397  * @details If enabled then the objects factory APIs are included in the
398  * kernel.
399  *
400  * @note The default is @p FALSE.
401  */
402 #if !defined(CH_CFG_USE_FACTORY)
403 #define CH_CFG_USE_FACTORY TRUE
404 #endif
405 
406 /**
407  * @brief Maximum length for object names.
408  * @details If the specified length is zero then the name is stored by
409  * pointer but this could have unintended side effects.
410  */
411 #if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
412 #define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8
413 #endif
414 
415 /**
416  * @brief Enables the registry of generic objects.
417  */
418 #if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
419 #define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE
420 #endif
421 
422 /**
423  * @brief Enables factory for generic buffers.
424  */
425 #if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
426 #define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE
427 #endif
428 
429 /**
430  * @brief Enables factory for semaphores.
431  */
432 #if !defined(CH_CFG_FACTORY_SEMAPHORES)
433 #define CH_CFG_FACTORY_SEMAPHORES TRUE
434 #endif
435 
436 /**
437  * @brief Enables factory for mailboxes.
438  */
439 #if !defined(CH_CFG_FACTORY_MAILBOXES)
440 #define CH_CFG_FACTORY_MAILBOXES TRUE
441 #endif
442 
443 /**
444  * @brief Enables factory for objects FIFOs.
445  */
446 #if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
447 #define CH_CFG_FACTORY_OBJ_FIFOS TRUE
448 #endif
449 
450 /** @} */
451 
452 /*===========================================================================*/
453 /**
454  * @name Debug options
455  * @{
456  */
457 /*===========================================================================*/
458 
459 /**
460  * @brief Debug option, kernel statistics.
461  *
462  * @note The default is @p FALSE.
463  */
464 #if !defined(CH_DBG_STATISTICS)
465 #define CH_DBG_STATISTICS FALSE
466 #endif
467 
468 /**
469  * @brief Debug option, system state check.
470  * @details If enabled the correct call protocol for system APIs is checked
471  * at runtime.
472  *
473  * @note The default is @p FALSE.
474  */
475 #if !defined(CH_DBG_SYSTEM_STATE_CHECK)
476 #define CH_DBG_SYSTEM_STATE_CHECK TRUE
477 #endif
478 
479 /**
480  * @brief Debug option, parameters checks.
481  * @details If enabled then the checks on the API functions input
482  * parameters are activated.
483  *
484  * @note The default is @p FALSE.
485  */
486 #if !defined(CH_DBG_ENABLE_CHECKS)
487 #define CH_DBG_ENABLE_CHECKS TRUE
488 #endif
489 
490 /**
491  * @brief Debug option, consistency checks.
492  * @details If enabled then all the assertions in the kernel code are
493  * activated. This includes consistency checks inside the kernel,
494  * runtime anomalies and port-defined checks.
495  *
496  * @note The default is @p FALSE.
497  */
498 #if !defined(CH_DBG_ENABLE_ASSERTS)
499 #define CH_DBG_ENABLE_ASSERTS TRUE
500 #endif
501 
502 /**
503  * @brief Debug option, trace buffer.
504  * @details If enabled then the trace buffer is activated.
505  *
506  * @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
507  */
508 #if !defined(CH_DBG_TRACE_MASK)
509 #define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_ALL
510 #endif
511 
512 /**
513  * @brief Trace buffer entries.
514  * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
515  * different from @p CH_DBG_TRACE_MASK_DISABLED.
516  */
517 #if !defined(CH_DBG_TRACE_BUFFER_SIZE)
518 #define CH_DBG_TRACE_BUFFER_SIZE 128
519 #endif
520 
521 /**
522  * @brief Debug option, stack checks.
523  * @details If enabled then a runtime stack check is performed.
524  *
525  * @note The default is @p FALSE.
526  * @note The stack check is performed in a architecture/port dependent way.
527  * It may not be implemented or some ports.
528  * @note The default failure mode is to halt the system with the global
529  * @p panic_msg variable set to @p NULL.
530  */
531 #if !defined(CH_DBG_ENABLE_STACK_CHECK)
532 #define CH_DBG_ENABLE_STACK_CHECK TRUE
533 #endif
534 
535 /**
536  * @brief Debug option, stacks initialization.
537  * @details If enabled then the threads working area is filled with a byte
538  * value when a thread is created. This can be useful for the
539  * runtime measurement of the used stack.
540  *
541  * @note The default is @p FALSE.
542  */
543 #if !defined(CH_DBG_FILL_THREADS)
544 #define CH_DBG_FILL_THREADS TRUE
545 #endif
546 
547 /**
548  * @brief Debug option, threads profiling.
549  * @details If enabled then a field is added to the @p thread_t structure that
550  * counts the system ticks occurred while executing the thread.
551  *
552  * @note The default is @p FALSE.
553  * @note This debug option is not currently compatible with the
554  * tickless mode.
555  */
556 #if !defined(CH_DBG_THREADS_PROFILING)
557 #define CH_DBG_THREADS_PROFILING FALSE
558 #endif
559 
560 /** @} */
561 
562 /*===========================================================================*/
563 /**
564  * @name Kernel hooks
565  * @{
566  */
567 /*===========================================================================*/
568 
569 /**
570  * @brief System structure extension.
571  * @details User fields added to the end of the @p ch_system_t structure.
572  */
573 #define CH_CFG_SYSTEM_EXTRA_FIELDS \
574  /* Add threads custom fields here.*/
575 
576 /**
577  * @brief System initialization hook.
578  * @details User initialization code added to the @p chSysInit() function
579  * just before interrupts are enabled globally.
580  */
581 #define CH_CFG_SYSTEM_INIT_HOOK() { \
582  /* Add threads initialization code here.*/ \
583 }
584 
585 /**
586  * @brief Threads descriptor structure extension.
587  * @details User fields added to the end of the @p thread_t structure.
588  */
589 #define CH_CFG_THREAD_EXTRA_FIELDS \
590  /* Add threads custom fields here.*/
591 
592 /**
593  * @brief Threads initialization hook.
594  * @details User initialization code added to the @p _thread_init() function.
595  *
596  * @note It is invoked from within @p _thread_init() and implicitly from all
597  * the threads creation APIs.
598  */
599 #define CH_CFG_THREAD_INIT_HOOK(tp) { \
600  /* Add threads initialization code here.*/ \
601 }
602 
603 /**
604  * @brief Threads finalization hook.
605  * @details User finalization code added to the @p chThdExit() API.
606  */
607 #define CH_CFG_THREAD_EXIT_HOOK(tp) { \
608  /* Add threads finalization code here.*/ \
609 }
610 
611 /**
612  * @brief Context switch hook.
613  * @details This hook is invoked just before switching between threads.
614  */
615 #define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
616  /* Context switch code here.*/ \
617 }
618 
619 /**
620  * @brief ISR enter hook.
621  */
622 #define CH_CFG_IRQ_PROLOGUE_HOOK() { \
623  /* IRQ prologue code here.*/ \
624 }
625 
626 /**
627  * @brief ISR exit hook.
628  */
629 #define CH_CFG_IRQ_EPILOGUE_HOOK() { \
630  /* IRQ epilogue code here.*/ \
631 }
632 
633 /**
634  * @brief Idle thread enter hook.
635  * @note This hook is invoked within a critical zone, no OS functions
636  * should be invoked from here.
637  * @note This macro can be used to activate a power saving mode.
638  */
639 #define CH_CFG_IDLE_ENTER_HOOK() { \
640  /* Idle-enter code here.*/ \
641 }
642 
643 /**
644  * @brief Idle thread leave hook.
645  * @note This hook is invoked within a critical zone, no OS functions
646  * should be invoked from here.
647  * @note This macro can be used to deactivate a power saving mode.
648  */
649 #define CH_CFG_IDLE_LEAVE_HOOK() { \
650  /* Idle-leave code here.*/ \
651 }
652 
653 /**
654  * @brief Idle Loop hook.
655  * @details This hook is continuously invoked by the idle thread loop.
656  */
657 #define CH_CFG_IDLE_LOOP_HOOK() { \
658  /* Idle loop code here.*/ \
659 }
660 
661 /**
662  * @brief System tick event hook.
663  * @details This hook is invoked in the system tick handler immediately
664  * after processing the virtual timers queue.
665  */
666 #define CH_CFG_SYSTEM_TICK_HOOK() { \
667  /* System tick event code here.*/ \
668 }
669 
670 /**
671  * @brief System halt hook.
672  * @details This hook is invoked in case to a system halting error before
673  * the system is halted.
674  */
675 #define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
676  /* System halt code here.*/ \
677 }
678 
679 /**
680  * @brief Trace hook.
681  * @details This hook is invoked each time a new record is written in the
682  * trace buffer.
683  */
684 #define CH_CFG_TRACE_HOOK(tep) { \
685  /* Trace code here.*/ \
686 }
687 
688 /** @} */
689 
690 /*===========================================================================*/
691 /* Port-specific settings (override port settings defaulted in chcore.h). */
692 /*===========================================================================*/
693 
694 #endif /* CHCONF_H */
695 
696 /** @} */