Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / aos_chconf.h @ 9f224ade

History | View | Annotate | Download (20 KB)

1
/*
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
 * @{
40
 */
41
/*===========================================================================*/
42

    
43
/**
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                 50
78
#endif
79

    
80
/** @} */
81

    
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
 * @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
#define CH_CFG_USE_OBJ_FIFOS                FALSE
322

    
323
/**
324
 * @brief   Dynamic Threads APIs.
325
 * @details If enabled then the dynamic threads creation APIs are included
326
 *          in the kernel.
327
 *
328
 * @note    The default is @p TRUE.
329
 * @note    Requires @p CH_CFG_USE_WAITEXIT.
330
 * @note    Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
331
 */
332
#define CH_CFG_USE_DYNAMIC                  FALSE
333

    
334
/** @} */
335

    
336
/*===========================================================================*/
337
/**
338
 * @name Objects factory options
339
 * @{
340
 */
341
/*===========================================================================*/
342

    
343
/**
344
 * @brief   Objects Factory APIs.
345
 * @details If enabled then the objects factory APIs are included in the
346
 *          kernel.
347
 *
348
 * @note    The default is @p FALSE.
349
 */
350
#if !defined(CH_CFG_USE_FACTORY)
351
#define CH_CFG_USE_FACTORY                  FALSE
352
#endif
353

    
354
/**
355
 * @brief   Maximum length for object names.
356
 * @details If the specified length is zero then the name is stored by
357
 *          pointer but this could have unintended side effects.
358
 */
359
#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
360
#define CH_CFG_FACTORY_MAX_NAMES_LENGTH     8
361
#endif
362

    
363
/**
364
 * @brief   Enables the registry of generic objects.
365
 */
366
#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
367
#define CH_CFG_FACTORY_OBJECTS_REGISTRY     TRUE
368
#endif
369

    
370
/**
371
 * @brief   Enables factory for generic buffers.
372
 */
373
#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
374
#define CH_CFG_FACTORY_GENERIC_BUFFERS      TRUE
375
#endif
376

    
377
/**
378
 * @brief   Enables factory for semaphores.
379
 */
380
#if !defined(CH_CFG_FACTORY_SEMAPHORES)
381
#define CH_CFG_FACTORY_SEMAPHORES           TRUE
382
#endif
383

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

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

    
398
/** @} */
399

    
400
/*===========================================================================*/
401
/**
402
 * @name Debug options
403
 * @{
404
 */
405
/*===========================================================================*/
406

    
407
/**
408
 * @brief   Debug option, kernel statistics.
409
 *
410
 * @note    The default is @p FALSE.
411
 */
412
#if ((CH_CFG_USE_TM == TRUE) && (AMIROOS_CFG_DBG == true)) || defined(__DOXYGEN__)
413
  #define CH_DBG_STATISTICS                 TRUE
414
#else
415
  #define CH_DBG_STATISTICS                 FALSE
416
#endif
417

    
418
/**
419
 * @brief   Debug option, system state check.
420
 * @details If enabled the correct call protocol for system APIs is checked
421
 *          at runtime.
422
 *
423
 * @note    The default is @p FALSE.
424
 */
425
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
426
  #define CH_DBG_SYSTEM_STATE_CHECK         TRUE
427
#else
428
  #define CH_DBG_SYSTEM_STATE_CHECK         FALSE
429
#endif
430

    
431
/**
432
 * @brief   Debug option, parameters checks.
433
 * @details If enabled then the checks on the API functions input
434
 *          parameters are activated.
435
 *
436
 * @note    The default is @p FALSE.
437
 */
438
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
439
  #define CH_DBG_ENABLE_CHECKS              TRUE
440
#else
441
  #define CH_DBG_ENABLE_CHECKS              FALSE
442
#endif
443

    
444
/**
445
 * @brief   Debug option, consistency checks.
446
 * @details If enabled then all the assertions in the kernel code are
447
 *          activated. This includes consistency checks inside the kernel,
448
 *          runtime anomalies and port-defined checks.
449
 *
450
 * @note    The default is @p FALSE.
451
 */
