qmk

QMK Firmware
git clone git://git.z3bra.org/qmk.git
Log | Files | Refs | Submodules | LICENSE

chconf.h (16462B)


      1 /*
      2     ChibiOS - Copyright (C) 2006..2015 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 
     33 /*===========================================================================*/
     34 /**
     35  * @name System timers settings
     36  * @{
     37  */
     38 /*===========================================================================*/
     39 
     40 /**
     41  * @brief   System time counter resolution.
     42  * @note    Allowed values are 16 or 32 bits.
     43  */
     44 #define CH_CFG_ST_RESOLUTION                32
     45 
     46 /**
     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.
     50  */
     51 #define CH_CFG_ST_FREQUENCY                 100000
     52 
     53 /**
     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
     59  *          this value.
     60  */
     61 #define CH_CFG_ST_TIMEDELTA                 0
     62 
     63 /** @} */
     64 
     65 /*===========================================================================*/
     66 /**
     67  * @name Kernel parameters and options
     68  * @{
     69  */
     70 /*===========================================================================*/
     71 
     72 /**
     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.
     83  */
     84 #define CH_CFG_TIME_QUANTUM                 0
     85 
     86 /**
     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.
     92  *
     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.
     96  */
     97 #define CH_CFG_MEMCORE_SIZE                 0
     98 
     99 /**
    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
    104  *          infinite loop.
    105  */
    106 #define CH_CFG_NO_IDLE_THREAD               FALSE
    107 
    108 /* Use __WFI in the idle thread for waiting. Does lower the power
    109  * consumption. */
    110 #define CORTEX_ENABLE_WFI_IDLE              TRUE
    111 
    112 /** @} */
    113 
    114 /*===========================================================================*/
    115 /**
    116  * @name Performance options
    117  * @{
    118  */
    119 /*===========================================================================*/
    120 
    121 /**
    122  * @brief   OS optimization.
    123  * @details If enabled then time efficient rather than space efficient code
    124  *          is used when two possible implementations exist.
    125  *
    126  * @note    This is not related to the compiler optimization options.
    127  * @note    The default is @p TRUE.
    128  */
    129 #define CH_CFG_OPTIMIZE_SPEED               TRUE
    130 
    131 /** @} */
    132 
    133 /*===========================================================================*/
    134 /**
    135  * @name Subsystem options
    136  * @{
    137  */
    138 /*===========================================================================*/
    139 
    140 /**
    141  * @brief   Time Measurement APIs.
    142  * @details If enabled then the time measurement APIs are included in
    143  *          the kernel.
    144  *
    145  * @note    The default is @p TRUE.
    146  */
    147 #define CH_CFG_USE_TM                       FALSE
    148 
    149 /**
    150  * @brief   Threads registry APIs.
    151  * @details If enabled then the registry APIs are included in the kernel.
    152  *
    153  * @note    The default is @p TRUE.
    154  */
    155 #define CH_CFG_USE_REGISTRY                 TRUE
    156 
    157 /**
    158  * @brief   Threads synchronization APIs.
    159  * @details If enabled then the @p chThdWait() function is included in
    160  *          the kernel.
    161  *
    162  * @note    The default is @p TRUE.
    163  */
    164 #define CH_CFG_USE_WAITEXIT                 TRUE
    165 
    166 /**
    167  * @brief   Semaphores APIs.
    168  * @details If enabled then the Semaphores APIs are included in the kernel.
    169  *
    170  * @note    The default is @p TRUE.
    171  */
    172 #define CH_CFG_USE_SEMAPHORES               TRUE
    173 
    174 /**
    175  * @brief   Semaphores queuing mode.
    176  * @details If enabled then the threads are enqueued on semaphores by
    177  *          priority rather than in FIFO order.
    178  *
    179  * @note    The default is @p FALSE. Enable this if you have special
    180  *          requirements.
    181  * @note    Requires @p CH_CFG_USE_SEMAPHORES.
    182  */
    183 #define CH_CFG_USE_SEMAPHORES_PRIORITY      FALSE
    184 
    185 /**
    186  * @brief   Mutexes APIs.
    187  * @details If enabled then the mutexes APIs are included in the kernel.
    188  *
    189  * @note    The default is @p TRUE.
    190  */
    191 #define CH_CFG_USE_MUTEXES                  TRUE
    192 
    193 /**
    194  * @brief   Enables recursive behavior on mutexes.
    195  * @note    Recursive mutexes are heavier and have an increased
    196  *          memory footprint.
    197  *
    198  * @note    The default is @p FALSE.
    199  * @note    Requires @p CH_CFG_USE_MUTEXES.
    200  */
    201 #define CH_CFG_USE_MUTEXES_RECURSIVE        FALSE
    202 
    203 /**
    204  * @brief   Conditional Variables APIs.
    205  * @details If enabled then the conditional variables APIs are included
    206  *          in the kernel.
    207  *
    208  * @note    The default is @p TRUE.
    209  * @note    Requires @p CH_CFG_USE_MUTEXES.
    210  */
    211 #define CH_CFG_USE_CONDVARS                 TRUE
    212 
    213 /**
    214  * @brief   Conditional Variables APIs with timeout.
    215  * @details If enabled then the conditional variables APIs with timeout
    216  *          specification are included in the kernel.
    217  *
    218  * @note    The default is @p TRUE.
    219  * @note    Requires @p CH_CFG_USE_CONDVARS.
    220  */
    221 #define CH_CFG_USE_CONDVARS_TIMEOUT         FALSE
    222 
    223 /**
    224  * @brief   Events Flags APIs.
    225  * @details If enabled then the event flags APIs are included in the kernel.
    226  *
    227  * @note    The default is @p TRUE.
    228  */
    229 #define CH_CFG_USE_EVENTS                   TRUE
    230 
    231 /**
    232  * @brief   Events Flags APIs with timeout.
    233  * @details If enabled then the events APIs with timeout specification
    234  *          are included in the kernel.
    235  *
    236  * @note    The default is @p TRUE.
    237  * @note    Requires @p CH_CFG_USE_EVENTS.
    238  */
    239 #define CH_CFG_USE_EVENTS_TIMEOUT           TRUE
    240 
    241 /**
    242  * @brief   Synchronous Messages APIs.
    243  * @details If enabled then the synchronous messages APIs are included
    244  *          in the kernel.
    245  *
    246  * @note    The default is @p TRUE.
    247  */
    248 #define CH_CFG_USE_MESSAGES                 TRUE
    249 
    250 /**
    251  * @brief   Synchronous Messages queuing mode.
    252  * @details If enabled then messages are served by priority rather than in
    253  *          FIFO order.
    254  *
    255  * @note    The default is @p FALSE. Enable this if you have special
    256  *          requirements.
    257  * @note    Requires @p CH_CFG_USE_MESSAGES.
    258  */
    259 #define CH_CFG_USE_MESSAGES_PRIORITY        FALSE
    260 
    261 /**
    262  * @brief   Mailboxes APIs.
    263  * @details If enabled then the asynchronous messages (mailboxes) APIs are
    264  *          included in the kernel.
    265  *
    266  * @note    The default is @p TRUE.
    267  * @note    Requires @p CH_CFG_USE_SEMAPHORES.
    268  */
    269 #define CH_CFG_USE_MAILBOXES                TRUE
    270 
    271 /**
    272  * @brief   Core Memory Manager APIs.
    273  * @details If enabled then the core memory manager APIs are included
    274  *          in the kernel.
    275  *
    276  * @note    The default is @p TRUE.
    277  */
    278 #define CH_CFG_USE_MEMCORE                  TRUE
    279 
    280 /**
    281  * @brief   Heap Allocator APIs.
    282  * @details If enabled then the memory heap allocator APIs are included
    283  *          in the kernel.
    284  *
    285  * @note    The default is @p TRUE.
    286  * @note    Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
    287  *          @p CH_CFG_USE_SEMAPHORES.
    288  * @note    Mutexes are recommended.
    289  */
    290 #define CH_CFG_USE_HEAP                     TRUE
    291 
    292 /**
    293  * @brief   Memory Pools Allocator APIs.
    294  * @details If enabled then the memory pools allocator APIs are included
    295  *          in the kernel.
    296  *
    297  * @note    The default is @p TRUE.
    298  */
    299 #define CH_CFG_USE_MEMPOOLS                 FALSE
    300 
    301 /**
    302  * @brief   Dynamic Threads APIs.
    303  * @details If enabled then the dynamic threads creation APIs are included
    304  *          in the kernel.
    305  *
    306  * @note    The default is @p TRUE.
    307  * @note    Requires @p CH_CFG_USE_WAITEXIT.
    308  * @note    Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
    309  */
    310 #define CH_CFG_USE_DYNAMIC                  FALSE
    311 
    312 /** @} */
    313 
    314 /*===========================================================================*/
    315 /**
    316  * @name Debug options
    317  * @{
    318  */
    319 /*===========================================================================*/
    320 
    321 /**
    322  * @brief   Debug option, kernel statistics.
    323  *
    324  * @note    The default is @p FALSE.
    325  */
    326 #define CH_DBG_STATISTICS                   FALSE
    327 
    328 /**
    329  * @brief   Debug option, system state check.
    330  * @details If enabled the correct call protocol for system APIs is checked
    331  *          at runtime.
    332  *
    333  * @note    The default is @p FALSE.
    334  */
    335 #define CH_DBG_SYSTEM_STATE_CHECK           FALSE
    336 
    337 /**
    338  * @brief   Debug option, parameters checks.
    339  * @details If enabled then the checks on the API functions input
    340  *          parameters are activated.
    341  *
    342  * @note    The default is @p FALSE.
    343  */
    344 #define CH_DBG_ENABLE_CHECKS                FALSE
    345 
    346 /**
    347  * @brief   Debug option, consistency checks.
    348  * @details If enabled then all the assertions in the kernel code are
    349  *          activated. This includes consistency checks inside the kernel,
    350  *          runtime anomalies and port-defined checks.
    351  *
    352  * @note    The default is @p FALSE.
    353  */
    354 #define CH_DBG_ENABLE_ASSERTS               FALSE
    355 
    356 /**
    357  * @brief   Debug option, trace buffer.
    358  * @details If enabled then the trace buffer is activated.
    359  *
    360  * @note    The default is @p CH_DBG_TRACE_MASK_DISABLED.
    361  */
    362 #define CH_DBG_TRACE_MASK                   CH_DBG_TRACE_MASK_DISABLED
    363 
    364 /**
    365  * @brief   Trace buffer entries.
    366  * @note    The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
    367  *          different from @p CH_DBG_TRACE_MASK_DISABLED.
    368  */
    369 #define CH_DBG_TRACE_BUFFER_SIZE            128
    370 
    371 /**
    372  * @brief   Debug option, stack checks.
    373  * @details If enabled then a runtime stack check is performed.
    374  *
    375  * @note    The default is @p FALSE.
    376  * @note    The stack check is performed in a architecture/port dependent way.
    377  *          It may not be implemented or some ports.
    378  * @note    The default failure mode is to halt the system with the global
    379  *          @p panic_msg variable set to @p NULL.
    380  */
    381 #define CH_DBG_ENABLE_STACK_CHECK           FALSE
    382 
    383 /**
    384  * @brief   Debug option, stacks initialization.
    385  * @details If enabled then the threads working area is filled with a byte
    386  *          value when a thread is created. This can be useful for the
    387  *          runtime measurement of the used stack.
    388  *
    389  * @note    The default is @p FALSE.
    390  */
    391 #define CH_DBG_FILL_THREADS                 FALSE
    392 
    393 /**
    394  * @brief   Debug option, threads profiling.
    395  * @details If enabled then a field is added to the @p thread_t structure that
    396  *          counts the system ticks occurred while executing the thread.
    397  *
    398  * @note    The default is @p FALSE.
    399  * @note    This debug option is not currently compatible with the
    400  *          tickless mode.
    401  */
    402 #define CH_DBG_THREADS_PROFILING            FALSE
    403 
    404 /** @} */
    405 
    406 /*===========================================================================*/
    407 /**
    408  * @name Kernel hooks
    409  * @{
    410  */
    411 /*===========================================================================*/
    412 
    413 /**
    414  * @brief   Threads descriptor structure extension.
    415  * @details User fields added to the end of the @p thread_t structure.
    416  */
    417 #define CH_CFG_THREAD_EXTRA_FIELDS                                          \
    418   /* Add threads custom fields here.*/
    419 
    420 /**
    421  * @brief   Threads initialization hook.
    422  * @details User initialization code added to the @p chThdInit() API.
    423  *
    424  * @note    It is invoked from within @p chThdInit() and implicitly from all
    425  *          the threads creation APIs.
    426  */
    427 #define CH_CFG_THREAD_INIT_HOOK(tp) {                                       \
    428   /* Add threads initialization code here.*/                                \
    429 }
    430 
    431 /**
    432  * @brief   Threads finalization hook.
    433  * @details User finalization code added to the @p chThdExit() API.
    434  */
    435 #define CH_CFG_THREAD_EXIT_HOOK(tp) {                                       \
    436   /* Add threads finalization code here.*/                                  \
    437 }
    438 
    439 /**
    440  * @brief   Context switch hook.
    441  * @details This hook is invoked just before switching between threads.
    442  */
    443 #define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) {                              \
    444   /* Context switch code here.*/                                            \
    445 }
    446 
    447 /**
    448  * @brief   ISR enter hook.
    449  */
    450 #define CH_CFG_IRQ_PROLOGUE_HOOK() {                                        \
    451   /* IRQ prologue code here.*/                                              \
    452 }
    453 
    454 /**
    455  * @brief   ISR exit hook.
    456  */
    457 #define CH_CFG_IRQ_EPILOGUE_HOOK() {                                        \
    458   /* IRQ epilogue code here.*/                                              \
    459 }
    460 
    461 /**
    462  * @brief   Idle thread enter hook.
    463  * @note    This hook is invoked within a critical zone, no OS functions
    464  *          should be invoked from here.
    465  * @note    This macro can be used to activate a power saving mode.
    466  */
    467 #define CH_CFG_IDLE_ENTER_HOOK() {                                          \
    468   /* Idle-enter code here.*/                                                \
    469 }
    470 
    471 /**
    472  * @brief   Idle thread leave hook.
    473  * @note    This hook is invoked within a critical zone, no OS functions
    474  *          should be invoked from here.
    475  * @note    This macro can be used to deactivate a power saving mode.
    476  */
    477 #define CH_CFG_IDLE_LEAVE_HOOK() {                                          \
    478   /* Idle-leave code here.*/                                                \
    479 }
    480 
    481 /**
    482  * @brief   Idle Loop hook.
    483  * @details This hook is continuously invoked by the idle thread loop.
    484  */
    485 #define CH_CFG_IDLE_LOOP_HOOK() {                                           \
    486   /* Idle loop code here.*/                                                 \
    487 }
    488 
    489 /**
    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.
    493  */
    494 #define CH_CFG_SYSTEM_TICK_HOOK() {                                         \
    495   /* System tick event code here.*/                                         \
    496 }
    497 
    498 /**
    499  * @brief   System halt hook.
    500  * @details This hook is invoked in case to a system halting error before
    501  *          the system is halted.
    502  */
    503 #define CH_CFG_SYSTEM_HALT_HOOK(reason) {                                   \
    504   /* System halt code here.*/                                               \
    505 }
    506 
    507 /**
    508  * @brief   Trace hook.
    509  * @details This hook is invoked each time a new record is written in the
    510  *          trace buffer.
    511  */
    512 #define CH_CFG_TRACE_HOOK(tep) {                                            \
    513   /* Trace code here.*/                                                     \
    514 }
    515 
    516 /** @} */
    517 
    518 /*===========================================================================*/
    519 /* Port-specific settings (override port settings defaulted in chcore.h).    */
    520 /*===========================================================================*/
    521 
    522 #endif  /* CHCONF_H */
    523 
    524 /** @} */