ChibiOS 21.11.5
nil/templates/chconf.h
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006-2026 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 nil/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 NIL_CONFIG
24 * @details Kernel related settings and hooks.
25 * @{
26 */
27
28#ifndef CHCONF_H
29#define CHCONF_H
30
31#define _CHIBIOS_NIL_CONF_
32#define _CHIBIOS_NIL_CONF_VER_4_0_
33
34/*===========================================================================*/
35/**
36 * @name Kernel parameters and options
37 * @{
38 */
39/*===========================================================================*/
40
41/**
42 * @brief Maximum number of user threads in the application.
43 * @note This number is not inclusive of the idle thread which is
44 * implicitly handled.
45 * @note Set this value to be exactly equal to the number of threads you
46 * will use or you would be wasting RAM and cycles.
47 * @note This values also defines the number of available priorities
48 * (0..CH_CFG_MAX_THREADS-1).
49 */
50#if !defined(CH_CFG_MAX_THREADS)
51#define CH_CFG_MAX_THREADS 4
52#endif
53
54/**
55 * @brief Auto starts threads when @p chSysInit() is invoked.
56 */
57#if !defined(CH_CFG_AUTOSTART_THREADS)
58#define CH_CFG_AUTOSTART_THREADS TRUE
59#endif
60
61/** @} */
62
63/*===========================================================================*/
64/**
65 * @name System timer settings
66 * @{
67 */
68/*===========================================================================*/
69
70/**
71 * @brief System time counter resolution.
72 * @note Allowed values are 16 or 32 bits.
73 */
74#if !defined(CH_CFG_ST_RESOLUTION)
75#define CH_CFG_ST_RESOLUTION 32
76#endif
77
78/**
79 * @brief System tick frequency.
80 * @note This value together with the @p CH_CFG_ST_RESOLUTION
81 * option defines the maximum amount of time allowed for
82 * timeouts.
83 */
84#if !defined(CH_CFG_ST_FREQUENCY)
85#define CH_CFG_ST_FREQUENCY 1000
86#endif
87
88/**
89 * @brief Time delta constant for the tick-less mode.
90 * @note If this value is zero then the system uses the classic
91 * periodic tick. This value represents the minimum number
92 * of ticks that is safe to specify in a timeout directive.
93 * The value one is not valid, timeouts are rounded up to
94 * this value.
95 */
96#if !defined(CH_CFG_ST_TIMEDELTA)
97#define CH_CFG_ST_TIMEDELTA 0
98#endif
99
100/** @} */
101
102/*===========================================================================*/
103/**
104 * @name Subsystem options
105 * @{
106 */
107/*===========================================================================*/
108
109/**
110 * @brief Threads synchronization APIs.
111 * @details If enabled then the @p chThdWait() function is included in
112 * the kernel.
113 *
114 * @note The default is @p TRUE.
115 */
116#if !defined(CH_CFG_USE_WAITEXIT)
117#define CH_CFG_USE_WAITEXIT TRUE
118#endif
119
120/**
121 * @brief Semaphores APIs.
122 * @details If enabled then the Semaphores APIs are included in the kernel.
123 *
124 * @note The default is @p TRUE.
125 */
126#if !defined(CH_CFG_USE_SEMAPHORES)
127#define CH_CFG_USE_SEMAPHORES TRUE
128#endif
129
130/**
131 * @brief Mutexes APIs.
132 * @details If enabled then the mutexes APIs are included in the kernel.
133 *
134 * @note Feature not currently implemented.
135 * @note The default is @p FALSE.
136 */
137#if !defined(CH_CFG_USE_MUTEXES)
138#define CH_CFG_USE_MUTEXES FALSE
139#endif
140
141/**
142 * @brief Events Flags APIs.
143 * @details If enabled then the event flags APIs are included in the kernel.
144 *
145 * @note The default is @p TRUE.
146 */
147#if !defined(CH_CFG_USE_EVENTS)
148#define CH_CFG_USE_EVENTS TRUE
149#endif
150
151/**
152 * @brief Synchronous Messages APIs.
153 * @details If enabled then the synchronous messages APIs are included
154 * in the kernel.
155 *
156 * @note The default is @p TRUE.
157 */
158#if !defined(CH_CFG_USE_MESSAGES)
159#define CH_CFG_USE_MESSAGES TRUE
160#endif
161
162/** @} */
163
164/*===========================================================================*/
165/**
166 * @name OSLIB options
167 * @{
168 */
169/*===========================================================================*/
170
171/**
172 * @brief Mailboxes APIs.
173 * @details If enabled then the asynchronous messages (mailboxes) APIs are
174 * included in the kernel.
175 *
176 * @note The default is @p TRUE.
177 * @note Requires @p CH_CFG_USE_SEMAPHORES.
178 */
179#if !defined(CH_CFG_USE_MAILBOXES)
180#define CH_CFG_USE_MAILBOXES TRUE
181#endif
182
183/**
184 * @brief Memory checks APIs.
185 * @details If enabled then the memory checks APIs are included in the kernel.
186 *
187 * @note The default is @p TRUE.
188 */
189#if !defined(CH_CFG_USE_MEMCHECKS)
190#define CH_CFG_USE_MEMCHECKS TRUE
191#endif
192
193/**
194 * @brief Core Memory Manager APIs.
195 * @details If enabled then the core memory manager APIs are included
196 * in the kernel.
197 *
198 * @note The default is @p TRUE.
199 */
200#if !defined(CH_CFG_USE_MEMCORE)
201#define CH_CFG_USE_MEMCORE TRUE
202#endif
203
204/**
205 * @brief Managed RAM size.
206 * @details Size of the RAM area to be managed by the OS. If set to zero
207 * then the whole available RAM is used. The core memory is made
208 * available to the heap allocator and/or can be used directly through
209 * the simplified core memory allocator.
210 *
211 * @note In order to let the OS manage the whole RAM the linker script must
212 * provide the @p __heap_base__ and @p __heap_end__ symbols.
213 * @note Requires @p CH_CFG_USE_MEMCORE.
214 */
215#if !defined(CH_CFG_MEMCORE_SIZE)
216#define CH_CFG_MEMCORE_SIZE 0
217#endif
218
219/**
220 * @brief Heap Allocator APIs.
221 * @details If enabled then the memory heap allocator APIs are included
222 * in the kernel.
223 *
224 * @note The default is @p TRUE.
225 */
226#if !defined(CH_CFG_USE_HEAP)
227#define CH_CFG_USE_HEAP TRUE
228#endif
229
230/**
231 * @brief Memory Pools Allocator APIs.
232 * @details If enabled then the memory pools allocator APIs are included
233 * in the kernel.
234 *
235 * @note The default is @p TRUE.
236 */
237#if !defined(CH_CFG_USE_MEMPOOLS)
238#define CH_CFG_USE_MEMPOOLS TRUE
239#endif
240
241/**
242 * @brief Objects FIFOs APIs.
243 * @details If enabled then the objects FIFOs APIs are included
244 * in the kernel.
245 *
246 * @note The default is @p TRUE.
247 */
248#if !defined(CH_CFG_USE_OBJ_FIFOS)
249#define CH_CFG_USE_OBJ_FIFOS TRUE
250#endif
251
252/**
253 * @brief Pipes APIs.
254 * @details If enabled then the pipes APIs are included
255 * in the kernel.
256 *
257 * @note The default is @p TRUE.
258 */
259#if !defined(CH_CFG_USE_PIPES)
260#define CH_CFG_USE_PIPES TRUE
261#endif
262
263/**
264 * @brief Objects Caches APIs.
265 * @details If enabled then the objects caches APIs are included
266 * in the kernel.
267 *
268 * @note The default is @p TRUE.
269 */
270#if !defined(CH_CFG_USE_OBJ_CACHES)
271#define CH_CFG_USE_OBJ_CACHES TRUE
272#endif
273
274/**
275 * @brief Delegate threads APIs.
276 * @details If enabled then the delegate threads APIs are included
277 * in the kernel.
278 *
279 * @note The default is @p TRUE.
280 */
281#if !defined(CH_CFG_USE_DELEGATES)
282#define CH_CFG_USE_DELEGATES TRUE
283#endif
284
285/**
286 * @brief Jobs Queues APIs.
287 * @details If enabled then the jobs queues APIs are included
288 * in the kernel.
289 *
290 * @note The default is @p TRUE.
291 */
292#if !defined(CH_CFG_USE_JOBS)
293#define CH_CFG_USE_JOBS TRUE
294#endif
295
296/** @} */
297
298/*===========================================================================*/
299/**
300 * @name Objects factory options
301 * @{
302 */
303/*===========================================================================*/
304
305/**
306 * @brief Objects Factory APIs.
307 * @details If enabled then the objects factory APIs are included in the
308 * kernel.
309 *
310 * @note The default is @p FALSE.
311 */
312#if !defined(CH_CFG_USE_FACTORY)
313#define CH_CFG_USE_FACTORY TRUE
314#endif
315
316/**
317 * @brief Maximum length for object names.
318 * @details If the specified length is zero then the name is stored by
319 * pointer but this could have unintended side effects.
320 */
321#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
322#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8
323#endif
324
325/**
326 * @brief Enables the registry of generic objects.
327 */
328#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
329#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE
330#endif
331
332/**
333 * @brief Enables factory for generic buffers.
334 */
335#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
336#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE
337#endif
338
339/**
340 * @brief Enables factory for semaphores.
341 */
342#if !defined(CH_CFG_FACTORY_SEMAPHORES)
343#define CH_CFG_FACTORY_SEMAPHORES TRUE
344#endif
345
346/**
347 * @brief Enables factory for mailboxes.
348 */
349#if !defined(CH_CFG_FACTORY_MAILBOXES)
350#define CH_CFG_FACTORY_MAILBOXES TRUE
351#endif
352
353/**
354 * @brief Enables factory for objects FIFOs.
355 */
356#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
357#define CH_CFG_FACTORY_OBJ_FIFOS TRUE
358#endif
359
360/**
361 * @brief Enables factory for Pipes.
362 */
363#if !defined(CH_CFG_FACTORY_PIPES)
364#define CH_CFG_FACTORY_PIPES TRUE
365#endif
366
367/** @} */
368
369/*===========================================================================*/
370/**
371 * @name Debug options
372 * @{
373 */
374/*===========================================================================*/
375
376/**
377 * @brief Debug option, kernel statistics.
378 *
379 * @note Feature not currently implemented.
380 * @note The default is @p FALSE.
381 */
382#if !defined(CH_DBG_STATISTICS)
383#define CH_DBG_STATISTICS FALSE
384#endif
385
386/**
387 * @brief Debug option, system state check.
388 *
389 * @note The default is @p FALSE.
390 */
391#if !defined(CH_DBG_SYSTEM_STATE_CHECK)
392#define CH_DBG_SYSTEM_STATE_CHECK TRUE
393#endif
394
395/**
396 * @brief Debug option, parameters checks.
397 *
398 * @note The default is @p FALSE.
399 */
400#if !defined(CH_DBG_ENABLE_CHECKS)
401#define CH_DBG_ENABLE_CHECKS TRUE
402#endif
403
404/**
405 * @brief System assertions.
406 *
407 * @note The default is @p FALSE.
408 */
409#if !defined(CH_DBG_ENABLE_ASSERTS)
410#define CH_DBG_ENABLE_ASSERTS TRUE
411#endif
412
413/**
414 * @brief Stack check.
415 *
416 * @note The default is @p FALSE.
417 */
418#if !defined(CH_DBG_ENABLE_STACK_CHECK)
419#define CH_DBG_ENABLE_STACK_CHECK TRUE
420#endif
421
422/** @} */
423
424/*===========================================================================*/
425/**
426 * @name Kernel hooks
427 * @{
428 */
429/*===========================================================================*/
430
431/**
432 * @brief System initialization hook.
433 */
434#define CH_CFG_SYSTEM_INIT_HOOK() { \
435}
436
437/**
438 * @brief Threads descriptor structure extension.
439 * @details User fields added to the end of the @p thread_t structure.
440 */
441#define CH_CFG_THREAD_EXT_FIELDS \
442 /* Add threads custom fields here.*/
443
444/**
445 * @brief Threads initialization hook.
446 */
447#define CH_CFG_THREAD_EXT_INIT_HOOK(tr) { \
448 /* Add custom threads initialization code here.*/ \
449}
450
451/**
452 * @brief Threads finalization hook.
453 * @details User finalization code added to the @p chThdExit() API.
454 */
455#define CH_CFG_THREAD_EXIT_HOOK(tp) {}
456
457/**
458 * @brief Idle thread enter hook.
459 * @note This hook is invoked within a critical zone, no OS functions
460 * should be invoked from here.
461 * @note This macro can be used to activate a power saving mode.
462 */
463#define CH_CFG_IDLE_ENTER_HOOK() { \
464}
465
466/**
467 * @brief Idle thread leave hook.
468 * @note This hook is invoked within a critical zone, no OS functions
469 * should be invoked from here.
470 * @note This macro can be used to deactivate a power saving mode.
471 */
472#define CH_CFG_IDLE_LEAVE_HOOK() { \
473}
474
475/**
476 * @brief System halt hook.
477 */
478#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
479}
480
481/** @} */
482
483/*===========================================================================*/
484/* Port-specific settings (override port settings defaulted in nilcore.h). */
485/*===========================================================================*/
486
487#endif /* CHCONF_H */
488
489/** @} */