Statistics
| Branch: | Tag: | Revision:

amiro-os / os / modules / PowerManagement_1-1 / chconf.h @ 76ca5065

History | View | Annotate | Download (17.704 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/PowerManagement/chconf.h
21
 * @brief   ChibiOS Configuration file for the PowerManagement module.
22
 * @details Contains the application specific kernel settings.
23
 *
24
 * @addtogroup config
25
 * @details Kernel related settings and hooks.
26
 * @{
27
 */
28

    
29
#ifndef _CHCONF_H_
30
#define _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 time counter resolution.
45
 * @note    Allowed values are 16 or 32 bits.
46
 */
47
#define CH_CFG_ST_RESOLUTION                32
48

    
49
/**
50
 * @brief   System tick frequency.
51
 * @details Frequency of the system timer that drives the system ticks. This
52
 *          setting also defines the system tick time unit.
53
 */
54
#define CH_CFG_ST_FREQUENCY                 1000000UL
55

    
56
/**
57
 * @brief   Time delta constant for the tick-less mode.
58
 * @note    If this value is zero then the system uses the classic
59
 *          periodic tick. This value represents the minimum number
60
 *          of ticks that is safe to specify in a timeout directive.
61
 *          The value one is not valid, timeouts are rounded up to
62
 *          this value.
63
 */
64
#define CH_CFG_ST_TIMEDELTA                 10
65

    
66
/** @} */
67

    
68
/*===========================================================================*/
69
/**
70
 * @name Kernel parameters and options
71
 * @{
72
 */
73
/*===========================================================================*/
74

    
75
/**
76
 * @brief   Round robin interval.
77
 * @details This constant is the number of system ticks allowed for the
78
 *          threads before preemption occurs. Setting this value to zero
79
 *          disables the preemption for threads with equal priority and the
80
 *          round robin becomes cooperative. Note that higher priority
81
 *          threads can still preempt, the kernel is always preemptive.
82
 * @note    Disabling the round robin preemption makes the kernel more compact
83
 *          and generally faster.
84
 * @note    The round robin preemption is not supported in tickless mode and
85
 *          must be set to zero in that case.
86
 */
87
#define CH_CFG_TIME_QUANTUM                 0
88

    
89
/**
90
 * @brief   Managed RAM size.
91
 * @details Size of the RAM area to be managed by the OS. If set to zero
92
 *          then the whole available RAM is used. The core memory is made
93
 *          available to the heap allocator and/or can be used directly through
94
 *          the simplified core memory allocator.
95
 *
96
 * @note    In order to let the OS manage the whole RAM the linker script must
97
 *          provide the @p __heap_base__ and @p __heap_end__ symbols.
98
 * @note    Requires @p CH_CFG_USE_MEMCORE.
99
 */
100
#define CH_CFG_MEMCORE_SIZE                 0
101

    
102
/**
103
 * @brief   Idle thread automatic spawn suppression.
104
 * @details When this option is activated the function @p chSysInit()
105
 *          does not spawn the idle thread. The application @p main()
106
 *          function becomes the idle thread and must implement an
107
 *          infinite loop.
108
 */
109
#define CH_CFG_NO_IDLE_THREAD               FALSE
110

    
111
/** @} */
112

    
113
/*===========================================================================*/
114
/**
115
 * @name Performance options
116
 * @{
117
 */
118
/*===========================================================================*/
119

    
120
/**
121
 * @brief   OS optimization.
122
 * @details If enabled then time efficient rather than space efficient code
123
 *          is used when two possible implementations exist.
124
 *
125
 * @note    This is not related to the compiler optimization options.
126
 * @note    The default is @p TRUE.
127
 */
128
#define CH_CFG_OPTIMIZE_SPEED               TRUE
129

    
130
/** @} */
131

    
132
/*===========================================================================*/
133
/**
134
 * @name Subsystem options
135
 * @{
136
 */
137
/*===========================================================================*/
138

    
139
/**
140
 * @brief   Time Measurement APIs.
141
 * @details If enabled then the time measurement APIs are included in
142
 *          the kernel.
143
 *
144
 * @note    The default is @p TRUE.
145
 */
146
#define CH_CFG_USE_TM                       FALSE
147

    
148
/**
149
 * @brief   Threads registry APIs.
150
 * @details If enabled then the registry APIs are included in the kernel.
151
 *
152
 * @note    The default is @p TRUE.
153
 */
154
#define CH_CFG_USE_REGISTRY                 FALSE
155

    
156
/**
157
 * @brief   Threads synchronization APIs.
158
 * @details If enabled then the @p chThdWait() function is included in
159
 *          the kernel.
160
 *
161
 * @note    The default is @p TRUE.
162
 */
163
#define CH_CFG_USE_WAITEXIT                 TRUE
164

    
165
/**
166
 * @brief   Semaphores APIs.
167
 * @details If enabled then the Semaphores APIs are included in the kernel.
168
 *
169
 * @note    The default is @p TRUE.
170
 */
171
#define CH_CFG_USE_SEMAPHORES               FALSE
172

    
173
/**
174
 * @brief   Semaphores queuing mode.
175
 * @details If enabled then the threads are enqueued on semaphores by
176
 *          priority rather than in FIFO order.
177
 *
178
 * @note    The default is @p FALSE. Enable this if you have special
179
 *          requirements.
180
 * @note    Requires @p CH_CFG_USE_SEMAPHORES.
181
 */
182
#define CH_CFG_USE_SEMAPHORES_PRIORITY      FALSE
183

    
184
/**
185
 * @brief   Mutexes APIs.
186
 * @details If enabled then the mutexes APIs are included in the kernel.
187
 *
188
 * @note    The default is @p TRUE.
189
 */
190
#define CH_CFG_USE_MUTEXES                  TRUE
191

    
192
/**
193
 * @brief   Enables recursive behavior on mutexes.
194
 * @note    Recursive mutexes are heavier and have an increased
195
 *          memory footprint.
196
 *
197
 * @note    The default is @p FALSE.
198
 * @note    Requires @p CH_CFG_USE_MUTEXES.
199
 */
200
#define CH_CFG_USE_MUTEXES_RECURSIVE        FALSE
201

    
202
/**
203
 * @brief   Conditional Variables APIs.
204
 * @details If enabled then the conditional variables APIs are included
205
 *          in the kernel.
206
 *
207
 * @note    The default is @p TRUE.
208
 * @note    Requires @p CH_CFG_USE_MUTEXES.
209
 */
210
#define CH_CFG_USE_CONDVARS                 FALSE
211

    
212
/**
213
 * @brief   Conditional Variables APIs with timeout.
214
 * @details If enabled then the conditional variables APIs with timeout
215
 *          specification are included in the kernel.
216
 *
217
 * @note    The default is @p TRUE.
218
 * @note    Requires @p CH_CFG_USE_CONDVARS.
219
 */
220
#define CH_CFG_USE_CONDVARS_TIMEOUT         FALSE
221

    
222
/**
223
 * @brief   Events Flags APIs.
224
 * @details If enabled then the event flags APIs are included in the kernel.
225
 *
226
 * @note    The default is @p TRUE.
227
 */
228
#define CH_CFG_USE_EVENTS                   TRUE
229

    
230
/**
231
 * @brief   Events Flags APIs with timeout.
232
 * @details If enabled then the events APIs with timeout specification
233
 *          are included in the kernel.
234
 *
235
 * @note    The default is @p TRUE.
236
 * @note    Requires @p CH_CFG_USE_EVENTS.
237
 */
238
#define CH_CFG_USE_EVENTS_TIMEOUT           TRUE
239

    
240
/**
241
 * @brief   Synchronous Messages APIs.
242
 * @details If enabled then the synchronous messages APIs are included
243
 *          in the kernel.
244
 *
245
 * @note    The default is @p TRUE.
246
 */
247
#define CH_CFG_USE_MESSAGES                 FALSE
248

    
249
/**
250
 * @brief   Synchronous Messages queuing mode.
251
 * @details If enabled then messages are served by priority rather than in
252
 *          FIFO order.
253
 *
254
 * @note    The default is @p FALSE. Enable this if you have special
255
 *          requirements.
256
 * @note    Requires @p CH_CFG_USE_MESSAGES.
257
 */
258
#define CH_CFG_USE_MESSAGES_PRIORITY        FALSE
259

    
260
/**
261
 * @brief   Mailboxes APIs.
262
 * @details If enabled then the asynchronous messages (mailboxes) APIs are
263
 *          included in the kernel.
264
 *
265
 * @note    The default is @p TRUE.
266
 * @note    Requires @p CH_CFG_USE_SEMAPHORES.
267
 */
268
#define CH_CFG_USE_MAILBOXES                FALSE
269

    
270
/**
271
 * @brief   I/O Queues APIs.
272
 * @details If enabled then the I/O queues APIs are included in the kernel.
273
 *
274
 * @note    The default is @p TRUE.
275
 */
276
#define CH_CFG_USE_QUEUES                   FALSE
277

    
278
/**
279
 * @brief   Core Memory Manager APIs.
280
 * @details If enabled then the core memory manager APIs are included
281
 *          in the kernel.
282
 *
283
 * @note    The default is @p TRUE.
284
 */
285
#define CH_CFG_USE_MEMCORE                  FALSE
286

    
287
/**
288
 * @brief   Heap Allocator APIs.
289
 * @details If enabled then the memory heap allocator APIs are included
290
 *          in the kernel.
291
 *
292
 * @note    The default is @p TRUE.
293
 * @note    Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
294
 *          @p CH_CFG_USE_SEMAPHORES.
295
 * @note    Mutexes are recommended.
296
 */
297
#define CH_CFG_USE_HEAP                     FALSE
298

    
299
/**
300
 * @brief   Memory Pools Allocator APIs.
301
 * @details If enabled then the memory pools allocator APIs are included
302
 *          in the kernel.
303
 *
304
 * @note    The default is @p TRUE.
305
 */
306
#define CH_CFG_USE_MEMPOOLS                 FALSE
307

    
308
/**
309
 * @brief   Dynamic Threads APIs.
310
 * @details If enabled then the dynamic threads creation APIs are included
311
 *          in the kernel.
312
 *
313
 * @note    The default is @p TRUE.
314
 * @note    Requires @p CH_CFG_USE_WAITEXIT.
315
 * @note    Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
316
 */
317
#define CH_CFG_USE_DYNAMIC                  FALSE
318

    
319
/** @} */
320

    
321
/*===========================================================================*/
322
/**
323
 * @name Debug options
324
 * @{
325
 */
326
/*===========================================================================*/
327

    
328
/**
329
 * @brief   Debug option, kernel statistics.
330
 *
331
 * @note    The default is @p FALSE.
332
 */
333
#define CH_DBG_STATISTICS                   FALSE
334

    
335
/**
336
 * @brief   Debug option, system state check.
337
 * @details If enabled the correct call protocol for system APIs is checked
338
 *          at runtime.
339
 *
340
 * @note    The default is @p FALSE.
341
 */
342
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
343
#define CH_DBG_SYSTEM_STATE_CHECK           TRUE
344
#else
345
#define CH_DBG_SYSTEM_STATE_CHECK           FALSE
346
#endif
347

    
348
/**
349
 * @brief   Debug option, parameters checks.
350
 * @details If enabled then the checks on the API functions input
351
 *          parameters are activated.
352
 *
353
 * @note    The default is @p FALSE.
354
 */
355
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
356
#define CH_DBG_ENABLE_CHECKS                TRUE
357
#else
358
#define CH_DBG_ENABLE_CHECKS                FALSE
359
#endif
360

    
361
/**
362
 * @brief   Debug option, consistency checks.
363
 * @details If enabled then all the assertions in the kernel code are
364
 *          activated. This includes consistency checks inside the kernel,
365
 *          runtime anomalies and port-defined checks.
366
 *
367
 * @note    The default is @p FALSE.
368
 */
369
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
370
#define CH_DBG_ENABLE_ASSERTS               TRUE
371
#else
372
#define CH_DBG_ENABLE_ASSERTS               FALSE
373
#endif
374

    
375
/**
376
 * @brief   Debug option, trace buffer.
377
 * @details If enabled then the trace buffer is activated.
378
 *
379
 * @note    The default is @p CH_DBG_TRACE_MASK_DISABLED.
380
 */
381
#define CH_DBG_TRACE_MASK                   CH_DBG_TRACE_MASK_DISABLED
382

    
383
/**
384
 * @brief   Trace buffer entries.
385
 * @note    The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
386
 *          different from @p CH_DBG_TRACE_MASK_DISABLED.
387
 */
388
#define CH_DBG_TRACE_BUFFER_SIZE            128
389

    
390
/**
391
 * @brief   Debug option, stack checks.
392
 * @details If enabled then a runtime stack check is performed.
393
 *
394
 * @note    The default is @p FALSE.
395
 * @note    The stack check is performed in a architecture/port dependent way.
396
 *          It may not be implemented or some ports.
397
 * @note    The default failure mode is to halt the system with the global
398
 *          @p panic_msg variable set to @p NULL.
399
 */
400
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
401
#define CH_DBG_ENABLE_STACK_CHECK           TRUE
402
#else
403
#define CH_DBG_ENABLE_STACK_CHECK           FALSE
404
#endif
405

    
406
/**
407
 * @brief   Debug option, stacks initialization.
408
 * @details If enabled then the threads working area is filled with a byte
409
 *          value when a thread is created. This can be useful for the
410
 *          runtime measurement of the used stack.
411
 *
412
 * @note    The default is @p FALSE.
413
 */
414
#if (AMIROOS_CFG_PROFILE == true) || defined(__DOXYGEN__)
415
#define CH_DBG_FILL_THREADS                 TRUE
416
#else
417
#define CH_DBG_FILL_THREADS                 FALSE
418
#endif
419

    
420
/**
421
 * @brief   Debug option, threads profiling.
422
 * @details If enabled then a field is added to the @p thread_t structure that
423
 *          counts the system ticks occurred while executing the thread.
424
 *
425
 * @note    The default is @p FALSE.
426
 * @note    This debug option is not currently compatible with the
427
 *          tickless mode.
428
 */
429
#if ((CH_CFG_ST_TIMEDELTA == 0) && (AMIROOS_CFG_PROFILE == true)) || defined(__DOXYGEN__)
430
  #define CH_DBG_THREADS_PROFILING          TRUE
431
#else
432
  #define CH_DBG_THREADS_PROFILING          FALSE
433
#endif
434

    
435
/** @} */
436

    
437
/*===========================================================================*/
438
/**
439
 * @name Kernel hooks
440
 * @{
441
 */
442
/*===========================================================================*/
443

    
444
/**
445
 * @brief   Threads descriptor structure extension.
446
 * @details User fields added to the end of the @p thread_t structure.
447
 */
448
#define CH_CFG_THREAD_EXTRA_FIELDS                                          \
449
  /* Add threads custom fields here.*/
450

    
451
/**
452
 * @brief   Threads initialization hook.
453
 * @details User initialization code added to the @p chThdInit() API.
454
 *
455
 * @note    It is invoked from within @p chThdInit() and implicitly from all
456
 *          the threads creation APIs.
457
 */
458
#define CH_CFG_THREAD_INIT_HOOK(tp) {                                       \
459
  /* Add threads initialization code here.*/                                \
460
}
461

    
462
/**
463
 * @brief   Threads finalization hook.
464
 * @details User finalization code added to the @p chThdExit() API.
465
 *
466
 * @note    It is inserted into lock zone.
467
 * @note    It is also invoked when the threads simply return in order to
468
 *          terminate.
469
 */
470
#define CH_CFG_THREAD_EXIT_HOOK(tp) {                                       \
471
  /* Add threads finalization code here.*/                                  \
472
}
473

    
474
/**
475
 * @brief   Context switch hook.
476
 * @details This hook is invoked just before switching between threads.
477
 */
