Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / aos_chconf.h @ 7da800ab

History | View | Annotate | Download (20.4 KB)

1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2019  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
#define _CHIBIOS_RT_CONF_VER_5_1_
34

    
35
/*===========================================================================*/
36
/**
37
 * @name System timers settings
38
 * @{
39
 */
40
/*===========================================================================*/
41

    
42
/**
43
 * @brief   System tick frequency.
44
 * @details Frequency of the system timer that drives the system ticks. This
45
 *          setting also defines the system tick time unit.
46
 */
47
#if !defined(CH_CFG_ST_FREQUENCY)
48
#define CH_CFG_ST_FREQUENCY                 1000000UL
49
#endif
50

    
51
/**
52
 * @brief   Time intervals data size.
53
 * @note    Allowed values are 16, 32 or 64 bits.
54
 */
55
#if !defined(CH_CFG_INTERVALS_SIZE)
56
#define CH_CFG_INTERVALS_SIZE               32
57
#endif
58

    
59
/**
60
 * @brief   Time types data size.
61
 * @note    Allowed values are 16 or 32 bits.
62
 */
63
#if !defined(CH_CFG_TIME_TYPES_SIZE)
64
#define CH_CFG_TIME_TYPES_SIZE              32
65
#endif
66

    
67
/**
68
 * @brief   Time delta constant for the tick-less mode.
69
 * @note    If this value is zero then the system uses the classic
70
 *          periodic tick. This value represents the minimum number
71
 *          of ticks that is safe to specify in a timeout directive.
72
 *          The value one is not valid, timeouts are rounded up to
73
 *          this value.
74
 */
75
#if !defined(CH_CFG_ST_TIMEDELTA)
76
#define CH_CFG_ST_TIMEDELTA                 50
77
#endif
78

    
79
/** @} */
80

    
81
/*===========================================================================*/
82
/**
83
 * @name Kernel parameters and options
84
 * @{
85
 */
86
/*===========================================================================*/
87

    
88
/**
89
 * @brief   Round robin interval.
90
 * @details This constant is the number of system ticks allowed for the
91
 *          threads before preemption occurs. Setting this value to zero
92
 *          disables the preemption for threads with equal priority and the
93
 *          round robin becomes cooperative. Note that higher priority
94
 *          threads can still preempt, the kernel is always preemptive.
95
 * @note    Disabling the round robin preemption makes the kernel more compact
96
 *          and generally faster.
97
 * @note    The round robin preemption is not supported in tickless mode and
98
 *          must be set to zero in that case.
99
 */
100
#define CH_CFG_TIME_QUANTUM                 0
101

    
102
/**
103
 * @brief   Managed RAM size.
104
 * @details Size of the RAM area to be managed by the OS. If set to zero
105
 *          then the whole available RAM is used. The core memory is made
106
 *          available to the heap allocator and/or can be used directly through
107
 *          the simplified core memory allocator.
108
 *
109
 * @note    In order to let the OS manage the whole RAM the linker script must
110
 *          provide the @p __heap_base__ and @p __heap_end__ symbols.
111
 * @note    Requires @p CH_CFG_USE_MEMCORE.
112
 */
113
#define CH_CFG_MEMCORE_SIZE                 0
114

    
115
/**
116
 * @brief   Idle thread automatic spawn suppression.
117
 * @details When this option is activated the function @p chSysInit()
118
 *          does not spawn the idle thread. The application @p main()
119
 *          function becomes the idle thread and must implement an
120
 *          infinite loop.
121
 */
122
#define CH_CFG_NO_IDLE_THREAD               FALSE
123

    
124
/** @} */
125

    
126
/*===========================================================================*/
127
/**
128
 * @name Performance options
129
 * @{
130
 */
131
/*===========================================================================*/
132

    
133
/**
134
 * @brief   OS optimization.
135
 * @details If enabled then time efficient rather than space efficient code
136
 *          is used when two possible implementations exist.
137
 *
138
 * @note    This is not related to the compiler optimization options.
139
 * @note    The default is @p TRUE.
140
 */
141
#define CH_CFG_OPTIMIZE_SPEED               TRUE
142

    
143
/** @} */
144

    
145
/*===========================================================================*/
146
/**
147
 * @name Subsystem options
148
 * @{
149
 */
150
/*===========================================================================*/
151

    
152
/**
153
 * @brief   Time Measurement APIs.
154
 * @details If enabled then the time measurement APIs are included in
155
 *          the kernel.
156
 *
157
 * @note    The default is @p TRUE.
158
 */
