You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

714 lines
20 KiB

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