RTX_Config.c 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /*
  2. * Copyright (c) 2013-2016 ARM Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. * -----------------------------------------------------------------------------
  19. *
  20. * $Revision: V5.0.0
  21. *
  22. * Project: CMSIS-RTOS RTX
  23. * Title: RTX Configuration
  24. *
  25. * -----------------------------------------------------------------------------
  26. */
  27. //-------- <<< Use Configuration Wizard in Context Menu >>> --------------------
  28. // <h>System Configuration
  29. // =======================
  30. // <o>Global Dynamic Memory size [bytes] <0-1073741824:8>
  31. // <i> Defines the combined global dynamic memory size.
  32. // <i> Default: 4096
  33. #define OS_DYNAMIC_MEM_SIZE 4096
  34. // <o>Kernel Tick Frequency [Hz] <1-1000000>
  35. // <i> Defines base time unit for delays and timeouts.
  36. // <i> Default: 1000 (1ms tick)
  37. #define OS_TICK_FREQ 1000
  38. // <e>Round-Robin Thread switching
  39. // <i> Enables Round-Robin Thread switching.
  40. #define OS_ROBIN_ENABLE 1
  41. // <o>Round-Robin Timeout <1-1000>
  42. // <i> Defines how many ticks a thread will execute before a thread switch.
  43. // <i> Default: 5
  44. #define OS_ROBIN_TIMEOUT 5
  45. // </e>
  46. // <o>ISR FIFO Queue
  47. // <4=> 4 entries <8=> 8 entries <12=> 12 entries <16=> 16 entries
  48. // <24=> 24 entries <32=> 32 entries <48=> 48 entries <64=> 64 entries
  49. // <96=> 96 entries <128=> 128 entries <196=> 196 entries <256=> 256 entries
  50. // <i> RTOS Functions called from ISR store requests to this buffer.
  51. // <i> Default: 16 entries
  52. #define OS_ISR_FIFO_QUEUE 16
  53. // </h>
  54. // <h>Thread Configuration
  55. // =======================
  56. // <e>Object specific Memory allocation
  57. // <i> Enables object specific memory allocation.
  58. #define OS_THREAD_OBJ_MEM 0
  59. // <o>Number of user Threads (total) <1-1000>
  60. // <i> Defines maximum number of user threads that can be active at the same time.
  61. // <i> Applies to user threads with system provided memory for control blocks.
  62. #define OS_THREAD_NUM 1
  63. // <o>Number of user Threads with user-provided Stack size <0-1000>
  64. // <i> Defines maximum number of user threads with user-provided stack size.
  65. // <i> Default: 0
  66. #define OS_THREAD_USER_STACK_NUM 0
  67. // <o>Total Stack size [bytes] for user Threads with user-provided Stack size <0-1073741824:8>
  68. // <i> Defines the combined stack size for user threads with user-provided stack size.
  69. // <i> Default: 0
  70. #define OS_THREAD_USER_STACK_SIZE 0
  71. // </e>
  72. // <o>Default Thread Stack size [bytes] <96-1073741824:8>
  73. // <i> Defines stack size for threads with zero stack size specified.
  74. // <i> Default: 200
  75. #define OS_STACK_SIZE 200
  76. // <o>Idle Thread Stack size [bytes] <72-1073741824:8>
  77. // <i> Defines stack size for Idle thread.
  78. // <i> Default: 200
  79. #define OS_IDLE_THREAD_STACK_SIZE 200
  80. // <q>Stack overrun checking
  81. // <i> Enable stack overrun checks at thread switch.
  82. // <i> Enabling this option increases slightly the execution time of a thread switch.
  83. #define OS_STACK_CHECK 1
  84. // <q>Stack usage watermark
  85. // <i> Initialize thread stack with watermark pattern for analyzing stack usage.
  86. // <i> Enabling this option increases significantly the execution time of thread creation.
  87. #define OS_STACK_WATERMARK 0
  88. // <o>Processor mode for Thread execution
  89. // <0=> Unprivileged mode
  90. // <1=> Privileged mode
  91. // <i> Default: Privileged mode
  92. #define OS_PRIVILEGE_MODE 1
  93. // </h>
  94. // <h>Timer Configuration
  95. // ======================
  96. // <e>Object specific Memory allocation
  97. // <i> Enables object specific memory allocation.
  98. #define OS_TIMER_OBJ_MEM 0
  99. // <o>Number of Timer objects <1-1000>
  100. // <i> Defines maximum number of objects that can be active at the same time.
  101. // <i> Applies to objects with system provided memory for control blocks.
  102. #define OS_TIMER_NUM 1
  103. // </e>
  104. // <o>Timer Thread Priority
  105. // <8=> Low
  106. // <16=> Below Normal <24=> Normal <32=> Above Normal
  107. // <40=> High
  108. // <48=> Realtime
  109. // <i> Defines priority for timer thread
  110. // <i> Default: High
  111. #define OS_TIMER_THREAD_PRIO 40
  112. // <o>Timer Thread Stack size [bytes] <0-1073741824:8>
  113. // <i> Defines stack size for Timer thread.
  114. // <i> May be set to 0 when timers are not used.
  115. // <i> Default: 200
  116. #define OS_TIMER_THREAD_STACK_SIZE 200
  117. // <o>Timer Callback Queue entries <0-256>
  118. // <i> Number of concurrent active timer callback functions.
  119. // <i> May be set to 0 when timers are not used.
  120. // <i> Default: 4
  121. #define OS_TIMER_CB_QUEUE 4
  122. // </h>
  123. // <h>Event Flags Configuration
  124. // ============================
  125. // <e>Object specific Memory allocation
  126. // <i> Enables object specific memory allocation.
  127. #define OS_EVFLAGS_OBJ_MEM 0
  128. // <o>Number of Event Flags objects <1-1000>
  129. // <i> Defines maximum number of objects that can be active at the same time.
  130. // <i> Applies to objects with system provided memory for control blocks.
  131. #define OS_EVFLAGS_NUM 1
  132. // </e>
  133. // </h>
  134. // <h>Mutex Configuration
  135. // ======================
  136. // <e>Object specific Memory allocation
  137. // <i> Enables object specific memory allocation.
  138. #define OS_MUTEX_OBJ_MEM 0
  139. // <o>Number of Mutex objects <1-1000>
  140. // <i> Defines maximum number of objects that can be active at the same time.
  141. // <i> Applies to objects with system provided memory for control blocks.
  142. #define OS_MUTEX_NUM 1
  143. // </e>
  144. // </h>
  145. // <h>Semaphore Configuration
  146. // ==========================
  147. // <e>Object specific Memory allocation
  148. // <i> Enables object specific memory allocation.
  149. #define OS_SEMAPHORE_OBJ_MEM 0
  150. // <o>Number of Semaphore objects <1-1000>
  151. // <i> Defines maximum number of objects that can be active at the same time.
  152. // <i> Applies to objects with system provided memory for control blocks.
  153. #define OS_SEMAPHORE_NUM 1
  154. // </e>
  155. // </h>
  156. // <h>Memory Pool Configuration
  157. // ============================
  158. // <e>Object specific Memory allocation
  159. // <i> Enables object specific memory allocation.
  160. #define OS_MEMPOOL_OBJ_MEM 0
  161. // <o>Number of Memory Pool objects <1-1000>
  162. // <i> Defines maximum number of objects that can be active at the same time.
  163. // <i> Applies to objects with system provided memory for control blocks.
  164. #define OS_MEMPOOL_NUM 1
  165. // <o>Data Storage Memory size [bytes] <0-1073741824:8>
  166. // <i> Defines the combined data storage memory size.
  167. // <i> Applies to objects with system provided memory for data storage.
  168. // <i> Default: 0
  169. #define OS_MEMPOOL_DATA_SIZE 0
  170. // </e>
  171. // </h>
  172. // <h>Message Queue Configuration
  173. // ==============================
  174. // <e>Object specific Memory allocation
  175. // <i> Enables object specific memory allocation.
  176. #define OS_MSGQUEUE_OBJ_MEM 0
  177. // <o>Number of Message Queue objects <1-1000>
  178. // <i> Defines maximum number of objects that can be active at the same time.
  179. // <i> Applies to objects with system provided memory for control blocks.
  180. #define OS_MSGQUEUE_NUM 1
  181. // <o>Data Storage Memory size [bytes] <0-1073741824:8>
  182. // <i> Defines the combined data storage memory size.
  183. // <i> Applies to objects with system provided memory for data storage.
  184. // <i> Default: 0
  185. #define OS_MSGQUEUE_DATA_SIZE 0
  186. // </e>
  187. // </h>
  188. // Number of Threads which use standard C/C++ library libspace
  189. // (when thread specific memory allocation is not used).
  190. #if (OS_THREAD_OBJ_MEM == 0)
  191. #define OS_THREAD_LIBSPACE_NUM 4
  192. #else
  193. #define OS_THREAD_LIBSPACE_NUM OS_THREAD_NUM
  194. #endif
  195. //------------- <<< end of configuration section >>> ---------------------------
  196. #include "rtx_os.h"
  197. // OS Idle Thread
  198. __NO_RETURN void os_IdleThread (void *argument) {
  199. (void)argument;
  200. for (;;) {}
  201. }
  202. // OS Error Callback function
  203. uint32_t os_Error (uint32_t code, void *object_id) {
  204. (void)object_id;
  205. switch (code) {
  206. case os_ErrorStackUnderflow:
  207. // Stack underflow detected for thread (thread_id=object_id)
  208. break;
  209. case os_ErrorISRQueueOverflow:
  210. // ISR Queue overflow detected when inserting object (object_id)
  211. break;
  212. case os_ErrorTimerQueueOverflow:
  213. // User Timer Callback Queue overflow detected for timer (timer_id=object_id)
  214. break;
  215. case os_ErrorClibSpace:
  216. // Standard C/C++ library libspace not available: increase OS_THREAD_LIBSPACE_NUM
  217. break;
  218. case os_ErrorClibMutex:
  219. // Standard C/C++ library mutex initialization failed
  220. break;
  221. default:
  222. break;
  223. }
  224. for (;;) {}
  225. //return 0U;
  226. }
  227. #include "rtx_config.h"