159
#define CH_CFG_USE_TM                       TRUE
160

    
161
/**
162
 * @brief   Threads registry APIs.
163
 * @details If enabled then the registry APIs are included in the kernel.
164
 *
165
 * @note    The default is @p TRUE.
166
 */
167
#define CH_CFG_USE_REGISTRY                 FALSE
168

    
169
/**
170
 * @brief   Thread hierarchy APIs.
171
 * @details Id enabled then the thread hierarchy APIs are included in the kernel.
172
 *
173
 * @note    The default is @p FALSE.
174
 */
175
#define CH_CFG_USE_THREADHIERARCHY          TRUE
176

    
177
/**
178
 * @brief   Enable ordering of child lists.
179
 * @details Children will be ordered by their priority (descending).
180
 *          If sibliblings have identical priority, they are ordered by age (descending).
181
 */
182
#define CH_CFG_THREADHIERARCHY_ORDERED      TRUE
183

    
184
/**
185
 * @brief   Threads synchronization APIs.
186
 * @details If enabled then the @p chThdWait() function is included in
187
 *          the kernel.
188
 *
189
 * @note    The default is @p TRUE.
190
 */
191
#define CH_CFG_USE_WAITEXIT                 TRUE
192

    
193
/**
194
 * @brief   Semaphores APIs.
195
 * @details If enabled then the Semaphores APIs are included in the kernel.
196
 *
197
 * @note    The default is @p TRUE.
198
 */
199
#define CH_CFG_USE_SEMAPHORES               TRUE
200

    
201
/**
202
 * @brief   Semaphores queuing mode.
203
 * @details If enabled then the threads are enqueued on semaphores by
204
 *          priority rather than in FIFO order.
205
 *
206
 * @note    The default is @p FALSE. Enable this if you have special
207
 *          requirements.
208
 * @note    Requires @p CH_CFG_USE_SEMAPHORES.
209
 */
210
#define CH_CFG_USE_SEMAPHORES_PRIORITY      FALSE
211

    
212
/**
213
 * @brief   Mutexes APIs.
214
 * @details If enabled then the mutexes APIs are included in the kernel.
215
 *
216
 * @note    The default is @p TRUE.
217
 */
218
#define CH_CFG_USE_MUTEXES                  TRUE
219

    
220
/**
221
 * @brief   Enables recursive behavior on mutexes.
222
 * @note    Recursive mutexes are heavier and have an increased
223
 *          memory footprint.
224
 *
225
 * @note    The default is @p FALSE.
226
 * @note    Requires @p CH_CFG_USE_MUTEXES.
227
 */
228
#define CH_CFG_USE_MUTEXES_RECURSIVE        FALSE
229

    
230
/**
231
 * @brief   Conditional Variables APIs.
232
 * @details If enabled then the conditional variables APIs are included
233
 *          in the kernel.
234
 *
235
 * @note    The default is @p TRUE.
236
 * @note    Requires @p CH_CFG_USE_MUTEXES.
237
 */
238
#define CH_CFG_USE_CONDVARS                 TRUE
239

    
240
/**
241
 * @brief   Conditional Variables APIs with timeout.
242
 * @details If enabled then the conditional variables APIs with timeout
243
 *          specification are included in the kernel.
244
 *
245
 * @note    The default is @p TRUE.
246
 * @note    Requires @p CH_CFG_USE_CONDVARS.
247
 */
248
#define CH_CFG_USE_CONDVARS_TIMEOUT         TRUE
249

    
250
/**
251
 * @brief   Events Flags APIs.
252
 * @details If enabled then the event flags APIs are included in the kernel.
253
 *
254
 * @note    The default is @p TRUE.
255
 */
256
#define CH_CFG_USE_EVENTS                   TRUE
257

    
258
/**
259
 * @brief   Events Flags APIs with timeout.
260
 * @details If enabled then the events APIs with timeout specification
261
 *          are included in the kernel.
262
 *
263
 * @note    The default is @p TRUE.
264
 * @note    Requires @p CH_CFG_USE_EVENTS.
265
 */
266
#define CH_CFG_USE_EVENTS_TIMEOUT           TRUE
267

    
268
/**
269
 * @brief   Synchronous Messages APIs.
270
 * @details If enabled then the synchronous messages APIs are included
271
 *          in the kernel.
272
 *
273
 * @note    The default is @p TRUE.
274
 */
275
#define CH_CFG_USE_MESSAGES                 FALSE
276

    
277
/**
278
 * @brief   Synchronous Messages queuing mode.
279
 * @details If enabled then messages are served by priority rather than in
280
 *          FIFO order.
281
 *
282
 * @note    The default is @p FALSE. Enable this if you have special
283
 *          requirements.
284
 * @note    Requires @p CH_CFG_USE_MESSAGES.
285
 */
