Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / aos_chconf.h @ 1703dfdf

History | View | Annotate | Download (20.002 KB)

1 043cdf33 Thomas Schöpping
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2018  Thomas Schöpping et al.
4

5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9

10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14

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