PD Buddy Sink Firmware
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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