ChibiOS/RT
2.5.1
chconf.h
Go to the documentation of this file.
00001 /*
00002     ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
00003                  2011,2012 Giovanni Di Sirio.
00004 
00005     This file is part of ChibiOS/RT.
00006 
00007     ChibiOS/RT is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     ChibiOS/RT is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 /**
00022  * @file    templates/chconf.h
00023  * @brief   Configuration file template.
00024  * @details A copy of this file must be placed in each project directory, it
00025  *          contains the application specific kernel settings.
00026  *
00027  * @addtogroup config
00028  * @details Kernel related settings and hooks.
00029  * @{
00030  */
00031 
00032 #ifndef _CHCONF_H_
00033 #define _CHCONF_H_
00034 
00035 /*===========================================================================*/
00036 /**
00037  * @name Kernel parameters and options
00038  * @{
00039  */
00040 /*===========================================================================*/
00041 
00042 /**
00043  * @brief   System tick frequency.
00044  * @details Frequency of the system timer that drives the system ticks. This
00045  *          setting also defines the system tick time unit.
00046  */
00047 #if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
00048 #define CH_FREQUENCY                    1000
00049 #endif
00050 
00051 /**
00052  * @brief   Round robin interval.
00053  * @details This constant is the number of system ticks allowed for the
00054  *          threads before preemption occurs. Setting this value to zero
00055  *          disables the preemption for threads with equal priority and the
00056  *          round robin becomes cooperative. Note that higher priority
00057  *          threads can still preempt, the kernel is always preemptive.
00058  *
00059  * @note    Disabling the round robin preemption makes the kernel more compact
00060  *          and generally faster.
00061  */
00062 #if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
00063 #define CH_TIME_QUANTUM                 20
00064 #endif
00065 
00066 /**
00067  * @brief   Managed RAM size.
00068  * @details Size of the RAM area to be managed by the OS. If set to zero
00069  *          then the whole available RAM is used. The core memory is made
00070  *          available to the heap allocator and/or can be used directly through
00071  *          the simplified core memory allocator.
00072  *
00073  * @note    In order to let the OS manage the whole RAM the linker script must
00074  *          provide the @p __heap_base__ and @p __heap_end__ symbols.
00075  * @note    Requires @p CH_USE_MEMCORE.
00076  */
00077 #if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__)
00078 #define CH_MEMCORE_SIZE                 0
00079 #endif
00080 
00081 /**
00082  * @brief   Idle thread automatic spawn suppression.
00083  * @details When this option is activated the function @p chSysInit()
00084  *          does not spawn the idle thread automatically. The application has
00085  *          then the responsibility to do one of the following:
00086  *          - Spawn a custom idle thread at priority @p IDLEPRIO.
00087  *          - Change the main() thread priority to @p IDLEPRIO then enter
00088  *            an endless loop. In this scenario the @p main() thread acts as
00089  *            the idle thread.
00090  *          .
00091  * @note    Unless an idle thread is spawned the @p main() thread must not
00092  *          enter a sleep state.
00093  */
00094 #if !defined(CH_NO_IDLE_THREAD) || defined(__DOXYGEN__)
00095 #define CH_NO_IDLE_THREAD               FALSE
00096 #endif
00097 
00098 /** @} */
00099 
00100 /*===========================================================================*/
00101 /**
00102  * @name Performance options
00103  * @{
00104  */
00105 /*===========================================================================*/
00106 
00107 /**
00108  * @brief   OS optimization.
00109  * @details If enabled then time efficient rather than space efficient code
00110  *          is used when two possible implementations exist.
00111  *
00112  * @note    This is not related to the compiler optimization options.
00113  * @note    The default is @p TRUE.
00114  */
00115 #if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
00116 #define CH_OPTIMIZE_SPEED               TRUE
00117 #endif
00118 
00119 /** @} */
00120 
00121 /*===========================================================================*/
00122 /**
00123  * @name Subsystem options
00124  * @{
00125  */
00126 /*===========================================================================*/
00127 
00128 /**
00129  * @brief   Threads registry APIs.
00130  * @details If enabled then the registry APIs are included in the kernel.
00131  *
00132  * @note    The default is @p TRUE.
00133  */
00134 #if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__)
00135 #define CH_USE_REGISTRY                 TRUE
00136 #endif
00137 
00138 /**
00139  * @brief   Threads synchronization APIs.
00140  * @details If enabled then the @p chThdWait() function is included in
00141  *          the kernel.
00142  *
00143  * @note    The default is @p TRUE.
00144  */
00145 #if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
00146 #define CH_USE_WAITEXIT                 TRUE
00147 #endif
00148 
00149 /**
00150  * @brief   Semaphores APIs.
00151  * @details If enabled then the Semaphores APIs are included in the kernel.
00152  *
00153  * @note    The default is @p TRUE.
00154  */
00155 #if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
00156 #define CH_USE_SEMAPHORES               TRUE
00157 #endif
00158 
00159 /**
00160  * @brief   Semaphores queuing mode.
00161  * @details If enabled then the threads are enqueued on semaphores by
00162  *          priority rather than in FIFO order.
00163  *
00164  * @note    The default is @p FALSE. Enable this if you have special requirements.
00165  * @note    Requires @p CH_USE_SEMAPHORES.
00166  */
00167 #if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
00168 #define CH_USE_SEMAPHORES_PRIORITY      FALSE
00169 #endif
00170 
00171 /**
00172  * @brief   Atomic semaphore API.
00173  * @details If enabled then the semaphores the @p chSemSignalWait() API
00174  *          is included in the kernel.
00175  *
00176  * @note    The default is @p TRUE.
00177  * @note    Requires @p CH_USE_SEMAPHORES.
00178  */
00179 #if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
00180 #define CH_USE_SEMSW                    TRUE
00181 #endif
00182 
00183 /**
00184  * @brief   Mutexes APIs.
00185  * @details If enabled then the mutexes APIs are included in the kernel.
00186  *
00187  * @note    The default is @p TRUE.
00188  */
00189 #if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
00190 #define CH_USE_MUTEXES                  TRUE
00191 #endif
00192 
00193 /**
00194  * @brief   Conditional Variables APIs.
00195  * @details If enabled then the conditional variables APIs are included
00196  *          in the kernel.
00197  *
00198  * @note    The default is @p TRUE.
00199  * @note    Requires @p CH_USE_MUTEXES.
00200  */
00201 #if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
00202 #define CH_USE_CONDVARS                 TRUE
00203 #endif
00204 
00205 /**
00206  * @brief   Conditional Variables APIs with timeout.
00207  * @details If enabled then the conditional variables APIs with timeout
00208  *          specification are included in the kernel.
00209  *
00210  * @note    The default is @p TRUE.
00211  * @note    Requires @p CH_USE_CONDVARS.
00212  */
00213 #if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
00214 #define CH_USE_CONDVARS_TIMEOUT         TRUE
00215 #endif
00216 
00217 /**
00218  * @brief   Events Flags APIs.
00219  * @details If enabled then the event flags APIs are included in the kernel.
00220  *
00221  * @note    The default is @p TRUE.
00222  */
00223 #if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
00224 #define CH_USE_EVENTS                   TRUE
00225 #endif
00226 
00227 /**
00228  * @brief   Events Flags APIs with timeout.
00229  * @details If enabled then the events APIs with timeout specification
00230  *          are included in the kernel.
00231  *
00232  * @note    The default is @p TRUE.
00233  * @note    Requires @p CH_USE_EVENTS.
00234  */
00235 #if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
00236 #define CH_USE_EVENTS_TIMEOUT           TRUE
00237 #endif
00238 
00239 /**
00240  * @brief   Synchronous Messages APIs.
00241  * @details If enabled then the synchronous messages APIs are included
00242  *          in the kernel.
00243  *
00244  * @note    The default is @p TRUE.
00245  */
00246 #if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
00247 #define CH_USE_MESSAGES                 TRUE
00248 #endif
00249 
00250 /**
00251  * @brief   Synchronous Messages queuing mode.
00252  * @details If enabled then messages are served by priority rather than in
00253  *          FIFO order.
00254  *
00255  * @note    The default is @p FALSE. Enable this if you have special requirements.
00256  * @note    Requires @p CH_USE_MESSAGES.
00257  */
00258 #if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
00259 #define CH_USE_MESSAGES_PRIORITY        FALSE
00260 #endif
00261 
00262 /**
00263  * @brief   Mailboxes APIs.
00264  * @details If enabled then the asynchronous messages (mailboxes) APIs are
00265  *          included in the kernel.
00266  *
00267  * @note    The default is @p TRUE.
00268  * @note    Requires @p CH_USE_SEMAPHORES.
00269  */
00270 #if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
00271 #define CH_USE_MAILBOXES                TRUE
00272 #endif
00273 
00274 /**
00275  * @brief   I/O Queues APIs.
00276  * @details If enabled then the I/O queues APIs are included in the kernel.
00277  *
00278  * @note    The default is @p TRUE.
00279  */
00280 #if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
00281 #define CH_USE_QUEUES                   TRUE
00282 #endif
00283 
00284 /**
00285  * @brief   Core Memory Manager APIs.
00286  * @details If enabled then the core memory manager APIs are included
00287  *          in the kernel.
00288  *
00289  * @note    The default is @p TRUE.
00290  */
00291 #if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__)
00292 #define CH_USE_MEMCORE                  TRUE
00293 #endif
00294 
00295 /**
00296  * @brief   Heap Allocator APIs.
00297  * @details If enabled then the memory heap allocator APIs are included
00298  *          in the kernel.
00299  *
00300  * @note    The default is @p TRUE.
00301  * @note    Requires @p CH_USE_MEMCORE and either @p CH_USE_MUTEXES or
00302  *          @p CH_USE_SEMAPHORES.
00303  * @note    Mutexes are recommended.
00304  */
00305 #if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
00306 #define CH_USE_HEAP                     TRUE
00307 #endif
00308 
00309 /**
00310  * @brief   C-runtime allocator.
00311  * @details If enabled the the heap allocator APIs just wrap the C-runtime
00312  *          @p malloc() and @p free() functions.
00313  *
00314  * @note    The default is @p FALSE.
00315  * @note    Requires @p CH_USE_HEAP.
00316  * @note    The C-runtime may or may not require @p CH_USE_MEMCORE, see the
00317  *          appropriate documentation.
00318  */
00319 #if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
00320 #define CH_USE_MALLOC_HEAP              FALSE
00321 #endif
00322 
00323 /**
00324  * @brief   Memory Pools Allocator APIs.
00325  * @details If enabled then the memory pools allocator APIs are included
00326  *          in the kernel.
00327  *
00328  * @note    The default is @p TRUE.
00329  */
00330 #if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
00331 #define CH_USE_MEMPOOLS                 TRUE
00332 #endif
00333 
00334 /**
00335  * @brief   Dynamic Threads APIs.
00336  * @details If enabled then the dynamic threads creation APIs are included
00337  *          in the kernel.
00338  *
00339  * @note    The default is @p TRUE.
00340  * @note    Requires @p CH_USE_WAITEXIT.
00341  * @note    Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS.
00342  */
00343 #if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
00344 #define CH_USE_DYNAMIC                  TRUE
00345 #endif
00346 
00347 /** @} */
00348 
00349 /*===========================================================================*/
00350 /**
00351  * @name Debug options
00352  * @{
00353  */
00354 /*===========================================================================*/
00355 
00356 /**
00357  * @brief   Debug option, system state check.
00358  * @details If enabled the correct call protocol for system APIs is checked
00359  *          at runtime.
00360  *
00361  * @note    The default is @p FALSE.
00362  */
00363 #if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
00364 #define CH_DBG_SYSTEM_STATE_CHECK       FALSE
00365 #endif
00366 
00367 /**
00368  * @brief   Debug option, parameters checks.
00369  * @details If enabled then the checks on the API functions input
00370  *          parameters are activated.
00371  *
00372  * @note    The default is @p FALSE.
00373  */
00374 #if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
00375 #define CH_DBG_ENABLE_CHECKS            FALSE
00376 #endif
00377 
00378 /**
00379  * @brief   Debug option, consistency checks.
00380  * @details If enabled then all the assertions in the kernel code are
00381  *          activated. This includes consistency checks inside the kernel,
00382  *          runtime anomalies and port-defined checks.
00383  *
00384  * @note    The default is @p FALSE.
00385  */
00386 #if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
00387 #define CH_DBG_ENABLE_ASSERTS           FALSE
00388 #endif
00389 
00390 /**
00391  * @brief   Debug option, trace buffer.
00392  * @details If enabled then the context switch circular trace buffer is
00393  *          activated.
00394  *
00395  * @note    The default is @p FALSE.
00396  */
00397 #if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
00398 #define CH_DBG_ENABLE_TRACE             FALSE
00399 #endif
00400 
00401 /**
00402  * @brief   Debug option, stack checks.
00403  * @details If enabled then a runtime stack check is performed.
00404  *
00405  * @note    The default is @p FALSE.
00406  * @note    The stack check is performed in a architecture/port dependent way.
00407  *          It may not be implemented or some ports.
00408  * @note    The default failure mode is to halt the system with the global
00409  *          @p panic_msg variable set to @p NULL.
00410  */
00411 #if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
00412 #define CH_DBG_ENABLE_STACK_CHECK       FALSE
00413 #endif
00414 
00415 /**
00416  * @brief   Debug option, stacks initialization.
00417  * @details If enabled then the threads working area is filled with a byte
00418  *          value when a thread is created. This can be useful for the
00419  *          runtime measurement of the used stack.
00420  *
00421  * @note    The default is @p FALSE.
00422  */
00423 #if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
00424 #define CH_DBG_FILL_THREADS             FALSE
00425 #endif
00426 
00427 /**
00428  * @brief   Debug option, threads profiling.
00429  * @details If enabled then a field is added to the @p Thread structure that
00430  *          counts the system ticks occurred while executing the thread.
00431  *
00432  * @note    The default is @p TRUE.
00433  * @note    This debug option is defaulted to TRUE because it is required by
00434  *          some test cases into the test suite.
00435  */
00436 #if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
00437 #define CH_DBG_THREADS_PROFILING        TRUE
00438 #endif
00439 
00440 /** @} */
00441 
00442 /*===========================================================================*/
00443 /**
00444  * @name Kernel hooks
00445  * @{
00446  */
00447 /*===========================================================================*/
00448 
00449 /**
00450  * @brief   Threads descriptor structure extension.
00451  * @details User fields added to the end of the @p Thread structure.
00452  */
00453 #if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
00454 #define THREAD_EXT_FIELDS                                                   \
00455   /* Add threads custom fields here.*/
00456 #endif
00457 
00458 /**
00459  * @brief   Threads initialization hook.
00460  * @details User initialization code added to the @p chThdInit() API.
00461  *
00462  * @note    It is invoked from within @p chThdInit() and implicitly from all
00463  *          the threads creation APIs.
00464  */
00465 #if !defined(THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__)
00466 #define THREAD_EXT_INIT_HOOK(tp) {                                          \
00467   /* Add threads initialization code here.*/                                \
00468 }
00469 #endif
00470 
00471 /**
00472  * @brief   Threads finalization hook.
00473  * @details User finalization code added to the @p chThdExit() API.
00474  *
00475  * @note    It is inserted into lock zone.
00476  * @note    It is also invoked when the threads simply return in order to
00477  *          terminate.
00478  */
00479 #if !defined(THREAD_EXT_EXIT_HOOK) || defined(__DOXYGEN__)
00480 #define THREAD_EXT_EXIT_HOOK(tp) {                                          \
00481   /* Add threads finalization code here.*/                                  \
00482 }
00483 #endif
00484 
00485 /**
00486  * @brief   Context switch hook.
00487  * @details This hook is invoked just before switching between threads.
00488  */
00489 #if !defined(THREAD_CONTEXT_SWITCH_HOOK) || defined(__DOXYGEN__)
00490 #define THREAD_CONTEXT_SWITCH_HOOK(ntp, otp) {                              \
00491   /* System halt code here.*/                                               \
00492 }
00493 #endif
00494 
00495 /**
00496  * @brief   Idle Loop hook.
00497  * @details This hook is continuously invoked by the idle thread loop.
00498  */
00499 #if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
00500 #define IDLE_LOOP_HOOK() {                                                  \
00501   /* Idle loop code here.*/                                                 \
00502 }
00503 #endif
00504 
00505 /**
00506  * @brief   System tick event hook.
00507  * @details This hook is invoked in the system tick handler immediately
00508  *          after processing the virtual timers queue.
00509  */
00510 #if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__)
00511 #define SYSTEM_TICK_EVENT_HOOK() {                                          \
00512   /* System tick event code here.*/                                         \
00513 }
00514 #endif
00515 
00516 /**
00517  * @brief   System halt hook.
00518  * @details This hook is invoked in case to a system halting error before
00519  *          the system is halted.
00520  */
00521 #if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
00522 #define SYSTEM_HALT_HOOK() {                                                \
00523   /* System halt code here.*/                                               \
00524 }
00525 #endif
00526 
00527 /** @} */
00528 
00529 /*===========================================================================*/
00530 /* Port-specific settings (override port settings defaulted in chcore.h).    */
00531 /*===========================================================================*/
00532 
00533 #endif  /* _CHCONF_H_ */
00534 
00535 /** @} */