286
#define CH_CFG_USE_MESSAGES_PRIORITY        FALSE
287

    
288
/**
289
 * @brief   Mailboxes APIs.
290
 * @details If enabled then the asynchronous messages (mailboxes) APIs are
291
 *          included in the kernel.
292
 *
293
 * @note    The default is @p TRUE.
294
 * @note    Requires @p CH_CFG_USE_SEMAPHORES.
295
 */
296
#define CH_CFG_USE_MAILBOXES                FALSE
297

    
298
/**
299
 * @brief   Core Memory Manager APIs.
300
 * @details If enabled then the core memory manager APIs are included
301
 *          in the kernel.
302
 *
303
 * @note    The default is @p TRUE.
304
 */
305
#define CH_CFG_USE_MEMCORE                  FALSE
306

    
307
/**
308
 * @brief   Heap Allocator APIs.
309
 * @details If enabled then the memory heap allocator APIs are included
310
 *          in the kernel.
311
 *
312
 * @note    The default is @p TRUE.
313
 * @note    Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
314
 *          @p CH_CFG_USE_SEMAPHORES.
315
 * @note    Mutexes are recommended.
316
 */
317
#define CH_CFG_USE_HEAP                     FALSE
318

    
319
/**
320
 * @brief   Memory Pools Allocator APIs.
321
 * @details If enabled then the memory pools allocator APIs are included
322
 *          in the kernel.
323
 *
324
 * @note    The default is @p TRUE.
325
 */
326
#define CH_CFG_USE_MEMPOOLS                 FALSE
327

    
328
/**
329
 * @brief  Objects FIFOs APIs.
330
 * @details If enabled then the objects FIFOs APIs are included
331
 *          in the kernel.
332
 *
333
 * @note    The default is @p TRUE.
334
 */
335
#define CH_CFG_USE_OBJ_FIFOS                FALSE
336

    
337
/**
338
 * @brief   Dynamic Threads APIs.
339
 * @details If enabled then the dynamic threads creation APIs are included
340
 *          in the kernel.
341
 *
342
 * @note    The default is @p TRUE.
343
 * @note    Requires @p CH_CFG_USE_WAITEXIT.
344
 * @note    Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
345
 */
346
#define CH_CFG_USE_DYNAMIC                  FALSE
347

    
348
/** @} */
349

    
350
/*===========================================================================*/
351
/**
352
 * @name Objects factory options
353
 * @{
354
 */
355
/*===========================================================================*/
356

    
357
/**
358
 * @brief   Objects Factory APIs.
359
 * @details If enabled then the objects factory APIs are included in the
360
 *          kernel.
361
 *
362
 * @note    The default is @p FALSE.
363
 */
364
#if !defined(CH_CFG_USE_FACTORY)
365
#define CH_CFG_USE_FACTORY                  FALSE
366
#endif
367

    
368
/**
369
 * @brief   Maximum length for object names.
370
 * @details If the specified length is zero then the name is stored by
371
 *          pointer but this could have unintended side effects.
372
 */
373
#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
374
#define CH_CFG_FACTORY_MAX_NAMES_LENGTH     8
375
#endif
376

    
377
/**
378
 * @brief   Enables the registry of generic objects.
379
 */
380
#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
381
#define CH_CFG_FACTORY_OBJECTS_REGISTRY     TRUE
382
#endif
383

    
384
/**
385
 * @brief   Enables factory for generic buffers.
386
 */
387
#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
388
#define CH_CFG_FACTORY_GENERIC_BUFFERS      TRUE
389
#endif
390

    
391
/**
392
 * @brief   Enables factory for semaphores.
393
 */
394
#if !defined(CH_CFG_FACTORY_SEMAPHORES)
395
#define CH_CFG_FACTORY_SEMAPHORES           TRUE
396
#endif
397

    
398
/**
399
 * @brief   Enables factory for mailboxes.
400
 */
401
#if !defined(CH_CFG_FACTORY_MAILBOXES)
402
#define CH_CFG_FACTORY_MAILBOXES            TRUE
403
#endif
404

    
405
/**
406
 * @brief   Enables factory for objects FIFOs.
407
 */
408
#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
409
#define CH_CFG_FACTORY_OBJ_FIFOS            TRUE
410
#endif
411

    
412
/** @} */
413

    
414
/*===========================================================================*/
415
/**
416
 * @name Debug options
417
 * @{
418
 */
419
/*===========================================================================*/
420

    
421
/**
422
 * @brief   Debug option, kernel statistics.
423
 *
424
 * @note    The default is @p FALSE.
425
 */