478
#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) {                              \
479
  /* Context switch code here.*/                                            \
480
}
481

    
482
/**
483
 * @brief   ISR enter hook.
484
 */
485
#define CH_CFG_IRQ_PROLOGUE_HOOK() {                                        \
486
  /* IRQ prologue code here.*/                                              \
487
}
488

    
489
/**
490
 * @brief   ISR exit hook.
491
 */
492
#define CH_CFG_IRQ_EPILOGUE_HOOK() {                                        \
493
  /* IRQ epilogue code here.*/                                              \
494
}
495

    
496
/**
497
 * @brief   Idle thread enter hook.
498
 * @note    This hook is invoked within a critical zone, no OS functions
499
 *          should be invoked from here.
500
 * @note    This macro can be used to activate a power saving mode.
501
 */
502
#define CH_CFG_IDLE_ENTER_HOOK() {                                          \
503
  /* Idle-enter code here.*/                                                \
504
}
505

    
506
/**
507
 * @brief   Idle thread leave hook.
508
 * @note    This hook is invoked within a critical zone, no OS functions
509
 *          should be invoked from here.
510
 * @note    This macro can be used to deactivate a power saving mode.
511
 */
512
#define CH_CFG_IDLE_LEAVE_HOOK() {                                          \
513
  /* Idle-leave code here.*/                                                \
