PD Buddy Sink Firmware
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.

chconf.h 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. /*
  2. ChibiOS - Copyright (C) 2006..2015 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 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. /*===========================================================================*/
  26. /**
  27. * @name System timers settings
  28. * @{
  29. */
  30. /*===========================================================================*/
  31. /**
  32. * @brief System time counter resolution.
  33. * @note Allowed values are 16 or 32 bits.
  34. */
  35. #define CH_CFG_ST_RESOLUTION 32
  36. /**
  37. * @brief System tick frequency.
  38. * @details Frequency of the system timer that drives the system ticks. This
  39. * setting also defines the system tick time unit.
  40. */
  41. #define CH_CFG_ST_FREQUENCY 10000
  42. /**
  43. * @brief Time delta constant for the tick-less mode.
  44. * @note If this value is zero then the system uses the classic
  45. * periodic tick. This value represents the minimum number
  46. * of ticks that is safe to specify in a timeout directive.
  47. * The value one is not valid, timeouts are rounded up to
  48. * this value.
  49. */
  50. #define CH_CFG_ST_TIMEDELTA 2
  51. /** @} */
  52. /*===========================================================================*/
  53. /**
  54. * @name Kernel parameters and options
  55. * @{
  56. */
  57. /*===========================================================================*/
  58. /**
  59. * @brief Round robin interval.
  60. * @details This constant is the number of system ticks allowed for the
  61. * threads before preemption occurs. Setting this value to zero
  62. * disables the preemption for threads with equal priority and the
  63. * round robin becomes cooperative. Note that higher priority
  64. * threads can still preempt, the kernel is always preemptive.
  65. * @note Disabling the round robin preemption makes the kernel more compact
  66. * and generally faster.
  67. * @note The round robin preemption is not supported in tickless mode and
  68. * must be set to zero in that case.
  69. */
  70. #define CH_CFG_TIME_QUANTUM 0
  71. /**
  72. * @brief Managed RAM size.
  73. * @details Size of the RAM area to be managed by the OS. If set to zero
  74. * then the whole available RAM is used. The core memory is made
  75. * available to the heap allocator and/or can be used directly through
  76. * the simplified core memory allocator.
  77. *
  78. * @note In order to let the OS manage the whole RAM the linker script must
  79. * provide the @p __heap_base__ and @p __heap_end__ symbols.
  80. * @note Requires @p CH_CFG_USE_MEMCORE.
  81. */
  82. #define CH_CFG_MEMCORE_SIZE 0
  83. /**
  84. * @brief Idle thread automatic spawn suppression.
  85. * @details When this option is activated the function @p chSysInit()
  86. * does not spawn the idle thread. The application @p main()
  87. * function becomes the idle thread and must implement an
  88. * infinite loop.
  89. */
  90. #define CH_CFG_NO_IDLE_THREAD FALSE
  91. /** @} */
  92. /*===========================================================================*/
  93. /**
  94. * @name Performance options
  95. * @{
  96. */
  97. /*===========================================================================*/
  98. /**
  99. * @brief OS optimization.
  100. * @details If enabled then time efficient rather than space efficient code
  101. * is used when two possible implementations exist.
  102. *
  103. * @note This is not related to the compiler optimization options.
  104. * @note The default is @p TRUE.
  105. */
  106. #define CH_CFG_OPTIMIZE_SPEED TRUE
  107. /** @} */
  108. /*===========================================================================*/
  109. /**
  110. * @name Subsystem options
  111. * @{
  112. */
  113. /*===========================================================================*/
  114. /**
  115. * @brief Time Measurement APIs.
  116. * @details If enabled then the time measurement APIs are included in
  117. * the kernel.
  118. *
  119. * @note The default is @p TRUE.
  120. */
  121. #define CH_CFG_USE_TM FALSE
  122. /**
  123. * @brief Threads registry APIs.
  124. * @details If enabled then the registry APIs are included in the kernel.
  125. *
  126. * @note The default is @p TRUE.
  127. */
  128. #define CH_CFG_USE_REGISTRY TRUE
  129. /**
  130. * @brief Threads synchronization APIs.
  131. * @details If enabled then the @p chThdWait() function is included in
  132. * the kernel.
  133. *
  134. * @note The default is @p TRUE.
  135. */
  136. #define CH_CFG_USE_WAITEXIT TRUE
  137. /**
  138. * @brief Semaphores APIs.
  139. * @details If enabled then the Semaphores APIs are included in the kernel.
  140. *
  141. * @note The default is @p TRUE.
  142. */
  143. #define CH_CFG_USE_SEMAPHORES TRUE
  144. /**
  145. * @brief Semaphores queuing mode.
  146. * @details If enabled then the threads are enqueued on semaphores by
  147. * priority rather than in FIFO order.
  148. *
  149. * @note The default is @p FALSE. Enable this if you have special
  150. * requirements.
  151. * @note Requires @p CH_CFG_USE_SEMAPHORES.
  152. */
  153. #define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
  154. /**
  155. * @brief Mutexes APIs.
  156. * @details If enabled then the mutexes APIs are included in the kernel.
  157. *
  158. * @note The default is @p TRUE.
  159. */
  160. #define CH_CFG_USE_MUTEXES TRUE
  161. /**
  162. * @brief Enables recursive behavior on mutexes.
  163. * @note Recursive mutexes are heavier and have an increased
  164. * memory footprint.
  165. *
  166. * @note The default is @p FALSE.
  167. * @note Requires @p CH_CFG_USE_MUTEXES.
  168. */
  169. #define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
  170. /**
  171. * @brief Conditional Variables APIs.
  172. * @details If enabled then the conditional variables APIs are included
  173. * in the kernel.
  174. *
  175. * @note The default is @p TRUE.
  176. * @note Requires @p CH_CFG_USE_MUTEXES.
  177. */
  178. #define CH_CFG_USE_CONDVARS TRUE
  179. /**
  180. * @brief Conditional Variables APIs with timeout.
  181. * @details If enabled then the conditional variables APIs with timeout
  182. * specification are included in the kernel.
  183. *
  184. * @note The default is @p TRUE.
  185. * @note Requires @p CH_CFG_USE_CONDVARS.
  186. */
  187. #define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
  188. /**
  189. * @brief Events Flags APIs.
  190. * @details If enabled then the event flags APIs are included in the kernel.
  191. *
  192. * @note The default is @p TRUE.
  193. */
  194. #define CH_CFG_USE_EVENTS TRUE
  195. /**
  196. * @brief Events Flags APIs with timeout.
  197. * @details If enabled then the events APIs with timeout specification
  198. * are included in the kernel.
  199. *
  200. * @note The default is @p TRUE.
  201. * @note Requires @p CH_CFG_USE_EVENTS.
  202. */
  203. #define CH_CFG_USE_EVENTS_TIMEOUT TRUE
  204. /**
  205. * @brief Synchronous Messages APIs.
  206. * @details If enabled then the synchronous messages APIs are included
  207. * in the kernel.
  208. *
  209. * @note The default is @p TRUE.
  210. */
  211. #define CH_CFG_USE_MESSAGES TRUE
  212. /**
  213. * @brief Synchronous Messages queuing mode.
  214. * @details If enabled then messages are served by priority rather than in
  215. * FIFO order.
  216. *
  217. * @note The default is @p FALSE. Enable this if you have special
  218. * requirements.
  219. * @note Requires @p CH_CFG_USE_MESSAGES.
  220. */
  221. #define CH_CFG_USE_MESSAGES_PRIORITY FALSE
  222. /**
  223. * @brief Mailboxes APIs.
  224. * @details If enabled then the asynchronous messages (mailboxes) APIs are
  225. * included in the kernel.
  226. *
  227. * @note The default is @p TRUE.
  228. * @note Requires @p CH_CFG_USE_SEMAPHORES.
  229. */
  230. #define CH_CFG_USE_MAILBOXES TRUE
  231. /**
  232. * @brief I/O Queues APIs.
  233. * @details If enabled then the I/O queues APIs are included in the kernel.
  234. *
  235. * @note The default is @p TRUE.
  236. */
  237. #define CH_CFG_USE_QUEUES TRUE
  238. /**
  239. * @brief Core Memory Manager APIs.
  240. * @details If enabled then the core memory manager APIs are included
  241. * in the kernel.
  242. *
  243. * @note The default is @p TRUE.
  244. */
  245. #define CH_CFG_USE_MEMCORE TRUE
  246. /**
  247. * @brief Heap Allocator APIs.
  248. * @details If enabled then the memory heap allocator APIs are included
  249. * in the kernel.
  250. *
  251. * @note The default is @p TRUE.
  252. * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
  253. * @p CH_CFG_USE_SEMAPHORES.
  254. * @note Mutexes are recommended.
  255. */
  256. #define CH_CFG_USE_HEAP TRUE
  257. /**
  258. * @brief Memory Pools Allocator APIs.
  259. * @details If enabled then the memory pools allocator APIs are included
  260. * in the kernel.
  261. *
  262. * @note The default is @p TRUE.
  263. */
  264. #define CH_CFG_USE_MEMPOOLS TRUE
  265. /**
  266. * @brief Dynamic Threads APIs.
  267. * @details If enabled then the dynamic threads creation APIs are included
  268. * in the kernel.
  269. *
  270. * @note The default is @p TRUE.
  271. * @note Requires @p CH_CFG_USE_WAITEXIT.
  272. * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
  273. */
  274. #define CH_CFG_USE_DYNAMIC TRUE
  275. /** @} */
  276. /*===========================================================================*/
  277. /**
  278. * @name Debug options
  279. * @{
  280. */
  281. /*===========================================================================*/
  282. /**
  283. * @brief Debug option, kernel statistics.
  284. *
  285. * @note The default is @p FALSE.
  286. */
  287. #define CH_DBG_STATISTICS FALSE
  288. /**
  289. * @brief Debug option, system state check.
  290. * @details If enabled the correct call protocol for system APIs is checked
  291. * at runtime.
  292. *
  293. * @note The default is @p FALSE.
  294. */
  295. #define CH_DBG_SYSTEM_STATE_CHECK TRUE
  296. /**
  297. * @brief Debug option, parameters checks.
  298. * @details If enabled then the checks on the API functions input
  299. * parameters are activated.
  300. *
  301. * @note The default is @p FALSE.
  302. */
  303. #define CH_DBG_ENABLE_CHECKS TRUE
  304. /**
  305. * @brief Debug option, consistency checks.
  306. * @details If enabled then all the assertions in the kernel code are
  307. * activated. This includes consistency checks inside the kernel,
  308. * runtime anomalies and port-defined checks.
  309. *
  310. * @note The default is @p FALSE.
  311. */
  312. #define CH_DBG_ENABLE_ASSERTS TRUE
  313. /**
  314. * @brief Debug option, trace buffer.
  315. * @details If enabled then the context switch circular trace buffer is
  316. * activated.
  317. *
  318. * @note The default is @p FALSE.
  319. */
  320. #define CH_DBG_ENABLE_TRACE TRUE
  321. /**
  322. * @brief Debug option, stack checks.
  323. * @details If enabled then a runtime stack check is performed.
  324. *
  325. * @note The default is @p FALSE.
  326. * @note The stack check is performed in a architecture/port dependent way.
  327. * It may not be implemented or some ports.
  328. * @note The default failure mode is to halt the system with the global
  329. * @p panic_msg variable set to @p NULL.
  330. */
  331. #define CH_DBG_ENABLE_STACK_CHECK TRUE
  332. /**
  333. * @brief Debug option, stacks initialization.
  334. * @details If enabled then the threads working area is filled with a byte
  335. * value when a thread is created. This can be useful for the
  336. * runtime measurement of the used stack.
  337. *
  338. * @note The default is @p FALSE.
  339. */
  340. #define CH_DBG_FILL_THREADS TRUE
  341. /**
  342. * @brief Debug option, threads profiling.
  343. * @details If enabled then a field is added to the @p thread_t structure that
  344. * counts the system ticks occurred while executing the thread.
  345. *
  346. * @note The default is @p FALSE.
  347. * @note This debug option is not currently compatible with the
  348. * tickless mode.
  349. */
  350. #define CH_DBG_THREADS_PROFILING FALSE
  351. /** @} */
  352. /*===========================================================================*/
  353. /**
  354. * @name Kernel hooks
  355. * @{
  356. */
  357. /*===========================================================================*/
  358. /**
  359. * @brief Threads descriptor structure extension.
  360. * @details User fields added to the end of the @p thread_t structure.
  361. */
  362. #define CH_CFG_THREAD_EXTRA_FIELDS \
  363. /* Add threads custom fields here.*/
  364. /**
  365. * @brief Threads initialization hook.
  366. * @details User initialization code added to the @p chThdInit() API.
  367. *
  368. * @note It is invoked from within @p chThdInit() and implicitly from all
  369. * the threads creation APIs.
  370. */
  371. #define CH_CFG_THREAD_INIT_HOOK(tp) { \
  372. /* Add threads initialization code here.*/ \
  373. }
  374. /**
  375. * @brief Threads finalization hook.
  376. * @details User finalization code added to the @p chThdExit() API.
  377. *
  378. * @note It is inserted into lock zone.
  379. * @note It is also invoked when the threads simply return in order to
  380. * terminate.
  381. */
  382. #define CH_CFG_THREAD_EXIT_HOOK(tp) { \
  383. /* Add threads finalization code here.*/ \
  384. }
  385. /**
  386. * @brief Context switch hook.
  387. * @details This hook is invoked just before switching between threads.
  388. */
  389. #define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
  390. /* Context switch code here.*/ \
  391. }
  392. /**
  393. * @brief Idle thread enter hook.
  394. * @note This hook is invoked within a critical zone, no OS functions
  395. * should be invoked from here.
  396. * @note This macro can be used to activate a power saving mode.
  397. */
  398. #define CH_CFG_IDLE_ENTER_HOOK() { \
  399. }
  400. /**
  401. * @brief Idle thread leave hook.
  402. * @note This hook is invoked within a critical zone, no OS functions
  403. * should be invoked from here.
  404. * @note This macro can be used to deactivate a power saving mode.
  405. */
  406. #define CH_CFG_IDLE_LEAVE_HOOK() { \
  407. }
  408. /**
  409. * @brief Idle Loop hook.
  410. * @details This hook is continuously invoked by the idle thread loop.
  411. */
  412. #define CH_CFG_IDLE_LOOP_HOOK() { \
  413. /* Idle loop code here.*/ \
  414. }
  415. /**
  416. * @brief System tick event hook.
  417. * @details This hook is invoked in the system tick handler immediately
  418. * after processing the virtual timers queue.
  419. */
  420. #define CH_CFG_SYSTEM_TICK_HOOK() { \
  421. /* System tick event code here.*/ \
  422. }
  423. /**
  424. * @brief System halt hook.
  425. * @details This hook is invoked in case to a system halting error before
  426. * the system is halted.
  427. */
  428. #define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
  429. /* System halt code here.*/ \
  430. }
  431. /** @} */
  432. /*===========================================================================*/
  433. /* Port-specific settings (override port settings defaulted in chcore.h). */
  434. /*===========================================================================*/
  435. #endif /* _CHCONF_H_ */
  436. /** @} */