452
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
453
  #define CH_DBG_ENABLE_ASSERTS             TRUE
454
#else
455
  #define CH_DBG_ENABLE_ASSERTS             FALSE
456
#endif
457

    
458
/**
459
 * @brief   Debug option, trace buffer.
460
 * @details If enabled then the trace buffer is activated.
461
 *
462
 * @note    The default is @p CH_DBG_TRACE_MASK_DISABLED.
463
 */
464
#define CH_DBG_TRACE_MASK                   CH_DBG_TRACE_MASK_DISABLED
465

    
466
/**
467
 * @brief   Trace buffer entries.
468
 * @note    The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
469
 *          different from @p CH_DBG_TRACE_MASK_DISABLED.
470
 */
471
#define CH_DBG_TRACE_BUFFER_SIZE            128
472

    
473
/**
474
 * @brief   Debug option, stack checks.
475
 * @details If enabled then a runtime stack check is performed.
476
 *
477
 * @note    The default is @p FALSE.
478
 * @note    The stack check is performed in a architecture/port dependent way.
479
 *          It may not be implemented or some ports.
480
 * @note    The default failure mode is to halt the system with the global
481
 *          @p panic_msg variable set to @p NULL.
482
 */
483
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
484
  #define CH_DBG_ENABLE_STACK_CHECK         TRUE
485
#else
486
  #define CH_DBG_ENABLE_STACK_CHECK         FALSE
487
#endif
488

    
489
/**
490
 * @brief   Debug option, stacks initialization.
491
 * @details If enabled then the threads working area is filled with a byte
492
 *          value when a thread is created. This can be useful for the
493
 *          runtime measurement of the used stack.
494
 *
495
 * @note    The default is @p FALSE.
496
 */
497
#if (AMIROOS_CFG_PROFILE == true) || defined(__DOXYGEN__)
498
  #define CH_DBG_FILL_THREADS               TRUE
499
#else
500
  #define CH_DBG_FILL_THREADS               FALSE
501
#endif
502

    
503
/**
504
 * @brief   Debug option, threads profiling.
505
 * @details If enabled then a field is added to the @p thread_t structure that
506
 *          counts the system ticks occurred while executing the thread.
507
 *
508
 * @note    The default is @p FALSE.
509
 * @note    This debug option is not currently compatible with the
510
 *          tickless mode.
511
 */
512
#if ((CH_CFG_ST_TIMEDELTA == 0) && (AMIROOS_CFG_PROFILE == true)) || defined(__DOXYGEN__)
513
  #define CH_DBG_THREADS_PROFILING          TRUE
514
#else
515
  #define CH_DBG_THREADS_PROFILING          FALSE
516
#endif
517

    
518
/** @} */
519

    
520
/*===========================================================================*/
521
/**
522
 * @name Kernel hooks
523
 * @{
524
 */
525
/*===========================================================================*/
526

    
527
/**
528
 * @brief   System structure extension.
529
 * @details User fields added to the end of the @p ch_system_t structure.
530
 */
531
#define CH_CFG_SYSTEM_EXTRA_FIELDS                                          \
532
  /* Add threads custom fields here.*/
533

    
534
/**
535
 * @brief   System initialization hook.
536
 * @details User initialization code added to the @p chSysInit() function
537
 *          just before interrupts are enabled globally.
538
 */
539
#define CH_CFG_SYSTEM_INIT_HOOK() {                                         \
540
  /* Add threads initialization code here.*/                                \
541
}
542

    
543
/**
544
 * @brief   Threads descriptor structure extension.
545
 * @details User fields added to the end of the @p thread_t structure.
546
 */
547
#define CH_CFG_THREAD_EXTRA_FIELDS                                          \
548
  /* Add threads custom fields here.*/
549

    
550
/**
551
 * @brief   Threads initialization hook.
552
 * @details User initialization code added to the @p _thread_init() function.
553
 *
554
 * @note    It is invoked from within @p _thread_init() and implicitly from all
555
 *          the threads creation APIs.
556
 */