514
}
515

    
516
/**
517
 * @brief   Idle Loop hook.
518
 * @details This hook is continuously invoked by the idle thread loop.
519
 */
520
#define CH_CFG_IDLE_LOOP_HOOK() {                                           \
521
  /* Idle loop code here.*/                                                 \
522
}
523

    
524
/**
525
 * @brief   System tick event hook.
526
 * @details This hook is invoked in the system tick handler immediately
527
 *          after processing the virtual timers queue.
528
 */
529
#define CH_CFG_SYSTEM_TICK_HOOK() {                                         \
530
  /* System tick event code here.*/                                         \
531
}
532

    
533
/**
534
 * @brief   System halt hook.
535
 * @details This hook is invoked in case to a system halting error before
536
 *          the system is halted.
537
 */
538
#define CH_CFG_SYSTEM_HALT_HOOK(reason) {                                   \
539
  extern void aosPrintHaltErrorCode(const char* reason);                       \
540
  aosPrintHaltErrorCode(reason);                                               \
541
}
542

    
543
/**
544
 * @brief   Trace hook.
545
 * @details This hook is invoked each time a new record is written in the
546
 *          trace buffer.
547
 */
548
#define CH_CFG_TRACE_HOOK(tep) {                                            \
549
  /* Trace code here.*/                                                     \
550
}
551

    
552
/** @} */
553

    
554
/*===========================================================================*/
555
/**
556
 * @name Port specific settings
557
 * @{
558
 */
559
/*===========================================================================*/
560

    
561
/**
562
 * @brief   NVIC VTOR initialization offset.
563
 * @details On initialization, the code at this address in the flash memory will be executed.
564
 */
565
#define CORTEX_VTOR_INIT 0x00008000U
566

    
567
/** @} */
568

    
569
/*===========================================================================*/
570
/**
571
 * @name other
572
 * @{
573
 */
574
/*===========================================================================*/
575

    
576
/**
577
 * @brief   Flag to enable/disable floating point support in chprinf()
578
 */
579
#define CHPRINTF_USE_FLOAT                  TRUE
580

    
581
/** @} */
582

    
583
#endif  /* _CHCONF_H_ */
584

    
585
/** @} */