426
#if ((CH_CFG_USE_TM == TRUE) && (AMIROOS_CFG_DBG == true)) || defined(__DOXYGEN__)
427
  #define CH_DBG_STATISTICS                 TRUE
428
#else
429
  #define CH_DBG_STATISTICS                 FALSE
430
#endif
431

    
432
/**
433
 * @brief   Debug option, system state check.
434
 * @details If enabled the correct call protocol for system APIs is checked
435
 *          at runtime.
436
 *
437
 * @note    The default is @p FALSE.
438
 */
439
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
440
  #define CH_DBG_SYSTEM_STATE_CHECK         TRUE
441
#else
442
  #define CH_DBG_SYSTEM_STATE_CHECK         FALSE
443
#endif
444

    
445
/**
446
 * @brief   Debug option, parameters checks.
447
 * @details If enabled then the checks on the API functions input
448
 *          parameters are activated.
449
 *
450
 * @note    The default is @p FALSE.
451
 */
452
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
453
  #define CH_DBG_ENABLE_CHECKS              TRUE
454
#else
455
  #define CH_DBG_ENABLE_CHECKS              FALSE
456
#endif
457

    
458
/**
459
 * @brief   Debug option, consistency checks.
460
 * @details If enabled then all the assertions in the kernel code are
461
 *          activated. This includes consistency checks inside the kernel,
462
 *          runtime anomalies and port-defined checks.
463
 *
464
 * @note    The default is @p FALSE.
465
 */
466
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
467
  #define CH_DBG_ENABLE_ASSERTS             TRUE
468
#else
469
  #define CH_DBG_ENABLE_ASSERTS             FALSE
470
#endif
471

    
472
/**
473
 * @brief   Debug option, trace buffer.
474
 * @details If enabled then the trace buffer is activated.
475
 *
476
 * @note    The default is @p CH_DBG_TRACE_MASK_DISABLED.
477
 */
478
#define CH_DBG_TRACE_MASK                   CH_DBG_TRACE_MASK_DISABLED
479

    
480
/**
481
 * @brief   Trace buffer entries.
482
 * @note    The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
483
 *          different from @p CH_DBG_TRACE_MASK_DISABLED.
484
 */
485
#define CH_DBG_TRACE_BUFFER_SIZE            128
486

    
487
/**
488
 * @brief   Debug option, stack checks.
489
 * @details If enabled then a runtime stack check is performed.
490
 *
491
 * @note    The default is @p FALSE.
492
 * @note    The stack check is performed in a architecture/port dependent way.
493
 *          It may not be implemented or some ports.
494
 * @note    The default failure mode is to halt the system with the global
495
 *          @p panic_msg variable set to @p NULL.
496
 */
497
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
498
  #define CH_DBG_ENABLE_STACK_CHECK         TRUE
499
#else
500
  #define CH_DBG_ENABLE_STACK_CHECK         FALSE
501
#endif
502

    
503
/**
504
 * @brief   Debug option, stacks initialization.
505
 * @details If enabled then the threads working area is filled with a byte
506
 *          value when a thread is created. This can be useful for the
507
 *          runtime measurement of the used stack.
508
 *
509
 * @note    The default is @p FALSE.
510
 */
511
#if (AMIROOS_CFG_PROFILE == true) || defined(__DOXYGEN__)
512
  #define CH_DBG_FILL_THREADS               TRUE
513
#else
514
  #define CH_DBG_FILL_THREADS               FALSE
515
#endif
516

    
517
/**
518
 * @brief   Debug option, threads profiling.
519
 * @details If enabled then a field is added to the @p thread_t structure that
520
 *          counts the system ticks occurred while executing the thread.
521
 *
522
 * @note    The default is @p FALSE.
523
 * @note    This debug option is not currently compatible with the
524
 *          tickless mode.
525
 */
526
#if ((CH_CFG_ST_TIMEDELTA == 0) && (AMIROOS_CFG_PROFILE == true)) || defined(__DOXYGEN__)
527
  #define CH_DBG_THREADS_PROFILING          TRUE
528
#else
529
  #define CH_DBG_THREADS_PROFILING          FALSE
530
#endif
531

    
532
/** @} */
533

    
534
/*===========================================================================*/
535
/**
536
 * @name Kernel hooks
537
 * @{
538
 */
539
/*===========================================================================*/
540

    
541
/**
542
 * @brief   System structure extension.
543
 * @details User fields added to the end of the @p ch_system_t structure.
544
 */
545
#define CH_CFG_SYSTEM_EXTRA_FIELDS                                          \
546
  /* Add threads custom fields here.*/
