Keyboard firmwares for Atmel AVR and Cortex-M
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 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  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 16
  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 2000
  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. /* Use __WFI in the idle thread for waiting. Does lower the power
  92. * consumption. */
  93. #define CORTEX_ENABLE_WFI_IDLE TRUE
  94. /** @} */
  95. /*===========================================================================*/
  96. /**
  97. * @name Performance options
  98. * @{
  99. */
  100. /*===========================================================================*/
  101. /**
  102. * @brief OS optimization.
  103. * @details If enabled then time efficient rather than space efficient code
  104. * is used when two possible implementations exist.
  105. *
  106. * @note This is not related to the compiler optimization options.
  107. * @note The default is @p TRUE.
  108. */
  109. #define CH_CFG_OPTIMIZE_SPEED TRUE
  110. /** @} */
  111. /*===========================================================================*/
  112. /**
  113. * @name Subsystem options
  114. * @{
  115. */
  116. /*===========================================================================*/
  117. /**
  118. * @brief Time Measurement APIs.
  119. * @details If enabled then the time measurement APIs are included in
  120. * the kernel.
  121. *
  122. * @note The default is @p TRUE.
  123. */
  124. #define CH_CFG_USE_TM FALSE
  125. /**
  126. * @brief Threads registry APIs.
  127. * @details If enabled then the registry APIs are included in the kernel.
  128. *
  129. * @note The default is @p TRUE.
  130. */
  131. #define CH_CFG_USE_REGISTRY TRUE
  132. /**
  133. * @brief Threads synchronization APIs.
  134. * @details If enabled then the @p chThdWait() function is included in
  135. * the kernel.
  136. *
  137. * @note The default is @p TRUE.
  138. */
  139. #define CH_CFG_USE_WAITEXIT TRUE
  140. /**
  141. * @brief Semaphores APIs.
  142. * @details If enabled then the Semaphores APIs are included in the kernel.
  143. *
  144. * @note The default is @p TRUE.
  145. */
  146. #define CH_CFG_USE_SEMAPHORES TRUE
  147. /**
  148. * @brief Semaphores queuing mode.
  149. * @details If enabled then the threads are enqueued on semaphores by
  150. * priority rather than in FIFO order.
  151. *
  152. * @note The default is @p FALSE. Enable this if you have special
  153. * requirements.
  154. * @note Requires @p CH_CFG_USE_SEMAPHORES.
  155. */
  156. #define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
  157. /**
  158. * @brief Mutexes APIs.
  159. * @details If enabled then the mutexes APIs are included in the kernel.
  160. *
  161. * @note The default is @p TRUE.
  162. */
  163. #define CH_CFG_USE_MUTEXES TRUE
  164. /**
  165. * @brief Enables recursive behavior on mutexes.
  166. * @note Recursive mutexes are heavier and have an increased
  167. * memory footprint.
  168. *
  169. * @note The default is @p FALSE.
  170. * @note Requires @p CH_CFG_USE_MUTEXES.
  171. */
  172. #define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
  173. /**
  174. * @brief Conditional Variables APIs.
  175. * @details If enabled then the conditional variables APIs are included
  176. * in the kernel.
  177. *
  178. * @note The default is @p TRUE.
  179. * @note Requires @p CH_CFG_USE_MUTEXES.
  180. */
  181. #define CH_CFG_USE_CONDVARS TRUE
  182. /**
  183. * @brief Conditional Variables APIs with timeout.
  184. * @details If enabled then the conditional variables APIs with timeout
  185. * specification are included in the kernel.
  186. *
  187. * @note The default is @p TRUE.
  188. * @note Requires @p CH_CFG_USE_CONDVARS.
  189. */
  190. #define CH_CFG_USE_CONDVARS_TIMEOUT FALSE
  191. /**
  192. * @brief Events Flags APIs.
  193. * @details If enabled then the event flags APIs are included in the kernel.
  194. *
  195. * @note The default is @p TRUE.
  196. */
  197. #define CH_CFG_USE_EVENTS TRUE
  198. /**
  199. * @brief Events Flags APIs with timeout.
  200. * @details If enabled then the events APIs with timeout specification
  201. * are included in the kernel.
  202. *
  203. * @note The default is @p TRUE.
  204. * @note Requires @p CH_CFG_USE_EVENTS.
  205. */
  206. #define CH_CFG_USE_EVENTS_TIMEOUT TRUE
  207. /**
  208. * @brief Synchronous Messages APIs.
  209. * @details If enabled then the synchronous messages APIs are included
  210. * in the kernel.
  211. *
  212. * @note The default is @p TRUE.
  213. */
  214. #define CH_CFG_USE_MESSAGES TRUE
  215. /**
  216. * @brief Synchronous Messages queuing mode.
  217. * @details If enabled then messages are served by priority rather than in
  218. * FIFO order.
  219. *
  220. * @note The default is @p FALSE. Enable this if you have special
  221. * requirements.
  222. * @note Requires @p CH_CFG_USE_MESSAGES.
  223. */
  224. #define CH_CFG_USE_MESSAGES_PRIORITY FALSE
  225. /**
  226. * @brief Mailboxes APIs.
  227. * @details If enabled then the asynchronous messages (mailboxes) APIs are
  228. * included in the kernel.
  229. *
  230. * @note The default is @p TRUE.
  231. * @note Requires @p CH_CFG_USE_SEMAPHORES.
  232. */
  233. #define CH_CFG_USE_MAILBOXES TRUE
  234. /**
  235. * @brief I/O Queues APIs.
  236. * @details If enabled then the I/O queues APIs are included in the kernel.
  237. *
  238. * @note The default is @p TRUE.
  239. */
  240. #define CH_CFG_USE_QUEUES TRUE
  241. /**
  242. * @brief Core Memory Manager APIs.
  243. * @details If enabled then the core memory manager APIs are included
  244. * in the kernel.
  245. *
  246. * @note The default is @p TRUE.
  247. */
  248. #define CH_CFG_USE_MEMCORE TRUE
  249. /**
  250. * @brief Heap Allocator APIs.
  251. * @details If enabled then the memory heap allocator APIs are included
  252. * in the kernel.
  253. *
  254. * @note The default is @p TRUE.
  255. * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
  256. * @p CH_CFG_USE_SEMAPHORES.
  257. * @note Mutexes are recommended.
  258. */
  259. #define CH_CFG_USE_HEAP TRUE
  260. /**
  261. * @brief Memory Pools Allocator APIs.
  262. * @details If enabled then the memory pools allocator APIs are included
  263. * in the kernel.
  264. *
  265. * @note The default is @p TRUE.
  266. */
  267. #define CH_CFG_USE_MEMPOOLS FALSE
  268. /**
  269. * @brief Dynamic Threads APIs.
  270. * @details If enabled then the dynamic threads creation APIs are included
  271. * in the kernel.
  272. *
  273. * @note The default is @p TRUE.
  274. * @note Requires @p CH_CFG_USE_WAITEXIT.
  275. * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
  276. */
  277. #define CH_CFG_USE_DYNAMIC FALSE
  278. /** @} */
  279. /*===========================================================================*/
  280. /**
  281. * @name Debug options
  282. * @{
  283. */
  284. /*===========================================================================*/
  285. /**
  286. * @brief Debug option, kernel statistics.
  287. *
  288. * @note The default is @p FALSE.
  289. */
  290. #define CH_DBG_STATISTICS FALSE
  291. /**
  292. * @brief Debug option, system state check.
  293. * @details If enabled the correct call protocol for system APIs is checked
  294. * at runtime.
  295. *
  296. * @note The default is @p FALSE.
  297. */
  298. #define CH_DBG_SYSTEM_STATE_CHECK FALSE
  299. /**
  300. * @brief Debug option, parameters checks.
  301. * @details If enabled then the checks on the API functions input
  302. * parameters are activated.
  303. *
  304. * @note The default is @p FALSE.
  305. */
  306. #define CH_DBG_ENABLE_CHECKS FALSE
  307. /**
  308. * @brief Debug option, consistency checks.
  309. * @details If enabled then all the assertions in the kernel code are
  310. * activated. This includes consistency checks inside the kernel,
  311. * runtime anomalies and port-defined checks.
  312. *
  313. * @note The default is @p FALSE.
  314. */
  315. #define CH_DBG_ENABLE_ASSERTS FALSE
  316. /**
  317. * @brief Debug option, trace buffer.
  318. * @details If enabled then the context switch circular trace buffer is
  319. * activated.
  320. *
  321. * @note The default is @p FALSE.
  322. */
  323. #define CH_DBG_ENABLE_TRACE FALSE
  324. /**
  325. * @brief Debug option, stack checks.
  326. * @details If enabled then a runtime stack check is performed.
  327. *
  328. * @note The default is @p FALSE.
  329. * @note The stack check is performed in a architecture/port dependent way.
  330. * It may not be implemented or some ports.
  331. * @note The default failure mode is to halt the system with the global
  332. * @p panic_msg variable set to @p NULL.
  333. */
  334. #define CH_DBG_ENABLE_STACK_CHECK FALSE
  335. /**
  336. * @brief Debug option, stacks initialization.
  337. * @details If enabled then the threads working area is filled with a byte
  338. * value when a thread is created. This can be useful for the
  339. * runtime measurement of the used stack.
  340. *
  341. * @note The default is @p FALSE.
  342. */
  343. #define CH_DBG_FILL_THREADS FALSE
  344. /**
  345. * @brief Debug option, threads profiling.
  346. * @details If enabled then a field is added to the @p thread_t structure that
  347. * counts the system ticks occurred while executing the thread.
  348. *
  349. * @note The default is @p FALSE.
  350. * @note This debug option is not currently compatible with the
  351. * tickless mode.
  352. */
  353. #define CH_DBG_THREADS_PROFILING FALSE
  354. /** @} */
  355. /*===========================================================================*/
  356. /**
  357. * @name Kernel hooks
  358. * @{
  359. */
  360. /*===========================================================================*/
  361. /**
  362. * @brief Threads descriptor structure extension.
  363. * @details User fields added to the end of the @p thread_t structure.
  364. */
  365. #define CH_CFG_THREAD_EXTRA_FIELDS \
  366. /* Add threads custom fields here.*/
  367. /**
  368. * @brief Threads initialization hook.
  369. * @details User initialization code added to the @p chThdInit() API.
  370. *
  371. * @note It is invoked from within @p chThdInit() and implicitly from all
  372. * the threads creation APIs.
  373. */
  374. #define CH_CFG_THREAD_INIT_HOOK(tp) { \
  375. /* Add threads initialization code here.*/ \
  376. }
  377. /**
  378. * @brief Threads finalization hook.
  379. * @details User finalization code added to the @p chThdExit() API.
  380. *
  381. * @note It is inserted into lock zone.
  382. * @note It is also invoked when the threads simply return in order to
  383. * terminate.
  384. */
  385. #define CH_CFG_THREAD_EXIT_HOOK(tp) { \
  386. /* Add threads finalization code here.*/ \
  387. }
  388. /**
  389. * @brief Context switch hook.
  390. * @details This hook is invoked just before switching between threads.
  391. */
  392. #define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
  393. /* Context switch code here.*/ \
  394. }
  395. /**
  396. * @brief Idle thread enter hook.
  397. * @note This hook is invoked within a critical zone, no OS functions
  398. * should be invoked from here.
  399. * @note This macro can be used to activate a power saving mode.
  400. */
  401. #define CH_CFG_IDLE_ENTER_HOOK() { \
  402. }
  403. /**
  404. * @brief Idle thread leave hook.
  405. * @note This hook is invoked within a critical zone, no OS functions
  406. * should be invoked from here.
  407. * @note This macro can be used to deactivate a power saving mode.
  408. */
  409. #define CH_CFG_IDLE_LEAVE_HOOK() { \
  410. }
  411. /**
  412. * @brief Idle Loop hook.
  413. * @details This hook is continuously invoked by the idle thread loop.
  414. */
  415. #define CH_CFG_IDLE_LOOP_HOOK() { \
  416. /* Idle loop code here.*/ \
  417. }
  418. /**
  419. * @brief System tick event hook.
  420. * @details This hook is invoked in the system tick handler immediately
  421. * after processing the virtual timers queue.
  422. */
  423. #define CH_CFG_SYSTEM_TICK_HOOK() { \
  424. /* System tick event code here.*/ \
  425. }
  426. /**
  427. * @brief System halt hook.
  428. * @details This hook is invoked in case to a system halting error before
  429. * the system is halted.
  430. */
  431. #define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
  432. /* System halt code here.*/ \
  433. }
  434. /** @} */
  435. /*===========================================================================*/
  436. /* Port-specific settings (override port settings defaulted in chcore.h). */
  437. /*===========================================================================*/
  438. #endif /* _CHCONF_H_ */
  439. /** @} */