557
#define CH_CFG_THREAD_INIT_HOOK(tp) {                                       \
558
  /* Add threads initialization code here.*/                                \
559
}
560

    
561
/**
562
 * @brief   Threads finalization hook.
563
 * @details User finalization code added to the @p chThdExit() API.
564
 */
565
#define CH_CFG_THREAD_EXIT_HOOK(tp) {                                       \
566
  /* Add threads finalization code here.*/                                  \
567
}
568

    
569
/**
570
 * @brief   Context switch hook.
571
 * @details This hook is invoked just before switching between threads.
572
 */
573
#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) {                              \
574
  /* Context switch code here.*/                                            \
575
}
576

    
577
/**
578
 * @brief   ISR enter hook.
579
 */
580
#define CH_CFG_IRQ_PROLOGUE_HOOK() {                                        \
581
  /* IRQ prologue code here.*/                                              \
582
}
583

    
584
/**
585
 * @brief   ISR exit hook.
586
 */
587
#define CH_CFG_IRQ_EPILOGUE_HOOK() {                                        \
588
  /* IRQ epilogue code here.*/                                              \
589
}
590

    
591
/**
592
 * @brief   Idle thread enter hook.
593
 * @note    This hook is invoked within a critical zone, no OS functions
594
 *          should be invoked from here.
595
 * @note    This macro can be used to activate a power saving mode.
596
 */
597
#define CH_CFG_IDLE_ENTER_HOOK() {                                          \
598
  /* Idle-enter code here.*/                                                \
599
}
600

    
601
/**
602
 * @brief   Idle thread leave hook.
603
 * @note    This hook is invoked within a critical zone, no OS functions
604
 *          should be invoked from here.
605
 * @note    This macro can be used to deactivate a power saving mode.
606
 */
607
#define CH_CFG_IDLE_LEAVE_HOOK() {                                          \
608
  /* Idle-leave code here.*/                                                \
609
}
610

    
611
/**
612
 * @brief   Idle Loop hook.
613
 * @details This hook is continuously invoked by the idle thread loop.
614
 */
615
#define CH_CFG_IDLE_LOOP_HOOK() {                                           \
616
  /* Idle loop code here.*/                                                 \
617
}
618

    
619
/**
620
 * @brief   System tick event hook.
621
 * @details This hook is invoked in the system tick handler immediately
622
 *          after processing the virtual timers queue.
623
 */
624
#define CH_CFG_SYSTEM_TICK_HOOK() {                                         \
625
  /* System tick event code here.*/                                         \
626
}
627

    
628
/**
629
 * @brief   System halt hook.
630
 * @details This hook is invoked in case to a system halting error before
631
 *          the system is halted.
632
 */
633
#define CH_CFG_SYSTEM_HALT_HOOK(reason) {                                   \
634
  extern void aosPrintHaltErrorCode(const char* reason);                    \
635
  aosPrintHaltErrorCode(reason);                                            \
636
}
637

    
638
/**
639
 * @brief   Trace hook.
640
 * @details This hook is invoked each time a new record is written in the
641
 *          trace buffer.
642
 */
643
#define CH_CFG_TRACE_HOOK(tep) {                                            \
644
  /* Trace code here.*/                                                     \
645
}
646

    
647
/** @} */
648

    
649
/*===========================================================================*/
650
/**
651
 * @name Port specific settings
652
 */
653
/*===========================================================================*/
654

    
655
// These settings are specific to each module.
656

    
657
/*===========================================================================*/
658
/**
659
 * @name other
660
 * @{
661
 */
662
/*===========================================================================*/
663

    
664
/**
665
 * @brief   Flag to enable/disable floating point support in chprintf() and all deriviates.
666
 */
667
#define CHPRINTF_USE_FLOAT                  TRUE
668

    
669
/** @} */
670

    
671
#endif  /* _AOS_CHCONF_H_ */
672

    
673
/** @} */