547

    
548
/**
549
 * @brief   System initialization hook.
550
 * @details User initialization code added to the @p chSysInit() function
551
 *          just before interrupts are enabled globally.
552
 */
553
#define CH_CFG_SYSTEM_INIT_HOOK() {                                         \
554
  /* Add threads initialization code here.*/                                \
555
}
556

    
557
/**
558
 * @brief   Threads descriptor structure extension.
559
 * @details User fields added to the end of the @p thread_t structure.
560
 */
561
#define CH_CFG_THREAD_EXTRA_FIELDS                                          \
562
  /* Add threads custom fields here.*/
563

    
564
/**
565
 * @brief   Threads initialization hook.
566
 * @details User initialization code added to the @p _thread_init() function.
567
 *
568
 * @note    It is invoked from within @p _thread_init() and implicitly from all
569
 *          the threads creation APIs.
570
 */
571
#define CH_CFG_THREAD_INIT_HOOK(tp) {                                       \
572
  /* Add threads initialization code here.*/                                \
573
}
574

    
575
/**
576
 * @brief   Threads finalization hook.
577
 * @details User finalization code added to the @p chThdExit() API.
578
 */
579
#define CH_CFG_THREAD_EXIT_HOOK(tp) {                                       \
580
  /* Add threads finalization code here.*/                                  \
581
}
582

    
583
/**
584
 * @brief   Context switch hook.
585
 * @details This hook is invoked just before switching between threads.
586
 */
587
#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) {                              \
588
  /* Context switch code here.*/                                            \
589
}
590

    
591
/**
592
 * @brief   ISR enter hook.
593
 */
594
#define CH_CFG_IRQ_PROLOGUE_HOOK() {                                        \
595
  /* IRQ prologue code here.*/                                              \
596
}
597

    
598
/**
599
 * @brief   ISR exit hook.
600
 */
601
#define CH_CFG_IRQ_EPILOGUE_HOOK() {                                        \
602
  /* IRQ epilogue code here.*/                                              \
603
}
604

    
605
/**
606
 * @brief   Idle thread enter hook.
607
 * @note    This hook is invoked within a critical zone, no OS functions
608
 *          should be invoked from here.
609
 * @note    This macro can be used to activate a power saving mode.
610
 */
611
#define CH_CFG_IDLE_ENTER_HOOK() {                                          \
612
  /* Idle-enter code here.*/                                                \
613
}
614

    
615
/**
616
 * @brief   Idle thread leave hook.
617
 * @note    This hook is invoked within a critical zone, no OS functions
618
 *          should be invoked from here.
619
 * @note    This macro can be used to deactivate a power saving mode.
620
 */
621
#define CH_CFG_IDLE_LEAVE_HOOK() {                                          \
622
  /* Idle-leave code here.*/                                                \
623
}
624

    
625
/**
626
 * @brief   Idle Loop hook.
627
 * @details This hook is continuously invoked by the idle thread loop.
628
 */
629
#define CH_CFG_IDLE_LOOP_HOOK() {                                           \
630
  /* Idle loop code here.*/                                                 \
631
}
632

    
633
/**
634
 * @brief   System tick event hook.
635
 * @details This hook is invoked in the system tick handler immediately
636
 *          after processing the virtual timers queue.
637
 */
638
#define CH_CFG_SYSTEM_TICK_HOOK() {                                         \
639
  /* System tick event code here.*/                                         \
640
}
641

    
642
/**
643
 * @brief   System halt hook.
644
 * @details This hook is invoked in case to a system halting error before
645
 *          the system is halted.
646
 */
647
#define CH_CFG_SYSTEM_HALT_HOOK(reason) {                                   \
648
  /* System halt code here.*/                                               \
649
}
650

    
651
/**
652
 * @brief   Trace hook.
653
 * @details This hook is invoked each time a new record is written in the
654
 *          trace buffer.
655
 */
656
#define CH_CFG_TRACE_HOOK(tep) {                                            \
657
  /* Trace code here.*/                                                     \
658
}
659

    
660
/** @} */
661

    
662
/*===========================================================================*/
663
/**
664
 * @name Port specific settings
665
 */
666
/*===========================================================================*/
667

    
668
// These settings are specific to each module.
669

    
670
/*===========================================================================*/
671
/**
672
 * @name other
673
 * @{
674
 */
675
/*===========================================================================*/
676

    
677
/**
678
 * @brief   Flag to enable/disable floating point support in chprintf() and all deriviates.
679
 */
680
#define CHPRINTF_USE_FLOAT                  TRUE
681

    
682
/** @} */
683

    
684
#endif  /* AOS_CHCONF_H */
685

    
686
/** @} */